library(shinygouv)

selectInput_options_dsfr_template

selectInput_dsfr_template

selectInput_dsfr

## Only run examples in interactive R sessions
if (interactive()) {
  library(shiny)
  library(shinygouv)

  ui <- fluidPage_dsfr(
    header = header_dsfr(
      intitule = "Intitule",
      officiel = "Officiel",
      nom_site_service = "Nom du site / service",
      baseline = "baseline - precisions sur l organisation",
      class = "fr-m-1w"
    ),
    title = "Exemple",
    fluidRow_dsfr(
      # sans vecteur nommé
      selectInput_dsfr(
        inputId = "myselectInput",
        label = "Mon label",
        choices = c(
          "cyl",
          "am",
          "gear"
        )
      ),
      fluidRow_dsfr(
        # avec un vecteur nommé et une valeur sélectionnée
        selectInput_dsfr(
          inputId = "myselectInput2",
          label = "Mon label2",
          choices = c(
            "Cylinders" = "cyl",
            "Transmission" = "am",
            "Gears" = "gear"
          ),
          selected = "gear"
        )
      )
    )
  )
  server <- function(input, output, session) {
  }

  shinyApp(ui, server)
}

updateSelectInput_dsfr

## Only run examples in interactive R sessions
if (interactive()) {
  library(shiny)
  library(shinygouv)

  ui <- fluidPage_dsfr(
    header = header_dsfr(
      intitule = "Intitule",
      officiel = "Officiel",
      nom_site_service = "Nom du site / service",
      baseline = "baseline - precisions sur l organisation",
      class = "fr-m-1w"
    ),
    title = "Exemple",
    fluidRow_dsfr(
      selectInput_dsfr(
        inputId = "variable",
        label = "Variable:",
        choices = c(
          "Cylinders" = "cyl",
          "Transmission" = "am",
          "Gears" = "gear"
        )
      )
    ),
    fluidRow_dsfr(
      actionButton_dsfr(inputId = "update", label = "update label")
    ),
    fluidRow_dsfr(
      actionButton_dsfr(inputId = "update2", label = "update choices")
    ),
    fluidRow_dsfr(
      actionButton_dsfr(inputId = "update3", label = "update selected")
    )
  )
  server <- function(input, output, session) {
    observeEvent(input$update, {
      updateSelectInput_dsfr(inputId = "variable", label = "Nouveau label")
    })

    observeEvent(input$update2, {
      updateSelectInput_dsfr(inputId = "variable", choices = LETTERS)
    })

    observeEvent(input$update3, {
      updateSelectInput_dsfr(inputId = "variable", selected = LETTERS[12])
    })
  }

  shinyApp(ui, server)
}