Skip to content

Commit

Permalink
added inputType arg to searchInput and textInputIcon
Browse files Browse the repository at this point in the history
  • Loading branch information
pvictor committed Dec 6, 2024
1 parent abe4a2d commit efab1c4
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: shinyWidgets
Title: Custom Inputs Widgets for Shiny
Version: 0.8.7.9100
Version: 0.8.7.9200
Authors@R: c(
person("Victor", "Perrier", email = "[email protected]", role = c("aut", "cre", "cph")),
person("Fanny", "Meyer", role = "aut"),
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
shinyWidgets 0.8.8
======================

* New argument `inputType` in `searchInput()` and `textInputIcon()` to specify the input's type, for example `"password"`.
* `knobInput()` and `switchInput()` are softly deprecated, since the JavaScript libraries used by those widgets are no longer actively maintained.
* Updated virtual-select to 1.0.46 (fix focus issue), see https://github.com/sa-si-dev/virtual-select/releases.
* Updated @simonwep/pickr to 1.9.1, see https://github.com/simonwep/pickr/releases.
Expand Down
5 changes: 4 additions & 1 deletion R/input-icon.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#' or text, to be displayed on the right or left of the text input.
#' @param size Size of the input, default to `NULL`, can
#' be `"sm"` (small) or `"lg"` (large).
#' @param inputType The type of input to use, default is `"text"` but you can also use `"password"` for example,
#' see [developer.mozilla.org](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text) for other possible types.
#'
#' @return A text input control that can be added to a UI definition.
#' @seealso See [updateTextInputIcon()] to update server-side, and [numericInputIcon()] for using numeric value.
Expand All @@ -24,6 +26,7 @@ textInputIcon <- function(inputId,
placeholder = NULL,
icon = NULL,
size = NULL,
inputType = "text",
width = NULL) {
value <- shiny::restoreInput(id = inputId, default = value)
tags$div(
Expand All @@ -36,7 +39,7 @@ textInputIcon <- function(inputId,
markup_input_group(icon, "left", theme_func = shiny::getCurrentTheme),
tags$input(
id = inputId,
type = "text",
type = inputType,
class = "form-control text-input-icon",
value = value,
placeholder = placeholder
Expand Down
5 changes: 4 additions & 1 deletion R/input-search.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#' @param btnClass Class to add to buttons, if a vector of length 2 the first value is used for search button and second one for reset button.
#' @param resetValue Value used when reset button is clicked, default to `""` (empty string),
#' if `NULL` value is not reset.
#' @param inputType The type of input to use, default is `"text"` but you can also use `"password"` for example,
#' see [developer.mozilla.org](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text) for other possible types.
#' @param width The width of the input, e.g. `400px`, or `100%`.
#'
#' @note The two buttons ('search' and 'reset') act like [shiny::actionButton()], you can
Expand All @@ -34,6 +36,7 @@ searchInput <- function(inputId,
btnReset = NULL,
btnClass = "btn-default btn-outline-secondary",
resetValue = "",
inputType = "text",
width = NULL) {
value <- shiny::restoreInput(id = inputId, default = value)
btnClass <- rep_len(btnClass, length.out = 2)
Expand Down Expand Up @@ -65,7 +68,7 @@ searchInput <- function(inputId,
class = "input-group search-text",
htmltools::tags$input(
id = paste0(inputId, "_text"),
type = "text",
type = inputType,
class = "form-control",
value = value,
placeholder = placeholder
Expand Down
4 changes: 4 additions & 0 deletions man/searchInput.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions man/textInputIcon.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit efab1c4

Please sign in to comment.