mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-20 12:23:02 +00:00
feat(text-area): add maxCount prop
This commit is contained in:
parent
f41493a071
commit
5cede07630
1 changed files with 24 additions and 10 deletions
|
@ -11,6 +11,12 @@
|
||||||
/** Specify the number of rows */
|
/** Specify the number of rows */
|
||||||
export let rows = 4;
|
export let rows = 4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify the max character count
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
export let maxCount = undefined;
|
||||||
|
|
||||||
/** Set to `true` to enable the light variant */
|
/** Set to `true` to enable the light variant */
|
||||||
export let light = false;
|
export let light = false;
|
||||||
|
|
||||||
|
@ -61,16 +67,23 @@
|
||||||
class:bx--form-item="{true}"
|
class:bx--form-item="{true}"
|
||||||
>
|
>
|
||||||
{#if (labelText || $$slots.labelText) && !hideLabel}
|
{#if (labelText || $$slots.labelText) && !hideLabel}
|
||||||
<label
|
<div class:bx--text-area__label-wrapper="{true}">
|
||||||
for="{id}"
|
<label
|
||||||
class:bx--label="{true}"
|
for="{id}"
|
||||||
class:bx--visually-hidden="{hideLabel}"
|
class:bx--label="{true}"
|
||||||
class:bx--label--disabled="{disabled}"
|
class:bx--visually-hidden="{hideLabel}"
|
||||||
>
|
class:bx--label--disabled="{disabled}"
|
||||||
<slot name="labelText">
|
>
|
||||||
{labelText}
|
<slot name="labelText">
|
||||||
</slot>
|
{labelText}
|
||||||
</label>
|
</slot>
|
||||||
|
</label>
|
||||||
|
{#if maxCount}
|
||||||
|
<div class:bx--label="{true}" class:bx--label--disabled="{disabled}">
|
||||||
|
{value.length}/{maxCount}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div
|
<div
|
||||||
class:bx--text-area__wrapper="{true}"
|
class:bx--text-area__wrapper="{true}"
|
||||||
|
@ -94,6 +107,7 @@
|
||||||
class:bx--text-area="{true}"
|
class:bx--text-area="{true}"
|
||||||
class:bx--text-area--light="{light}"
|
class:bx--text-area--light="{light}"
|
||||||
class:bx--text-area--invalid="{invalid}"
|
class:bx--text-area--invalid="{invalid}"
|
||||||
|
maxlength="{maxCount ?? undefined}"
|
||||||
{...$$restProps}
|
{...$$restProps}
|
||||||
on:change
|
on:change
|
||||||
on:input
|
on:input
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue