Refactor UI Shell global search component (#417)

* feat(ui-shell): refactor UI Shell search component

* fix(ui-shell): dispatched event is "select", not "search"

* test(header-search): validate HeaderSearch types

* fix(header-search): selecting a result should reset the search

* feat(header-search): deefault selectedResultIndex should be 0

Reset selectedResultIndex, value after dispatching.

* docs(header-search): demo basic filtering

* chore: rebuild types, docs

* feat(header-search): pass index as a slot prop
This commit is contained in:
Eric Liu 2020-11-26 15:42:15 -08:00 committed by GitHub
commit 30cfc842d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 737 additions and 5 deletions

View file

@ -1,5 +1,5 @@
{
"total": 154,
"total": 155,
"components": [
{
"moduleName": "SkeletonText",
@ -10258,6 +10258,93 @@
"typedefs": [],
"rest_props": { "type": "Element", "name": "button" }
},
{
"moduleName": "HeaderSearch",
"filePath": "/src/UIShell/HeaderSearch.svelte",
"props": [
{
"name": "value",
"kind": "let",
"description": "Specify the search input value",
"type": "string",
"value": "\"\"",
"isFunction": false,
"constant": false,
"reactive": true
},
{
"name": "active",
"kind": "let",
"description": "Set to `true` to activate and focus the search bar",
"type": "boolean",
"value": "false",
"isFunction": false,
"constant": false,
"reactive": true
},
{
"name": "ref",
"kind": "let",
"description": "Obtain a reference to the input HTML element",
"type": "null | HTMLInputElement",
"value": "null",
"isFunction": false,
"constant": false,
"reactive": true
},
{
"name": "results",
"kind": "let",
"description": "Render a list of search results",
"type": "HeaderSearchResult[]",
"value": "[]",
"isFunction": false,
"constant": false,
"reactive": false
},
{
"name": "selectedResultIndex",
"kind": "let",
"description": "Specify the selected result index",
"type": "number",
"value": "0",
"isFunction": false,
"constant": false,
"reactive": true
}
],
"slots": [
{
"name": "__default__",
"default": true,
"fallback": "{result.text}\n {#if result.description}<span> {result.description}</span>{/if}",
"slot_props": "{ result: HeaderSearchResult; index: number }"
}
],
"events": [
{ "type": "dispatched", "name": "active", "detail": "any" },
{ "type": "dispatched", "name": "inactive", "detail": "any" },
{ "type": "dispatched", "name": "clear", "detail": "any" },
{
"type": "dispatched",
"name": "select",
"detail": "{ value: string; selectedResultIndex: number; selectedResult: HeaderSearchResult }"
},
{ "type": "forwarded", "name": "change", "element": "input" },
{ "type": "forwarded", "name": "input", "element": "input" },
{ "type": "forwarded", "name": "focus", "element": "input" },
{ "type": "forwarded", "name": "blur", "element": "input" },
{ "type": "forwarded", "name": "keydown", "element": "input" }
],
"typedefs": [
{
"type": "{ href: string; text: string; description?: string; }",
"name": "HeaderSearchResult",
"ts": "interface HeaderSearchResult { href: string; text: string; description?: string; }"
}
],
"rest_props": { "type": "Element", "name": "input" }
},
{
"moduleName": "UnorderedList",
"filePath": "/src/UnorderedList/UnorderedList.svelte",