@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.
Files changed (51) hide show
  1. package/lib/cjs/index.js +1 -0
  2. package/lib/cjs/index.js.map +1 -1
  3. package/lib/cjs/progress-bar/ProgressBar.js +2 -2
  4. package/lib/cjs/progress-bar/ProgressBar.js.map +1 -1
  5. package/lib/cjs/table/Table.js +124 -0
  6. package/lib/cjs/table/Table.js.map +1 -0
  7. package/lib/cjs/table/TableNavigation.js +51 -0
  8. package/lib/cjs/table/TableNavigation.js.map +1 -0
  9. package/lib/cjs/table/helpers.js +119 -0
  10. package/lib/cjs/table/helpers.js.map +1 -0
  11. package/lib/cjs/table/hooks/hookCallbackTypes.js +23 -0
  12. package/lib/cjs/table/hooks/hookCallbackTypes.js.map +1 -0
  13. package/lib/cjs/table/hooks/index.js +40 -0
  14. package/lib/cjs/table/hooks/index.js.map +1 -0
  15. package/lib/cjs/table/hooks/useMultiRowSelect.js +84 -0
  16. package/lib/cjs/table/hooks/useMultiRowSelect.js.map +1 -0
  17. package/lib/cjs/table/hooks/useSingleRowSelect.js +61 -0
  18. package/lib/cjs/table/hooks/useSingleRowSelect.js.map +1 -0
  19. package/lib/cjs/table/index.js +44 -0
  20. package/lib/cjs/table/index.js.map +1 -0
  21. package/lib/esm/index.js +1 -0
  22. package/lib/esm/index.js.map +1 -1
  23. package/lib/esm/progress-bar/ProgressBar.js +2 -2
  24. package/lib/esm/progress-bar/ProgressBar.js.map +1 -1
  25. package/lib/esm/table/Table.js +117 -0
  26. package/lib/esm/table/Table.js.map +1 -0
  27. package/lib/esm/table/TableNavigation.js +44 -0
  28. package/lib/esm/table/TableNavigation.js.map +1 -0
  29. package/lib/esm/table/helpers.js +112 -0
  30. package/lib/esm/table/helpers.js.map +1 -0
  31. package/lib/esm/table/hooks/hookCallbackTypes.js +22 -0
  32. package/lib/esm/table/hooks/hookCallbackTypes.js.map +1 -0
  33. package/lib/esm/table/hooks/index.js +24 -0
  34. package/lib/esm/table/hooks/index.js.map +1 -0
  35. package/lib/esm/table/hooks/useMultiRowSelect.js +82 -0
  36. package/lib/esm/table/hooks/useMultiRowSelect.js.map +1 -0
  37. package/lib/esm/table/hooks/useSingleRowSelect.js +57 -0
  38. package/lib/esm/table/hooks/useSingleRowSelect.js.map +1 -0
  39. package/lib/esm/table/index.js +23 -0
  40. package/lib/esm/table/index.js.map +1 -0
  41. package/lib/types/index.d.ts +1 -0
  42. package/lib/types/progress-bar/ProgressBar.d.ts +2 -3
  43. package/lib/types/table/Table.d.ts +78 -0
  44. package/lib/types/table/TableNavigation.d.ts +39 -0
  45. package/lib/types/table/helpers.d.ts +51 -0
  46. package/lib/types/table/hooks/hookCallbackTypes.d.ts +27 -0
  47. package/lib/types/table/hooks/index.d.ts +23 -0
  48. package/lib/types/table/hooks/useMultiRowSelect.d.ts +42 -0
  49. package/lib/types/table/hooks/useSingleRowSelect.d.ts +37 -0
  50. package/lib/types/table/index.d.ts +22 -0
  51. package/package.json +6 -4
package/lib/cjs/index.js CHANGED
@@ -48,5 +48,6 @@ __exportStar(require("./view-selector"), exports);
48
48
  __exportStar(require("./popover"), exports);
49
49
  __exportStar(require("./icons"), exports);
50
50
  __exportStar(require("./progress-bar"), exports);
51
+ __exportStar(require("./table"), exports);
51
52
  __exportStar(require("./drag-and-drop"), exports);
52
53
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;;;;;;;;;;;AAEH,2CAAyB;AACzB,0CAAwB;AACxB,0CAAwB;AACxB,4CAA0B;AAC1B,6CAA2B;AAC3B,2CAAyB;AACzB,0CAAwB;AACxB,iDAA+B;AAC/B,oDAAkC;AAClC,yCAAuB;AACvB,kDAAgC;AAChC,4CAA0B;AAC1B,0CAAwB;AACxB,iDAA+B;AAC/B,kDAAgC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;;;;;;;;;;;AAEH,2CAAyB;AACzB,0CAAwB;AACxB,0CAAwB;AACxB,4CAA0B;AAC1B,6CAA2B;AAC3B,2CAAyB;AACzB,0CAAwB;AACxB,iDAA+B;AAC/B,oDAAkC;AAClC,yCAAuB;AACvB,kDAAgC;AAChC,4CAA0B;AAC1B,0CAAwB;AACxB,iDAA+B;AAC/B,0CAAwB;AACxB,kDAAgC"}
@@ -38,9 +38,9 @@ const jsx_runtime_1 = require("react/jsx-runtime");
38
38
  const react_1 = __importDefault(require("react"));
