@ballistix.digital/react-components 0.5.8 → 0.5.10

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/index.js CHANGED
@@ -1104,11 +1104,11 @@ var useExcel = function () {
1104
1104
  });
1105
1105
  });
1106
1106
  };
1107
- var generate = function (table) {
1107
+ var generate = function (table, exportData) {
1108
1108
  var _a, _b, _c, _d;
1109
1109
  var sheets = [];
1110
1110
  var columns = table.getAllColumns();
1111
- var rows = (_b = (_a = table.getRowModel()) === null || _a === void 0 ? void 0 : _a.flatRows) === null || _b === void 0 ? void 0 : _b.map(function (row) { return row.original; });
1111
+ var rows = exportData !== null && exportData !== void 0 ? exportData : (_b = (_a = table.getRowModel()) === null || _a === void 0 ? void 0 : _a.flatRows) === null || _b === void 0 ? void 0 : _b.map(function (row) { return row.original; });
1112
1112
  var order = table.getState().columnOrder;
1113
1113
  var headerNames = (_d = (_c = columns === null || columns === void 0 ? void 0 : columns.sort(function (a, b) {
1114
1114
  var _a, _b;
@@ -1156,7 +1156,7 @@ var useExcel = function () {
1156
1156
  })
1157
1157
  .forEach(function (key) {
1158
1158
  var _a, _b;
1159
- var cell = (_b = (_a = columns === null || columns === void 0 ? void 0 : columns.find(function (column) { return column.id === key; })) === null || _a === void 0 ? void 0 : _a.columnDef.meta) === null || _b === void 0 ? void 0 : _b.excel(row[key]);
1159
+ var cell = (_b = (_a = columns === null || columns === void 0 ? void 0 : columns.find(function (column) { return column.id === key; })) === null || _a === void 0 ? void 0 : _a.columnDef.meta) === null || _b === void 0 ? void 0 : _b.excel(lodash.get(row, key));
1160
1160
  result[key] = cell;
1161
1161
  });
1162
1162
  return result;
@@ -1236,7 +1236,7 @@ var PanelPaginationNavigation = function (props) {
1236
1236
  component = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("button", { className: toClassName(styles.button.default, current === min && styles.button.active), onClick: function () { return handleChangeCurrent(min); }, children: min }), max >= min + 1 && (jsxRuntime.jsx("button", { className: toClassName(styles.button.default, current === min + 1 && styles.button.active), onClick: function () { return handleChangeCurrent(min + 1); }, children: min + 1 })), max >= min + 2 && (jsxRuntime.jsx("button", { className: toClassName(styles.button.default, current === min + 2 && styles.button.active), onClick: function () { return handleChangeCurrent(min + 2); }, children: min + 2 })), max >= min + 3 && (jsxRuntime.jsx("button", { className: toClassName(styles.button.default, current === min + 3 && styles.button.active), onClick: function () { return handleChangeCurrent(min + 3); }, children: min + 3 }))] }));
1237
1237
  break;
1238
1238
  }
1239
- return (jsxRuntime.jsxs("div", { className: styles.container, children: [jsxRuntime.jsxs("div", { className: "flex flex-1 justify-between sm:hidden", children: [jsxRuntime.jsx("button", { className: toClassName(styles.mobile.button, current === min && styles.button.disabled), disabled: current === min, onClick: function () { return handleChangeCurrent(current - 1); }, children: "Previous" }), jsxRuntime.jsx("button", { className: toClassName(styles.mobile.button, current === max && styles.button.disabled), disabled: current === max, onClick: function () { return handleChangeCurrent(current + 1); }, children: "Next" })] }), jsxRuntime.jsxs("div", { className: styles.desktop.container, children: [jsxRuntime.jsx("div", { children: jsxRuntime.jsx("div", { className: "text-sm text-gray-700", children: children && children({ min: min, max: max, current: current }) }) }), jsxRuntime.jsx("div", { children: jsxRuntime.jsxs("nav", { className: styles.desktop.navigation, "aria-label": "Pagination", children: [jsxRuntime.jsxs("button", { className: toClassName(styles.desktop.leftButton, current === min && styles.button.disabled), disabled: current === min, onClick: function () { return handleChangeCurrent(current - 1); }, children: [jsxRuntime.jsx("span", { className: styles.label, children: "Previous" }), jsxRuntime.jsx(solid.ChevronLeftIcon, { className: styles.icon, "aria-hidden": "true" })] }), component, jsxRuntime.jsxs("button", { className: toClassName(styles.desktop.rightButton, current === max && styles.button.disabled), disabled: current === max, onClick: function () { return handleChangeCurrent(current + 1); }, children: [jsxRuntime.jsx("span", { className: styles.label, children: "Next" }), jsxRuntime.jsx(solid.ChevronRightIcon, { className: styles.icon, "aria-hidden": "true" })] })] }) })] })] }));
1239
+ return (jsxRuntime.jsxs("div", { className: styles.container, children: [jsxRuntime.jsxs("div", { className: "flex flex-1 justify-between sm:hidden", children: [jsxRuntime.jsx("button", { className: toClassName(styles.mobile.button, current === min && styles.button.disabled), disabled: current === min, onClick: function () { return handleChangeCurrent(current - 1); }, children: "Previous" }), jsxRuntime.jsx("button", { className: toClassName(styles.mobile.button, current === max && styles.button.disabled), disabled: current === max, onClick: function () { return handleChangeCurrent(current + 1); }, children: "Next" })] }), jsxRuntime.jsxs("div", { className: styles.desktop.container, children: [jsxRuntime.jsx("div", { children: jsxRuntime.jsx("div", { className: "text-sm text-gray-700", children: children && children({ min: min, max: max, current: current }) }) }), jsxRuntime.jsx("div", { children: jsxRuntime.jsxs("nav", { className: styles.desktop.navigation, "aria-label": "Pagination", children: [jsxRuntime.jsxs("button", { className: toClassName(styles.desktop.outerLeftButton, current === min && styles.button.disabled), disabled: current === min, onClick: function () { return handleChangeCurrent(1); }, children: [jsxRuntime.jsx("span", { className: styles.label, children: "First" }), jsxRuntime.jsx(solid.ChevronDoubleLeftIcon, { className: styles.icon, "aria-hidden": "true" })] }), jsxRuntime.jsxs("button", { className: toClassName(styles.desktop.innerButton, current === min && styles.button.disabled), disabled: current === min, onClick: function () { return handleChangeCurrent(current - 1); }, children: [jsxRuntime.jsx("span", { className: styles.label, children: "Previous" }), jsxRuntime.jsx(solid.ChevronLeftIcon, { className: styles.icon, "aria-hidden": "true" })] }), component, jsxRuntime.jsxs("button", { className: toClassName(styles.desktop.innerButton, current === max && styles.button.disabled), disabled: current === max, onClick: function () { return handleChangeCurrent(current + 1); }, children: [jsxRuntime.jsx("span", { className: styles.label, children: "Next" }), jsxRuntime.jsx(solid.ChevronRightIcon, { className: styles.icon, "aria-hidden": "true" })] }), jsxRuntime.jsxs("button", { className: toClassName(styles.desktop.outerRightButton, current === max && styles.button.disabled), disabled: current === max, onClick: function () { return handleChangeCurrent(max); }, children: [jsxRuntime.jsx("span", { className: styles.label, children: "Last" }), jsxRuntime.jsx(solid.ChevronDoubleRightIcon, { className: styles.icon, "aria-hidden": "true" })] })] }) })] })] }));
1240
1240
  };
1241
1241
 
1242
1242
  var base$e = {
@@ -1247,8 +1247,9 @@ var base$e = {
1247
1247
  },
1248
1248
  desktop: {
1249
1249
  container: 'hidden sm:flex sm:flex-1 sm:items-center sm:justify-between',
1250
- leftButton: 'relative inline-flex items-center rounded-l-md border border-gray-300 bg-white px-2 py-2 text-sm font-medium text-gray-500 hover:bg-gray-50 focus:z-20',
1251
- rightButton: 'relative inline-flex items-center rounded-r-md border border-gray-300 bg-white px-2 py-2 text-sm font-medium text-gray-500 hover:bg-gray-50 focus:z-20',
1250
+ outerRightButton: 'relative inline-flex items-center rounded-r-md border border-gray-300 bg-white px-2 py-2 text-sm font-medium text-gray-500 hover:bg-gray-50 focus:z-20',
1251
+ outerLeftButton: 'relative inline-flex items-center rounded-l-md border border-gray-300 bg-white px-2 py-2 text-sm font-medium text-gray-500 hover:bg-gray-50 focus:z-20',
1252
+ innerButton: 'relative inline-flex items-center border border-gray-300 bg-white px-2 py-2 text-sm font-medium text-gray-500 hover:bg-gray-50 focus:z-20',
1252
1253
  navigation: 'isolate inline-flex -space-x-px rounded-md shadow-sm',
1253
1254
  },
1254
1255
  button: {
@@ -1557,11 +1558,11 @@ var isValidState = function (state) {
1557
1558
  };
1558
1559
 
1559
1560
  var TableList2 = function (props) {
1560
- var _a, _b, _c, _d;
1561
+ var _a, _b, _c, _d, _e, _f;
1561
1562
  var id = props.id, config = props.table, head = props.head, foot = props.foot, isLoading = props.isLoading, onRowClick = props.onRowClick, onChange = props.onChange, stylesOverrides = props.styles;
1562
- var _e = React.useState([]), sorting = _e[0], setSorting = _e[1];
1563
- var _f = React.useState({}), columnVisibility = _f[0], setColumnVisibility = _f[1];
1564
- var _g = React.useState([]), columnOrder = _g[0], setColumnOrder = _g[1];
1563
+ var _g = React.useState((_b = (_a = config.options) === null || _a === void 0 ? void 0 : _a.defaultSorting) !== null && _b !== void 0 ? _b : []), sorting = _g[0], setSorting = _g[1];
1564
+ var _h = React.useState({}), columnVisibility = _h[0], setColumnVisibility = _h[1];
1565
+ var _j = React.useState([]), columnOrder = _j[0], setColumnOrder = _j[1];
1565
1566
  var handleGenerateStyle = function () {
1566
1567
  var result = deepCopyObject(styles$f.base);
1567
1568
  var keys = calculateNestedKeys(styles$f.base);
@@ -1633,7 +1634,7 @@ var TableList2 = function (props) {
1633
1634
  }
1634
1635
  setColumnVisibility(visibility_1);
1635
1636
  }
1636
- }, [(_a = config === null || config === void 0 ? void 0 : config.options) === null || _a === void 0 ? void 0 : _a.defaultVisibility, id, table]);
1637
+ }, [(_c = config === null || config === void 0 ? void 0 : config.options) === null || _c === void 0 ? void 0 : _c.defaultVisibility, id, table]);
1637
1638
  React.useEffect(function () {
1638
1639
  var _a, _b, _c;
1639
1640
  var savedOrder = (_a = getTableState(id)) === null || _a === void 0 ? void 0 : _a.columnOrder;
@@ -1646,7 +1647,7 @@ var TableList2 = function (props) {
1646
1647
  else if (lodash.some(config.columns, function (column) { return (column === null || column === void 0 ? void 0 : column.id) || lodash.get(column, 'accessorKey'); })) {
1647
1648
  setColumnOrder(lodash.map(config.columns, function (column) { var _a; return ((_a = column === null || column === void 0 ? void 0 : column.id) !== null && _a !== void 0 ? _a : lodash.get(column, 'accessorKey')); }));
1648
1649
  }
1649
- }, [config.columns, (_b = config === null || config === void 0 ? void 0 : config.options) === null || _b === void 0 ? void 0 : _b.defaultOrder, id]);
1650
+ }, [config.columns, (_d = config === null || config === void 0 ? void 0 : config.options) === null || _d === void 0 ? void 0 : _d.defaultOrder, id]);
1650
1651
  // Write state to local storage when it changes
1651
1652
  React.useEffect(function () {
1652
1653
  if (state) {
@@ -1687,7 +1688,7 @@ var TableList2 = function (props) {
1687
1688
  ((_c = (_b = table === null || table === void 0 ? void 0 : table.getState()) === null || _b === void 0 ? void 0 : _b.pagination) === null || _c === void 0 ? void 0 : _c.pageSize) - 1 &&
1688
1689
  'border-b border-gray-200'), children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id));
1689
1690
  }) }, row.id));
1690
- }) }))] }), lodash.isEmpty(table === null || table === void 0 ? void 0 : table.getRowModel().rows) && !isLoading && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: ((_c = config === null || config === void 0 ? void 0 : config.options) === null || _c === void 0 ? void 0 : _c.emptyComponent) ? ((_d = config === null || config === void 0 ? void 0 : config.options) === null || _d === void 0 ? void 0 : _d.emptyComponent) : (jsxRuntime.jsx("div", { className: "w-full flex justify-center my-2", children: "There is no data to show..." })) })), isLoading && (jsxRuntime.jsx("div", { className: "flex flex-col gap-y-2 w-full pt-5", children: new Array(8).fill(undefined).map(function (index) { return (jsxRuntime.jsxs("div", { className: "flex gap-2", children: [jsxRuntime.jsx("div", { className: "w-20 h-12 rounded-md bg-gray-100 animate-pulse" }), jsxRuntime.jsx("div", { className: "w-full h-12 rounded-md bg-gray-100 animate-pulse" })] }, index)); }) }))] }) }) }) }), jsxRuntime.jsx("div", { className: styles.foot, children: foot && foot(state) })] }));
1691
+ }) }))] }), lodash.isEmpty(table === null || table === void 0 ? void 0 : table.getRowModel().rows) && !isLoading && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: ((_e = config === null || config === void 0 ? void 0 : config.options) === null || _e === void 0 ? void 0 : _e.emptyComponent) ? ((_f = config === null || config === void 0 ? void 0 : config.options) === null || _f === void 0 ? void 0 : _f.emptyComponent) : (jsxRuntime.jsx("div", { className: "w-full flex justify-center my-2", children: "There is no data to show..." })) })), isLoading && (jsxRuntime.jsx("div", { className: "flex flex-col gap-y-2 w-full pt-5", children: new Array(8).fill(undefined).map(function (index) { return (jsxRuntime.jsxs("div", { className: "flex gap-2", children: [jsxRuntime.jsx("div", { className: "w-20 h-12 rounded-md bg-gray-100 animate-pulse" }), jsxRuntime.jsx("div", { className: "w-full h-12 rounded-md bg-gray-100 animate-pulse" })] }, index)); }) }))] }) }) }) }), jsxRuntime.jsx("div", { className: styles.foot, children: foot && foot(state) })] }));
1691
1692
  };
1692
1693
 
1693
1694
  var base$c = {
@@ -2456,8 +2457,8 @@ var styles$7 = {
2456
2457
  var TableExcelExportCustom = function (props) {
2457
2458
  var table = props.table, fileName = props.fileName, children = props.children;
2458
2459
  var _a = useExcel(), generate = _a.generate, write = _a.write;
2459
- var handleExport = function () {
2460
- var sheets = generate(table);
2460
+ var handleExport = function (exportData) {
2461
+ var sheets = generate(table, exportData);
2461
2462
  write(sheets, { fileName: fileName });
2462
2463
  };
2463
2464
  return jsxRuntime.jsx("div", { children: children({ handleExport: handleExport }) });