R/wa_textarea.R

Defines functions update_wa_textarea wa_textarea

Documented in update_wa_textarea wa_textarea

# Generated by tools/generate_components.R. Do not edit by hand.
# nolint start: object_usage_linter.

#' Create a `wa-textarea` component
#'
#' Generated wrapper for the Web Awesome `wa-textarea` component. When
#' used as a Shiny input, `input$<input_id>` reflects the component's
#' current `value` value.
#' Generated from Web Awesome metadata.
#'
#' @param ... Child content for the component's default slot.
#' @param input_id Shiny input id for the component. This is also used as
#' the rendered DOM `id` attribute.
#' @param class Optional CSS class string.
#' @param style Optional inline CSS style string.
#' @param value String. The default value of the form control. Primarily
#' used for resetting the form control. This wrapper argument sets the
#' HTML `value` attribute, which maps to the component's `defaultValue`
#' field/property rather than its live `value` property.
#' @param disabled Boolean. Default: `FALSE`. Disables the textarea.
#' @param label String. Default: `""`. The textarea's label. If you need
#' to display HTML, use the `label` slot instead.
#' @param hint String. Default: `""`. The textarea's hint. If you need to
#' display HTML, use the `hint` slot instead.
#' @param name String. Default: `null`. The name of the textarea,
#' submitted as a name/value pair with form data.
#' @param appearance Enumerated string. Allowed values: `filled`,
#' `filled-outlined`, `outlined`. Default: `outlined`. The textarea's
#' visual appearance.
#' @param autocapitalize Enumerated string. Allowed values: `characters`,
#' `none`, `off`, `on`, `sentences`, `words`. Controls whether and how
#' text input is automatically capitalized as it is entered by the user.
#' @param autocomplete String. Specifies what permission the browser has
#' to provide assistance in filling out form field values. Refer to this
#' page on MDN for available values.
#' @param autocorrect Boolean. Default: `FALSE`. Indicates whether the
#' browser's autocorrect feature is on or off. When set as an attribute,
#' use `"off"` or `"on"`. When set as a property, use `TRUE` or `FALSE`.
#' Because the upstream implementation treats attributes and properties
#' differently for this field, this argument accepts `TRUE`, `FALSE`,
#' `"on"`, `"off"`, `NULL`. `TRUE` emits `autocorrect="on"` and `FALSE`
#' emits `autocorrect="off"`. `NULL` omits the attribute. Accepted string
#' values: `"on"` is emitted unchanged; `"off"` is emitted unchanged.
#' @param autofocus Boolean. Default: `FALSE`. Indicates that the input
#' should receive focus on page load.
#' @param custom_error String. Default: `null`. Optional Web Awesome
#' attribute.
#' @param dir String. Optional Web Awesome attribute.
#' @param enterkeyhint Enumerated string. Allowed values: `done`, `enter`,
#' `go`, `next`, `previous`, `search`, `send`. Used to customize the label
#' or icon of the Enter key on virtual keyboards.
#' @param inputmode Enumerated string. Allowed values: `decimal`, `email`,
#' `none`, `numeric`, `search`, `tel`, `text`, `url`. Tells the browser
#' what type of data will be entered by the user, allowing it to display
#' the appropriate virtual keyboard on supportive devices.
#' @param lang String. Optional Web Awesome attribute.
#' @param maxlength Number. The maximum length of input that will be
#' considered valid.
#' @param minlength Number. The minimum length of input that will be
#' considered valid.
#' @param placeholder String. Default: `""`. Placeholder text to show as a
#' hint when the input is empty.
#' @param readonly Boolean. Default: `FALSE`. Makes the textarea readonly.
#' @param required Boolean. Default: `FALSE`. Makes the textarea a
#' required field.
#' @param resize Enumerated string. Allowed values: `auto`, `both`,
#' `horizontal`, `none`, `vertical`. Default: `vertical`. Controls how the
#' textarea can be resized.
#' @param rows Number. Default: `4`. The number of rows to display by
#' default.
#' @param size Enumerated string. Allowed values: `large`, `medium`,
#' `small`. Default: `medium`. The textarea's size.
#' @param spellcheck Boolean. Default: `TRUE`. Enables spell checking on
#' the textarea.
#' @param title String. Default: `""`. Optional Web Awesome attribute.
#' @param with_count Boolean. Default: `FALSE`. Shows a character count
#' below the textarea. When `maxlength` is set, shows remaining characters
#' instead.
#' @param with_hint Boolean. Default: `FALSE`. Only required for SSR. Set
#' to `TRUE` if you're slotting in a `hint` element so the server-rendered
#' markup includes the hint before the component hydrates on the client.
#' @param with_label Boolean. Default: `FALSE`. Only required for SSR. Set
#' to `TRUE` if you're slotting in a `label` element so the
#' server-rendered markup includes the label before the component hydrates
#' on the client.
#' @param hint_slot Text that describes how to use the input.
#' Alternatively, you can use the `hint` attribute.
#' @param label_slot The textarea's label. Alternatively, you can use the
#' `label` attribute.
#'
#' @section Shiny Bindings:
#' `input$<input_id>` reflects the component's current `value` value.
#'
#' @return An HTML tag for the component.
#'
#' @export
wa_textarea <- function(
  input_id,
  ...,
  class = NULL,
  style = NULL,
  value = NULL,
  disabled = NULL,
  label = NULL,
  hint = NULL,
  name = NULL,
  appearance = NULL,
  autocapitalize = NULL,
  autocomplete = NULL,
  autocorrect = NULL,
  autofocus = NULL,
  custom_error = NULL,
  dir = NULL,
  enterkeyhint = NULL,
  inputmode = NULL,
  lang = NULL,
  maxlength = NULL,
  minlength = NULL,
  placeholder = NULL,
  readonly = NULL,
  required = NULL,
  resize = NULL,
  rows = NULL,
  size = NULL,
  spellcheck = NULL,
  title = NULL,
  with_count = NULL,
  with_hint = NULL,
  with_label = NULL,
  hint_slot = NULL,
  label_slot = NULL
) {
  children <- list(...)
  children <- c(
    children,
    list(
      .wa_slot(hint_slot, "hint")
    )
  )
  children <- c(
    children,
    list(
      .wa_slot(label_slot, "label")
    )
  )

  autocorrect <- .wa_match_constructor_attr(
    autocorrect,
    "autocorrect",
    true_value = "on",
    false_value = "off",
    string_map = c(
      "on" = "on",
      "off" = "off"
    )
  )

  if (!is.null(appearance)) {
    appearance <- .wa_match_arg(
      appearance,
      "appearance",
      c(
        "filled",
        "filled-outlined",
        "outlined"
      )
    )
  }

  if (!is.null(autocapitalize)) {
    autocapitalize <- .wa_match_arg(
      autocapitalize,
      "autocapitalize",
      c(
        "characters",
        "none",
        "off",
        "on",
        "sentences",
        "words"
      )
    )
  }

  if (!is.null(enterkeyhint)) {
    enterkeyhint <- .wa_match_arg(
      enterkeyhint,
      "enterkeyhint",
      c(
        "done",
        "enter",
        "go",
        "next",
        "previous",
        "search",
        "send"
      )
    )
  }

  if (!is.null(inputmode)) {
    inputmode <- .wa_match_arg(
      inputmode,
      "inputmode",
      c(
        "decimal",
        "email",
        "none",
        "numeric",
        "search",
        "tel",
        "text",
        "url"
      )
    )
  }

  if (!is.null(resize)) {
    resize <- .wa_match_arg(
      resize,
      "resize",
      c(
        "auto",
        "both",
        "horizontal",
        "none",
        "vertical"
      )
    )
  }

  if (!is.null(size)) {
    size <- .wa_match_arg(
      size,
      "size",
      c(
        "large",
        "medium",
        "small"
      )
    )
  }

  attrs <- .wa_normalize_attrs(
    list(
      "id" = input_id,
      "class" = class,
      "style" = style,
      "value" = value,
      "disabled" = disabled,
      "label" = label,
      "hint" = hint,
      "name" = name,
      "appearance" = appearance,
      "autocapitalize" = autocapitalize,
      "autocomplete" = autocomplete,
      "autocorrect" = autocorrect,
      "autofocus" = autofocus,
      "custom-error" = custom_error,
      "dir" = dir,
      "enterkeyhint" = enterkeyhint,
      "inputmode" = inputmode,
      "lang" = lang,
      "maxlength" = maxlength,
      "minlength" = minlength,
      "placeholder" = placeholder,
      "readonly" = readonly,
      "required" = required,
      "resize" = resize,
      "rows" = rows,
      "size" = size,
      "spellcheck" = spellcheck,
      "title" = title,
      "with-count" = with_count,
      "with-hint" = with_hint,
      "with-label" = with_label
    ),
    boolean_names = c(
      "disabled",
      "autofocus",
      "readonly",
      "required",
      "spellcheck",
      "with-count",
      "with-hint",
      "with-label"
    ),
    boolean_arg_names = c(
      "disabled" = "disabled",
      "autofocus" = "autofocus",
      "readonly" = "readonly",
      "required" = "required",
      "spellcheck" = "spellcheck",
      "with-count" = "with_count",
      "with-hint" = "with_hint",
      "with-label" = "with_label"
    )
  )

  do.call(
    .wa_component,
    c(
      list("wa-textarea", .attrs = attrs),
      children
    )
  )
}
# nolint end

# Generated by tools/generate_components.R. Do not edit by hand.

#' Update a `wa-textarea` component
#'
#' Generated update helper for the Web Awesome `wa-textarea` component.
#'
#' @param session Shiny session object.
#' @param input_id Input id of the component to update.
#' @param value Optional value to send to the component.
#' @param label Optional label text to send to the component.
#' @param hint Optional hint text to send to the component.
#' @param disabled Optional logical disabled state to send to the component.
#'
#' @return Invisibly returns `NULL`.
#'
#' @rdname wa_textarea
#' @export
update_wa_textarea <- function(
  session,
  input_id,
  value = NULL,
  label = NULL,
  hint = NULL,
  disabled = NULL
) {
  message <- Filter(
    Negate(is.null),
    list(
      value = value,
      label = label,
      hint = hint,
      disabled = disabled
    )
  )

  if (length(message) == 0L) {
    return(invisible(NULL))
  }

  session$sendInputMessage(input_id, message)
  invisible(NULL)
}

Try the shiny.webawesome package in your browser

Any scripts or data that you put into this service are public.

shiny.webawesome documentation built on April 22, 2026, 1:09 a.m.