mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-20 12:23:02 +00:00
Merge 3ca9fd5657
into 8d3ac75170
This commit is contained in:
commit
d97b7c7a46
3 changed files with 49 additions and 2 deletions
|
@ -11509,6 +11509,28 @@
|
||||||
"constant": false,
|
"constant": false,
|
||||||
"reactive": false
|
"reactive": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "warn",
|
||||||
|
"kind": "let",
|
||||||
|
"description": "Set to `true` to indicate an warning state",
|
||||||
|
"type": "boolean",
|
||||||
|
"value": "false",
|
||||||
|
"isFunction": false,
|
||||||
|
"isFunctionDeclaration": false,
|
||||||
|
"constant": false,
|
||||||
|
"reactive": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "warnText",
|
||||||
|
"kind": "let",
|
||||||
|
"description": "Specify the warning state text",
|
||||||
|
"type": "string",
|
||||||
|
"value": "\"\"",
|
||||||
|
"isFunction": false,
|
||||||
|
"isFunctionDeclaration": false,
|
||||||
|
"constant": false,
|
||||||
|
"reactive": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "id",
|
"name": "id",
|
||||||
"kind": "let",
|
"kind": "let",
|
||||||
|
|
|
@ -31,6 +31,10 @@ components: ["TextArea", "TextAreaSkeleton"]
|
||||||
|
|
||||||
<TextArea invalid invalidText="Only plain text characters are allowed" labelText="App description" placeholder="Enter a description..." />
|
<TextArea invalid invalidText="Only plain text characters are allowed" labelText="App description" placeholder="Enter a description..." />
|
||||||
|
|
||||||
|
### Warning state
|
||||||
|
|
||||||
|
<TextArea warn warnText="It is recommended to enter a longer description" labelText="App description" placeholder="Enter a description..." />
|
||||||
|
|
||||||
### Disabled state
|
### Disabled state
|
||||||
|
|
||||||
<TextArea disabled labelText="App description" placeholder="Enter a description..." />
|
<TextArea disabled labelText="App description" placeholder="Enter a description..." />
|
||||||
|
|
|
@ -35,6 +35,12 @@
|
||||||
/** Specify the text for the invalid state */
|
/** Specify the text for the invalid state */
|
||||||
export let invalidText = "";
|
export let invalidText = "";
|
||||||
|
|
||||||
|
/** Set to `true` to indicate an warning state */
|
||||||
|
export let warn = false;
|
||||||
|
|
||||||
|
/** Specify the warning state text */
|
||||||
|
export let warnText = "";
|
||||||
|
|
||||||
/** Set an id for the textarea element */
|
/** Set an id for the textarea element */
|
||||||
export let id = "ccs-" + Math.random().toString(36);
|
export let id = "ccs-" + Math.random().toString(36);
|
||||||
|
|
||||||
|
@ -48,8 +54,10 @@
|
||||||
export let ref = null;
|
export let ref = null;
|
||||||
|
|
||||||
import WarningFilled16 from "../icons/WarningFilled16.svelte";
|
import WarningFilled16 from "../icons/WarningFilled16.svelte";
|
||||||
|
import WarningAltFilled16 from "../icons/WarningAltFilled16.svelte";
|
||||||
|
|
||||||
$: errorId = `error-${id}`;
|
$: errorId = `error-${id}`;
|
||||||
|
$: warnId = `warn-${id}`;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- svelte-ignore a11y-mouse-events-have-key-events -->
|
<!-- svelte-ignore a11y-mouse-events-have-key-events -->
|
||||||
|
@ -75,14 +83,23 @@
|
||||||
<div
|
<div
|
||||||
class:bx--text-area__wrapper="{true}"
|
class:bx--text-area__wrapper="{true}"
|
||||||
data-invalid="{invalid || undefined}"
|
data-invalid="{invalid || undefined}"
|
||||||
|
data-warn="{warn || undefined}"
|
||||||
>
|
>
|
||||||
{#if invalid}
|
{#if invalid}
|
||||||
<WarningFilled16 class="bx--text-area__invalid-icon" />
|
<WarningFilled16 class="bx--text-area__invalid-icon" />
|
||||||
{/if}
|
{/if}
|
||||||
|
{#if !invalid && warn}
|
||||||
|
<WarningAltFilled16
|
||||||
|
class="bx--text-area__invalid-icon
|
||||||
|
bx--text-area__invalid-icon--warning"
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
<textarea
|
<textarea
|
||||||
bind:this="{ref}"
|
bind:this="{ref}"
|
||||||
|
data-invalid="{invalid || undefined}"
|
||||||
aria-invalid="{invalid || undefined}"
|
aria-invalid="{invalid || undefined}"
|
||||||
aria-describedby="{invalid ? errorId : undefined}"
|
data-warn="{warn || undefined}"
|
||||||
|
aria-describedby="{invalid ? errorId : warn ? warnId : undefined}"
|
||||||
disabled="{disabled}"
|
disabled="{disabled}"
|
||||||
id="{id}"
|
id="{id}"
|
||||||
name="{name}"
|
name="{name}"
|
||||||
|
@ -94,6 +111,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}"
|
||||||
|
class:bx--text-area--warn="{warn}"
|
||||||
{...$$restProps}
|
{...$$restProps}
|
||||||
on:change
|
on:change
|
||||||
on:input
|
on:input
|
||||||
|
@ -105,7 +123,7 @@
|
||||||
on:focus
|
on:focus
|
||||||
on:blur></textarea>
|
on:blur></textarea>
|
||||||
</div>
|
</div>
|
||||||
{#if !invalid && helperText}
|
{#if !invalid && !warn && helperText}
|
||||||
<div
|
<div
|
||||||
class:bx--form__helper-text="{true}"
|
class:bx--form__helper-text="{true}"
|
||||||
class:bx--form__helper-text--disabled="{disabled}"
|
class:bx--form__helper-text--disabled="{disabled}"
|
||||||
|
@ -116,4 +134,7 @@
|
||||||
{#if invalid}
|
{#if invalid}
|
||||||
<div id="{errorId}" class:bx--form-requirement="{true}">{invalidText}</div>
|
<div id="{errorId}" class:bx--form-requirement="{true}">{invalidText}</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
{#if !invalid && warn}
|
||||||
|
<div id="{warnId}" class:bx--form-requirement="{true}">{warnText}</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue