page InputGroupcomponent { seo { title = "InputGroup component" description = "Theme-aware, responsive input group component." } view {
W WRNexusJS
forms component

InputGroup

Theme-aware, responsive input group component.

@wrnexus/ui 0.5.023 props0 slots6 events

Usage

Components are auto-discovered. Use the component directly in any .wrn view:

<InputGroup
  size="default"
  color="primary"
  id="id"
  name="name"
  label="Input group"
/>

Legacy mount name: data-component="InputGroup".

Props and attributes

PropTypeRequirementDefault
sizestringOptional"default"
colorstringOptional"primary"
idstringOptional""
namestringOptional""
labelstringOptional"Input group"
hiddenLabelbooleanOptionalfalse
valuestringOptional""
placeholderstringOptional""
typestringOptional"text"
startTextstringOptional""
endTextstringOptional""
iconstringOptional""
iconPositionstringOptional"start"
actionLabelstringOptional""
helperTextstringOptional""
cornerHintstringOptional""
errorstringOptional""
inlinebooleanOptionalfalse
variantstringOptional"normal"
readonlybooleanOptionalfalse
disabledbooleanOptionalfalse
requiredbooleanOptionalfalse
classstringOptional""

Slots

This component does not declare a slot.

Events

  • input
  • change
  • focus
  • blur
  • submit
  • action

Source contract

Installed source: components/InputGroup.wrn

component InputGroup {
  props {
    @event input = function
    @event change = function
    @event focus = function
    @event blur = function
    @event submit = function
    @event action = function
    size = "default"
    color = "primary"
    id = ""
    name = ""
    label = "Input group"
    hiddenLabel = false
    value = ""
    placeholder = ""
    type = "text"
    startText = ""
    endText = ""
    icon = ""
    iconPosition = "start"
    actionLabel = ""
    helperText = ""
    cornerHint = ""
    error = ""
    inline = false
    variant = "normal"
    readonly = false
    disabled = false
    required = false
    class = ""
  }
  functions {
    function emitField(nameEvent, sourceEvent) { sourceEvent.stopPropagation(); $emit(nameEvent, { value: sourceEvent.currentTarget.value, name: name, sourceEvent: sourceEvent }) }
    function handleKeydown(sourceEvent) { if (sourceEvent.key === "Enter") { sourceEvent.stopPropagation(); $emit("submit", { value: sourceEvent.currentTarget.value, name: name, sourceEvent: sourceEvent }) } }
    function handleAction(sourceEvent) { $emit("action", { name: name, sourceEvent: sourceEvent }) }
  }
  view {
        <div {...attrs} class="wire-next wire-next--color-{color} wire-next--size-{size} wire-next--field wire-next--input-group {class}" data-variant="{variant}" data-inline="{inline}" data-invalid="{error ? 'true' : 'false'}">
        <div class="wire-next__field-heading">
        <label class="{hiddenLabel ? 'wire-next__sr-only' : ''}" for="{id || name}">{label}</label>{#if cornerHint}<span class="wire-next__field-hint">{cornerHint}</span>{/if}</div>
        <div class="wire-next__input-group-control">
        {#if startText}<span class="wire-next__input-addon">{startText}</span>{/if}
        {#if icon}<span class="{icon} wire-next__field-icon" data-position="{iconPosition}" aria-hidden="true">
        </span>{/if}
        <input id="{id || name}" type="{type}" name="{name}" value="{value}" placeholder="{placeholder}" readonly="{readonly}" disabled="{disabled}" required="{required}" aria-invalid="{error ? 'true' : 'false'}" @input="emitField('input', event)" @change="emitField('change', event)" @focus="emitField('focus', event)" @blur="emitField('blur', event)" @keydown="handleKeydown(event)" />
        {#if endText}<span class="wire-next__input-addon">{endText}</span>{/if}
        {#if actionLabel}<button type="button" disabled="{disabled}" @click="handleAction(event)">{actionLabel}</button>{/if}
      </div>
      {#if helperText}<small class="wire-next__field-help">{helperText}</small>{/if}<small class="wire-next__field-error" data-error="{name}">{error}</small>
        </div>
    }
}
} }