mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-16 10:51:06 +00:00
refactor(search): use native binding for value
prop (#1173)
* refactor(search): use native binding for value prop * feat(search): type the value prop as any
This commit is contained in:
parent
59ecc53a89
commit
ba0abe8e34
4 changed files with 26 additions and 47 deletions
|
@ -4,6 +4,12 @@
|
|||
* @event {null} collapse
|
||||
*/
|
||||
|
||||
/**
|
||||
* Specify the value of the search input
|
||||
* @type {any}
|
||||
*/
|
||||
export let value = "";
|
||||
|
||||
/**
|
||||
* @deprecated this prop will be removed in the next major release
|
||||
* Use size="sm" instead
|
||||
|
@ -34,12 +40,6 @@
|
|||
/** Set to `true to expand the search input */
|
||||
export let expanded = false;
|
||||
|
||||
/** Specify the value of the search input */
|
||||
export let value = "";
|
||||
|
||||
/** Specify the `type` attribute of the search input */
|
||||
export let type = "text";
|
||||
|
||||
/** Specify the `placeholder` attribute of the search input */
|
||||
export let placeholder = "Search...";
|
||||
|
||||
|
@ -125,6 +125,8 @@
|
|||
<!-- svelte-ignore a11y-autofocus -->
|
||||
<input
|
||||
bind:this="{ref}"
|
||||
bind:value
|
||||
type="text"
|
||||
role="searchbox"
|
||||
class:bx--search-input="{true}"
|
||||
autofocus="{autofocus === true ? true : undefined}"
|
||||
|
@ -132,14 +134,9 @@
|
|||
disabled="{disabled}"
|
||||
id="{id}"
|
||||
placeholder="{placeholder}"
|
||||
type="{type}"
|
||||
value="{value}"
|
||||
{...$$restProps}
|
||||
on:change
|
||||
on:input
|
||||
on:input="{({ target }) => {
|
||||
value = target.value;
|
||||
}}"
|
||||
on:focus
|
||||
on:focus="{() => {
|
||||
if (expandable) expanded = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue