mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
feat: rebuild types, component api
This commit is contained in:
parent
dfc00f6668
commit
e39efc5668
5 changed files with 52 additions and 25 deletions
|
@ -655,7 +655,7 @@ export interface ComboBoxItem {
|
||||||
### Props
|
### Props
|
||||||
|
|
||||||
| Prop name | Kind | Reactive | Type | Default value | Description |
|
| Prop name | Kind | Reactive | Type | Default value | Description |
|
||||||
| :--------------- | :--------------- | :------- | :---------------------------------------------------------- | ----------------------------------------------------- | ------------------------------------------------------------------------ |
|
| :--------------- | :-------------------- | :------- | :---------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
|
||||||
| listRef | <code>let</code> | Yes | <code>null | HTMLDivElement</code> | <code>null</code> | Obtain a reference to the list HTML element |
|
| listRef | <code>let</code> | Yes | <code>null | HTMLDivElement</code> | <code>null</code> | Obtain a reference to the list HTML element |
|
||||||
| ref | <code>let</code> | Yes | <code>null | HTMLInputElement</code> | <code>null</code> | Obtain a reference to the input HTML element |
|
| ref | <code>let</code> | Yes | <code>null | HTMLInputElement</code> | <code>null</code> | Obtain a reference to the input HTML element |
|
||||||
| open | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true` to open the combobox menu dropdown |
|
| open | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true` to open the combobox menu dropdown |
|
||||||
|
@ -678,6 +678,7 @@ export interface ComboBoxItem {
|
||||||
| translateWithId | <code>let</code> | No | <code>(id: any) => string</code> | -- | Override the default translation ids |
|
| translateWithId | <code>let</code> | No | <code>(id: any) => string</code> | -- | Override the default translation ids |
|
||||||
| id | <code>let</code> | No | <code>string</code> | <code>"ccs-" + Math.random().toString(36)</code> | Set an id for the list box component |
|
| id | <code>let</code> | No | <code>string</code> | <code>"ccs-" + Math.random().toString(36)</code> | Set an id for the list box component |
|
||||||
| name | <code>let</code> | No | <code>string</code> | -- | Specify a name attribute for the input |
|
| name | <code>let</code> | No | <code>string</code> | -- | Specify a name attribute for the input |
|
||||||
|
| clear | <code>function</code> | No | <code>() => void</code> | <code>() => { selectedIndex = -1; highlightedIndex = -1; open = false; inputValue = ""; ref?.focus(); }</code> | Clear the combo box programmatically |
|
||||||
|
|
||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
|
|
|
@ -1588,6 +1588,17 @@
|
||||||
"isFunctionDeclaration": false,
|
"isFunctionDeclaration": false,
|
||||||
"constant": false,
|
"constant": false,
|
||||||
"reactive": true
|
"reactive": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "clear",
|
||||||
|
"kind": "function",
|
||||||
|
"description": "Clear the combo box programmatically",
|
||||||
|
"type": "() => void",
|
||||||
|
"value": "() => { selectedIndex = -1; highlightedIndex = -1; open = false; inputValue = \"\"; ref?.focus(); }",
|
||||||
|
"isFunction": true,
|
||||||
|
"isFunctionDeclaration": true,
|
||||||
|
"constant": false,
|
||||||
|
"reactive": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"slots": [],
|
"slots": [],
|
||||||
|
|
|
@ -123,6 +123,10 @@
|
||||||
highlightedIndex = index;
|
highlightedIndex = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear the combo box programmatically
|
||||||
|
* @type {() => void}
|
||||||
|
*/
|
||||||
export function clear() {
|
export function clear() {
|
||||||
selectedIndex = -1;
|
selectedIndex = -1;
|
||||||
highlightedIndex = -1;
|
highlightedIndex = -1;
|
||||||
|
|
|
@ -7,9 +7,14 @@
|
||||||
{ id: "1", text: "Email" },
|
{ id: "1", text: "Email" },
|
||||||
{ id: "2", text: "Fax" },
|
{ id: "2", text: "Fax" },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
let ref: ComboBox;
|
||||||
|
|
||||||
|
$: ref?.clear();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ComboBox
|
<ComboBox
|
||||||
|
bind:this="{ref}"
|
||||||
direction="top"
|
direction="top"
|
||||||
titleText="Contact"
|
titleText="Contact"
|
||||||
placeholder="Select contact method"
|
placeholder="Select contact method"
|
||||||
|
|
8
types/ComboBox/ComboBox.d.ts
vendored
8
types/ComboBox/ComboBox.d.ts
vendored
|
@ -154,4 +154,10 @@ export default class ComboBox extends SvelteComponentTyped<
|
||||||
scroll: WindowEventMap["scroll"];
|
scroll: WindowEventMap["scroll"];
|
||||||
},
|
},
|
||||||
{}
|
{}
|
||||||
> {}
|
> {
|
||||||
|
/**
|
||||||
|
* Clear the combo box programmatically
|
||||||
|
* @default () => { selectedIndex = -1; highlightedIndex = -1; open = false; inputValue = ""; ref?.focus(); }
|
||||||
|
*/
|
||||||
|
clear: () => void;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue