mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 11:36:36 +00:00
feat(text-input): support read-only variant
This commit is contained in:
parent
008b10c852
commit
4aceb6c95a
5 changed files with 36 additions and 5 deletions
|
@ -4072,7 +4072,8 @@ None.
|
||||||
| warn | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to indicate an warning state |
|
| warn | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to indicate an warning state |
|
||||||
| warnText | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the warning state text |
|
| warnText | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the warning state text |
|
||||||
| required | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to mark the field as required |
|
| required | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to mark the field as required |
|
||||||
| inline | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use inline version |
|
| inline | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use the inline variant |
|
||||||
|
| readonly | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use the read-only variant |
|
||||||
|
|
||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
|
|
|
@ -10416,7 +10416,17 @@
|
||||||
{
|
{
|
||||||
"name": "inline",
|
"name": "inline",
|
||||||
"kind": "let",
|
"kind": "let",
|
||||||
"description": "Set to `true` to use inline version",
|
"description": "Set to `true` to use the inline variant",
|
||||||
|
"type": "boolean",
|
||||||
|
"value": "false",
|
||||||
|
"isFunction": false,
|
||||||
|
"constant": false,
|
||||||
|
"reactive": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "readonly",
|
||||||
|
"kind": "let",
|
||||||
|
"description": "Set to `true` to use the read-only variant",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"value": "false",
|
"value": "false",
|
||||||
"isFunction": false,
|
"isFunction": false,
|
||||||
|
|
|
@ -23,10 +23,14 @@ components: ["TextInput", "TextInputSkeleton"]
|
||||||
|
|
||||||
<TextInput light labelText="User name" placeholder="Enter user name..." />
|
<TextInput light labelText="User name" placeholder="Enter user name..." />
|
||||||
|
|
||||||
### Inline
|
### Inline variant
|
||||||
|
|
||||||
<TextInput inline labelText="User name" placeholder="Enter user name..." />
|
<TextInput inline labelText="User name" placeholder="Enter user name..." />
|
||||||
|
|
||||||
|
### Read-only variant
|
||||||
|
|
||||||
|
<TextInput readonly labelText="User name" value="IBM" />
|
||||||
|
|
||||||
### Extra-large size
|
### Extra-large size
|
||||||
|
|
||||||
<TextInput size="xl" labelText="User name" placeholder="Enter user name..." />
|
<TextInput size="xl" labelText="User name" placeholder="Enter user name..." />
|
||||||
|
|
|
@ -59,12 +59,16 @@
|
||||||
/** Set to `true` to mark the field as required */
|
/** Set to `true` to mark the field as required */
|
||||||
export let required = false;
|
export let required = false;
|
||||||
|
|
||||||
/** Set to `true` to use inline version */
|
/** Set to `true` to use the inline variant */
|
||||||
export let inline = false;
|
export let inline = false;
|
||||||
|
|
||||||
|
/** Set to `true` to use the read-only variant */
|
||||||
|
export let readonly = false;
|
||||||
|
|
||||||
import { getContext } from "svelte";
|
import { getContext } from "svelte";
|
||||||
import WarningFilled16 from "carbon-icons-svelte/lib/WarningFilled16/WarningFilled16.svelte";
|
import WarningFilled16 from "carbon-icons-svelte/lib/WarningFilled16/WarningFilled16.svelte";
|
||||||
import WarningAltFilled16 from "carbon-icons-svelte/lib/WarningAltFilled16/WarningAltFilled16.svelte";
|
import WarningAltFilled16 from "carbon-icons-svelte/lib/WarningAltFilled16/WarningAltFilled16.svelte";
|
||||||
|
import EditOff16 from "carbon-icons-svelte/lib/EditOff16/EditOff16.svelte";
|
||||||
|
|
||||||
const ctx = getContext("Form");
|
const ctx = getContext("Form");
|
||||||
|
|
||||||
|
@ -77,6 +81,8 @@
|
||||||
class:bx--form-item="{true}"
|
class:bx--form-item="{true}"
|
||||||
class:bx--text-input-wrapper="{true}"
|
class:bx--text-input-wrapper="{true}"
|
||||||
class:bx--text-input-wrapper--inline="{inline}"
|
class:bx--text-input-wrapper--inline="{inline}"
|
||||||
|
class:bx--text-input-wrapper--light="{light}"
|
||||||
|
class:bx--text-input-wrapper--readonly="{readonly}"
|
||||||
on:click
|
on:click
|
||||||
on:mouseover
|
on:mouseover
|
||||||
on:mouseenter
|
on:mouseenter
|
||||||
|
@ -142,6 +148,9 @@
|
||||||
bx--text-input__invalid-icon--warning"
|
bx--text-input__invalid-icon--warning"
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
{#if readonly}
|
||||||
|
<EditOff16 class="bx--text-input__readonly-icon" />
|
||||||
|
{/if}
|
||||||
<input
|
<input
|
||||||
bind:this="{ref}"
|
bind:this="{ref}"
|
||||||
data-invalid="{invalid || undefined}"
|
data-invalid="{invalid || undefined}"
|
||||||
|
@ -155,6 +164,7 @@
|
||||||
type="{type}"
|
type="{type}"
|
||||||
value="{value}"
|
value="{value}"
|
||||||
required="{required}"
|
required="{required}"
|
||||||
|
readonly="{readonly}"
|
||||||
class:bx--text-input="{true}"
|
class:bx--text-input="{true}"
|
||||||
class:bx--text-input--light="{light}"
|
class:bx--text-input--light="{light}"
|
||||||
class:bx--text-input--invalid="{invalid}"
|
class:bx--text-input--invalid="{invalid}"
|
||||||
|
|
8
types/TextInput/TextInput.d.ts
vendored
8
types/TextInput/TextInput.d.ts
vendored
|
@ -104,10 +104,16 @@ export interface TextInputProps
|
||||||
required?: boolean;
|
required?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set to `true` to use inline version
|
* Set to `true` to use the inline variant
|
||||||
* @default false
|
* @default false
|
||||||
*/
|
*/
|
||||||
inline?: boolean;
|
inline?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set to `true` to use the read-only variant
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
readonly?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class TextInput extends SvelteComponentTyped<
|
export default class TextInput extends SvelteComponentTyped<
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue