R/wa_number_input.R

Defines functions update_wa_number_input wa_number_input

Documented in update_wa_number_input wa_number_input

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

#' Create a `wa-number-input` component
#'
#' Generated wrapper for the Web Awesome `wa-number-input` 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 form control.
#' @param label String. Default: `""`. The input's label. If you need to
#' display HTML, use the `label` slot instead.
#' @param hint String. Default: `""`. The input's hint. If you need to
#' display HTML, use the `hint` slot instead.
#' @param name String. Default: `null`. The name of the input, submitted
#' as a name/value pair with form data.
#' @param appearance Enumerated string. Allowed values: `filled`,
#' `filled-outlined`, `outlined`. Default: `outlined`. The input's visual
#' appearance.
#' @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 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`,
#' `numeric`. Default: `numeric`. 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 max Number. The input's maximum value.
#' @param min Number. The input's minimum value.
#' @param pill Boolean. Default: `FALSE`. Draws a pill-style input with
#' rounded edges.
#' @param placeholder String. Default: `""`. Placeholder text to show as a
#' hint when the input is empty.
#' @param readonly Boolean. Default: `FALSE`. Makes the input readonly.
#' @param required Boolean. Default: `FALSE`. Makes the input a required
#' field.
#' @param size Enumerated string. Allowed values: `large`, `medium`,
#' `small`. Default: `medium`. The input's size.
#' @param step Default: `1`. Specifies the granularity that the value must
#' adhere to, or the special value `any` which means no stepping is
#' implied, allowing any numeric value.
#' @param title String. Default: `""`. Optional Web Awesome attribute.
#' @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 without_steppers Boolean. Default: `FALSE`. Hides the
#' increment/decrement stepper buttons.
#' @param decrement_icon An icon to use in lieu of the default decrement
#' icon.
#' @param end An element, such as `<wa-icon>`, placed at the end of the
#' input control (before steppers).
#' @param hint_slot Text that describes how to use the input.
#' Alternatively, you can use the `hint` attribute.
#' @param increment_icon An icon to use in lieu of the default increment
#' icon.
#' @param label_slot The input's label. Alternatively, you can use the
#' `label` attribute.
#' @param start An element, such as `<wa-icon>`, placed at the start of
#' the input control.
#'
#' @section Shiny Bindings:
#' `input$<input_id>` reflects the component's current `value` value.
#'
#' @return An HTML tag for the component.
#'
#' @export
wa_number_input <- function(
  input_id,
  ...,
  class = NULL,
  style = NULL,
  value = NULL,
  disabled = NULL,
  label = NULL,
  hint = NULL,
  name = NULL,
  appearance = NULL,
  autocomplete = NULL,
  autofocus = NULL,
  custom_error = NULL,
  dir = NULL,
  enterkeyhint = NULL,
  inputmode = NULL,
  lang = NULL,
  max = NULL,
  min = NULL,
  pill = NULL,
  placeholder = NULL,
  readonly = NULL,
  required = NULL,
  size = NULL,
  step = NULL,
  title = NULL,
  with_hint = NULL,
  with_label = NULL,
  without_steppers = NULL,
  decrement_icon = NULL,
  end = NULL,
  hint_slot = NULL,
  increment_icon = NULL,
  label_slot = NULL,
  start = NULL
) {
  children <- list(...)
  children <- c(
    children,
    list(
      .wa_slot(decrement_icon, "decrement-icon")
    )
  )
  children <- c(
    children,
    list(
      .wa_slot(end, "end")
    )
  )
  children <- c(
    children,
    list(
      .wa_slot(hint_slot, "hint")
    )
  )
  children <- c(
    children,
    list(
      .wa_slot(increment_icon, "increment-icon")
    )
  )
  children <- c(
    children,
    list(
      .wa_slot(label_slot, "label")
    )
  )
  children <- c(
    children,
    list(
      .wa_slot(start, "start")
    )
  )

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

  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",
        "numeric"
      )
    )
  }

  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,
      "autocomplete" = autocomplete,
      "autofocus" = autofocus,
      "custom-error" = custom_error,
      "dir" = dir,
      "enterkeyhint" = enterkeyhint,
      "inputmode" = inputmode,
      "lang" = lang,
      "max" = max,
      "min" = min,
      "pill" = pill,
      "placeholder" = placeholder,
      "readonly" = readonly,
      "required" = required,
      "size" = size,
      "step" = step,
      "title" = title,
      "with-hint" = with_hint,
      "with-label" = with_label,
      "without-steppers" = without_steppers
    ),
    boolean_names = c(
      "disabled",
      "autofocus",
      "pill",
      "readonly",
      "required",
      "with-hint",
      "with-label",
      "without-steppers"
    ),
    boolean_arg_names = c(
      "disabled" = "disabled",
      "autofocus" = "autofocus",
      "pill" = "pill",
      "readonly" = "readonly",
      "required" = "required",
      "with-hint" = "with_hint",
      "with-label" = "with_label",
      "without-steppers" = "without_steppers"
    )
  )

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

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

#' Update a `wa-number-input` component
#'
#' Generated update helper for the Web Awesome `wa-number-input` 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_number_input
#' @export
update_wa_number_input <- 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.