mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
refactor(text-area): update bound value on input
This commit is contained in:
parent
bfb6e88abc
commit
b63e62e6f1
1 changed files with 20 additions and 28 deletions
|
@ -4,13 +4,13 @@
|
||||||
export let cols = 50;
|
export let cols = 50;
|
||||||
export let disabled = false;
|
export let disabled = false;
|
||||||
export let id = Math.random();
|
export let id = Math.random();
|
||||||
export let labelText = undefined;
|
export let labelText = '';
|
||||||
export let placeholder = '';
|
export let placeholder = '';
|
||||||
export let rows = 4;
|
export let rows = 4;
|
||||||
export let value = undefined;
|
export let value = '';
|
||||||
export let invalid = false;
|
export let invalid = false;
|
||||||
export let invalidText = undefined;
|
export let invalidText = '';
|
||||||
export let helperText = undefined;
|
export let helperText = '';
|
||||||
export let hideLabel = false;
|
export let hideLabel = false;
|
||||||
export let light = false;
|
export let light = false;
|
||||||
export let props = {};
|
export let props = {};
|
||||||
|
@ -33,24 +33,6 @@
|
||||||
invalid && '--text-area--invalid',
|
invalid && '--text-area--invalid',
|
||||||
className
|
className
|
||||||
);
|
);
|
||||||
|
|
||||||
function handleClick(event) {
|
|
||||||
if (!disabled) {
|
|
||||||
dispatch('click', event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleChange(event) {
|
|
||||||
if (!disabled) {
|
|
||||||
dispatch('change', event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleInput(event) {
|
|
||||||
if (!disabled) {
|
|
||||||
dispatch('input', event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class={cx('--form-item')}>
|
<div class={cx('--form-item')}>
|
||||||
|
@ -66,12 +48,22 @@
|
||||||
{/if}
|
{/if}
|
||||||
<textarea
|
<textarea
|
||||||
{...props}
|
{...props}
|
||||||
on:click
|
on:click={event => {
|
||||||
on:click={handleClick}
|
if (!disabled) {
|
||||||
on:change
|
dispatch('click', event);
|
||||||
on:change={handleChange}
|
}
|
||||||
on:input
|
}}
|
||||||
on:input={handleInput}
|
on:change={event => {
|
||||||
|
if (!disabled) {
|
||||||
|
dispatch('change', event);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
on:input={event => {
|
||||||
|
value = event.target.value;
|
||||||
|
if (!disabled) {
|
||||||
|
dispatch('input', event);
|
||||||
|
}
|
||||||
|
}}
|
||||||
class={_textAreaClass}
|
class={_textAreaClass}
|
||||||
aria-invalid={invalid || undefined}
|
aria-invalid={invalid || undefined}
|
||||||
aria-describedby={invalid ? errorId : undefined}
|
aria-describedby={invalid ? errorId : undefined}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue