## -----------------------------------------------------------------------------
#| include: false
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
# This is a self-contained HTML document, so every htmlwidget dependency is
# embedded. Load the DuckDB-WASM engine from the CDN (a small script reference)
# rather than embedding the ~80 MB local engine bundle into the page.
options(datasetviewer.use_local_engine = FALSE)


## -----------------------------------------------------------------------------
library(datasetviewer)
dataset_viewer(mtcars)


## -----------------------------------------------------------------------------
#| eval: !expr requireNamespace("artoo", quietly = TRUE)
# artoo ships the CDISC pilot ADaM datasets used across these docs.
dataset_viewer(artoo::cdisc_adsl, view = "labels")


## -----------------------------------------------------------------------------
#| eval: false
# library(shiny)
# library(datasetviewer)
# 
# ui <- fluidPage(
#   datasetviewerOutput("viewer", height = "560px"),
#   verbatimTextOutput("state")
# )
# 
# server <- function(input, output, session) {
#   output$viewer <- renderDatasetViewer(dataset_viewer(mtcars))
# 
#   # State changes in the widget arrive as inputs, namespaced by output id.
#   output$state <- renderPrint({
#     list(
#       columns = input$viewer_columns, # columns currently shown
#       filter  = input$viewer_filter, # active filter expression
#       sort    = input$viewer_sort, # active sort
#       view    = input$viewer_view # "names" or "labels"
#     )
#   })
# }
# 
# shinyApp(ui, server)


## -----------------------------------------------------------------------------
#| eval: false
# options(datasetviewer.use_local_engine = FALSE)

