3232# ' @seealso [picks()] for creating `picks`` objects
3333# '
3434# ' @name picks_module
35+ # ' @examples
36+ # ' library(shiny)
37+ # '
38+ # ' example_pick <- picks(
39+ # ' datasets("ADSL"),
40+ # ' variables(selected = c("SEX", "COUNTRY", "ARMCD"))
41+ # ' )
42+ # ' ui <- fluidPage(
43+ # ' picks_ui("my_picks", picks = example_pick),
44+ # ' h4("Resolved picks:"),
45+ # ' verbatimTextOutput("result"),
46+ # ' h4("Table:"),
47+ # ' tableOutput("table")
48+ # ' )
49+ # ' server <- function(input, output, session) {
50+ # ' data <- teal.data::teal_data("ADSL" = teal.data::rADSL)
51+ # ' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys["ADSL"]
52+ # ' selectors <- picks_srv(
53+ # ' picks = list(my_picks = example_pick),
54+ # ' data = reactive(data)
55+ # ' )
56+ # ' anl <- merge_srv("merge", data = reactive(data), selectors = selectors)
57+ # ' output$result <- renderPrint(cat(gsub("\033\\[[0-9;]*m", "", format(selectors$my_picks()))))
58+ # ' output$table <- renderTable(anl$data()$anl)
59+ # ' }
60+ # '
61+ # ' if (interactive()) {
62+ # ' shinyApp(ui, server)
63+ # ' }
3564NULL
3665
3766# ' @rdname picks_module
@@ -327,6 +356,7 @@ picks_srv.picks <- function(id, picks, data) {
327356.pick_ui_fixed <- function (id , selected ) {
328357 htmltools :: tags $ div(
329358 class = " form-group shiny-input-container" ,
359+ style = " visibility: hidden; position: absolute;" ,
330360 htmltools :: tags $ input(
331361 id = id ,
332362 disabled = " disabled" ,
@@ -396,6 +426,7 @@ picks_srv.picks <- function(id, picks, data) {
396426# ' @param rv (`reactiveVal`)
397427# ' @param value (`vector`)
398428# ' @param log (`character(1)`) message to `log_debug`
429+ # ' @return the result of `reactiveVal` update if new value is different, `NULL` otherwise.
399430# ' @keywords internal
400431.update_rv <- function (rv , value , log ) {
401432 if (! isTRUE(all.equal(rv(), value , tolerance = 1e-15 ))) { # tolerance 1e-15 is a max precision in widgets.
@@ -420,6 +451,8 @@ picks_srv.picks <- function(id, picks, data) {
420451# ' @param picks_resolved (`reactiveVal`)
421452# ' @param old_picks (`picks`)
422453# ' @param data (`any` asserted further in `resolver`)
454+ # ' @return The result of changing the `picks_resolved` `reactiveVal` given as argument.
455+ # ' It returns `NULL` if it does nothing.
423456# ' @keywords internal
424457.resolve <- function (selected , slot_name , picks_resolved , old_picks , data ) {
425458 checkmate :: assert_vector(selected , null.ok = TRUE )
@@ -479,7 +512,6 @@ picks_srv.picks <- function(id, picks, data) {
479512# ' Otherwise `default`.
480513# '
481514# ' @keywords internal
482- # '
483515restoreValue <- function (value , default ) { # nolint: object_name.
484516 checkmate :: assert_character(" value" )
485517 session_default <- shiny :: getDefaultReactiveDomain()
0 commit comments