🔍 An RStudio addin slash regex utility belt
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

73 lines
2.8KB

  1. # ---- Modified Shiny Inputs ----
  2. # The shiny package as a whole is distributed under GPL-3
  3. # (GNU GENERAL PUBLIC LICENSE version 3).
  4. # See https://github.com/rstudio/shiny/blob/master/LICENSE
  5. #' Modified Text Area Input
  6. #'
  7. #' @inheritParams shiny::textAreaInput
  8. textAreaInputAlt <- function(inputId, label, value = "", width = NULL, height = NULL,
  9. cols = NULL, rows = NULL, placeholder = NULL, resize = NULL,
  10. is_code = TRUE) {
  11. `%AND%` <- shiny:::`%AND%`
  12. value <- shiny::restoreInput(id = inputId, default = value)
  13. if (!is.null(resize)) {
  14. resize <- match.arg(resize, c("both", "none", "vertical", "horizontal"))
  15. }
  16. style <- paste(
  17. if (!is.null(width)) paste0("width: ", shiny::validateCssUnit(width), ";"),
  18. if (!is.null(height)) paste0("height: ", shiny::validateCssUnit(height), ";"),
  19. if (!is.null(resize)) paste0("resize: ", resize, ";"),
  20. if (is_code) 'font-family: "Monaco", "Inconsolata", monospace;'
  21. )
  22. parent_style <- paste(
  23. if (!is.null(width) && grepl("%", width)) paste0("width: ", width, ";"),
  24. if (!is.null(height) && grepl("%", height)) paste0("height: ", height, ";")
  25. )
  26. # Workaround for tag attribute=character(0) bug:
  27. # https://github.com/rstudio/htmltools/issues/65
  28. if (length(style) == 0) style <- NULL
  29. shiny::div(class = "form-group shiny-input-container",
  30. label %AND% shiny::tags$label(label, `for` = inputId),
  31. style = if (!parent_style %in% c(" ", "", " ")) parent_style,
  32. shiny::tags$textarea(
  33. id = inputId,
  34. class = "form-control",
  35. placeholder = placeholder,
  36. style = style,
  37. rows = rows,
  38. cols = cols,
  39. autocomplete = "off",
  40. autocorrect = "off",
  41. autocapitalize = "off",
  42. spellcheck = "false",
  43. value
  44. )
  45. )
  46. }
  47. #' Modified Text Input
  48. #'
  49. #' @inheritParams shiny::textInput
  50. textInputCode <- function(inputId, label, value = "", width = NULL,
  51. placeholder = NULL) {
  52. `%AND%` <- shiny:::`%AND%`
  53. value <- shiny::restoreInput(id = inputId, default = value)
  54. shiny::div(class = "form-group shiny-input-container",
  55. style = if (!is.null(width)) paste0("width: ", shiny::validateCssUnit(width), ";"),
  56. label %AND% shiny::tags$label(label, `for` = inputId),
  57. shiny::tags$input(id = inputId, type="text", class="form-control", value=value,
  58. style = 'font-family: "Monaco", "Inconsolata", monospace;',
  59. autocomplete = "off", autocorrect = "off",
  60. autocapitalize = "off", spellcheck = "false",
  61. placeholder = placeholder)
  62. )
  63. }