dreamRs / shinyWidgets

Compare b6ae8a0 ... +5 ... 874a04c


@@ -21,7 +21,7 @@
Loading
21 21
#'
22 22
#'
23 23
#' @importFrom shiny restoreInput
24 -
#' @importFrom htmltools tags validateCssUnit
24 +
#' @importFrom htmltools tags validateCssUnit attachDependencies findDependencies
25 25
#'
26 26
#' @export
27 27
#'
@@ -48,17 +48,35 @@
Loading
48 48
#' }
49 49
#' shinyApp(ui, server)
50 50
#' }
51 -
switchInput <- function(inputId, label = NULL, value = FALSE, onLabel = 'ON', offLabel = 'OFF',
52 -
                        onStatus = NULL, offStatus = NULL, size = "default", labelWidth = "auto",
53 -
                        handleWidth = "auto", disabled = FALSE, inline = FALSE, width = NULL) {
51 +
switchInput <- function(inputId,
52 +
                        label = NULL,
53 +
                        value = FALSE,
54 +
                        onLabel = "ON",
55 +
                        offLabel = "OFF",
56 +
                        onStatus = NULL,
57 +
                        offStatus = NULL,
58 +
                        size = "default",
59 +
                        labelWidth = "auto",
60 +
                        handleWidth = "auto",
61 +
                        disabled = FALSE,
62 +
                        inline = FALSE,
63 +
                        width = NULL) {
54 64
  value <- shiny::restoreInput(id = inputId, default = value)
55 65
  size <- match.arg(arg = size, choices = c('default', 'mini', 'small', 'normal', 'large'))
56 66
  switchProps <- dropNulls(
57 67
    list(
58 -
      id = inputId, type = "checkbox", class = "sw-switchInput", `data-input-id` = inputId,
59 -
      `data-on-text` = onLabel, `data-off-text` = offLabel, `data-label-text` = label,
60 -
      `data-on-color` = onStatus, `data-off-color` = offStatus, #`data-state` = value,
61 -
      `data-label-width` = labelWidth, `data-handle-width` = handleWidth,
68 +
      id = inputId,
69 +
      type = "checkbox",
70 +
      class = "sw-switchInput",
71 +
      `data-input-id` = inputId,
72 +
      `data-on-text` = onLabel,
73 +
      `data-off-text` = offLabel,
74 +
      `data-label-text` = label,
75 +
      `data-on-color` = onStatus,
76 +
      `data-off-color` = offStatus,
77 +
      #`data-state` = value,
78 +
      `data-label-width` = labelWidth,
79 +
      `data-handle-width` = handleWidth,
62 80
      `disabled` =  if (!disabled) NULL else disabled,
63 81
      `data-size` = if (size == "default") "" else size
64 82
    )
@@ -80,7 +98,11 @@
Loading
80 98
    style = if (!is.null(width)) paste0("width: ", htmltools::validateCssUnit(width), ";"),
81 99
    inputTag
82 100
  )
83 -
  # Dep
101 +
  # Dependencies
102 +
  switchInputTag <- attachDependencies(
103 +
    switchInputTag,
104 +
    htmltools::findDependencies(tagList(label, offLabel, onLabel))
105 +
  )
84 106
  attachShinyWidgetsDep(switchInputTag, "bsswitch")
85 107
}
86 108

@@ -65,13 +65,16 @@
Loading
65 65
  # create custom css background for each slider
66 66
  # selected by the user
67 67
  sliderCol <- lapply(sliderId, FUN = function(i) {
68 -
    paste0(".js-irs-", i, " .irs-single,",
69 -
           " .js-irs-", i, " .irs-from,",
70 -
           " .js-irs-", i, " .irs-to,",
71 -
           " .js-irs-", i, " .irs-bar-edge,",
72 -
           " .js-irs-", i, " .irs-bar{
73 -
           background: ", color[i+1], ";
74 -
  }"
68 +
    paste0(
69 +
      ".js-irs-", i, " .irs-single,",
70 +
      " .js-irs-", i, " .irs-from,",
71 +
      " .js-irs-", i, " .irs-to,",
72 +
      " .js-irs-", i, " .irs-bar-edge,",
73 +
      " .js-irs-", i,
74 +
      " .irs-bar{background: ", color[i+1],
75 +
      "; border-top: 1px solid ", color[i+1],
76 +
      "; border-bottom: 1px solid ", color[i+1],
77 +
      ";}"
75 78
    )
76 79
  })
77 80

@@ -65,7 +65,12 @@
Loading
65 65
      class = "shiny-numeric-range-input form-group shiny-input-container",
66 66
      style = if (!is.null(width)) paste0("width: ", htmltools::validateCssUnit(width), ";"),
67 67
68 -
      controlLabel(inputId, label),
68 +
      tags$label(
69 +
        class = "control-label",
70 +
        `for` = inputId,
71 +
        label,
72 +
        class = if (is.null(label)) "shiny-label-null"
73 +
      ),
69 74
      # input-daterange class is needed for dropdown behavior
70 75
      htmltools::tags$div(
71 76
        class = "input-numeric-range input-group",

@@ -376,12 +376,18 @@
Loading
376 376
    options$minDate <- to_ms(options$minDate)
377 377
    options$maxDate <- to_ms(options$maxDate)
378 378
  }
379 +
  if (!is.null(options$disabledDates)) {
380 +
    options$disabledDates <- list1(options$disabledDates)
381 +
  }
382 +
  if (!is.null(options$highlightedDates)) {
383 +
    options$highlightedDates <- list1(options$highlightedDates)
384 +
  }
379 385
  message <- dropNulls(list(
380 386
    id = session$ns(inputId),
381 387
    label = label,
382 388
    value = value,
383 389
    clear = isTRUE(clear),
384 -
    options = options,
390 +
    options = dropNulls(options),
385 391
    show = isTRUE(show),
386 392
    hide = isTRUE(hide)
387 393
  ))

@@ -96,27 +96,15 @@
Loading
96 96
}
97 97
98 98
99 -
`%AND%` <- function(x, y) {
100 -
  if (!is.null(x) && !anyNA(x))
101 -
    if (!is.null(y) && !anyNA(y))
102 -
      return(y)
103 -
  return(NULL)
104 -
}
105 -
106 99
107 100
`%||%` <- function(x, y) {
108 101
  if (!is.null(x)) x else y
109 102
}
110 103
111 -
escape_jquery <- function(string) {
112 -
  gsub(x = string, pattern = "(\\W)", replacement = "\\\\\\\\\\1")
113 -
}
114 -
115 104
116 105
117 106
118 -
firstChoice <- function(choices)
119 -
{
107 +
firstChoice <- function(choices) {
120 108
  if (length(choices) == 0L)
121 109
    return()
122 110
  choice <- choices[[1]]
@@ -183,9 +171,7 @@
Loading
183 171
  }
184 172
}
185 173
186 -
controlLabel <- function(controlName, label) {
187 -
  label %AND% htmltools::tags$label(class = "control-label", `for` = controlName, label)
188 -
}
174 +
189 175
190 176
formatNoSci <- function(x) {
191 177
  if (is.null(x)) return(NULL)

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Everything is accounted for!

No changes detected that need to be reviewed.
What changes does Codecov check for?
Lines, not adjusted in diff, that have changed coverage data.
Files that introduced coverage data that had none before.
Files that have missing coverage data that once were tracked.
Files Coverage
R/actionBttn.R 55.26%
R/addSpinner.R 95.93%
R/bootstrap-utils.R 45.45%
R/chooseSliderSkin.R 78.57%
R/color-pickr.R 0.00%
R/demos.R 0.00%
R/dependencies.R -4.94% 60.00%
R/drop-menu.R 75.90%
R/execute_safely.R 0.00%
R/input-actiongroupbuttons.R 100.00%
R/input-airDatepicker.R -2.05% 75.50%
R/input-autonumeric.R 95.38%
R/input-awesomecheckbox.R 97.33%
R/input-awesomeradio.R 96.72%
R/input-checkboxgroupbuttons.R 97.53%
R/input-circlebutton.R 100.00%
R/input-colorselector.R 91.04%
R/input-dropdown.R 92.59%
R/input-icon.R 63.10%
R/input-knob.R 91.67%
R/input-materialswitch.R 100.00%
R/input-multi.R 92.68%
R/input-noUiSlider.R 86.44%
R/input-numericRange.R +2.98% 82.14%
R/input-pretty.R 78.52%
R/input-radiogroupbuttons.R 96.59%
R/input-search.R 83.78%
R/input-selectpicker.R 73.40%
R/input-sliderText.R 97.73%
R/input-spectrum.R 92.31%
R/input-switch.R +1.49% 95.24%
R/input-textaddon.R 100.00%
R/module-pickerGroup.R 100.00%
R/module-selectizeGroup.R 100.00%
R/module-utils.R 37.50%
R/onLoad.R 0.00%
R/pickerOptions.R 100.00%
R/progressBars.R 67.92%
R/set-background.R 90.00%
R/setShadow.R 81.82%
R/setSliderColor.R 0.00%
R/stati-card.R 0.00%
R/sw-dropdown.R 76.36%
R/sweetalert.R 59.91%
R/useArgonDash.R 0.00%
R/useBs4Dash.R 0.00%
R/useShinydashboard.R 0.00%
R/useShinydashboardPlus.R 0.00%
R/useTablerDash.R 0.00%
R/utils.R -0.11% 64.84%
R/vertical-tab.R 83.96%
Project Totals (51 files) 74.85%
Loading