Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow update input labels with HTML #3996

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
51 changes: 39 additions & 12 deletions R/update-input.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@
updateTextInput <- function(session = getDefaultReactiveDomain(), inputId, label = NULL, value = NULL, placeholder = NULL) {
validate_session_object(session)

message <- dropNulls(list(label=label, value=value, placeholder=placeholder))
message <- dropNulls(list(
label = processDeps(label, session),
value = value,
placeholder = placeholder
))
session$sendInputMessage(inputId, message)
}

Expand Down Expand Up @@ -111,7 +115,10 @@ updateTextAreaInput <- updateTextInput
updateCheckboxInput <- function(session = getDefaultReactiveDomain(), inputId, label = NULL, value = NULL) {
validate_session_object(session)

message <- dropNulls(list(label=label, value=value))
message <- dropNulls(list(
label = processDeps(label, session),
value = value
))
session$sendInputMessage(inputId, message)
}

Expand Down Expand Up @@ -175,13 +182,17 @@ updateActionButton <- function(session = getDefaultReactiveDomain(), inputId, la
validate_session_object(session)

if (!is.null(icon)) icon <- as.character(validateIcon(icon))
message <- dropNulls(list(label=label, icon=icon, disabled=disabled))
message <- dropNulls(list(
label = processDeps(label, session),
icon = icon,
disabled = disabled
))
session$sendInputMessage(inputId, message)
}
#' @rdname updateActionButton
#' @export
updateActionLink <- function(session = getDefaultReactiveDomain(), inputId, label = NULL, icon = NULL) {
updateActionButton(session, inputId=inputId, label=label, icon=icon)
updateActionButton(session, inputId = inputId, label = processDeps(label, session), icon = icon)
}


Expand Down Expand Up @@ -225,7 +236,12 @@ updateDateInput <- function(session = getDefaultReactiveDomain(), inputId, label
min <- dateYMD(min, "min")
max <- dateYMD(max, "max")

message <- dropNulls(list(label=label, value=value, min=min, max=max))
message <- dropNulls(list(
label = processDeps(label, session),
value = value,
min = min,
max = max
))
session$sendInputMessage(inputId, message)
}

Expand Down Expand Up @@ -275,7 +291,7 @@ updateDateRangeInput <- function(session = getDefaultReactiveDomain(), inputId,
max <- dateYMD(max, "max")

message <- dropNulls(list(
label = label,
label = processDeps(label, session),
value = dropNulls(list(start = start, end = end)),
min = min,
max = max
Expand Down Expand Up @@ -374,13 +390,16 @@ updateNavlistPanel <- updateTabsetPanel
#' }
#' @export
updateNumericInput <- function(session = getDefaultReactiveDomain(), inputId, label = NULL, value = NULL,
min = NULL, max = NULL, step = NULL) {
min = NULL, max = NULL, step = NULL) {

validate_session_object(session)

message <- dropNulls(list(
label = label, value = formatNoSci(value),
min = formatNoSci(min), max = formatNoSci(max), step = formatNoSci(step)
label = processDeps(label, session),
value = formatNoSci(value),
min = formatNoSci(min),
max = formatNoSci(max),
step = formatNoSci(step)
))
session$sendInputMessage(inputId, message)
}
Expand Down Expand Up @@ -460,7 +479,7 @@ updateSliderInput <- function(session = getDefaultReactiveDomain(), inputId, lab
}

message <- dropNulls(list(
label = label,
label = processDeps(label, session),
value = formatNoSci(value),
min = formatNoSci(min),
max = formatNoSci(max),
Expand Down Expand Up @@ -491,7 +510,11 @@ updateInputOptions <- function(session, inputId, label = NULL, choices = NULL,
))
}

message <- dropNulls(list(label = label, options = options, value = selected))
message <- dropNulls(list(
label = processDeps(label, session),
options = options,
value = selected
))

session$sendInputMessage(inputId, message)
}
Expand Down Expand Up @@ -644,7 +667,11 @@ updateSelectInput <- function(session = getDefaultReactiveDomain(), inputId, lab
choices <- if (!is.null(choices)) choicesWithNames(choices)
if (!is.null(selected)) selected <- as.character(selected)
options <- if (!is.null(choices)) selectOptions(choices, selected, inputId, FALSE)
message <- dropNulls(list(label = label, options = options, value = selected))
message <- dropNulls(list(
label = processDeps(label, session),
options = options,
value = selected
))
session$sendInputMessage(inputId, message)
}

Expand Down