Skip to content

Commit aeb2b84

Browse files
authored
Merge pull request alibaba#8 from bindoon/panel-update
fix: Panel for Search
2 parents b01e618 + 52378c2 commit aeb2b84

File tree

4 files changed

+39
-4
lines changed

4 files changed

+39
-4
lines changed

packages/plugin-components-pane/demo/component.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ order: 2
77

88
````jsx
99
import React, { Component } from 'react';
10-
import ComponentPane, { PaneIcon } from '@alife/lowcode-plugin-components-pane';
10+
import ComponentPane, { PaneIcon } from '@alilc/lowcode-plugin-components-pane';
1111
import Editor from '../schema/editor';
1212
import mock from '../schema/mock.json';
1313

packages/plugin-components-pane/demo/epoch.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ order: 3
77

88
````jsx
99
import React, { Component } from 'react';
10-
import ComponentPane, { PaneIcon } from '@alife/lowcode-plugin-components-pane';
10+
import ComponentPane, { PaneIcon } from '@alilc/lowcode-plugin-components-pane';
1111
import Editor from '../schema/editor';
1212
import mock from '../schema/mock2.json';
1313

packages/plugin-components-pane/demo/usage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ order: 1
99
import React, { Component } from 'react';
1010
import ReactDOM from 'react-dom';
1111
import { Icon } from '@alifd/next';
12-
import ComponentPane, { PaneIcon } from '@alife/lowcode-plugin-components-pane';
12+
import ComponentPane, { PaneIcon } from '@alilc/lowcode-plugin-components-pane';
1313
import './index.scss';
1414

1515
const packages = [

packages/plugin-components-pane/src/index.tsx

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export default class ComponentPane extends React.Component<ComponentPaneProps, C
202202
}
203203

204204
renderContent() {
205-
const { filter = [] } = this.state;
205+
const { filter = [], keyword } = this.state;
206206
const hasContent = filter.filter(item => {
207207
return item?.categories?.filter(category => {
208208
return category?.components?.length;
@@ -211,6 +211,40 @@ export default class ComponentPane extends React.Component<ComponentPaneProps, C
211211
if (!hasContent) {
212212
return this.renderEmptyContent();
213213
}
214+
if (keyword) {
215+
return (
216+
<div ref={this.registerAdditive}>
217+
{filter.map((group) => {
218+
const { categories } = group;
219+
{return categories.map((category) => {
220+
const { components } = category;
221+
const cname = this.t(category.name);
222+
return (
223+
<Category key={cname} name={cname}>
224+
<List>
225+
{components.map((component) => {
226+
const { componentName, snippets = [] } = component;
227+
return snippets.filter(snippet => snippet.id).map(snippet => {
228+
return (
229+
<Component
230+
data={{
231+
title: snippet.title || component.title,
232+
icon: snippet.screenshot || component.icon,
233+
snippets: [snippet]
234+
}}
235+
key={`${this.t(group.name)}_${this.t(componentName)}_${this.t(snippet.title)}`}
236+
/>
237+
);
238+
});
239+
})}
240+
</List>
241+
</Category>
242+
);
243+
})}
244+
})}
245+
</div>
246+
)
247+
}
214248
return (
215249
<Tab className={cx('tabs')}>
216250
{filter.map((group) => {
@@ -260,6 +294,7 @@ export default class ComponentPane extends React.Component<ComponentPaneProps, C
260294
placeholder="搜索组件"
261295
shape="simple"
262296
hasClear
297+
autoFocus
263298
onSearch={this.handleSearch}
264299
onChange={this.handleSearch}
265300
/>

0 commit comments

Comments
 (0)