diff --git a/NAMESPACE b/NAMESPACE index 15e1808..0ba2b68 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -7,7 +7,6 @@ export(cookies_panel_server) export(cookies_panel_ui) export(custom_disconnect_message) export(dfe_cookies_script) -export(dfe_reactable) export(external_link) export(header) export(init_analytics) diff --git a/R/dfe_reactable.R b/R/dfe_reactable.R index 9b5f555..f967d67 100644 --- a/R/dfe_reactable.R +++ b/R/dfe_reactable.R @@ -4,46 +4,6 @@ #' and user-friendly tables tailored to the Department for Education's requirements. #' #' @param data A data frame to display in the table. -#' @param columns A named list of column definitions created with `reactable::colDef()`. -#' @param columnGroups A list of column groups created with `reactable::colGroup()`. -#' @param rownames Logical or character. If `TRUE`, show row names. If a string, the row names -#' will be displayed in a column with that name. Defaults to `NULL`. -#' @param groupBy A character vector of column names to group rows by. -#' @param sortable Logical. Enable sorting for all columns by default. -#' @param filterable Logical. Enable column filters. -#' @param searchable Logical. Add a global search box. -#' @param searchMethod Custom search function for global search. -#' @param defaultColDef Default column settings created with `reactable::colDef()`. -#' @param defaultColGroup Default column group settings created with `reactable::colGroup()`. -#' @param defaultSortOrder The default sort order for sortable columns. One of `"asc"` or `"desc"`. -#' @param defaultSorted A named list or character vector of columns to sort by default. -#' @param pagination Logical. Enable pagination. -#' @param defaultPageSize Number of rows to show per page by default. -#' @param showPageSizeOptions Logical. Allow users to change the page size. -#' @param pageSizeOptions A vector of page size options for the page size dropdown. -#' @param paginationType Pagination control type. One of `"numbers"` or `"jump"`. -#' @param showPagination Logical. Show pagination controls. -#' @param showPageInfo Logical. Show page info (e.g., "1–10 of 100 rows"). -#' @param minRows Minimum number of rows to show, even when the data has fewer rows. -#' @param paginateSubRows Logical. Paginate sub rows when rows are grouped. -#' @param details A function or formula for creating expandable row details. -#' @param defaultExpanded Logical or character vector. Expand rows by default. -#' @param selection Selection mode. One of `"multiple"`, `"single"`, or `"none"`. -#' @param defaultSelected A character vector of row names or indices to select by default. -#' @param onClick Callback function for row click events. -#' @param striped Logical. Add zebra-striping to rows. -#' @param compact Logical. Make rows compact. -#' @param wrap Logical. Allow cell text to wrap. -#' @param class CSS class to apply to the table. -#' @param style Inline styles to apply to the table. -#' @param rowClass CSS class to apply to each row. -#' @param rowStyle Inline styles to apply to each row. -#' @param width Table width in pixels or as a CSS value. -#' @param height Table height in pixels or as a CSS value. -#' @param meta Arbitrary metadata to include with the table. -#' @param elementId Element ID for the table widget. -#' @param static Logical. Render a static (non-interactive) table. -#' @param selectionId Element ID to store selected row indices. #' @param ... Additional arguments passed to `reactable::reactable`. #' #' @details @@ -64,11 +24,15 @@ #' #' @examples #' if (interactive()) { -#' library(reactable) -#' dfe_reactable(mtcars) +#' library(shiny) +#' library(dfeshiny) +#' ui <- fluidPage( +#' h1("Example of dfe_reactable in a Shiny app"), +#' dfe_reactable(mtcars) +#' ) +#' server <- function(input, output, session) {} +#' shinyApp(ui, server) #' } -#' -#' @export dfe_reactable <- function(data, ...) { diff --git a/_pkgdown.yml b/_pkgdown.yml index 1e51cb2..af1103b 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -32,3 +32,7 @@ reference: desc: A wrapper for shinyGovstyle::header() that automatically uses the DfE logo. contents: - header +- title: Charts and Tables + desc: Functions to create and manage tables and visualisations. + contents: + - dfe_reactable diff --git a/man/dfe_reactable.Rd b/man/dfe_reactable.Rd index 97cf61a..385ad22 100644 --- a/man/dfe_reactable.Rd +++ b/man/dfe_reactable.Rd @@ -10,85 +10,6 @@ dfe_reactable(data, ...) \item{data}{A data frame to display in the table.} \item{...}{Additional arguments passed to \code{reactable::reactable}.} - -\item{columns}{A named list of column definitions created with \code{reactable::colDef()}.} - -\item{columnGroups}{A list of column groups created with \code{reactable::colGroup()}.} - -\item{rownames}{Logical or character. If \code{TRUE}, show row names. If a string, the row names -will be displayed in a column with that name. Defaults to \code{NULL}.} - -\item{groupBy}{A character vector of column names to group rows by.} - -\item{sortable}{Logical. Enable sorting for all columns by default.} - -\item{filterable}{Logical. Enable column filters.} - -\item{searchable}{Logical. Add a global search box.} - -\item{searchMethod}{Custom search function for global search.} - -\item{defaultColDef}{Default column settings created with \code{reactable::colDef()}.} - -\item{defaultColGroup}{Default column group settings created with \code{reactable::colGroup()}.} - -\item{defaultSortOrder}{The default sort order for sortable columns. One of \code{"asc"} or \code{"desc"}.} - -\item{defaultSorted}{A named list or character vector of columns to sort by default.} - -\item{pagination}{Logical. Enable pagination.} - -\item{defaultPageSize}{Number of rows to show per page by default.} - -\item{showPageSizeOptions}{Logical. Allow users to change the page size.} - -\item{pageSizeOptions}{A vector of page size options for the page size dropdown.} - -\item{paginationType}{Pagination control type. One of \code{"numbers"} or \code{"jump"}.} - -\item{showPagination}{Logical. Show pagination controls.} - -\item{showPageInfo}{Logical. Show page info (e.g., "1–10 of 100 rows").} - -\item{minRows}{Minimum number of rows to show, even when the data has fewer rows.} - -\item{paginateSubRows}{Logical. Paginate sub rows when rows are grouped.} - -\item{details}{A function or formula for creating expandable row details.} - -\item{defaultExpanded}{Logical or character vector. Expand rows by default.} - -\item{selection}{Selection mode. One of \code{"multiple"}, \code{"single"}, or \code{"none"}.} - -\item{defaultSelected}{A character vector of row names or indices to select by default.} - -\item{onClick}{Callback function for row click events.} - -\item{striped}{Logical. Add zebra-striping to rows.} - -\item{compact}{Logical. Make rows compact.} - -\item{wrap}{Logical. Allow cell text to wrap.} - -\item{class}{CSS class to apply to the table.} - -\item{style}{Inline styles to apply to the table.} - -\item{rowClass}{CSS class to apply to each row.} - -\item{rowStyle}{Inline styles to apply to each row.} - -\item{width}{Table width in pixels or as a CSS value.} - -\item{height}{Table height in pixels or as a CSS value.} - -\item{meta}{Arbitrary metadata to include with the table.} - -\item{elementId}{Element ID for the table widget.} - -\item{static}{Logical. Render a static (non-interactive) table.} - -\item{selectionId}{Element ID to store selected row indices.} } \value{ A \code{reactable} HTML widget object. @@ -113,8 +34,13 @@ and alignment. } \examples{ if (interactive()) { - library(reactable) - dfe_reactable(mtcars) + library(shiny) + library(dfeshiny) + ui <- fluidPage( + h1("Example of dfe_reactable in a Shiny app"), + dfe_reactable(mtcars) + ) + server <- function(input, output, session) {} + shinyApp(ui, server) } - } diff --git a/tests/test_dashboard/server.R b/tests/test_dashboard/server.R index 56103a8..531a107 100644 --- a/tests/test_dashboard/server.R +++ b/tests/test_dashboard/server.R @@ -15,4 +15,6 @@ server <- function(input, output, session) { input_cookies = shiny::reactive(input$cookies), google_analytics_key = ga_key # nolint: [object_usage_linter] ) + + output$reactable_example <- reactable::renderReactable(dfe_reactable(mtcars)) } diff --git a/tests/test_dashboard/tests/testthat/_snaps/UI-04-table/table_example-001.json b/tests/test_dashboard/tests/testthat/_snaps/UI-04-table/table_example-001.json new file mode 100644 index 0000000..fd2ae4b --- /dev/null +++ b/tests/test_dashboard/tests/testthat/_snaps/UI-04-table/table_example-001.json @@ -0,0 +1,5 @@ +{ + "output": { + + } +} diff --git a/tests/test_dashboard/tests/testthat/test-UI-04-table.R b/tests/test_dashboard/tests/testthat/test-UI-04-table.R new file mode 100644 index 0000000..5b5512c --- /dev/null +++ b/tests/test_dashboard/tests/testthat/test-UI-04-table.R @@ -0,0 +1,13 @@ +app <- AppDriver$new( + name = "table_example", + expect_values_screenshot_args = FALSE +) + +app$wait_for_idle(50) + +test_that("Table renders as expected", { + # Check the initial rendering of the table + app$wait_for_idle(50) + app$expect_values(output = "reactable_example") +}) + diff --git a/tests/test_dashboard/ui.R b/tests/test_dashboard/ui.R index 285e6e9..c9bf086 100644 --- a/tests/test_dashboard/ui.R +++ b/tests/test_dashboard/ui.R @@ -99,6 +99,14 @@ ui <- function(input, output, session) { ), " code in a cave without distractions." ) + ), + + ## Example table panel -------------------------------------------------------- + shiny::tabPanel( + value = "table_panel_ui", + "Table example", + shiny::tags$h1("Reactable example"), + reactable::reactableOutput("reactable_example") ) ) )