inst/examples/app-dateRangeInput.R

library(shiny)
library(shinyinvoer)

ui <- fluidPage(
  uiOutput("the_input"),
  uiOutput("the_other_input"),
  verbatimTextOutput("the_output"),
  verbatimTextOutput("the_other_output"),
  checkboxInput('the_update', 'Reset with new dates')
)

server <- function(input, output, session) {
  output$the_input <- renderUI({
    shinyinvoer::dateRangeInput(
      inputId = "date_range",
      label = 'Seleccione el rango de fechas',
      start = '2022-04-11',
      end = '2022-04-18',
      min = '2022-01-01',
      max = '2022-12-31',
      startLabel = 'Fecha inicial',
      endLabel = 'Fecha final',
      resetLabel = 'Restablecer fechas',
      locale = 'es'
    )
  })

  output$the_other_input <- renderUI({
    shinyinvoer::dateRangeInput(
      inputId = "other_date_range",
      label = 'Seleccione el rango de fechas',
      start = '2021-04-11',
      end = '2021-04-18',
      min = '2021-01-01',
      max = '2021-12-31',
      startLabel = 'Fecha inicial',
      endLabel = 'Fecha final',
      resetLabel = 'Restablecer fechas',
      locale = 'es'
    )
  })

  output$the_output <- renderPrint({
    input$date_range
  })

  output$the_other_output <- renderPrint({
    input$other_date_range
  })

  observe({
    if (input$the_update) {
      shinyinvoer::updateDateRangeInput(
        session,
        inputId = "date_range",
        start = '2021-05-07',
        end = '2021-08-23',
        minDate = '2020-01-01',
        maxDate = '2022-01-01'
      )
    }
  })
}

shinyApp(ui, server)
datasketch/shinyinvoer documentation built on June 2, 2025, 2:14 a.m.