#' Select Function
#'
#' This function inserts a select box
#' @param inputId Input Id for the component
#' @param label Insert the text for the label
#' @param select_text Add the text that will apply in the drop down as a list
#' @param select_value Add the value that will be used for each selection
#' @return a select input HTML shiny tag object
#' @family Govstyle select inputs
#' @export
#' @examples
#' ui <- shiny::fluidPage(
#'   shinyGovstyle::header(
#'     org_name = "Example",
#'     service_name = "User Examples",
#'     logo = "shinyGovstyle/images/moj_logo.png",
#'     logo_alt_text = "Ministry of Justice logo"
#'   ),
#'   shinyGovstyle::gov_layout(
#'     size = "full",
#'     select_Input(
#'       inputId = "sorter",
#'       label = "Sort by",
#'       select_text = c(
#'         "Recently published",
#'         "Recently updated",
#'         "Most views",
#'         "Most comments"
#'       ),
#'       select_value = c("published", "updated", "view", "comments")
#'     ),
#'     shiny::tags$br()
#'   ),
#'   shinyGovstyle::footer(full = TRUE)
#' )
#'
#' server <- function(input, output, session) {}
#' if (interactive()) shinyApp(ui = ui, server = server)
select_Input <- # nolint
  function(
    inputId, # nolint
    label,
    select_text,
    select_value
  ) {
    gov_select <- shiny::tags$div(
      class = "govuk-form-group",
      shiny::tags$label(
        shiny::HTML(label),
        class = "govuk-label",
        `for` = inputId
      ),
      shiny::tags$select(
        id = inputId,
        class = "govuk-select",
        Map(
          function(x, y) {
            shiny::tags$option(value = y, x)
          },
          x = select_text,
          y = select_value
        )
      )
    )
    attachDependency(gov_select)
  }