39
39
  const classnames_1 = __importDefault(require("classnames"));
40
40
  const ProgressBar = react_1.default.forwardRef(function ProgressBar(_a, ref) {
41
- var { heading, estimatedTime, value, barSize = 'small', className } = _a, rest = __rest(_a, ["heading", "estimatedTime", "value", "barSize", "className"]);
41
+ var { heading, value, barSize = 'small', className } = _a, rest = __rest(_a, ["heading", "value", "barSize", "className"]);
42
42
  const classes = (0, classnames_1.default)('ndl-progress-bar-wrapper', barSize, className);
43
- return ((0, jsx_runtime_1.jsxs)("div", Object.assign({}, rest, { className: classes, ref: ref }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "header" }, { children: [(0, jsx_runtime_1.jsx)("span", Object.assign({ className: "heading" }, { children: heading })), (0, jsx_runtime_1.jsx)("span", Object.assign({ className: "progress-number" }, { children: value + '%' }))] })), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "progress-bar-container", role: "progressbar", title: "progress bar", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": value }, { children: (0, jsx_runtime_1.jsx)("div", { className: "progress-bar", style: { width: value + '%' } }) })), estimatedTime && ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "details" }, { children: [(0, jsx_runtime_1.jsx)("span", Object.assign({ className: "estimated-time-heading" }, { children: "Estimated time:" })), (0, jsx_runtime_1.jsx)("span", Object.assign({ className: "estimated-time" }, { children: estimatedTime }))] })))] })));
43
+ return ((0, jsx_runtime_1.jsxs)("div", Object.assign({}, rest, { className: classes, ref: ref }, { children: [heading && ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "header" }, { children: [(0, jsx_runtime_1.jsx)("span", Object.assign({ className: "heading" }, { children: heading })), (0, jsx_runtime_1.jsx)("span", Object.assign({ className: "progress-number" }, { children: value + '%' }))] }))), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "progress-bar-container", role: "progressbar", title: "progress bar", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": value }, { children: (0, jsx_runtime_1.jsx)("div", { className: "progress-bar", style: { width: value + '%' } }) }))] })));
44
44
  });
45
45
  exports.default = ProgressBar;
46
46
  //# sourceMappingURL=ProgressBar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProgressBar.js","sourceRoot":"","sources":["../../../src/progress-bar/ProgressBar.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,kDAA0B;AAC1B,4DAAoC;AAUpC,MAAM,WAAW,GAAG,eAAK,CAAC,UAAU,CAAC,SAAS,WAAW,CACvD,EAOmB,EACnB,GAAuC;QARvC,EACE,OAAO,EACP,aAAa,EACb,KAAK,EACL,OAAO,GAAG,OAAO,EACjB,SAAS,OAEQ,EADd,IAAI,cANT,6DAOC,CADQ;IAIT,MAAM,OAAO,GAAG,IAAA,oBAAU,EAAC,0BAA0B,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;IAE3E,OAAO,CACL,iDAAS,IAAI,IAAE,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,iBACzC,+CAAK,SAAS,EAAC,QAAQ,iBACrB,+CAAM,SAAS,EAAC,SAAS,gBAAE,OAAO,IAAQ,EAC1C,+CAAM,SAAS,EAAC,iBAAiB,gBAAE,KAAK,GAAG,GAAG,IAA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,KAAK,EAAC,cAAc,mBACL,CAAC,mBACD,GAAG,mBACH,KAAK,gBAEpB,gCAAK,SAAS,EAAC,cAAc,EAAC,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,GAAG,GAAG,EAAE,GAAI,IAC3D,KACF,CACP,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,kBAAe,WAAW,CAAC"}
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.fixedHeight = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ /**
9
+ *
10
+ * Copyright (c) "Neo4j"
11
+ * Neo4j Sweden AB [http://neo4j.com]
12
+ *
13
+ * This file is part of Neo4j.
14
+ *
15
+ * Neo4j is free software: you can redistribute it and/or modify
16
+ * it under the terms of the GNU General Public License as published by
17
+ * the Free Software Foundation, either version 3 of the License, or
18
+ * (at your option) any later version.
19
+ *
20
+ * This program is distributed in the hope that it will be useful,
21
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ * GNU General Public License for more details.
24
+ *
25
+ * You should have received a copy of the GNU General Public License
26
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
27
+ */
28
+ const classnames_1 = __importDefault(require("classnames"));
29
+ const helpers_1 = require("./helpers");
30
+ const TableNavigation_1 = __importDefault(require("./TableNavigation"));
31
+ /** Table results per page, with the first option being the default */
32
+ const TABLE_RESULTS = {
33
+ DEFAULT: 10,
34
+ values: [10, 25, 50, 100],
35
+ };
36
+ /**
37
+ *
38
+ * Small Utilities
39
+ * for table styling and functionality
40
+ *
41
+ */
42
+ /** For fixed row height tables, we should have a fixed body size */
43
+ const fixedHeight = (items, height) => ({
44
+ style: { height: `${height * items}px` },
45
+ });
46
+ exports.fixedHeight = fixedHeight;
47
+ const DefaultHeader = ({ headerGroups, }) => ((0, jsx_runtime_1.jsx)("thead", { children:
48
+ // Loop over the header rows
49
+ headerGroups.map((headerGroup) => (
50
+ // Apply the header row props
51
+ // Key is defined from getHeaderGroupProps so we can ignore the false-negative
52
+ // eslint-disable-next-line react/jsx-key
53
+ (0, jsx_runtime_1.jsx)("tr", Object.assign({}, headerGroup.getHeaderGroupProps(), { children:
54
+ // Loop over the headers in each row
55
+ headerGroup.headers.map((column) => {
56
+ const castedColumn = column;
57
+ const sortable = !!castedColumn.getSortByToggleProps;
58
+ // Dont use "group" class inside the @apply component
59
+ // https://github.com/tailwindlabs/tailwindcss/issues/2848#issuecomment-734523233
60
+ const headerClasses = (0, classnames_1.default)('group', 'table-column-styling', {
61
+ sortable,
62
+ });
63
+ return (
64
+ // Apply the header cell props
65
+ // Key is defined from getHeaderGroupProps so we can ignore the false-negative
66
+ // eslint-disable-next-line react/jsx-key
67
+ (0, jsx_runtime_1.jsxs)("th", Object.assign({ style: Object.assign(Object.assign({}, castedColumn.getHeaderProps().style), {
68
+ /** 0.25px */
69
+ letterSpacing: '0.25px' }), scope: "col", className: headerClasses }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "table-header-cell" }, { children: [castedColumn.render('Header'), castedColumn.canSort && ((0, jsx_runtime_1.jsx)(helpers_1.SortIcon, Object.assign({}, castedColumn.getSortByToggleProps(), { isSortedDesc: castedColumn.isSortedDesc })))] })), 'canResize' in castedColumn &&
70
+ 'getResizerProps' in castedColumn && ((0, jsx_runtime_1.jsx)(helpers_1.ResizingBar, Object.assign({}, castedColumn.getResizerProps())))] })));
71
+ }) })))) }));
72
+ const DefaultBody = ({ getTableBodyProps, page, prepareRow, actionsButtons, rows, }) => {
73
+ // Page is defined when using the usePagination plugin, otherwise rows is defined
74
+ const iterable = page !== null && page !== void 0 ? page : rows;
75
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: iterable.length > 0 ? ((0, jsx_runtime_1.jsx)("tbody", Object.assign({}, getTableBodyProps(), { className: "n-bg-light-neutral-bg-weak" }, { children: iterable.length > 0 &&
76
+ iterable.map((row) => {
77
+ prepareRow(row);
78
+ return (
79
+ // Key is defined from getHeaderGroupProps so we can ignore the false-negative
80
+ // eslint-disable-next-line react/jsx-key
81
+ (0, jsx_runtime_1.jsxs)("tr", Object.assign({ className: "table-row" }, row.getRowProps(), { children: [row.cells.map((cell) => (
82
+ // Key is defined from getHeaderGroupProps so we can ignore the false-negative
83
+ // eslint-disable-next-line react/jsx-key
84
+ (0, jsx_runtime_1.jsx)("td", Object.assign({ className: "table-cell" }, cell.getCellProps(), { children: cell.render('Cell') })))), actionsButtons && actionsButtons(row)] })));
85
+ }) }))) : ((0, jsx_runtime_1.jsx)("tr", { children: (0, jsx_runtime_1.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" })) })) }));
86
+ };
87
+ const DefaultNavigation = ({ state, rows, page, canPreviousPage, nextPage, pageOptions, pageCount, gotoPage, canNextPage, previousPage, setPageSize, }) => {
88
+ // Navigation is only needed if pagination exists
89
+ if (!page || state.pageSize === undefined || state.pageIndex === undefined) {
90
+ return null;
91
+ }
92
+ return ((0, jsx_runtime_1.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: [(0, jsx_runtime_1.jsx)(helpers_1.TableResults, { pageIndex: state.pageIndex, rowsLength: rows.length, pageLength: page.length }), (0, jsx_runtime_1.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 && ((0, jsx_runtime_1.jsx)(TableNavigation_1.default, { canPreviousPage: canPreviousPage, canNextPage: canNextPage, onPageClick: gotoPage, previousPage: previousPage, nextPage: nextPage, pageIndex: state.pageIndex, pageOptions: pageOptions })), (0, jsx_runtime_1.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", (0, jsx_runtime_1.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])]
93
+ .sort((a, b) => a - b)
94
+ .map((option) => ((0, jsx_runtime_1.jsx)("option", Object.assign({ value: `${option}` }, { children: option }), `${option}`))) }))] }))] }))] })));
95
+ };
96
+ /**
97
+ * Table Skeleton to keep most section logic DRY
98
+ *
99
+ * How the table component is divided into sections:
100
+ *
101
+ * @example
102
+ * +----------------+
103
+ * | Table Controls |
104
+ * | (ex: Search) |
105
+ * +----------------+
106
+ * | Header |
107
+ * +----------------+
108
+ * | Body (data) |
109
+ * +----------------+
110
+ * | Navigation |
111
+ * +----------------+
112
+ *
113
+ */
114
+ const Table = (props
115
+ // props: any
116
+ ) => {
117
+ const { controls, getTableProps, header, body, navigation, styling, className = '', style = {}, role, } = props;
118
+ if (!getTableProps) {
119
+ throw new Error('getTableProps is required');
120
+ }
121
+ return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: (0, classnames_1.default)('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 && ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "n-px-7 n-py-6 n-flex n-flex-row n-items-center" }, { children: controls }))), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "n-overflow-x-auto" }, { children: (0, jsx_runtime_1.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 || (0, jsx_runtime_1.jsx)(DefaultHeader, Object.assign({}, props)), body || (0, jsx_runtime_1.jsx)(DefaultBody, Object.assign({}, props))] })) })), navigation || ((0, jsx_runtime_1.jsx)(DefaultNavigation, Object.assign({}, props)))] })));
122
+ };
123
+ exports.default = Table;
124
+ //# sourceMappingURL=Table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Table.js","sourceRoot":"","sources":["../../../src/table/Table.tsx"],"names":[],"mappings":";;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,4DAAoC;AAiBpC,uCAAgE;AAChE,wEAAgD;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;AAC7D,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;AAFU,QAAA,WAAW,eAErB;AAwBH,MAAM,aAAa,GAAG,CAAmB,EACvC,YAAY,GACU,EAAE,EAAE,CAAC,CAC3B;IAEI,4BAA4B;IAC5B,YAAY,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;IAChC,6BAA6B;IAC7B,8EAA8E;IAC9E,yCAAyC;IACzC,+CAAQ,WAAW,CAAC,mBAAmB,EAAE;QAErC,oCAAoC;QACpC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;YACjC,MAAM,YAAY,GAAG,MAAmC,CAAC;YAEzD,MAAM,QAAQ,GAAG,CAAC,CAAC,YAAY,CAAC,oBAAoB,CAAC;YACrD,qDAAqD;YACrD,iFAAiF;YACjF,MAAM,aAAa,GAAG,IAAA,oBAAU,EAC9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,IACL,CACP,EAED,8CAAK,SAAS,EAAC,mBAAmB,gBAEhC,mDACM,aAAa,EAAE,IACnB,SAAS,EAAC,gGAAgG,iBAGzG,MAAM,IAAI,uBAAC,aAAa,oBAAM,KAA+B,EAAI,EAEjE,IAAI,IAAI,uBAAC,WAAW,oBAAM,KAA6B,EAAI,KACtD,IACJ,EAEL,UAAU,IAAI,CACb,uBAAC,iBAAiB,oBAAM,KAAmC,EAAI,CAChE,KACG,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,KAAK,CAAC"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TableNavigation = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ /**
9
+ *
10
+ * Copyright (c) "Neo4j"
11
+ * Neo4j Sweden AB [http://neo4j.com]
12
+ *
13
+ * This file is part of Neo4j.
14
+ *
15
+ * Neo4j is free software: you can redistribute it and/or modify
16
+ * it under the terms of the GNU General Public License as published by
17
+ * the Free Software Foundation, either version 3 of the License, or
18
+ * (at your option) any later version.
19
+ *
20
+ * This program is distributed in the hope that it will be useful,
21
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ * GNU General Public License for more details.
24
+ *
25
+ * You should have received a copy of the GNU General Public License
26
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
27
+ */
28
+ const classnames_1 = __importDefault(require("classnames"));
29
+ const helpers_1 = require("./helpers");
30
+ const icons_1 = require("../icons");
31
+ const NavigationArrowButtonClasses = `
32
+ body-medium n-relative n-inline-flex n-items-center
33
+ n-px-2 n-py-2 n-rounded-xl
34
+ n-text-light-neutral-text-weaker
35
+ hover:n-bg-light-primary-bg-strong hover:n-bg-opacity-10
36
+ `;
37
+ const NavigationIconClasses = `
38
+ n-w-5 n-h-5 n-text-light-neutral-text-weak
39
+ `;
40
+ const TableNavigation = ({ canPreviousPage, canNextPage, onPageClick, previousPage, nextPage, pageIndex, pageOptions, }) => ((0, jsx_runtime_1.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 ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("button", Object.assign({ onClick: () => previousPage(), className: NavigationArrowButtonClasses }, { children: [(0, jsx_runtime_1.jsx)("span", Object.assign({ className: "n-sr-only" }, { children: "Previous" })), (0, jsx_runtime_1.jsx)(icons_1.HeroIcon, { iconName: "ChevronLeftIcon", className: NavigationIconClasses })] })) })) : null, (0, helpers_1.userFriendlyPagination)(pageIndex + 1, pageOptions.length).map((option, idx) => ((0, jsx_runtime_1.jsx)("button", Object.assign({ "data-testid": `table-${option}`, className: (0, classnames_1.default)('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', {
41
+ 'n-cursor-pointer hover:n-bg-light-neutral-bg-strong': typeof option === 'number' && option !== pageIndex + 1,
42
+ 'n-bg-light-primary-bg-strong n-text-light-neutral-text-inverse': option === pageIndex + 1,
43
+ 'n-text-light-neutral-text-weaker': option !== pageIndex + 1,
44
+ }), style: {
45
+ minWidth: '36px',
46
+ maxHeight: '36px',
47
+ minHeight: '36px',
48
+ }, onClick: () => typeof option === 'number' && onPageClick(option - 1) }, { children: option }), `${option}-${idx}`))), canNextPage ? ((0, jsx_runtime_1.jsxs)("button", Object.assign({ onClick: () => nextPage(), className: NavigationArrowButtonClasses }, { children: [(0, jsx_runtime_1.jsx)("span", Object.assign({ className: "n-sr-only" }, { children: "Next" })), (0, jsx_runtime_1.jsx)(icons_1.HeroIcon, { iconName: "ChevronRightIcon", className: NavigationIconClasses })] }))) : null] })));
49
+ exports.TableNavigation = TableNavigation;
50
+ exports.default = exports.TableNavigation;
51
+ //# sourceMappingURL=TableNavigation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableNavigation.js","sourceRoot":"","sources":["../../../src/table/TableNavigation.tsx"],"names":[],"mappings":";;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,4DAAoC;AACpC,uCAAmD;AACnD,oCAAoC;AAmBpC,MAAM,4BAA4B,GAAG;;;;;CAKpC,CAAC;AAEF,MAAM,qBAAqB,GAAG;;CAE7B,CAAC;AAEK,MAAM,eAAe,GAAG,CAAC,EAC9B,eAAe,EACf,WAAW,EACX,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,WAAW,GACU,EAAE,EAAE,CAAC,CAC1B,+CACE,SAAS,EAAC,mEAAmE,gBAClE,YAAY,iBAEtB,eAAe,CAAC,CAAC,CAAC,CACjB,2DACE,kDACE,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,EAAE,EAC7B,SAAS,EAAE,4BAA4B,iBAEvC,+CAAM,SAAS,EAAC,WAAW,8BAAgB,EAC3C,uBAAC,gBAAQ,IACP,QAAQ,EAAC,iBAAiB,EAC1B,SAAS,EAAE,qBAAqB,GAChC,KACK,GACR,CACJ,CAAC,CAAC,CAAC,IAAI,EAEP,IAAA,gCAAsB,EAAC,SAAS,GAAG,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,CAC5D,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,CACf,gEAIe,SAAS,MAAM,EAAE,EAC9B,SAAS,EAAE,IAAA,oBAAU,EACnB,+GAA+G,EAC/G;gBACE,qDAAqD,EACnD,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,SAAS,GAAG,CAAC;gBACxD,gEAAgE,EAC9D,MAAM,KAAK,SAAS,GAAG,CAAC;gBAC1B,kCAAkC,EAAE,MAAM,KAAK,SAAS,GAAG,CAAC;aAC7D,CACF,EACD,KAAK,EAAE;gBACL,QAAQ,EAAE,MAAM;gBAChB,SAAS,EAAE,MAAM;gBACjB,SAAS,EAAE,MAAM;aAClB,EACD,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,MAAM,KAAK,QAAQ,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,gBAEnE,MAAM,KAnBF,GAAG,MAAM,IAAI,GAAG,EAAE,CAoBhB,CACV,CACF,EAEA,WAAW,CAAC,CAAC,CAAC,CACb,kDACE,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,EAAE,EACzB,SAAS,EAAE,4BAA4B,iBAEvC,+CAAM,SAAS,EAAC,WAAW,0BAAY,EACvC,uBAAC,gBAAQ,IACP,QAAQ,EAAC,kBAAkB,EAC3B,SAAS,EAAE,qBAAqB,GAChC,KACK,CACV,CAAC,CAAC,CAAC,IAAI,KACJ,CACP,CAAC;AAtEW,QAAA,eAAe,mBAsE1B;AAEF,kBAAe,uBAAe,CAAC"}
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.toggleRowSelection = exports.userFriendlyPagination = exports.TableResults = exports.ResizingBar = exports.SortIcon = void 0;
15
+ const jsx_runtime_1 = require("react/jsx-runtime");
16
+ /**
17
+ *
18
+ * Copyright (c) "Neo4j"
19
+ * Neo4j Sweden AB [http://neo4j.com]
20
+ *
21
+ * This file is part of Neo4j.
22
+ *
23
+ * Neo4j is free software: you can redistribute it and/or modify
24
+ * it under the terms of the GNU General Public License as published by
25
+ * the Free Software Foundation, either version 3 of the License, or
26
+ * (at your option) any later version.
27
+ *
28
+ * This program is distributed in the hope that it will be useful,
29
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
30
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31
+ * GNU General Public License for more details.
32
+ *
33
+ * You should have received a copy of the GNU General Public License
34
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
35
+ */
36
+ const icons_1 = require("../icons");
37
+ const react_1 = require("react");
38
+ /**
39
+ *
40
+ * React Table helper to display sorting icon
41
+ * Source:
42
+ * https://react-table.tanstack.com/docs/api/useSortBy#column-properties
43
+ *
44
+ */
45
+ const SortIcon = (_a) => {
46
+ var { isSortedDesc } = _a, props = __rest(_a, ["isSortedDesc"]);
47
+ switch (true) {
48
+ case isSortedDesc === true:
49
+ return ((0, jsx_runtime_1.jsx)(icons_1.HeroIcon, Object.assign({}, props, { className: "n-w-4 n-h-4", type: "outline", iconName: "SortDescendingIcon" })));
50
+ case isSortedDesc === false:
51
+ return ((0, jsx_runtime_1.jsx)(icons_1.HeroIcon, Object.assign({}, props, { className: "n-w-4 n-h-4", type: "outline", iconName: "SortAscendingIcon" })));
52
+ default:
53
+ return ((0, jsx_runtime_1.jsx)(icons_1.HeroIcon, Object.assign({}, props, { className: "n-w-4 n-h-4", type: "outline", iconName: "MenuAlt1Icon" })));
54
+ }
55
+ };
56
+ exports.SortIcon = SortIcon;
57
+ exports.ResizingBar = (0, react_1.memo)(function ResizingBarMemoed(props) {
58
+ return ((0, jsx_runtime_1.jsx)("div", Object.assign({}, props, { className: "table-resizing-bar", style: {
59
+ width: '4px',
60
+ zIndex: 1,
61
+ // prevents from scrolling while dragging on touch devices
62
+ touchAction: 'none',
63
+ } })));
64
+ });
65
+ /**
66
+ * The left section of the bottom navigation
67
+ * that is showing the current page and how many results we can see
68
+ */
69
+ const TableResults = ({ pageIndex, pageLength, rowsLength, }) => ((0, jsx_runtime_1.jsx)("span", Object.assign({ className: "n-text-light-neutral-text-weaker body-medium n-whitespace-nowrap" }, { children: (0, jsx_runtime_1.jsxs)("span", { children: ["Showing", ' ', (0, jsx_runtime_1.jsxs)("b", { children: [pageIndex * 10, "-", pageIndex * 10 + pageLength] }), ' ', "of ", (0, jsx_runtime_1.jsx)("b", { children: rowsLength }), " results"] }) })));
70
+ exports.TableResults = TableResults;
71
+ /**
72
+ * Modified from here: https://gist.github.com/kottenator/9d936eb3e4e3c3e02598
73
+ *
74
+ * @param current Current Index
75
+ * @param max Max Index
76
+ * @returns
77
+ */
78
+ const userFriendlyPagination = (current, max) => {
79
+ const last = max;
80
+ const delta = 2;
81
+ const left = current - delta;
82
+ const right = current + delta + 1;
83
+ const range = [];
84
+ const rangeWithDots = [];
85
+ let l;
86
+ for (let i = 1; i <= last; i += 1) {
87
+ if (i === 1 || i === last || (i >= left && i < right)) {
88
+ range.push(i);
89
+ }
90
+ }
91
+ for (let i = 0; i < range.length; i += 1) {
92
+ if (l) {
93
+ if (range[i] - l === 2) {
94
+ rangeWithDots.push(l + 1);
95
+ }
96
+ else if (range[i] - l !== 1) {
97
+ rangeWithDots.push('...');
98
+ }
99
+ }
100
+ rangeWithDots.push(range[i]);
101
+ l = range[i];
102
+ }
103
+ return rangeWithDots;
104
+ };
105
+ exports.userFriendlyPagination = userFriendlyPagination;
106
+ /**
107
+ * Small helper to get handle the Checkbox
108
+ * functionality in tables
109
+ */
110
+ const toggleRowSelection = (list, idx) => {
111
+ // Removing from the list
112
+ if (list.includes(idx)) {
113
+ return list.filter((o) => o !== idx);
114
+ }
115
+ // Adding to the list
116
+ return [...list, idx];
117
+ };
118
+ exports.toggleRowSelection = toggleRowSelection;
119
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/table/helpers.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;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C,CAAC;AA5BW,QAAA,sBAAsB,0BA4BjC;AAEF;;;GAGG;AACI,MAAM,kBAAkB,GAAG,CAAC,IAAc,EAAE,GAAW,EAAE,EAAE;IAChE,yBAAyB;IACzB,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;KACtC;IACD,qBAAqB;IACrB,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,CAAC;AACxB,CAAC,CAAC;AAPW,QAAA,kBAAkB,sBAO7B"}
@@ -0,0 +1,23 @@
1
+ "use strict";
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
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ //# 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,40 @@
1
+ "use strict";
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
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ var desc = Object.getOwnPropertyDescriptor(m, k);
25
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
26
+ desc = { enumerable: true, get: function() { return m[k]; } };
27
+ }
28
+ Object.defineProperty(o, k2, desc);
29
+ }) : (function(o, m, k, k2) {
30
+ if (k2 === undefined) k2 = k;
31
+ o[k2] = m[k];
32
+ }));
33
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
34
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
35
+ };
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ __exportStar(require("./useMultiRowSelect"), exports);
38
+ __exportStar(require("./useSingleRowSelect"), exports);
39
+ __exportStar(require("./hookCallbackTypes"), exports);
40
+ //# 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,sDAAoC;AACpC,uDAAqC;AACrC,sDAAoC"}
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const jsx_runtime_1 = require("react/jsx-runtime");
4
+ /**
5
+ *
6
+ * Copyright (c) "Neo4j"
7
+ * Neo4j Sweden AB [http://neo4j.com]
8
+ *
9
+ * This file is part of Neo4j.
10
+ *
11
+ * Neo4j is free software: you can redistribute it and/or modify
12
+ * it under the terms of the GNU General Public License as published by
13
+ * the Free Software Foundation, either version 3 of the License, or
14
+ * (at your option) any later version.
15
+ *
16
+ * This program is distributed in the hope that it will be useful,
17
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
+ * GNU General Public License for more details.
20
+ *
21
+ * You should have received a copy of the GNU General Public License
22
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
23
+ */
24
+ const react_1 = require("react");
25
+ const react_table_1 = require("react-table");
26
+ const checkbox_1 = require("../../checkbox");
27
+ /**
28
+ * A react-table plugin to support controlled selected row state for multiple rows
29
+ *
30
+ * Required options provided to useTable:
31
+ *
32
+ * `onAllRowSelect`: A callback that is called when the all rows checkbox is toggled
33
+ * `onRowSelect`: A callback that is called when a rows checkbox is toggled
34
+ *
35
+ * Required fields on `data` provided to useTable:
36
+ *
37
+ * `isSelected`: a boolean that indicates if the row is selected. This key can be changed
38
+ * from `isSelected` to something else by setting the `manualRowSelectedKey` option
39
+ * in the useTable options. See the useRowSelect plugin docs for more details.
40
+ */
41
+ const useMultiRowSelect = (hooks) => {
42
+ (0, react_table_1.useRowSelect)(hooks);
43
+ /*
44
+ Used for the indeterminate
45
+ state of the checkbox
46
+ */
47
+ hooks.useControlledState.push((state, { instance }) => {
48
+ const { data } = instance;
49
+ const isSelectedKey = 'isSelected';
50
+ // eslint-disable-next-line react-hooks/rules-of-hooks
51
+ const newState = (0, react_1.useMemo)(() => (Object.assign(Object.assign({}, state), { selectedRowIds: data.reduce((acc, curr, index) => {
52
+ if (curr[isSelectedKey]) {
53
+ return Object.assign(Object.assign({}, acc), { [index]: true });
54
+ }
55
+ return acc;
56
+ }, {}) })), [state, data, isSelectedKey]);
57
+ return newState;
58
+ });
59
+ hooks.visibleColumns.push((columns, { instance }) => [
60
+ // Let's make a column for selection
61
+ {
62
+ id: 'ndl-checkbox-selection',
63
+ // The header can use the table's getToggleAllRowsSelectedProps method
64
+ // to render a checkbox
65
+ Header: ({ getToggleAllRowsSelectedProps, }) => {
66
+ const checkboxRef = (0, react_1.useRef)(null);
67
+ (0, react_1.useEffect)(() => {
68
+ if (checkboxRef && checkboxRef.current) {
69
+ checkboxRef.current.indeterminate =
70
+ getToggleAllRowsSelectedProps().indeterminate || false;
71
+ }
72
+ }, [checkboxRef, getToggleAllRowsSelectedProps]);
73
+ return ((0, jsx_runtime_1.jsx)(checkbox_1.Checkbox, Object.assign({ "aria-label": "all-rows-select", onClick: () => instance.onAllRowSelect() }, getToggleAllRowsSelectedProps(), { ref: checkboxRef })));
74
+ },
75
+ // The cell can use the individual row's getToggleRowSelectedProps method
76
+ // to the render a checkbox
77
+ Cell: ({ row }) => ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(checkbox_1.Checkbox, Object.assign({ "aria-label": `row-${row.index}`, onClick: () => instance.onRowSelect(row.original, row.index) }, row.getToggleRowSelectedProps())) })),
78
+ },
79
+ ...columns,
80
+ ]);
81
+ };
82
+ useMultiRowSelect.pluginName = 'useMultiRowSelect';
83
+ exports.default = useMultiRowSelect;
84
+ //# 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,iCAAmD;AACnD,6CASqB;AACrB,6CAA0C;AAW1C;;;;;;;;;;;;;GAaG;AACH,MAAM,iBAAiB,GAAG,CACxB,KAAe,EACf,EAAE;IACF,IAAA,0BAAY,EAAC,KAAK,CAAC,CAAC;IAEpB;;;MAGE;IACF,KAAK,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EA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B,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,0CACE,uBAAC,mBAAQ,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,kBAAe,iBAAiB,CAAC"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useSingleRowSelect = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ /**
6
+ *
7
+ * Copyright (c) "Neo4j"
8
+ * Neo4j Sweden AB [http://neo4j.com]
9
+ *
10
+ * This file is part of Neo4j.
11
+ *
12
+ * Neo4j is free software: you can redistribute it and/or modify
13
+ * it under the terms of the GNU General Public License as published by
14
+ * the Free Software Foundation, either version 3 of the License, or
15
+ * (at your option) any later version.
16
+ *
17
+ * This program is distributed in the hope that it will be useful,
18
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
+ * GNU General Public License for more details.
21
+ *
22
+ * You should have received a copy of the GNU General Public License
23
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
24
+ */
25
+ const react_table_1 = require("react-table");
26
+ const radio_1 = require("../../radio");
27
+ /**
28
+ * A react-table plugin to support controlled selected row state for a single row
29
+ *
30
+ * Required options provided to useTable:
31
+ *
32
+ * `onRowSelect`: A callback that is called when a rows checkbox is toggled
33
+ *
34
+ * Required fields on `data` provided to useTable:
35
+ *
36
+ * `isSelected`: a boolean that indicates if the row is selected. This key can be changed
37
+ * from `isSelected` to something else by setting the `manualRowSelectedKey` option
38
+ * in the useTable options. See the useRowSelect plugin docs for more details.
39
+ * There should only ever be 1 data entry with isSelected set to true
40
+ */
41
+ const useSingleRowSelect = (hooks) => {
42
+ (0, react_table_1.useRowSelect)(hooks);
43
+ hooks.visibleColumns.push((columns, { instance }) => [
44
+ // Let's make a column for selection
45
+ // This should be definitely unique to avoid collision
46
+ {
47
+ id: 'ndl-radio-selection',
48
+ Header: () => null,
49
+ width: 20,
50
+ // The cell can use the individual row's getToggleRowSelectedProps method
51
+ // to the render a checkbox
52
+ Cell: ({ row }) => {
53
+ return ((0, jsx_runtime_1.jsx)(radio_1.Radio, Object.assign({}, row.getToggleRowSelectedProps(), { onChange: () => instance.onRowSelect(row.original, row.index) })));
54
+ },
55
+ },
56
+ ...columns,
57
+ ]);
58
+ };
59
+ exports.useSingleRowSelect = useSingleRowSelect;
60
+ exports.default = exports.useSingleRowSelect;
61
+ //# 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,6CAAwD;AACxD,uCAAoC;AAGpC;;;;;;;;;;;;;GAaG;AACI,MAAM,kBAAkB,GAAG,CAChC,KAAe,EACf,EAAE;IACF,IAAA,0BAAY,EAAC,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,uBAAC,aAAK,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;AA3BW,QAAA,kBAAkB,sBA2B7B;AAEF,kBAAe,0BAAkB,CAAC"}
@@ -0,0 +1,44 @@
1
+ "use strict";
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
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ var desc = Object.getOwnPropertyDescriptor(m, k);
25
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
26
+ desc = { enumerable: true, get: function() { return m[k]; } };
27
+ }
28
+ Object.defineProperty(o, k2, desc);
29
+ }) : (function(o, m, k, k2) {
30
+ if (k2 === undefined) k2 = k;
31
+ o[k2] = m[k];
32
+ }));
33
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
34
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
35
+ };
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.Table = void 0;
41
+ var Table_1 = require("./Table");
42
+ Object.defineProperty(exports, "Table", { enumerable: true, get: function () { return __importDefault(Table_1).default; } });
43
+ __exportStar(require("./hooks"), exports);
44
+ //# sourceMappingURL=index.js.map