mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 18:31: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
|
@ -3163,8 +3163,8 @@ None.
|
|||
| Prop name | Kind | Reactive | Type | Default value | Description |
|
||||
| :------------------- | :--------------- | :------- | :--------------------------------------------------- | ------------------------------------------------ | ------------------------------------------------------- |
|
||||
| ref | <code>let</code> | Yes | <code>null | HTMLInputElement</code> | <code>null</code> | Obtain a reference to the input HTML element |
|
||||
| value | <code>let</code> | Yes | <code>string</code> | <code>""</code> | Specify the value of the search input |
|
||||
| expanded | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true to expand the search input |
|
||||
| value | <code>let</code> | Yes | <code>any</code> | <code>""</code> | Specify the value of the search input |
|
||||
| small | <code>let</code> | No | <code>boolean</code> | <code>false</code> | -- |
|
||||
| size | <code>let</code> | No | <code>"sm" | "lg" | "xl"</code> | <code>"xl"</code> | Specify the size of the search input |
|
||||
| searchClass | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the class name passed to the outer div element |
|
||||
|
@ -3172,7 +3172,6 @@ None.
|
|||
| light | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable the light variant |
|
||||
| disabled | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable the search input |
|
||||
| expandable | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable the expandable variant |
|
||||
| type | <code>let</code> | No | <code>string</code> | <code>"text"</code> | Specify the `type` attribute of the search input |
|
||||
| placeholder | <code>let</code> | No | <code>string</code> | <code>"Search..."</code> | Specify the `placeholder` attribute of the search input |
|
||||
| autocomplete | <code>let</code> | No | <code>"on" | "off"</code> | <code>"off"</code> | Specify the `autocomplete` attribute |
|
||||
| autofocus | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to auto focus the search element |
|
||||
|
|
|
@ -9115,6 +9115,17 @@
|
|||
"moduleName": "Search",
|
||||
"filePath": "src/Search/Search.svelte",
|
||||
"props": [
|
||||
{
|
||||
"name": "value",
|
||||
"kind": "let",
|
||||
"description": "Specify the value of the search input",
|
||||
"type": "any",
|
||||
"value": "\"\"",
|
||||
"isFunction": false,
|
||||
"isFunctionDeclaration": false,
|
||||
"constant": false,
|
||||
"reactive": true
|
||||
},
|
||||
{
|
||||
"name": "small",
|
||||
"kind": "let",
|
||||
|
@ -9202,28 +9213,6 @@
|
|||
"constant": false,
|
||||
"reactive": true
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
"kind": "let",
|
||||
"description": "Specify the value of the search input",
|
||||
"type": "string",
|
||||
"value": "\"\"",
|
||||
"isFunction": false,
|
||||
"isFunctionDeclaration": false,
|
||||
"constant": false,
|
||||
"reactive": true
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"kind": "let",
|
||||
"description": "Specify the `type` attribute of the search input",
|
||||
"type": "string",
|
||||
"value": "\"text\"",
|
||||
"isFunction": false,
|
||||
"isFunctionDeclaration": false,
|
||||
"constant": false,
|
||||
"reactive": false
|
||||
},
|
||||
{
|
||||
"name": "placeholder",
|
||||
"kind": "let",
|
||||
|
|
|
@ -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;
|
||||
|
|
18
types/Search/Search.svelte.d.ts
vendored
18
types/Search/Search.svelte.d.ts
vendored
|
@ -2,6 +2,12 @@
|
|||
import { SvelteComponentTyped } from "svelte";
|
||||
|
||||
export interface SearchProps {
|
||||
/**
|
||||
* Specify the value of the search input
|
||||
* @default ""
|
||||
*/
|
||||
value?: any;
|
||||
|
||||
/**
|
||||
* @default false
|
||||
*/
|
||||
|
@ -49,18 +55,6 @@ export interface SearchProps {
|
|||
*/
|
||||
expanded?: boolean;
|
||||
|
||||
/**
|
||||
* Specify the value of the search input
|
||||
* @default ""
|
||||
*/
|
||||
value?: string;
|
||||
|
||||
/**
|
||||
* Specify the `type` attribute of the search input
|
||||
* @default "text"
|
||||
*/
|
||||
type?: string;
|
||||
|
||||
/**
|
||||
* Specify the `placeholder` attribute of the search input
|
||||
* @default "Search..."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue