@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.d.ts +12 -14
- package/dist/index.esm.js +17 -16
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +16 -15
- package/dist/index.js.map +1 -1
- package/dist/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -411,13 +411,10 @@ type TTableListProps<TData> = {
|
|
|
411
411
|
table: {
|
|
412
412
|
columns: ColumnDef<TData>[];
|
|
413
413
|
data: TData[];
|
|
414
|
-
pages: {
|
|
415
|
-
current: number;
|
|
416
|
-
total: number;
|
|
417
|
-
};
|
|
418
414
|
options?: {
|
|
419
415
|
defaultOrder?: string[];
|
|
420
416
|
defaultVisibility?: string[];
|
|
417
|
+
defaultSorting?: SortingState;
|
|
421
418
|
emptyComponent?: ReactNode;
|
|
422
419
|
isStriped?: boolean;
|
|
423
420
|
hasStickyHeader?: boolean;
|
|
@@ -514,8 +511,9 @@ declare const base$b: {
|
|
|
514
511
|
};
|
|
515
512
|
desktop: {
|
|
516
513
|
container: string;
|
|
517
|
-
|
|
518
|
-
|
|
514
|
+
outerRightButton: string;
|
|
515
|
+
outerLeftButton: string;
|
|
516
|
+
innerButton: string;
|
|
519
517
|
navigation: string;
|
|
520
518
|
};
|
|
521
519
|
button: {
|
|
@@ -844,14 +842,14 @@ type TProps$1 = {
|
|
|
844
842
|
};
|
|
845
843
|
declare const TableColumnOptionsCustom: FC<TProps$1>;
|
|
846
844
|
|
|
847
|
-
type TProps = {
|
|
848
|
-
table: Table<
|
|
845
|
+
type TProps<TData> = {
|
|
846
|
+
table: Table<TData>;
|
|
849
847
|
fileName: string;
|
|
850
|
-
children: ({ handleExport }: {
|
|
851
|
-
handleExport: () => void;
|
|
848
|
+
children: ({ handleExport, }: {
|
|
849
|
+
handleExport: (exportData?: TData[]) => void;
|
|
852
850
|
}) => ReactNode;
|
|
853
851
|
};
|
|
854
|
-
declare const TableExcelExportCustom:
|
|
852
|
+
declare const TableExcelExportCustom: <TData extends object>(props: TProps<TData>) => react_jsx_runtime.JSX.Element;
|
|
855
853
|
|
|
856
854
|
type TSelectMenuFormProps = {
|
|
857
855
|
name: string;
|
|
@@ -1160,10 +1158,10 @@ type TExcelSheet = {
|
|
|
1160
1158
|
type TOptions = {
|
|
1161
1159
|
fileName: string;
|
|
1162
1160
|
};
|
|
1163
|
-
type TReturn = {
|
|
1164
|
-
generate: (
|
|
1161
|
+
type TReturn<TData> = {
|
|
1162
|
+
generate: (table: Table<TData>, exportData?: TData[]) => TExcelSheet[];
|
|
1165
1163
|
write: (sheets: TExcelSheet[], options: TOptions) => void;
|
|
1166
1164
|
};
|
|
1167
|
-
declare const useExcel: () => TReturn
|
|
1165
|
+
declare const useExcel: <TData extends object>() => TReturn<TData>;
|
|
1168
1166
|
|
|
1169
1167
|
export { AddressInputGroupForm, BadgeElement$1 as AlertElement, AvatarElement, BadgeElement, BreadcrumbsNavigation, ButtonElement, ButtonGroupElement, CheckboxInputGroupForm, ContainerLayout, DateMenuForm, DividerLayout, DropdownElement, FileInputGroupForm, IconElement, InputGroupForm, ListContainerLayout, MediaObjectLayout, ModalOverlay, NotificationOverlay, OpeningsHourInputGroupForm, PagePaginationNavigation, LayoutPanel as PanelLayout, PanelPaginationNavigation, SelectMenuForm, SlideOverOverlay, type TAddressInputGroupFormProps, type TAddressInputGroupFormStyles, type TAddressInputGroupFormValue, type TButtonElementProps, type TCheckboxInputGroupFormProps, type TCheckboxInputGroupFormStyles, type TDateMenuFormProps, type TDateMenuFormStyles, type TExcelCell, type TExcelRow, type TExcelSheet, type TFileInputGroupFormProps, type TFileInputGroupFormStyles, type TInputGroupFormProps, type TInputGroupStyles, type TModalOverlayProps, type TOpeningsHourInputGroupFormProps, type TOpeningsHourInputGroupFormStyles, type TSelectMenuFormProps, type TSelectMenuFormStyles, type TTableListProps as TTableList2Props, type TTableListProps$1 as TTableListProps, type TTableListStyles$1 as TTableListStyles, TabNavigation, TableColumnOptionsCustom, TableExcelExportCustom as TableExportCustom, TableList, TableList2, VerticalNavigation, useExcel };
|
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
2
|
-
import { ArrowPathIcon, ChevronDownIcon, EllipsisVerticalIcon, ExclamationCircleIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, ChevronUpDownIcon, HomeIcon, ArrowLongLeftIcon, ArrowLongRightIcon } from '@heroicons/react/20/solid';
|
|
2
|
+
import { ArrowPathIcon, ChevronDownIcon, EllipsisVerticalIcon, ExclamationCircleIcon, ChevronDoubleLeftIcon, ChevronLeftIcon, ChevronRightIcon, ChevronDoubleRightIcon, ChevronUpIcon, ChevronUpDownIcon, HomeIcon, ArrowLongLeftIcon, ArrowLongRightIcon } from '@heroicons/react/20/solid';
|
|
3
3
|
import { isArray, map, set, get, noop as noop$1, indexOf, pick, isEmpty, some, forEach, assign } from 'lodash';
|
|
4
4
|
import get$1 from 'lodash/get';
|
|
5
5
|
import React, { useState, useMemo, Children, Fragment, useEffect, useCallback, forwardRef, useImperativeHandle, useRef, useReducer, createElement, PureComponent, Component } from 'react';
|
|
@@ -1102,11 +1102,11 @@ var useExcel = function () {
|
|
|
1102
1102
|
});
|
|
1103
1103
|
});
|
|
1104
1104
|
};
|
|
1105
|
-
var generate = function (table) {
|
|
1105
|
+
var generate = function (table, exportData) {
|
|
1106
1106
|
var _a, _b, _c, _d;
|
|
1107
1107
|
var sheets = [];
|
|
1108
1108
|
var columns = table.getAllColumns();
|
|
1109
|
-
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; });
|
|
1109
|
+
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; });
|
|
1110
1110
|
var order = table.getState().columnOrder;
|
|
1111
1111
|
var headerNames = (_d = (_c = columns === null || columns === void 0 ? void 0 : columns.sort(function (a, b) {
|
|
1112
1112
|
var _a, _b;
|
|
@@ -1154,7 +1154,7 @@ var useExcel = function () {
|
|
|
1154
1154
|
})
|
|
1155
1155
|
.forEach(function (key) {
|
|
1156
1156
|
var _a, _b;
|
|
1157
|
-
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
|
|
1157
|
+
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(get(row, key));
|
|
1158
1158
|
result[key] = cell;
|
|
1159
1159
|
});
|
|
1160
1160
|
return result;
|
|
@@ -1234,7 +1234,7 @@ var PanelPaginationNavigation = function (props) {
|
|
|
1234
1234
|
component = (jsxs(Fragment$1, { children: [jsx("button", { className: toClassName(styles.button.default, current === min && styles.button.active), onClick: function () { return handleChangeCurrent(min); }, children: min }), max >= min + 1 && (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 && (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 && (jsx("button", { className: toClassName(styles.button.default, current === min + 3 && styles.button.active), onClick: function () { return handleChangeCurrent(min + 3); }, children: min + 3 }))] }));
|
|
1235
1235
|
break;
|
|
1236
1236
|
}
|
|
1237
|
-
return (jsxs("div", { className: styles.container, children: [jsxs("div", { className: "flex flex-1 justify-between sm:hidden", children: [jsx("button", { className: toClassName(styles.mobile.button, current === min && styles.button.disabled), disabled: current === min, onClick: function () { return handleChangeCurrent(current - 1); }, children: "Previous" }), jsx("button", { className: toClassName(styles.mobile.button, current === max && styles.button.disabled), disabled: current === max, onClick: function () { return handleChangeCurrent(current + 1); }, children: "Next" })] }), jsxs("div", { className: styles.desktop.container, children: [jsx("div", { children: jsx("div", { className: "text-sm text-gray-700", children: children && children({ min: min, max: max, current: current }) }) }), jsx("div", { children: jsxs("nav", { className: styles.desktop.navigation, "aria-label": "Pagination", children: [jsxs("button", { className: toClassName(styles.desktop.
|
|
1237
|
+
return (jsxs("div", { className: styles.container, children: [jsxs("div", { className: "flex flex-1 justify-between sm:hidden", children: [jsx("button", { className: toClassName(styles.mobile.button, current === min && styles.button.disabled), disabled: current === min, onClick: function () { return handleChangeCurrent(current - 1); }, children: "Previous" }), jsx("button", { className: toClassName(styles.mobile.button, current === max && styles.button.disabled), disabled: current === max, onClick: function () { return handleChangeCurrent(current + 1); }, children: "Next" })] }), jsxs("div", { className: styles.desktop.container, children: [jsx("div", { children: jsx("div", { className: "text-sm text-gray-700", children: children && children({ min: min, max: max, current: current }) }) }), jsx("div", { children: jsxs("nav", { className: styles.desktop.navigation, "aria-label": "Pagination", children: [jsxs("button", { className: toClassName(styles.desktop.outerLeftButton, current === min && styles.button.disabled), disabled: current === min, onClick: function () { return handleChangeCurrent(1); }, children: [jsx("span", { className: styles.label, children: "First" }), jsx(ChevronDoubleLeftIcon, { className: styles.icon, "aria-hidden": "true" })] }), jsxs("button", { className: toClassName(styles.desktop.innerButton, current === min && styles.button.disabled), disabled: current === min, onClick: function () { return handleChangeCurrent(current - 1); }, children: [jsx("span", { className: styles.label, children: "Previous" }), jsx(ChevronLeftIcon, { className: styles.icon, "aria-hidden": "true" })] }), component, jsxs("button", { className: toClassName(styles.desktop.innerButton, current === max && styles.button.disabled), disabled: current === max, onClick: function () { return handleChangeCurrent(current + 1); }, children: [jsx("span", { className: styles.label, children: "Next" }), jsx(ChevronRightIcon, { className: styles.icon, "aria-hidden": "true" })] }), jsxs("button", { className: toClassName(styles.desktop.outerRightButton, current === max && styles.button.disabled), disabled: current === max, onClick: function () { return handleChangeCurrent(max); }, children: [jsx("span", { className: styles.label, children: "Last" }), jsx(ChevronDoubleRightIcon, { className: styles.icon, "aria-hidden": "true" })] })] }) })] })] }));
|
|
1238
1238
|
};
|
|
1239
1239
|
|
|
1240
1240
|
var base$e = {
|
|
@@ -1245,8 +1245,9 @@ var base$e = {
|
|
|
1245
1245
|
},
|
|
1246
1246
|
desktop: {
|
|
1247
1247
|
container: 'hidden sm:flex sm:flex-1 sm:items-center sm:justify-between',
|
|
1248
|
-
|
|
1249
|
-
|
|
1248
|
+
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',
|
|
1249
|
+
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',
|
|
1250
|
+
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',
|
|
1250
1251
|
navigation: 'isolate inline-flex -space-x-px rounded-md shadow-sm',
|
|
1251
1252
|
},
|
|
1252
1253
|
button: {
|
|
@@ -1555,11 +1556,11 @@ var isValidState = function (state) {
|
|
|
1555
1556
|
};
|
|
1556
1557
|
|
|
1557
1558
|
var TableList2 = function (props) {
|
|
1558
|
-
var _a, _b, _c, _d;
|
|
1559
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1559
1560
|
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;
|
|
1560
|
-
var
|
|
1561
|
-
var
|
|
1562
|
-
var
|
|
1561
|
+
var _g = useState((_b = (_a = config.options) === null || _a === void 0 ? void 0 : _a.defaultSorting) !== null && _b !== void 0 ? _b : []), sorting = _g[0], setSorting = _g[1];
|
|
1562
|
+
var _h = useState({}), columnVisibility = _h[0], setColumnVisibility = _h[1];
|
|
1563
|
+
var _j = useState([]), columnOrder = _j[0], setColumnOrder = _j[1];
|
|
1563
1564
|
var handleGenerateStyle = function () {
|
|
1564
1565
|
var result = deepCopyObject(styles$f.base);
|
|
1565
1566
|
var keys = calculateNestedKeys(styles$f.base);
|
|
@@ -1631,7 +1632,7 @@ var TableList2 = function (props) {
|
|
|
1631
1632
|
}
|
|
1632
1633
|
setColumnVisibility(visibility_1);
|
|
1633
1634
|
}
|
|
1634
|
-
}, [(
|
|
1635
|
+
}, [(_c = config === null || config === void 0 ? void 0 : config.options) === null || _c === void 0 ? void 0 : _c.defaultVisibility, id, table]);
|
|
1635
1636
|
useEffect(function () {
|
|
1636
1637
|
var _a, _b, _c;
|
|
1637
1638
|
var savedOrder = (_a = getTableState(id)) === null || _a === void 0 ? void 0 : _a.columnOrder;
|
|
@@ -1644,7 +1645,7 @@ var TableList2 = function (props) {
|
|
|
1644
1645
|
else if (some(config.columns, function (column) { return (column === null || column === void 0 ? void 0 : column.id) || get(column, 'accessorKey'); })) {
|
|
1645
1646
|
setColumnOrder(map(config.columns, function (column) { var _a; return ((_a = column === null || column === void 0 ? void 0 : column.id) !== null && _a !== void 0 ? _a : get(column, 'accessorKey')); }));
|
|
1646
1647
|
}
|
|
1647
|
-
}, [config.columns, (
|
|
1648
|
+
}, [config.columns, (_d = config === null || config === void 0 ? void 0 : config.options) === null || _d === void 0 ? void 0 : _d.defaultOrder, id]);
|
|
1648
1649
|
// Write state to local storage when it changes
|
|
1649
1650
|
useEffect(function () {
|
|
1650
1651
|
if (state) {
|
|
@@ -1685,7 +1686,7 @@ var TableList2 = function (props) {
|
|
|
1685
1686
|
((_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 &&
|
|
1686
1687
|
'border-b border-gray-200'), children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id));
|
|
1687
1688
|
}) }, row.id));
|
|
1688
|
-
}) }))] }), isEmpty(table === null || table === void 0 ? void 0 : table.getRowModel().rows) && !isLoading && (jsx(Fragment$1, { children: ((
|
|
1689
|
+
}) }))] }), isEmpty(table === null || table === void 0 ? void 0 : table.getRowModel().rows) && !isLoading && (jsx(Fragment$1, { 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) : (jsx("div", { className: "w-full flex justify-center my-2", children: "There is no data to show..." })) })), isLoading && (jsx("div", { className: "flex flex-col gap-y-2 w-full pt-5", children: new Array(8).fill(undefined).map(function (index) { return (jsxs("div", { className: "flex gap-2", children: [jsx("div", { className: "w-20 h-12 rounded-md bg-gray-100 animate-pulse" }), jsx("div", { className: "w-full h-12 rounded-md bg-gray-100 animate-pulse" })] }, index)); }) }))] }) }) }) }), jsx("div", { className: styles.foot, children: foot && foot(state) })] }));
|
|
1689
1690
|
};
|
|
1690
1691
|
|
|
1691
1692
|
var base$c = {
|
|
@@ -2454,8 +2455,8 @@ var styles$7 = {
|
|
|
2454
2455
|
var TableExcelExportCustom = function (props) {
|
|
2455
2456
|
var table = props.table, fileName = props.fileName, children = props.children;
|
|
2456
2457
|
var _a = useExcel(), generate = _a.generate, write = _a.write;
|
|
2457
|
-
var handleExport = function () {
|
|
2458
|
-
var sheets = generate(table);
|
|
2458
|
+
var handleExport = function (exportData) {
|
|
2459
|
+
var sheets = generate(table, exportData);
|
|
2459
2460
|
write(sheets, { fileName: fileName });
|
|
2460
2461
|
};
|
|
2461
2462
|
return jsx("div", { children: children({ handleExport: handleExport }) });
|