Skip to content

Commit b463848

Browse files
committed
improve API filtering
1 parent eaaa120 commit b463848

File tree

4 files changed

+92
-78
lines changed

4 files changed

+92
-78
lines changed

src/.vitepress/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ const sidebar = {
328328
items: [
329329
{ text: 'Directives', link: '/api/built-in-directives' },
330330
{ text: 'Components', link: '/api/built-in-components' },
331+
{ text: 'Special Elements', link: '/api/built-in-special-elements' },
331332
{
332333
text: 'Special Attributes',
333334
link: '/api/built-in-special-attributes'

src/api/ApiIndex.vue

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,23 @@ import { ref, computed } from 'vue'
55
const query = ref('')
66
77
const filtered = computed(() => {
8-
const q = query.value
8+
const q = query.value.toLowerCase()
99
return apiIndex
1010
.map((section) => {
11+
if (section.text.toLowerCase().includes(q)) {
12+
return section
13+
}
1114
const items = section.items
12-
.map(({ text, link, headers }) => {
13-
headers = headers.filter((h) => {
14-
return h.toLowerCase().includes(q.toLowerCase())
15+
.map((item) => {
16+
if (item.text.toLowerCase().includes(q)) {
17+
return item
18+
}
19+
const headers = item.headers.filter((h) => {
20+
return h.toLowerCase().includes(q)
1521
})
16-
return headers.length ? { text, link, headers } : null
22+
return headers.length
23+
? { text: item.text, link: item.link, headers }
24+
: null
1725
})
1826
.filter((i) => i)
1927
return items.length ? { text: section.text, items } : null

src/api/built-in-components.md

Lines changed: 13 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2,69 +2,19 @@
22

33
Built-in components can be used directly in templates without needing to be registered.
44

5-
The `<keep-alive>`, `<transition>`, `<transition-group>`, and `<teleport>` components can all be tree-shaken by bundlers, so that they are only included in the build if they're used. They can also be imported explicitly if you need direct access to the component itself:
5+
The `<Transition>`, `<TransitionGroup>`, `<KeepAlive>`, `<Teleport>` and `<Suspense>` components can all be tree-shaken by bundlers, so that they are only included in the build if they're used.They can also be imported explicitly if you need direct access to the component itself:
66

77
```js
8-
// CDN build of Vue
9-
const { KeepAlive, Teleport, Transition, TransitionGroup } = Vue
8+
// ESM build of Vue
9+
import { Transition, TransitionGroup, KeepAlive, Teleport, Suspense } from 'vue'
1010
```
1111

1212
```js
13-
// ESM build of Vue
14-
import { KeepAlive, Teleport, Transition, TransitionGroup } from 'vue'
13+
// CDN build of Vue
14+
const { Transition, TransitionGroup, KeepAlive, Teleport, Suspense } = Vue
1515
```
1616

17-
`<component>` and `<slot>` are component-like features of template syntax. They are not true components and they can't be imported like the components shown above.
18-
19-
## component
20-
21-
- **Props:**
22-
23-
- `is` - `string | Component`
24-
25-
- **Usage:**
26-
27-
A "meta component" for rendering dynamic components. The actual component to render is determined by the `is` prop. An `is` prop as a string could be either an HTML tag name or a Component name.
28-
29-
```vue-html
30-
<!-- a dynamic component controlled by -->
31-
<!-- the `componentId` property on the vm -->
32-
<component :is="componentId"></component>
33-
34-
<!-- can also render registered component or component passed as prop -->
35-
<component :is="$options.components.child"></component>
36-
37-
<!-- can reference components by string -->
38-
<component :is="condition ? 'FooComponent' : 'BarComponent'"></component>
39-
40-
<!-- can be used to render native HTML elements -->
41-
<component :is="href ? 'a' : 'span'"></component>
42-
```
43-
44-
The built-in components `KeepAlive`, `Transition`, `TransitionGroup`, and `Teleport` can all be passed to `is`, but you must register them if you want to pass them by name. For example:
45-
46-
```js
47-
const { Transition, TransitionGroup } = Vue
48-
49-
const Component = {
50-
components: {
51-
Transition,
52-
TransitionGroup
53-
},
54-
55-
template: `
56-
<component :is="isGroup ? 'TransitionGroup' : 'Transition'">
57-
...
58-
</component>
59-
`
60-
}
61-
```
62-
63-
Registration is not required if you pass the component itself to `is` rather than its name.
64-
65-
- **See also:** [Dynamic Components](/guide/essentials/component-basics.html#dynamic-components)
66-
67-
## transition
17+
## `<Transition>`
6818

6919
- **Props:**
7020

@@ -138,7 +88,7 @@ import { KeepAlive, Teleport, Transition, TransitionGroup } from 'vue'
13888

13989
- **See also:** [Enter & Leave Transitions](/guide/built-ins/transitions-enterleave.html#transitioning-single-elements-components)
14090

141-
## transition-group
91+
## `<TransitionGroup>`
14292

14393
- **Props:**
14494

@@ -168,7 +118,7 @@ import { KeepAlive, Teleport, Transition, TransitionGroup } from 'vue'
168118

169119
- **See also:** [List Transitions](/guide/built-ins/transitions-list.html)
170120

171-
## keep-alive
121+
## `<KeepAlive>`
172122

173123
- **Props:**
174124

@@ -245,21 +195,7 @@ import { KeepAlive, Teleport, Transition, TransitionGroup } from 'vue'
245195

246196
- **See also:** [`<KeepAlive/>`](/guide/built-ins/keep-alive.html)
247197

248-
## slot
249-
250-
- **Props:**
251-
252-
- `name` - `string`, Used for named slot.
253-
254-
- **Usage:**
255-
256-
`<slot>` serve as content distribution outlets in component templates. `<slot>` itself will be replaced.
257-
258-
For detailed usage, see the guide section linked below.
259-
260-
- **See also:** [Content Distribution with Slots](/guide/essentials/component-basics.html#content-distribution-with-slots)
261-
262-
## teleport
198+
## `<Teleport>`
263199

264200
- **Props:**
265201

@@ -287,3 +223,7 @@ import { KeepAlive, Teleport, Transition, TransitionGroup } from 'vue'
287223
Notice that this will move the actual DOM nodes instead of being destroyed and recreated, and it will keep any component instances alive as well. All stateful HTML elements (i.e. a playing video) will keep their state.
288224

289225
- **See also:** [Teleport component](/guide/built-ins/teleport.html#teleport)
226+
227+
## `<Suspense>`
228+
229+
// TODO

src/api/built-in-special-elements.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Built-in Special Elements
2+
3+
`<component>` and `<slot>` are component-like features and part of the template syntax. They are not true components and are compiled away during template compilation.
4+
5+
## `<component>`
6+
7+
- **Props:**
8+
9+
- `is` - `string | Component`
10+
11+
- **Usage:**
12+
13+
A "meta component" for rendering dynamic components. The actual component to render is determined by the `is` prop. An `is` prop as a string could be either an HTML tag name or a Component name.
14+
15+
```vue-html
16+
<!-- a dynamic component controlled by -->
17+
<!-- the `componentId` property on the vm -->
18+
<component :is="componentId"></component>
19+
20+
<!-- can also render registered component or component passed as prop -->
21+
<component :is="$options.components.child"></component>
22+
23+
<!-- can reference components by string -->
24+
<component :is="condition ? 'FooComponent' : 'BarComponent'"></component>
25+
26+
<!-- can be used to render native HTML elements -->
27+
<component :is="href ? 'a' : 'span'"></component>
28+
```
29+
30+
The built-in components `KeepAlive`, `Transition`, `TransitionGroup`, and `Teleport` can all be passed to `is`, but you must register them if you want to pass them by name. For example:
31+
32+
```js
33+
const { Transition, TransitionGroup } = Vue
34+
35+
const Component = {
36+
components: {
37+
Transition,
38+
TransitionGroup
39+
},
40+
41+
template: `
42+
<component :is="isGroup ? 'TransitionGroup' : 'Transition'">
43+
...
44+
</component>
45+
`
46+
}
47+
```
48+
49+
Registration is not required if you pass the component itself to `is` rather than its name.
50+
51+
- **See also:** [Dynamic Components](/guide/essentials/component-basics.html#dynamic-components)
52+
53+
## `<slot>`
54+
55+
- **Props:**
56+
57+
- `name` - `string`, Used for named slot.
58+
59+
- **Usage:**
60+
61+
`<slot>` serve as content distribution outlets in component templates. `<slot>` itself will be replaced.
62+
63+
For detailed usage, see the guide section linked below.
64+
65+
- **See also:** [Content Distribution with Slots](/guide/essentials/component-basics.html#content-distribution-with-slots)

0 commit comments

Comments
 (0)