Skip to content

Commit

Permalink
add select and update select input
Browse files Browse the repository at this point in the history
  • Loading branch information
DivadNojnarg committed Jul 16, 2020
1 parent dc16fc5 commit 3dcd1d3
Show file tree
Hide file tree
Showing 4 changed files with 208 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export(page_386)
export(progress_386)
export(radio_input_386)
export(remove_modal_386)
export(select_input_386)
export(show_modal_386)
export(show_toast_386)
export(text_area_input_386)
Expand All @@ -26,6 +27,7 @@ export(toggle_input_386)
export(update_checkbox_input_386)
export(update_progress_386)
export(update_radio_input_386)
export(update_select_input_386)
export(update_toggle_input_386)
export(use_bs4_deps)
export(validate_progress_value)
Expand Down
67 changes: 67 additions & 0 deletions R/inputs.R
Original file line number Diff line number Diff line change
Expand Up @@ -332,3 +332,70 @@ update_radio_input_386 <- function(session, inputId, label = NULL, choices = NUL
choiceValues
)
}



#' Create a Bootstrap 386 select input
#' @inheritParams shiny::selectInput
#' @export
#' @examples
#' if (interactive()) {
#' library(shiny)
#' library(shiny386)
#'
#' ui <- page_386(
#' select_input_386("variable", "Variable:",
#' c("Cylinders" = "cyl",
#' "Transmission" = "am",
#' "Gears" = "gear")),
#' tableOutput("data")
#' )
#'
#' server <- function(input, output, session) {
#' output$data <- renderTable({
#' mtcars[, c("mpg", input$variable), drop = FALSE]
#' }, rownames = TRUE)
#' }
#' shinyApp(ui, server)
#'
#' }
select_input_386 <- shiny::selectInput



#' Update a Bootstrap 386 select input on the client
#' @inheritParams shiny::updateSelectInput
#' @export
#' @examples
#' if (interactive()) {
#' library(shiny)
#' library(shiny386)
#'
#' ui <- page_386(
#' p("The radio group controls the select input"),
#' radio_input_386("inCheckboxGroup", "Input checkbox",
#' c("Item A", "Item B", "Item C")),
#' select_input_386("inSelect", "Select input",
#' c("Item A", "Item B", "Item C"))
#' )
#'
#' server <- function(input, output, session) {
#' observe({
#' x <- input$inCheckboxGroup
#'
#' # Can use character(0) to remove all choices
#' if (is.null(x))
#' x <- character(0)
#'
#' # Can also set the label and select items
#' update_select_input_386(session, "inSelect",
#' label = paste("Select input label", length(x)),
#' choices = x,
#' selected = tail(x, 1)
#' )
#' })
#' }
#'
#' shinyApp(ui, server)
#' }
update_select_input_386 <- shiny::updateSelectInput
70 changes: 70 additions & 0 deletions man/select_input_386.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 69 additions & 0 deletions man/update_select_input_386.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3dcd1d3

Please sign in to comment.