% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/module_picks.R
\name{picks_module}
\alias{picks_module}
\alias{picks_ui}
\alias{picks_ui.list}
\alias{picks_ui.picks}
\alias{picks_srv}
\alias{picks_srv.list}
\alias{picks_srv.picks}
\title{Interactive picks}
\usage{
picks_ui(id, picks, container = "badge_dropdown")

\method{picks_ui}{list}(id, picks, container)

\method{picks_ui}{picks}(id, picks, container)

picks_srv(id = "", picks, data)

\method{picks_srv}{list}(id, picks, data)

\method{picks_srv}{picks}(id, picks, data)
}
\arguments{
\item{id}{(\code{character(1)}) Shiny module ID}

\item{picks}{(\code{picks} or \code{list}) object created by \code{picks()} or a named list of such objects}

\item{container}{(\code{character(1)} or \code{function}) UI container type. Can be one of \code{htmltools::tags}
functions. By default, elements are wrapped in a package-specific drop-down.}

\item{data}{(\code{reactive}) Reactive expression returning the data object to be used for populating choices}
}
\value{
\itemize{
\item \code{picks_ui()}: UI elements for the input controls
\item \code{picks_srv()}: Server-side reactive logic returning the processed data
}
}
\description{
Creates UI and server components for interactive \code{\link[=picks]{picks()}} in Shiny modules. The module is based on
configuration provided via \code{\link[=picks]{picks()}} and its responsibility is to determine relevant input
values

The module supports both single and combined \code{picks}:
\itemize{
\item Single \code{picks} objects for a single input
\item Named lists of \code{picks} objects for multiple inputs
}
}
\details{
The module uses S3 method dispatch to handle different ways to provide \code{picks}:
\itemize{
\item \code{.picks} methods handle single `picks`` object
\item \code{.list} methods handle multiple \code{picks} objects
}

The UI component (\code{picks_ui}) creates the visual elements, while the
server component (\code{picks_srv}) manages the reactive logic,
}
\examples{
library(shiny)

example_pick <- picks(
  datasets("ADSL"),
  variables(selected = c("SEX", "COUNTRY", "ARMCD"))
)
ui <- fluidPage(
  picks_ui("my_picks", picks = example_pick),
  h4("Resolved picks:"),
  verbatimTextOutput("result"),
  h4("Table:"),
  tableOutput("table")
)
server <- function(input, output, session) {
  data <- teal.data::teal_data("ADSL" = teal.data::rADSL)
  teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys["ADSL"]
  selectors <- picks_srv(
    picks = list(my_picks = example_pick),
    data = reactive(data)
  )
  anl <- merge_srv("merge", data = reactive(data), selectors = selectors)
  output$result <- renderPrint(cat(gsub("\033\\\\[[0-9;]*m", "", format(selectors$my_picks()))))
  output$table <- renderTable(anl$data()$anl)
}

if (interactive()) {
  shinyApp(ui, server)
}
}
\seealso{
\code{\link[=picks]{picks()}} for creating `picks`` objects
}
