@kne/super-select 0.1.10 → 0.1.12
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.
- package/README.md +35 -6
- package/dist/index.js +71 -2601
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +69 -2602
- package/dist/index.modern.js.map +1 -1
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -76,21 +76,21 @@ const BaseExample = () => {
|
|
|
76
76
|
<SuperSelect single options={[...optionList, {
|
|
77
77
|
value: 'other', label: '超长label项超长label项超长label项超长label项超长label项超长label项超长label项超长label项'
|
|
78
78
|
}]} />
|
|
79
|
-
<SuperSelect allowSelectedAll options={optionList} maxLength={10} getSearchCallback={(searchText, item) => {
|
|
80
|
-
return item.label.indexOf(searchText) > -1;
|
|
79
|
+
<SuperSelect allowSelectedAll options={optionList} maxLength={10} getSearchCallback={({ searchText }, item) => {
|
|
80
|
+
return !searchText || item.label.indexOf(searchText) > -1;
|
|
81
81
|
}} />
|
|
82
|
-
<SuperSelect allowSelectedAll options={optionList} isPopup={false} getSearchCallback={(searchText, item) => {
|
|
83
|
-
return item.label.indexOf(searchText) > -1;
|
|
82
|
+
<SuperSelect allowSelectedAll options={optionList} isPopup={false} getSearchCallback={({ searchText }, item) => {
|
|
83
|
+
return !searchText || item.label.indexOf(searchText) > -1;
|
|
84
84
|
}} />
|
|
85
85
|
<SuperSelect api={{
|
|
86
86
|
data: {}, loader: ({ data }) => {
|
|
87
|
-
const { searchText } = data;
|
|
87
|
+
const { searchText } = data.searchProps;
|
|
88
88
|
if (!searchText) {
|
|
89
89
|
return {
|
|
90
90
|
pageData: optionList, totalCount: optionList.length
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
|
-
const newOptionList = optionList.filter((item) => item.label.indexOf(searchText) > -1);
|
|
93
|
+
const newOptionList = optionList.filter((item) => !searchText || item.label.indexOf(searchText) > -1);
|
|
94
94
|
return {
|
|
95
95
|
pageData: newOptionList, totalCount: newOptionList.length
|
|
96
96
|
};
|
|
@@ -142,6 +142,35 @@ render(<BaseExample />);
|
|
|
142
142
|
|
|
143
143
|
```
|
|
144
144
|
|
|
145
|
+
- ref
|
|
146
|
+
- 展示ref的使用
|
|
147
|
+
- _SuperSelect(@kne/current-lib_super-select)[import * as _SuperSelect from "@kne/super-select"],antd(antd),(@kne/current-lib_super-select/dist/index.css)
|
|
148
|
+
|
|
149
|
+
```jsx
|
|
150
|
+
const { default: SuperSelect } = _SuperSelect;
|
|
151
|
+
const { Space, Button } = antd;
|
|
152
|
+
const { useRef } = React;
|
|
153
|
+
|
|
154
|
+
const optionList = Array.from({ length: 20 }).map((item, key) => {
|
|
155
|
+
return {
|
|
156
|
+
label: `第${key + 1}项`, value: key + 1, disabled: key === 1
|
|
157
|
+
};
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
const BaseExample = () => {
|
|
161
|
+
const ref = useRef();
|
|
162
|
+
return <Space wrap>
|
|
163
|
+
<SuperSelect options={optionList} ref={ref} />
|
|
164
|
+
<Button onClick={() => {
|
|
165
|
+
ref.current.onOpenChange(true);
|
|
166
|
+
}}>打开弹窗</Button>
|
|
167
|
+
</Space>;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
render(<BaseExample />);
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
|
|
145
174
|
|
|
146
175
|
### API
|
|
147
176
|
|