@bcgov-sso/common-react-components 1.31.0 → 1.31.1
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/cjs/index.js +38 -36
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/Table/Table.d.ts +4 -2
- package/dist/esm/index.js +38 -36
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/Table/Table.d.ts +4 -2
- package/dist/index.d.ts +4 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
export declare const TABLE_BACKGROUND_COLOR = "#ededed";
|
|
3
3
|
export declare const TABLE_ROW_ACTIVE_COLOR = "#4950FA";
|
|
4
4
|
export declare const TABLE_ROW_HOVER_COLOR = "#fdb913";
|
|
@@ -31,8 +31,10 @@ export interface TableProps {
|
|
|
31
31
|
defaultPageSize?: number;
|
|
32
32
|
enableGlobalSearch?: boolean;
|
|
33
33
|
globalSearchPlaceholder?: string;
|
|
34
|
+
globalSearchStyle?: React.CSSProperties;
|
|
34
35
|
enablePagination?: boolean;
|
|
35
36
|
pageSizeOptions?: number[];
|
|
37
|
+
noDataFoundText?: string;
|
|
36
38
|
}
|
|
37
|
-
declare const Table: ({ variant, columns, data, readOnly, onRowSelect, defaultPageSize, enableGlobalSearch, globalSearchPlaceholder, enablePagination, pageSizeOptions, }: TableProps) => JSX.Element;
|
|
39
|
+
declare const Table: ({ variant, columns, data, readOnly, onRowSelect, defaultPageSize, enableGlobalSearch, globalSearchPlaceholder, globalSearchStyle, enablePagination, pageSizeOptions, noDataFoundText, }: TableProps) => JSX.Element;
|
|
38
40
|
export default Table;
|
package/dist/esm/index.js
CHANGED
|
@@ -15993,29 +15993,6 @@ function useReactTable(options) {
|
|
|
15993
15993
|
return tableRef.current;
|
|
15994
15994
|
}
|
|
15995
15995
|
|
|
15996
|
-
const Wrapper = styled.div `
|
|
15997
|
-
width: 100%;
|
|
15998
|
-
position: relative;
|
|
15999
|
-
`;
|
|
16000
|
-
const Icon$2 = styled.i `
|
|
16001
|
-
position: absolute;
|
|
16002
|
-
right: 0.5em;
|
|
16003
|
-
top: 0.5em;
|
|
16004
|
-
color: grey;
|
|
16005
|
-
`;
|
|
16006
|
-
const Input$2 = styled.input `
|
|
16007
|
-
width: 100%;
|
|
16008
|
-
border: 2px solid #606060;
|
|
16009
|
-
padding: 0.3em 0.5em;
|
|
16010
|
-
border-radius: 0.25em;
|
|
16011
|
-
`;
|
|
16012
|
-
function SearchBar(props) {
|
|
16013
|
-
return (React__default.createElement(Wrapper, null,
|
|
16014
|
-
React__default.createElement(Input$2, Object.assign({ type: "text", maxLength: 100 }, props)),
|
|
16015
|
-
React__default.createElement(Icon$2, null,
|
|
16016
|
-
React__default.createElement(FontAwesomeIcon, { icon: faMagnifyingGlass }))));
|
|
16017
|
-
}
|
|
16018
|
-
|
|
16019
15996
|
function _typeof$2(o) {
|
|
16020
15997
|
"@babel/helpers - typeof";
|
|
16021
15998
|
|
|
@@ -20852,7 +20829,7 @@ var inputStyle = function inputStyle(isHidden) {
|
|
|
20852
20829
|
width: '100%'
|
|
20853
20830
|
}, spacingStyle);
|
|
20854
20831
|
};
|
|
20855
|
-
var Input = function Input(props) {
|
|
20832
|
+
var Input$1 = function Input(props) {
|
|
20856
20833
|
var cx = props.cx,
|
|
20857
20834
|
value = props.value;
|
|
20858
20835
|
var _cleanCommonProps = cleanCommonProps(props),
|
|
@@ -20874,7 +20851,7 @@ var Input = function Input(props) {
|
|
|
20874
20851
|
disabled: isDisabled
|
|
20875
20852
|
}, innerProps)));
|
|
20876
20853
|
};
|
|
20877
|
-
var Input$1 = Input;
|
|
20854
|
+
var Input$1$1 = Input$1;
|
|
20878
20855
|
|
|
20879
20856
|
var multiValueCSS = function multiValueCSS(_ref, unstyled) {
|
|
20880
20857
|
var _ref$theme = _ref.theme,
|
|
@@ -21085,7 +21062,7 @@ var components = {
|
|
|
21085
21062
|
GroupHeading: GroupHeading,
|
|
21086
21063
|
IndicatorsContainer: IndicatorsContainer,
|
|
21087
21064
|
IndicatorSeparator: IndicatorSeparator,
|
|
21088
|
-
Input: Input$1,
|
|
21065
|
+
Input: Input$1$1,
|
|
21089
21066
|
LoadingIndicator: LoadingIndicator,
|
|
21090
21067
|
Menu: Menu$1$1,
|
|
21091
21068
|
MenuList: MenuList,
|
|
@@ -23791,6 +23768,29 @@ var StateManagedSelect = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
23791
23768
|
});
|
|
23792
23769
|
var StateManagedSelect$1 = StateManagedSelect;
|
|
23793
23770
|
|
|
23771
|
+
const Wrapper = styled.div `
|
|
23772
|
+
width: 100%;
|
|
23773
|
+
position: relative;
|
|
23774
|
+
`;
|
|
23775
|
+
const Icon$2 = styled.i `
|
|
23776
|
+
position: absolute;
|
|
23777
|
+
right: -0.5em;
|
|
23778
|
+
top: 0.5em;
|
|
23779
|
+
color: grey;
|
|
23780
|
+
`;
|
|
23781
|
+
const Input = styled.input `
|
|
23782
|
+
width: 100%;
|
|
23783
|
+
border: 2px solid #606060;
|
|
23784
|
+
padding: 0.3em 0.5em;
|
|
23785
|
+
border-radius: 0.25em;
|
|
23786
|
+
`;
|
|
23787
|
+
function SearchBar(props) {
|
|
23788
|
+
return (React__default.createElement(Wrapper, null,
|
|
23789
|
+
React__default.createElement(Input, Object.assign({ type: "text", maxLength: 100 }, props)),
|
|
23790
|
+
React__default.createElement(Icon$2, null,
|
|
23791
|
+
React__default.createElement(FontAwesomeIcon, { icon: faMagnifyingGlass }))));
|
|
23792
|
+
}
|
|
23793
|
+
|
|
23794
23794
|
const TABLE_BACKGROUND_COLOR = '#ededed';
|
|
23795
23795
|
const TABLE_ROW_ACTIVE_COLOR = '#4950FA';
|
|
23796
23796
|
const TABLE_ROW_HOVER_COLOR = '#fdb913';
|
|
@@ -23802,12 +23802,13 @@ const StyledTable = styled.table `
|
|
|
23802
23802
|
width: 100%;
|
|
23803
23803
|
-webkit-box-shadow: none;
|
|
23804
23804
|
background-color: ${TABLE_BACKGROUND_COLOR};
|
|
23805
|
-
padding: 0
|
|
23805
|
+
padding: 0 0.6em;
|
|
23806
23806
|
box-shadow: none;
|
|
23807
23807
|
text-align: left;
|
|
23808
23808
|
border-collapse: separate;
|
|
23809
23809
|
border-spacing: 0 ${TABLE_ROW_SPACING}px;
|
|
23810
23810
|
color: black;
|
|
23811
|
+
margin-bottom: 0.5em;
|
|
23811
23812
|
|
|
23812
23813
|
& thead {
|
|
23813
23814
|
font-size: 16px;
|
|
@@ -23865,7 +23866,7 @@ const StyledTable = styled.table `
|
|
|
23865
23866
|
overflow: hidden;
|
|
23866
23867
|
}
|
|
23867
23868
|
`;
|
|
23868
|
-
const Table = ({ variant = 'default', columns = [], data = [], readOnly = false, onRowSelect = (rowData) => { }, defaultPageSize = 5, enableGlobalSearch = true, globalSearchPlaceholder = 'Search all columns...', enablePagination = true, pageSizeOptions = [5, 10, 20, 30, 40, 50], }) => {
|
|
23869
|
+
const Table = ({ variant = 'default', columns = [], data = [], readOnly = false, onRowSelect = (rowData) => { }, defaultPageSize = 5, enableGlobalSearch = true, globalSearchPlaceholder = 'Search all columns...', globalSearchStyle = {}, enablePagination = true, pageSizeOptions = [5, 10, 20, 30, 40, 50], noDataFoundText = 'No data found', }) => {
|
|
23869
23870
|
const [selectedRow, setSelectedRow] = useState();
|
|
23870
23871
|
const [pagination, setPagination] = React__default.useState({
|
|
23871
23872
|
pageIndex: 0,
|
|
@@ -23900,9 +23901,9 @@ const Table = ({ variant = 'default', columns = [], data = [], readOnly = false,
|
|
|
23900
23901
|
}
|
|
23901
23902
|
};
|
|
23902
23903
|
return (React__default.createElement(React__default.Fragment, null,
|
|
23903
|
-
React__default.createElement("div", { style: { display: 'flex', justifyContent: 'space-between', alignItems: '
|
|
23904
|
-
enableGlobalSearch && (React__default.createElement("div", { style: {
|
|
23905
|
-
React__default.createElement(SearchBar, { value: globalFilter !== null && globalFilter !== void 0 ? globalFilter : '', onChange: (e) => setGlobalFilter(String(e.target.value)), placeholder: globalSearchPlaceholder, style:
|
|
23904
|
+
React__default.createElement("div", { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'flex-end' } },
|
|
23905
|
+
enableGlobalSearch && (React__default.createElement("div", { style: { padding: '0.5em 0' } },
|
|
23906
|
+
React__default.createElement(SearchBar, { value: globalFilter !== null && globalFilter !== void 0 ? globalFilter : '', onChange: (e) => setGlobalFilter(String(e.target.value)), placeholder: globalSearchPlaceholder, style: globalSearchStyle }))),
|
|
23906
23907
|
React__default.createElement("div", { style: { display: 'flex', justifyContent: 'flex-end', flexWrap: 'wrap', padding: '0.5em 0', gap: '0.5em' } }, table.getHeaderGroups().map((headerGroup) => headerGroup.headers.map((header) => {
|
|
23907
23908
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
23908
23909
|
return header.column.getCanFilter() && (React__default.createElement("div", { key: header.id },
|
|
@@ -23933,21 +23934,22 @@ const Table = ({ variant = 'default', columns = [], data = [], readOnly = false,
|
|
|
23933
23934
|
desc: React__default.createElement(FontAwesomeIcon, { icon: faSortUp }),
|
|
23934
23935
|
}[header.column.getIsSorted()]) !== null && _a !== void 0 ? _a : React__default.createElement(FontAwesomeIcon, { icon: faSort })))));
|
|
23935
23936
|
}))))),
|
|
23936
|
-
React__default.createElement("tbody", null, table.getRowModel().rows.
|
|
23937
|
+
React__default.createElement("tbody", null, table.getRowModel().rows.length === 0 ? (React__default.createElement("tr", { key: "no-data" },
|
|
23938
|
+
React__default.createElement("td", { style: { textAlign: 'center' }, colSpan: columns.length }, noDataFoundText))) : (table.getRowModel().rows.map((row) => (React__default.createElement("tr", { key: row.id, onClick: () => {
|
|
23937
23939
|
onRowClick(row);
|
|
23938
|
-
}, className: row.id === (selectedRow === null || selectedRow === void 0 ? void 0 : selectedRow.id) ? 'active' : '' }, row.getVisibleCells().map((cell) => (React__default.createElement("td", { key: cell.id }, flexRender(cell.column.columnDef.cell, cell.getContext())))))))),
|
|
23940
|
+
}, className: row.id === (selectedRow === null || selectedRow === void 0 ? void 0 : selectedRow.id) ? 'active' : '' }, row.getVisibleCells().map((cell) => (React__default.createElement("td", { key: cell.id }, flexRender(cell.column.columnDef.cell, cell.getContext()))))))))),
|
|
23939
23941
|
React__default.createElement("tfoot", null, table.getFooterGroups().map((footerGroup) => (React__default.createElement("tr", { key: footerGroup.id }, footerGroup.headers.map((header) => (React__default.createElement("th", { key: header.id }, header.isPlaceholder ? null : flexRender(header.column.columnDef.footer, header.getContext()))))))))),
|
|
23940
|
-
enablePagination && (React__default.createElement("div", { style: { display: 'flex', justifyContent: 'space-between'
|
|
23942
|
+
enablePagination && (React__default.createElement("div", { style: { display: 'flex', justifyContent: 'space-between' } },
|
|
23941
23943
|
React__default.createElement("div", { style: { display: 'flex', gap: '0.5em' } },
|
|
23942
23944
|
React__default.createElement(Button, { onClick: () => table.previousPage(), disabled: !table.getCanPreviousPage() }, "Prev"),
|
|
23943
23945
|
React__default.createElement(Button, { onClick: () => table.nextPage(), disabled: !table.getCanNextPage() }, "Next")),
|
|
23944
|
-
React__default.createElement("div",
|
|
23946
|
+
React__default.createElement("div", { style: { position: 'relative', zIndex: 999 } },
|
|
23945
23947
|
React__default.createElement(StateManagedSelect$1, { defaultValue: {
|
|
23946
23948
|
label: `${table.getState().pagination.pageSize} per page`,
|
|
23947
23949
|
value: table.getState().pagination.pageSize,
|
|
23948
23950
|
}, options: pageSizeOptions.map((value) => ({ value, label: `${value} per page` })), onChange: (e) => {
|
|
23949
23951
|
table.setPageSize(Number(e.value));
|
|
23950
|
-
} }))))));
|
|
23952
|
+
}, menuPosition: "fixed" }))))));
|
|
23951
23953
|
};
|
|
23952
23954
|
|
|
23953
23955
|
function _typeof$1(obj) {
|