55 lines
3.5 KiB
Plaintext
55 lines
3.5 KiB
Plaintext
component InputGroup {
|
|
outputs {
|
|
input(payload: { value?: string | number | boolean | null; values?: Array<string | number | boolean | null | object>; sourceEvent?: Event; [key: string]: string | number | boolean | null | object } | string | number | boolean | null)
|
|
change(payload: { value?: string | number | boolean | null; values?: Array<string | number | boolean | null | object>; sourceEvent?: Event; [key: string]: string | number | boolean | null | object } | string | number | boolean | null)
|
|
focus(payload: { sourceEvent?: Event; [key: string]: string | number | boolean | null | object })
|
|
blur(payload: { sourceEvent?: Event; [key: string]: string | number | boolean | null | object })
|
|
submit(payload: { value: string | number | boolean | null | object; name: string; sourceEvent: Event })
|
|
action(payload: { name: string; sourceEvent: Event })
|
|
}
|
|
|
|
props {
|
|
size: string = "default"
|
|
color: string = "primary"
|
|
id: string = ""
|
|
name: string = ""
|
|
label: string = "Input group"
|
|
hiddenLabel: boolean = false
|
|
value: string = ""
|
|
placeholder: string = ""
|
|
type: string = "text"
|
|
startText: string = ""
|
|
endText: string = ""
|
|
icon: string = ""
|
|
iconPosition: string = "start"
|
|
actionLabel: string = ""
|
|
helperText: string = ""
|
|
cornerHint: string = ""
|
|
error: string = ""
|
|
inline: boolean = false
|
|
variant: string = "normal"
|
|
readonly: boolean = false
|
|
disabled: boolean = false
|
|
required: boolean = false
|
|
class: string = ""
|
|
}
|
|
functions {
|
|
client function emitField(nameEvent, sourceEvent) { sourceEvent.stopPropagation(); output[nameEvent]({ value: sourceEvent.currentTarget.value, name: name, sourceEvent: sourceEvent }) }
|
|
client function handleKeydown(sourceEvent) { if (sourceEvent.key === "Enter") { sourceEvent.stopPropagation(); output.submit({ value: sourceEvent.currentTarget.value, name: name, sourceEvent: sourceEvent }) } }
|
|
client function handleAction(sourceEvent) { output.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>
|
|
}
|
|
}
|