@alicloud/console-components-search 0.2.36 → 0.2.37-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,21 +2,20 @@
2
2
  * @title 场景1
3
3
  */
4
4
 
5
- import React from "react";
6
- import { Search, SearchFilter } from "@alicloud/console-components-search";
7
- import { ConfigProvider } from "@alicloud/console-components";
8
- import { useState } from "react";
9
-
10
- let options = [
5
+ import React, { useState } from 'react';
6
+ import { Search, SearchFilter } from '@alicloud/console-components-search';
7
+ import { ConfigProvider } from '@alicloud/console-components';
8
+
9
+ const options = [
11
10
  {
12
11
  label: '实例名称',
13
12
  dataIndex: 'name',
14
13
  template: 'input',
15
14
  templateProps: {
16
15
  // placeholder: '按实例名称搜索',
17
- dataSource: []
16
+ dataSource: [],
18
17
  },
19
- groupName:"test"
18
+ groupName: 'test',
20
19
  },
21
20
  {
22
21
  label: '网络类型',
@@ -25,13 +24,13 @@ import { useState } from "react";
25
24
  templateProps: {
26
25
  placeholder: '请选择网络类型',
27
26
  dataSource: [
28
- {label: 'A', value: 'a'},
29
- {label: 'B', value: 'b'},
30
- {label: 'C', value: 'c'},
31
- {label: 'D', value: 'd'},
32
- ]
27
+ { label: 'A', value: 'a' },
28
+ { label: 'B', value: 'b' },
29
+ { label: 'C', value: 'c' },
30
+ { label: 'D', value: 'd' },
31
+ ],
33
32
  },
34
- groupName:"test"
33
+ groupName: 'test',
35
34
  },
36
35
  {
37
36
  label: '付费类型',
@@ -40,88 +39,98 @@ import { useState } from "react";
40
39
  templateProps: {
41
40
  placeholder: '请选择付费类型',
42
41
  dataSource: [
43
- {label: 'A', value: 'a'},
44
- {label: 'B', value: 'b'},
45
- {label: 'C', value: 'c'},
46
- {label: 'D', value: 'd'},
47
- ]
42
+ { label: 'A', value: 'a' },
43
+ { label: 'B', value: 'b' },
44
+ { label: 'C', value: 'c' },
45
+ { label: 'D', value: 'd' },
46
+ ],
48
47
  },
49
- groupName:"test2"
50
- }
51
- ]
48
+ groupName: 'test2',
49
+ },
50
+ ];
52
51
 
53
- let options2 = [
52
+ const options2 = [
54
53
  {
55
54
  label: '实例名称',
56
55
  dataIndex: 'name',
57
56
  template: 'input',
58
57
  templateProps: {
59
58
  placeholder: '按实例名称搜索',
60
- dataSource: []
59
+ dataSource: [],
61
60
  },
62
- }
63
- ]
64
-
61
+ },
62
+ ];
65
63
 
66
- const Demo1: React.FC<{}> = (props) => {
67
- const [filters, setFilters] = useState<any>([
68
- {label: '实例名称', value: 'xxxxxx', dataIndex: 'name'},
69
- {value: [{tagKey: 'test', tagValue: ''}], dataIndex: 'tag'}
64
+ const Demo1: React.FC<{}> = (props) => {
65
+ const [filters, setFilters] = useState<any>([
66
+ { label: '实例名称', value: 'xxxxxx', dataIndex: 'name' },
67
+ { value: [{ tagKey: 'test', tagValue: '' }], dataIndex: 'tag' },
68
+ { value: [{ tagKey: 'test', tagValue: '' }], dataIndex: 'tag2' },
70
69
  ]);
71
- return (
70
+ return (
72
71
  <ConfigProvider>
73
- <div>
74
- <div>默认固定搜索条件</div>
75
- <Search
76
- defaultDataIndex="name"
77
- defaultSelectedDataIndex="name"
78
- options={[{
79
- label: '实例名称',
80
- dataIndex: 'name',
81
- template: 'input',
82
- templateProps: {
83
- placeholder: '按实例名称搜索',
84
- },
85
- }]}
86
- onSearch={(value, dataIndex) => {
87
- console.log(value, dataIndex)
88
- }}
89
- />
90
- <br/><br/>
91
- <Search
92
- defaultDataIndex="name"
93
- options={options2}
94
- onSearch={(value, dataIndex) => {
95
- console.log(value, dataIndex)
96
- }}
97
- suggestions={[{label: '实例名称', children: ['222222']}, '33333333']}
98
- />
99
- <br/><br/>
100
-
101
- <div>搜索条件成组</div>
102
- <Search
103
- defaultDataIndex="name"
104
- defaultSelectedDataIndex="name"
105
- options={options}
106
- onSearch={(value, dataIndex, extra) => {
107
- //@ts-ignore
108
- setFilters([...filters, extra])
109
- }}
110
- suggestions={[{label: '实例名称', children: ['222222']}, '33333333']}
111
- />
72
+ <div>
73
+ <div>默认固定搜索条件</div>
74
+ <Search
75
+ defaultDataIndex="name"
76
+ defaultSelectedDataIndex="name"
77
+ options={[{
78
+ label: '实例名称',
79
+ dataIndex: 'name',
80
+ template: 'input',
81
+ templateProps: {
82
+ placeholder: '按实例名称搜索',
83
+ },
84
+ }]}
85
+ onSearch={(value, dataIndex) => {
86
+ console.log(value, dataIndex);
87
+ }}
88
+ />
89
+ <br /><br />
90
+ <Search
91
+ defaultDataIndex="name"
92
+ options={options2}
93
+ onSearch={(value, dataIndex) => {
94
+ console.log(value, dataIndex);
95
+ }}
96
+ suggestions={[{ label: '实例名称', children: ['222222'] }, '33333333']}
97
+ />
98
+ <br /><br />
112
99
 
113
- <div style={{marginTop: 8}}>
114
- <SearchFilter
115
- dataSource={filters}
116
- onChange={(deletedFilter, remainFilters)=> {
117
- setFilters(remainFilters)
100
+ <div>搜索条件成组</div>
101
+ <Search
102
+ defaultDataIndex="name"
103
+ defaultSelectedDataIndex="name"
104
+ options={options}
105
+ onSearch={(value, dataIndex, extra) => {
106
+ // @ts-ignore
107
+ setFilters([...filters, extra]);
108
+ }}
109
+ suggestions={[{ label: '实例名称', children: ['222222'] }, '33333333']}
110
+ />
111
+ <Search
112
+ defaultDataIndex="name"
113
+ defaultSelectedDataIndex="name"
114
+ options={options}
115
+ prefixSelectMode="cascader"
116
+ onSearch={(value, dataIndex, extra) => {
117
+ // @ts-ignore
118
+ setFilters([...filters, extra]);
118
119
  }}
120
+ suggestions={[{ label: '实例名称', children: ['222222'] }, '33333333']}
119
121
  />
122
+
123
+ <div style={{ marginTop: 8 }}>
124
+ <SearchFilter
125
+ dataSource={filters}
126
+ onChange={(deletedFilter, remainFilters) => {
127
+ setFilters(remainFilters);
128
+ }}
129
+ />
130
+ </div>
120
131
  </div>
121
- </div>
122
132
  </ConfigProvider>
123
- );
124
- };
125
-
126
- export default Demo1;
127
-
133
+ );
134
+ };
135
+
136
+ export default Demo1;