@bcgov-sso/common-react-components 2.0.0 → 2.1.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/README.md +2 -0
- package/dist/index.cjs.js +15 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +6 -8
- package/dist/index.esm.js +15 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/types/src/components/Table/Table.d.ts +21 -4
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -15,6 +15,8 @@ storybook, merge in a feature branch to the `main` branch.
|
|
|
15
15
|
1. Merge your feature branch into `main`. This will automatically bump the package version based on the commits and generate a tag for the release.
|
|
16
16
|
2. Create a new [release](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository) using the generated tag.
|
|
17
17
|
|
|
18
|
+
This repository is granted access to publish via the [npm settings](https://docs.npmjs.com/trusted-publishers). To update see the package settings in NPM.
|
|
19
|
+
|
|
18
20
|
## Adding Components
|
|
19
21
|
|
|
20
22
|
To add a component:
|
package/dist/index.cjs.js
CHANGED
|
@@ -24215,7 +24215,7 @@ const StyledTable = dt$1.table `
|
|
|
24215
24215
|
overflow: hidden;
|
|
24216
24216
|
}
|
|
24217
24217
|
`;
|
|
24218
|
-
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', }) => {
|
|
24218
|
+
const Table = ({ variant = 'default', columns = [], hiddenColumns = [], 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', }) => {
|
|
24219
24219
|
const [selectedRow, setSelectedRow] = React.useState();
|
|
24220
24220
|
const [pagination, setPagination] = React.useState({
|
|
24221
24221
|
pageIndex: 0,
|
|
@@ -24224,6 +24224,17 @@ const Table = ({ variant = 'default', columns = [], data = [], readOnly = false,
|
|
|
24224
24224
|
const [globalFilter, setGlobalFilter] = React.useState('');
|
|
24225
24225
|
const [columnFilters, setColumnFilters] = React.useState([]);
|
|
24226
24226
|
const [filterState, setFilterState] = React.useState({});
|
|
24227
|
+
const initialVisibility = React.useMemo(() => {
|
|
24228
|
+
const visibility = {};
|
|
24229
|
+
columns.forEach((col) => {
|
|
24230
|
+
const key = col.accessorKey;
|
|
24231
|
+
if (key) {
|
|
24232
|
+
visibility[key] = !hiddenColumns.includes(key);
|
|
24233
|
+
}
|
|
24234
|
+
});
|
|
24235
|
+
return visibility;
|
|
24236
|
+
}, [columns, hiddenColumns]);
|
|
24237
|
+
const [columnVisibility, setColumnVisibility] = React.useState(initialVisibility);
|
|
24227
24238
|
const table = useReactTable({
|
|
24228
24239
|
data,
|
|
24229
24240
|
columns,
|
|
@@ -24241,7 +24252,9 @@ const Table = ({ variant = 'default', columns = [], data = [], readOnly = false,
|
|
|
24241
24252
|
pagination,
|
|
24242
24253
|
globalFilter,
|
|
24243
24254
|
columnFilters,
|
|
24255
|
+
columnVisibility,
|
|
24244
24256
|
},
|
|
24257
|
+
onColumnVisibilityChange: setColumnVisibility,
|
|
24245
24258
|
});
|
|
24246
24259
|
const onRowClick = (row) => {
|
|
24247
24260
|
if (!readOnly) {
|
|
@@ -24270,7 +24283,7 @@ const Table = ({ variant = 'default', columns = [], data = [], readOnly = false,
|
|
|
24270
24283
|
? Array.from(selected.values()).map((selection) => selection.value)
|
|
24271
24284
|
: selected?.value ?? '';
|
|
24272
24285
|
header.column?.setFilterValue(newFilter.toString());
|
|
24273
|
-
}, options: header.column.columnDef?.meta?.filterOptions || [], isMulti: header.column.columnDef?.meta?.multiSelect || false, placeholder: header.column.columnDef?.meta?.filterPlaceholder || 'Select...', isClearable: true })))))),
|
|
24286
|
+
}, options: header.column.columnDef?.meta?.filterOptions || [], isMulti: header.column.columnDef?.meta?.multiSelect || false, placeholder: header.column.columnDef?.meta?.filterPlaceholder || 'Select...', isClearable: true, defaultValue: header.column.columnDef?.meta?.defaultValue || null })))))),
|
|
24274
24287
|
React.createElement(StyledTable, { variant: variant, readOnly: readOnly },
|
|
24275
24288
|
React.createElement("thead", null, table.getHeaderGroups().map((headerGroup) => (React.createElement("tr", { key: headerGroup.id }, headerGroup.headers.map((header) => (React.createElement("th", { key: header.id },
|
|
24276
24289
|
React.createElement("div", { className: header.column.getCanSort() ? 'sortable' : '',
|