mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
feat(TextInput): add isFluid
from Form context
This commit is contained in:
parent
7689c33a75
commit
04443c5833
2 changed files with 24 additions and 5 deletions
|
@ -107,17 +107,21 @@
|
|||
*/
|
||||
export let ref = null;
|
||||
|
||||
import { getContext } from "svelte";
|
||||
import WarningFilled16 from "carbon-icons-svelte/lib/WarningFilled16";
|
||||
import View16 from "carbon-icons-svelte/lib/View16";
|
||||
import ViewOff16 from "carbon-icons-svelte/lib/ViewOff16";
|
||||
|
||||
const ctx = getContext("Form");
|
||||
|
||||
$: isFluid = !!ctx && ctx.isFluid;
|
||||
$: errorId = `error-${id}`;
|
||||
</script>
|
||||
|
||||
<div
|
||||
class:bx--form-item="{true}"
|
||||
class:bx--text-input-wrapper="{true}"
|
||||
class:bx--password-input-wrapper="{true}"
|
||||
class:bx--password-input-wrapper="{!isFluid}"
|
||||
{...$$restProps}
|
||||
on:click
|
||||
on:mouseover
|
||||
|
|
|
@ -107,9 +107,13 @@
|
|||
*/
|
||||
export let inline = false;
|
||||
|
||||
import { getContext } from "svelte";
|
||||
import WarningFilled16 from "carbon-icons-svelte/lib/WarningFilled16";
|
||||
import WarningAltFilled16 from "carbon-icons-svelte/lib/WarningAltFilled16";
|
||||
|
||||
const ctx = getContext("Form");
|
||||
|
||||
$: isFluid = !!ctx && ctx.isFluid;
|
||||
$: errorId = `error-${id}`;
|
||||
$: warnId = `warn-${id}`;
|
||||
</script>
|
||||
|
@ -138,7 +142,7 @@
|
|||
{labelText}
|
||||
</label>
|
||||
{/if}
|
||||
{#if helperText}
|
||||
{#if !isFluid && helperText}
|
||||
<div
|
||||
class:bx--form__helper-text="{true}"
|
||||
class:bx--form__helper-text--disabled="{disabled}"
|
||||
|
@ -206,8 +210,19 @@
|
|||
on:focus
|
||||
on:blur
|
||||
/>
|
||||
{#if isFluid}
|
||||
<hr className="bx--text-input__divider" />
|
||||
{/if}
|
||||
{#if isFluid && !inline && invalid}
|
||||
<div class:bx--form-requirement="{true}" id="{errorId}">
|
||||
{invalidText}
|
||||
</div>
|
||||
{/if}
|
||||
{#if isFluid && !inline && warn}
|
||||
<div class:bx--form-requirement="{true}" id="{warnId}">{warnText}</div>
|
||||
{/if}
|
||||
</div>
|
||||
{#if !invalid && !warn && !inline && helperText}
|
||||
{#if !invalid && !warn && !isFluid && !inline && helperText}
|
||||
<div
|
||||
class:bx--form__helper-text="{true}"
|
||||
class:bx--form__helper-text--disabled="{disabled}"
|
||||
|
@ -216,12 +231,12 @@
|
|||
{helperText}
|
||||
</div>
|
||||
{/if}
|
||||
{#if invalid}
|
||||
{#if !isFluid && invalid}
|
||||
<div class:bx--form-requirement="{true}" id="{errorId}">
|
||||
{invalidText}
|
||||
</div>
|
||||
{/if}
|
||||
{#if !invalid && warn}
|
||||
{#if !isFluid && !invalid && warn}
|
||||
<div class:bx--form-requirement="{true}" id="{warnId}">{warnText}</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue