mirror of
https://gitlab.nic.cz/turris/reforis/foris-js.git
synced 2025-06-16 13:46:16 +02:00
Compare commits
7 Commits
v6.6.0
...
bf0b2ce70c
Author | SHA1 | Date | |
---|---|---|---|
bf0b2ce70c | |||
1441f6ff5a | |||
c7d0655771 | |||
31cb8e2ae0 | |||
0a75f24a04 | |||
230ae8e35b | |||
eb4ffb0651 |
@ -8,6 +8,12 @@ and this project adheres to
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [6.6.1] - 2025-02-17
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Refactored RichTable component to use forwardRef
|
||||||
|
|
||||||
## [6.6.0] - 2025-02-07
|
## [6.6.0] - 2025-02-07
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
@ -435,7 +441,8 @@ and this project adheres to
|
|||||||
## [0.0.7] - 2019-09-02
|
## [0.0.7] - 2019-09-02
|
||||||
|
|
||||||
[unreleased]:
|
[unreleased]:
|
||||||
https://gitlab.nic.cz/turris/reforis/foris-js/-/compare/v6.6.0...dev
|
https://gitlab.nic.cz/turris/reforis/foris-js/-/compare/v6.6.1...dev
|
||||||
|
[6.6.1]: https://gitlab.nic.cz/turris/reforis/foris-js/-/compare/v6.6.0...v6.6.1
|
||||||
[6.6.0]: https://gitlab.nic.cz/turris/reforis/foris-js/-/compare/v6.5.0...v6.6.0
|
[6.6.0]: https://gitlab.nic.cz/turris/reforis/foris-js/-/compare/v6.5.0...v6.6.0
|
||||||
[6.5.0]: https://gitlab.nic.cz/turris/reforis/foris-js/-/compare/v6.4.0...v6.5.0
|
[6.5.0]: https://gitlab.nic.cz/turris/reforis/foris-js/-/compare/v6.4.0...v6.5.0
|
||||||
[6.4.0]: https://gitlab.nic.cz/turris/reforis/foris-js/-/compare/v6.3.0...v6.4.0
|
[6.4.0]: https://gitlab.nic.cz/turris/reforis/foris-js/-/compare/v6.3.0...v6.4.0
|
||||||
|
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "foris",
|
"name": "foris",
|
||||||
"version": "6.6.0",
|
"version": "6.6.1",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "foris",
|
"name": "foris",
|
||||||
"version": "6.6.0",
|
"version": "6.6.1",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fortawesome/fontawesome-svg-core": "^6.6.0",
|
"@fortawesome/fontawesome-svg-core": "^6.6.0",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "foris",
|
"name": "foris",
|
||||||
"version": "6.6.0",
|
"version": "6.6.1",
|
||||||
"description": "Foris JS library is a set of components and utils for reForis application and plugins.",
|
"description": "Foris JS library is a set of components and utils for reForis application and plugins.",
|
||||||
"author": "CZ.NIC, z.s.p.o.",
|
"author": "CZ.NIC, z.s.p.o.",
|
||||||
"repository": {
|
"repository": {
|
||||||
@ -70,4 +70,4 @@
|
|||||||
"docs": "npx styleguidist build ",
|
"docs": "npx styleguidist build ",
|
||||||
"docs:watch": "styleguidist server"
|
"docs:watch": "styleguidist server"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2019-2024 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
* Copyright (C) 2019-2025 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
||||||
*
|
*
|
||||||
* This is free software, licensed under the GNU General Public License v3.
|
* This is free software, licensed under the GNU General Public License v3.
|
||||||
* See /LICENSE for more information.
|
* See /LICENSE for more information.
|
||||||
@ -20,22 +20,20 @@ import RichTableBody from "./RichTableBody";
|
|||||||
import RichTableHeader from "./RichTableHeader";
|
import RichTableHeader from "./RichTableHeader";
|
||||||
import RichTablePagination from "./RichTablePagination";
|
import RichTablePagination from "./RichTablePagination";
|
||||||
|
|
||||||
const fallbackData = [];
|
|
||||||
|
|
||||||
RichTable.propTypes = {
|
RichTable.propTypes = {
|
||||||
/** Columns to be displayed in the table */
|
/** Columns to be displayed in the table */
|
||||||
columns: PropTypes.array.isRequired,
|
columns: PropTypes.array.isRequired,
|
||||||
/** Data to be displayed in the table */
|
/** Data to be displayed in the table, must be passed as a stable reference, for example, useState */
|
||||||
data: PropTypes.array.isRequired,
|
data: PropTypes.array.isRequired,
|
||||||
/** Whether to display pagination */
|
/** Whether to display pagination */
|
||||||
withPagination: PropTypes.bool,
|
withPagination: PropTypes.bool,
|
||||||
/** Number of rows per page */
|
/** Number of rows per page, the default is 5 */
|
||||||
pageSize: PropTypes.number,
|
pageSize: PropTypes.number,
|
||||||
/** Index of the current page */
|
/** Index of the current page */
|
||||||
pageIndex: PropTypes.number,
|
pageIndex: PropTypes.number,
|
||||||
};
|
};
|
||||||
|
|
||||||
function RichTable({
|
export default function RichTable({
|
||||||
columns,
|
columns,
|
||||||
data,
|
data,
|
||||||
withPagination,
|
withPagination,
|
||||||
@ -43,7 +41,6 @@ function RichTable({
|
|||||||
pageIndex = 0,
|
pageIndex = 0,
|
||||||
}) {
|
}) {
|
||||||
const tableColumns = useMemo(() => columns, [columns]);
|
const tableColumns = useMemo(() => columns, [columns]);
|
||||||
const [tableData] = useState(data ?? fallbackData);
|
|
||||||
const [sorting, setSorting] = useState([]);
|
const [sorting, setSorting] = useState([]);
|
||||||
const [pagination, setPagination] = useState({
|
const [pagination, setPagination] = useState({
|
||||||
pageIndex,
|
pageIndex,
|
||||||
@ -51,7 +48,7 @@ function RichTable({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const table = useReactTable({
|
const table = useReactTable({
|
||||||
data: tableData,
|
data,
|
||||||
columns: tableColumns,
|
columns: tableColumns,
|
||||||
getCoreRowModel: getCoreRowModel(),
|
getCoreRowModel: getCoreRowModel(),
|
||||||
getSortedRowModel: getSortedRowModel(),
|
getSortedRowModel: getSortedRowModel(),
|
||||||
@ -64,7 +61,7 @@ function RichTable({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const paginationIsNeeded = tableData.length > pageSize && withPagination;
|
const paginationIsNeeded = data.length > pageSize && withPagination;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="table-responsive">
|
<div className="table-responsive">
|
||||||
@ -76,11 +73,9 @@ function RichTable({
|
|||||||
<RichTablePagination
|
<RichTablePagination
|
||||||
table={table}
|
table={table}
|
||||||
tablePageSize={pageSize}
|
tablePageSize={pageSize}
|
||||||
allRows={tableData.length}
|
allRows={data.length}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default RichTable;
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
* Copyright (C) 2019-2025 CZ.NIC z.s.p.o. (https://www.nic.cz/)
|
||||||
*
|
*
|
||||||
* This is free software, licensed under the GNU General Public License v3.
|
* This is free software, licensed under the GNU General Public License v3.
|
||||||
* See /LICENSE for more information.
|
* See /LICENSE for more information.
|
||||||
@ -20,22 +20,25 @@ export const STATES = {
|
|||||||
SubmitButton.propTypes = {
|
SubmitButton.propTypes = {
|
||||||
disabled: PropTypes.bool,
|
disabled: PropTypes.bool,
|
||||||
state: PropTypes.oneOf(Object.keys(STATES).map((key) => STATES[key])),
|
state: PropTypes.oneOf(Object.keys(STATES).map((key) => STATES[key])),
|
||||||
|
label: PropTypes.string,
|
||||||
};
|
};
|
||||||
|
|
||||||
export function SubmitButton({ disabled, state, ...props }) {
|
export function SubmitButton({ disabled, state, label, ...props }) {
|
||||||
const disableSubmitButton = disabled || state !== STATES.READY;
|
const disableSubmitButton = disabled || state !== STATES.READY;
|
||||||
const loadingSubmitButton = state !== STATES.READY;
|
const loadingSubmitButton = state !== STATES.READY;
|
||||||
|
|
||||||
let labelSubmitButton;
|
let labelSubmitButton = label;
|
||||||
switch (state) {
|
if (!labelSubmitButton) {
|
||||||
case STATES.SAVING:
|
switch (state) {
|
||||||
labelSubmitButton = _("Updating");
|
case STATES.SAVING:
|
||||||
break;
|
labelSubmitButton = _("Updating");
|
||||||
case STATES.LOAD:
|
break;
|
||||||
labelSubmitButton = _("Load settings");
|
case STATES.LOAD:
|
||||||
break;
|
labelSubmitButton = _("Load settings");
|
||||||
default:
|
break;
|
||||||
labelSubmitButton = _("Save");
|
default:
|
||||||
|
labelSubmitButton = _("Save");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Reference in New Issue
Block a user