@rc-component/cascader 1.0.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.
- package/LICENSE.md +9 -0
- package/README.md +300 -0
- package/assets/index.less +3 -0
- package/assets/list.less +106 -0
- package/assets/panel.less +7 -0
- package/assets/select.less +3 -0
- package/es/Cascader.d.ts +88 -0
- package/es/Cascader.js +230 -0
- package/es/OptionList/CacheContent.d.ts +7 -0
- package/es/OptionList/CacheContent.js +8 -0
- package/es/OptionList/Checkbox.d.ts +10 -0
- package/es/OptionList/Checkbox.js +24 -0
- package/es/OptionList/Column.d.ts +21 -0
- package/es/OptionList/Column.js +175 -0
- package/es/OptionList/List.d.ts +6 -0
- package/es/OptionList/List.js +216 -0
- package/es/OptionList/index.d.ts +4 -0
- package/es/OptionList/index.js +13 -0
- package/es/OptionList/useActive.d.ts +6 -0
- package/es/OptionList/useActive.js +26 -0
- package/es/OptionList/useKeyboard.d.ts +10 -0
- package/es/OptionList/useKeyboard.js +165 -0
- package/es/Panel.d.ts +5 -0
- package/es/Panel.js +116 -0
- package/es/context.d.ts +21 -0
- package/es/context.js +3 -0
- package/es/hooks/useDisplayValues.d.ts +10 -0
- package/es/hooks/useDisplayValues.js +44 -0
- package/es/hooks/useEntities.d.ts +10 -0
- package/es/hooks/useEntities.js +35 -0
- package/es/hooks/useMissingValues.d.ts +3 -0
- package/es/hooks/useMissingValues.js +17 -0
- package/es/hooks/useOptions.d.ts +9 -0
- package/es/hooks/useOptions.js +20 -0
- package/es/hooks/useSearchConfig.d.ts +2 -0
- package/es/hooks/useSearchConfig.js +27 -0
- package/es/hooks/useSearchOptions.d.ts +4 -0
- package/es/hooks/useSearchOptions.js +63 -0
- package/es/hooks/useSelect.d.ts +4 -0
- package/es/hooks/useSelect.js +49 -0
- package/es/hooks/useValues.d.ts +9 -0
- package/es/hooks/useValues.js +21 -0
- package/es/index.d.ts +5 -0
- package/es/index.js +4 -0
- package/es/utils/commonUtil.d.ts +18 -0
- package/es/utils/commonUtil.js +69 -0
- package/es/utils/treeUtil.d.ts +9 -0
- package/es/utils/treeUtil.js +35 -0
- package/es/utils/warningPropsUtil.d.ts +4 -0
- package/es/utils/warningPropsUtil.js +29 -0
- package/lib/Cascader.d.ts +88 -0
- package/lib/Cascader.js +239 -0
- package/lib/OptionList/CacheContent.d.ts +7 -0
- package/lib/OptionList/CacheContent.js +16 -0
- package/lib/OptionList/Checkbox.d.ts +10 -0
- package/lib/OptionList/Checkbox.js +33 -0
- package/lib/OptionList/Column.d.ts +21 -0
- package/lib/OptionList/Column.js +185 -0
- package/lib/OptionList/List.d.ts +6 -0
- package/lib/OptionList/List.js +224 -0
- package/lib/OptionList/index.d.ts +4 -0
- package/lib/OptionList/index.js +22 -0
- package/lib/OptionList/useActive.d.ts +6 -0
- package/lib/OptionList/useActive.js +34 -0
- package/lib/OptionList/useKeyboard.d.ts +10 -0
- package/lib/OptionList/useKeyboard.js +175 -0
- package/lib/Panel.d.ts +5 -0
- package/lib/Panel.js +125 -0
- package/lib/context.d.ts +21 -0
- package/lib/context.js +11 -0
- package/lib/hooks/useDisplayValues.d.ts +10 -0
- package/lib/hooks/useDisplayValues.js +53 -0
- package/lib/hooks/useEntities.d.ts +10 -0
- package/lib/hooks/useEntities.js +44 -0
- package/lib/hooks/useMissingValues.d.ts +3 -0
- package/lib/hooks/useMissingValues.js +25 -0
- package/lib/hooks/useOptions.d.ts +9 -0
- package/lib/hooks/useOptions.js +29 -0
- package/lib/hooks/useSearchConfig.d.ts +2 -0
- package/lib/hooks/useSearchConfig.js +36 -0
- package/lib/hooks/useSearchOptions.d.ts +4 -0
- package/lib/hooks/useSearchOptions.js +71 -0
- package/lib/hooks/useSelect.d.ts +4 -0
- package/lib/hooks/useSelect.js +55 -0
- package/lib/hooks/useValues.d.ts +9 -0
- package/lib/hooks/useValues.js +29 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +16 -0
- package/lib/utils/commonUtil.d.ts +18 -0
- package/lib/utils/commonUtil.js +83 -0
- package/lib/utils/treeUtil.d.ts +9 -0
- package/lib/utils/treeUtil.js +42 -0
- package/lib/utils/warningPropsUtil.d.ts +4 -0
- package/lib/utils/warningPropsUtil.js +37 -0
- package/package.json +88 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014-present alipay.com
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
# rc-cascader
|
|
2
|
+
|
|
3
|
+
React Cascader Component.
|
|
4
|
+
|
|
5
|
+
[![NPM version][npm-image]][npm-url]
|
|
6
|
+
[![npm download][download-image]][download-url]
|
|
7
|
+
[![build status][github-actions-image]][github-actions-url]
|
|
8
|
+
[![Codecov][codecov-image]][codecov-url]
|
|
9
|
+
[![bundle size][bundlephobia-image]][bundlephobia-url]
|
|
10
|
+
[![dumi][dumi-image]][dumi-url]
|
|
11
|
+
|
|
12
|
+
[npm-image]: http://img.shields.io/npm/v/rc-cascader.svg?style=flat-square
|
|
13
|
+
[npm-url]: http://npmjs.org/package/rc-cascader
|
|
14
|
+
[travis-image]: https://img.shields.io/travis/react-component/cascader/master?style=flat-square
|
|
15
|
+
[travis-url]: https://travis-ci.com/react-component/cascader
|
|
16
|
+
[github-actions-image]: https://github.com/react-component/cascader/workflows/CI/badge.svg
|
|
17
|
+
[github-actions-url]: https://github.com/react-component/cascader/actions
|
|
18
|
+
[codecov-image]: https://img.shields.io/codecov/c/github/react-component/cascader/master.svg?style=flat-square
|
|
19
|
+
[codecov-url]: https://app.codecov.io/gh/react-component/cascader
|
|
20
|
+
[david-url]: https://david-dm.org/react-component/cascader
|
|
21
|
+
[david-image]: https://david-dm.org/react-component/cascader/status.svg?style=flat-square
|
|
22
|
+
[david-dev-url]: https://david-dm.org/react-component/cascader?type=dev
|
|
23
|
+
[david-dev-image]: https://david-dm.org/react-component/cascader/dev-status.svg?style=flat-square
|
|
24
|
+
[download-image]: https://img.shields.io/npm/dm/rc-cascader.svg?style=flat-square
|
|
25
|
+
[download-url]: https://npmjs.org/package/rc-cascader
|
|
26
|
+
[bundlephobia-url]: https://bundlephobia.com/package/rc-cascader
|
|
27
|
+
[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/rc-cascader
|
|
28
|
+
[dumi-url]: https://github.com/umijs/dumi
|
|
29
|
+
[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square
|
|
30
|
+
|
|
31
|
+
## Browser Support
|
|
32
|
+
|
|
33
|
+
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Safari | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/electron/electron_48x48.png" alt="Electron" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Electron |
|
|
34
|
+
| --- | --- | --- | --- | --- |
|
|
35
|
+
| IE11, Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions |
|
|
36
|
+
|
|
37
|
+
## Screenshots
|
|
38
|
+
|
|
39
|
+
<img src="https://os.alipayobjects.com/rmsportal/TYFXEbuQXIaMqQF.png" width="288"/>
|
|
40
|
+
|
|
41
|
+
## Example
|
|
42
|
+
|
|
43
|
+
https://cascader-react-component.vercel.app
|
|
44
|
+
|
|
45
|
+
## Install
|
|
46
|
+
|
|
47
|
+
[](https://npmjs.org/package/rc-cascader)
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
$ npm install rc-cascader --save
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Usage
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
import React from 'react';
|
|
57
|
+
import Cascader from '@rc-component/cascader';
|
|
58
|
+
|
|
59
|
+
const options = [{
|
|
60
|
+
'label': '福建',
|
|
61
|
+
'value': 'fj',
|
|
62
|
+
'children': [{
|
|
63
|
+
'label': '福州',
|
|
64
|
+
'value': 'fuzhou',
|
|
65
|
+
'children': [{
|
|
66
|
+
'label': '马尾',
|
|
67
|
+
'value': 'mawei',
|
|
68
|
+
}],
|
|
69
|
+
}, {
|
|
70
|
+
'label': '泉州',
|
|
71
|
+
'value': 'quanzhou',
|
|
72
|
+
}],
|
|
73
|
+
}, {
|
|
74
|
+
'label': '浙江',
|
|
75
|
+
'value': 'zj',
|
|
76
|
+
'children': [{
|
|
77
|
+
'label': '杭州',
|
|
78
|
+
'value': 'hangzhou',
|
|
79
|
+
'children': [{
|
|
80
|
+
'label': '余杭',
|
|
81
|
+
'value': 'yuhang',
|
|
82
|
+
}],
|
|
83
|
+
}],
|
|
84
|
+
}, {
|
|
85
|
+
'label': '北京',
|
|
86
|
+
'value': 'bj',
|
|
87
|
+
'children': [{
|
|
88
|
+
'label': '朝阳区',
|
|
89
|
+
'value': 'chaoyang',
|
|
90
|
+
}, {
|
|
91
|
+
'label': '海淀区',
|
|
92
|
+
'value': 'haidian',
|
|
93
|
+
}],
|
|
94
|
+
}];
|
|
95
|
+
|
|
96
|
+
React.render(
|
|
97
|
+
<Cascader options={options}>
|
|
98
|
+
...
|
|
99
|
+
</Cascader>
|
|
100
|
+
, container);
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## API
|
|
104
|
+
|
|
105
|
+
### props
|
|
106
|
+
|
|
107
|
+
<table class="table table-bordered table-striped">
|
|
108
|
+
<thead>
|
|
109
|
+
<tr>
|
|
110
|
+
<th style="width: 100px;">name</th>
|
|
111
|
+
<th style="width: 50px;">type</th>
|
|
112
|
+
<th style="width: 50px;">default</th>
|
|
113
|
+
<th>description</th>
|
|
114
|
+
</tr>
|
|
115
|
+
</thead>
|
|
116
|
+
<tbody>
|
|
117
|
+
<tr>
|
|
118
|
+
<td>autoClearSearchValue</td>
|
|
119
|
+
<td>boolean</td>
|
|
120
|
+
<td>true</td>
|
|
121
|
+
<td>Whether the current search will be cleared on selecting an item. Only applies when checkable</td>
|
|
122
|
+
</tr>
|
|
123
|
+
<tr>
|
|
124
|
+
<td>options</td>
|
|
125
|
+
<td>Object</td>
|
|
126
|
+
<td></td>
|
|
127
|
+
<td>The data options of cascade</td>
|
|
128
|
+
</tr>
|
|
129
|
+
<tr>
|
|
130
|
+
<td>value</td>
|
|
131
|
+
<td>Array</td>
|
|
132
|
+
<td></td>
|
|
133
|
+
<td>selected value</td>
|
|
134
|
+
</tr>
|
|
135
|
+
<tr>
|
|
136
|
+
<td>defaultValue</td>
|
|
137
|
+
<td>Array</td>
|
|
138
|
+
<td></td>
|
|
139
|
+
<td>initial selected value</td>
|
|
140
|
+
</tr>
|
|
141
|
+
<tr>
|
|
142
|
+
<td>onChange</td>
|
|
143
|
+
<td>Function(value, selectedOptions)</td>
|
|
144
|
+
<td></td>
|
|
145
|
+
<td>callback when finishing cascader select</td>
|
|
146
|
+
</tr>
|
|
147
|
+
<tr>
|
|
148
|
+
<td>changeOnSelect</td>
|
|
149
|
+
<td>Boolean</td>
|
|
150
|
+
<td>false</td>
|
|
151
|
+
<td>change value on each selection</td>
|
|
152
|
+
</tr>
|
|
153
|
+
<tr>
|
|
154
|
+
<td>loadData</td>
|
|
155
|
+
<td>Function(selectedOptions)</td>
|
|
156
|
+
<td></td>
|
|
157
|
+
<td>callback when click any option, use for loading more options</td>
|
|
158
|
+
</tr>
|
|
159
|
+
<tr>
|
|
160
|
+
<td>expandTrigger</td>
|
|
161
|
+
<td>String</td>
|
|
162
|
+
<td>'click'</td>
|
|
163
|
+
<td>expand current item when click or hover</td>
|
|
164
|
+
</tr>
|
|
165
|
+
<tr>
|
|
166
|
+
<td>open</td>
|
|
167
|
+
<td>Boolean</td>
|
|
168
|
+
<td></td>
|
|
169
|
+
<td>visibility of popup overlay</td>
|
|
170
|
+
</tr>
|
|
171
|
+
<tr>
|
|
172
|
+
<td>onPopupVisibleChange</td>
|
|
173
|
+
<td>Function(visible)</td>
|
|
174
|
+
<td></td>
|
|
175
|
+
<td>callback when popup overlay's visibility changed</td>
|
|
176
|
+
</tr>
|
|
177
|
+
<tr>
|
|
178
|
+
<td>transitionName</td>
|
|
179
|
+
<td>String</td>
|
|
180
|
+
<td></td>
|
|
181
|
+
<td>transition className like "slide-up"</td>
|
|
182
|
+
</tr>
|
|
183
|
+
<tr>
|
|
184
|
+
<td>prefixCls</td>
|
|
185
|
+
<td>String</td>
|
|
186
|
+
<td>rc-cascader</td>
|
|
187
|
+
<td>prefix className of popup overlay</td>
|
|
188
|
+
</tr>
|
|
189
|
+
<tr>
|
|
190
|
+
<td>popupClassName</td>
|
|
191
|
+
<td>String</td>
|
|
192
|
+
<td></td>
|
|
193
|
+
<td>additional className of popup overlay</td>
|
|
194
|
+
</tr>
|
|
195
|
+
<tr>
|
|
196
|
+
<td>popupPlacement</td>
|
|
197
|
+
<td>String</td>
|
|
198
|
+
<td>bottomLeft</td>
|
|
199
|
+
<td>use preset popup align config from builtinPlacements:bottomRight topRight bottomLeft topLeft</td>
|
|
200
|
+
</tr>
|
|
201
|
+
<tr>
|
|
202
|
+
<td>getPopupContainer</td>
|
|
203
|
+
<td>function(trigger:Node):Node</td>
|
|
204
|
+
<td>() => document.body</td>
|
|
205
|
+
<td>container which popup select menu rendered into</td>
|
|
206
|
+
</tr>
|
|
207
|
+
<tr>
|
|
208
|
+
<td>dropdownMenuColumnStyle</td>
|
|
209
|
+
<td>Object</td>
|
|
210
|
+
<td></td>
|
|
211
|
+
<td>style object for each cascader pop menu</td>
|
|
212
|
+
</tr>
|
|
213
|
+
<tr>
|
|
214
|
+
<td>fieldNames</td>
|
|
215
|
+
<td>Object</td>
|
|
216
|
+
<td>{ label: 'label', value: 'value', children: 'children' }</td>
|
|
217
|
+
<td>custom field name for label and value and children</td>
|
|
218
|
+
</tr>
|
|
219
|
+
<tr>
|
|
220
|
+
<td>expandIcon</td>
|
|
221
|
+
<td>ReactNode</td>
|
|
222
|
+
<td>></td>
|
|
223
|
+
<td>specific the default expand icon</td>
|
|
224
|
+
</tr>
|
|
225
|
+
<tr>
|
|
226
|
+
<td>loadingIcon</td>
|
|
227
|
+
<td>ReactNode</td>
|
|
228
|
+
<td>></td>
|
|
229
|
+
<td>specific the default loading icon</td>
|
|
230
|
+
</tr>
|
|
231
|
+
<tr>
|
|
232
|
+
<td>hidePopupOnSelect</td>
|
|
233
|
+
<td>Boolean</td>
|
|
234
|
+
<td>>true</td>
|
|
235
|
+
<td>hide popup on select</td>
|
|
236
|
+
</tr>
|
|
237
|
+
</tbody>
|
|
238
|
+
</table>
|
|
239
|
+
|
|
240
|
+
### option
|
|
241
|
+
|
|
242
|
+
<table class="table table-bordered table-striped">
|
|
243
|
+
<thead>
|
|
244
|
+
<tr>
|
|
245
|
+
<th style="width: 100px;">name</th>
|
|
246
|
+
<th style="width: 50px;">type</th>
|
|
247
|
+
<th style="width: 50px;">default</th>
|
|
248
|
+
<th>description</th>
|
|
249
|
+
</tr>
|
|
250
|
+
</thead>
|
|
251
|
+
<tbody>
|
|
252
|
+
<tr>
|
|
253
|
+
<td>label</td>
|
|
254
|
+
<td>String</td>
|
|
255
|
+
<td></td>
|
|
256
|
+
<td>option text to display</td>
|
|
257
|
+
</tr>
|
|
258
|
+
<tr>
|
|
259
|
+
<td>value</td>
|
|
260
|
+
<td>String</td>
|
|
261
|
+
<td></td>
|
|
262
|
+
<td>option value as react key</td>
|
|
263
|
+
</tr>
|
|
264
|
+
<tr>
|
|
265
|
+
<td>disabled</td>
|
|
266
|
+
<td>Boolean</td>
|
|
267
|
+
<td></td>
|
|
268
|
+
<td>disabled option</td>
|
|
269
|
+
</tr>
|
|
270
|
+
<tr>
|
|
271
|
+
<td>children</td>
|
|
272
|
+
<td>Array</td>
|
|
273
|
+
<td></td>
|
|
274
|
+
<td>children options</td>
|
|
275
|
+
</tr>
|
|
276
|
+
</tbody>
|
|
277
|
+
</table>
|
|
278
|
+
|
|
279
|
+
## Development
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
$ npm install
|
|
283
|
+
$ npm start
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## Test Case
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
$ npm test
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
## Coverage
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
$ npm run coverage
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
## License
|
|
299
|
+
|
|
300
|
+
rc-cascader is released under the MIT license.
|
package/assets/list.less
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
@select-prefix: ~'rc-cascader';
|
|
2
|
+
|
|
3
|
+
.@{select-prefix} {
|
|
4
|
+
&-dropdown {
|
|
5
|
+
min-height: auto;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
&-menus {
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-wrap: nowrap;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&-menu {
|
|
14
|
+
flex: none;
|
|
15
|
+
margin: 0;
|
|
16
|
+
padding: 0;
|
|
17
|
+
list-style: none;
|
|
18
|
+
border-left: 1px solid blue;
|
|
19
|
+
height: 180px;
|
|
20
|
+
min-width: 100px;
|
|
21
|
+
overflow: auto;
|
|
22
|
+
|
|
23
|
+
&:first-child {
|
|
24
|
+
border-left: 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&-item {
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-wrap: nowrap;
|
|
30
|
+
padding-right: 20px;
|
|
31
|
+
position: relative;
|
|
32
|
+
|
|
33
|
+
&:hover {
|
|
34
|
+
background: rgba(0, 0, 255, 0.1);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&-selected {
|
|
38
|
+
background: rgba(0, 0, 255, 0.05);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&-active {
|
|
42
|
+
background: rgba(0, 255, 0, 0.1);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&-disabled {
|
|
46
|
+
opacity: 0.5;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
&-content {
|
|
52
|
+
flex: auto;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&-expand-icon {
|
|
56
|
+
position: absolute;
|
|
57
|
+
right: 4px;
|
|
58
|
+
top: 50%;
|
|
59
|
+
transform: translateY(-50%);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&-checkbox {
|
|
65
|
+
position: relative;
|
|
66
|
+
display: block;
|
|
67
|
+
flex: none;
|
|
68
|
+
width: 20px;
|
|
69
|
+
height: 20px;
|
|
70
|
+
border: 1px solid blue;
|
|
71
|
+
|
|
72
|
+
&::after {
|
|
73
|
+
position: absolute;
|
|
74
|
+
top: 50%;
|
|
75
|
+
left: 50%;
|
|
76
|
+
transform: translate(-50%, -50%);
|
|
77
|
+
content: '';
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
&-checked::after {
|
|
81
|
+
content: '✔️';
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&-indeterminate::after {
|
|
85
|
+
content: '➖';
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// ====================== RTL ======================
|
|
90
|
+
&-rtl {
|
|
91
|
+
direction: rtl;
|
|
92
|
+
|
|
93
|
+
.@{select-prefix}-menu {
|
|
94
|
+
flex: none;
|
|
95
|
+
margin: 0;
|
|
96
|
+
padding: 0;
|
|
97
|
+
list-style: none;
|
|
98
|
+
border-left: none;
|
|
99
|
+
border-right: 1px solid blue;
|
|
100
|
+
|
|
101
|
+
&:first-child {
|
|
102
|
+
border-right: 0;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
package/es/Cascader.d.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { BuildInPlacements } from '@rc-component/trigger/lib/interface';
|
|
2
|
+
import type { BaseSelectPropsWithoutPrivate, BaseSelectRef } from '@rc-component/select';
|
|
3
|
+
import type { Placement } from '@rc-component/select/lib/BaseSelect';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import Panel from './Panel';
|
|
6
|
+
import { SHOW_CHILD, SHOW_PARENT } from './utils/commonUtil';
|
|
7
|
+
export interface BaseOptionType {
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
disableCheckbox?: boolean;
|
|
10
|
+
label?: React.ReactNode;
|
|
11
|
+
value?: string | number | null;
|
|
12
|
+
children?: DefaultOptionType[];
|
|
13
|
+
}
|
|
14
|
+
export type DefaultOptionType = BaseOptionType & Record<string, any>;
|
|
15
|
+
export interface ShowSearchType<OptionType extends DefaultOptionType = DefaultOptionType, ValueField extends keyof OptionType = keyof OptionType> {
|
|
16
|
+
filter?: (inputValue: string, options: OptionType[], fieldNames: FieldNames<OptionType, ValueField>) => boolean;
|
|
17
|
+
render?: (inputValue: string, path: OptionType[], prefixCls: string, fieldNames: FieldNames<OptionType, ValueField>) => React.ReactNode;
|
|
18
|
+
sort?: (a: OptionType[], b: OptionType[], inputValue: string, fieldNames: FieldNames<OptionType, ValueField>) => number;
|
|
19
|
+
matchInputWidth?: boolean;
|
|
20
|
+
limit?: number | false;
|
|
21
|
+
}
|
|
22
|
+
export type ShowCheckedStrategy = typeof SHOW_PARENT | typeof SHOW_CHILD;
|
|
23
|
+
interface BaseCascaderProps<OptionType extends DefaultOptionType = DefaultOptionType, ValueField extends keyof OptionType = keyof OptionType> extends Omit<BaseSelectPropsWithoutPrivate, 'tokenSeparators' | 'labelInValue' | 'mode' | 'showSearch'> {
|
|
24
|
+
id?: string;
|
|
25
|
+
prefixCls?: string;
|
|
26
|
+
fieldNames?: FieldNames<OptionType, ValueField>;
|
|
27
|
+
optionRender?: (option: OptionType) => React.ReactNode;
|
|
28
|
+
children?: React.ReactElement;
|
|
29
|
+
changeOnSelect?: boolean;
|
|
30
|
+
displayRender?: (label: string[], selectedOptions?: OptionType[]) => React.ReactNode;
|
|
31
|
+
checkable?: boolean | React.ReactNode;
|
|
32
|
+
showCheckedStrategy?: ShowCheckedStrategy;
|
|
33
|
+
autoClearSearchValue?: boolean;
|
|
34
|
+
showSearch?: boolean | ShowSearchType<OptionType>;
|
|
35
|
+
searchValue?: string;
|
|
36
|
+
onSearch?: (value: string) => void;
|
|
37
|
+
expandTrigger?: 'hover' | 'click';
|
|
38
|
+
options?: OptionType[];
|
|
39
|
+
/** @private Internal usage. Do not use in your production. */
|
|
40
|
+
dropdownPrefixCls?: string;
|
|
41
|
+
loadData?: (selectOptions: OptionType[]) => void;
|
|
42
|
+
/** @deprecated Use `open` instead */
|
|
43
|
+
popupVisible?: boolean;
|
|
44
|
+
popupClassName?: string;
|
|
45
|
+
dropdownMenuColumnStyle?: React.CSSProperties;
|
|
46
|
+
/** @deprecated Use `placement` instead */
|
|
47
|
+
popupPlacement?: Placement;
|
|
48
|
+
placement?: Placement;
|
|
49
|
+
builtinPlacements?: BuildInPlacements;
|
|
50
|
+
onPopupVisibleChange?: (open: boolean) => void;
|
|
51
|
+
expandIcon?: React.ReactNode;
|
|
52
|
+
loadingIcon?: React.ReactNode;
|
|
53
|
+
}
|
|
54
|
+
export interface FieldNames<OptionType extends DefaultOptionType = DefaultOptionType, ValueField extends keyof OptionType = keyof OptionType> {
|
|
55
|
+
label?: keyof OptionType;
|
|
56
|
+
value?: keyof OptionType | ValueField;
|
|
57
|
+
children?: keyof OptionType;
|
|
58
|
+
}
|
|
59
|
+
export type ValueType<OptionType extends DefaultOptionType = DefaultOptionType, ValueField extends keyof OptionType = keyof OptionType> = keyof OptionType extends ValueField ? unknown extends OptionType['value'] ? OptionType[ValueField] : OptionType['value'] : OptionType[ValueField];
|
|
60
|
+
export type GetValueType<OptionType extends DefaultOptionType = DefaultOptionType, ValueField extends keyof OptionType = keyof OptionType, Multiple extends boolean | React.ReactNode = false> = false extends Multiple ? ValueType<Required<OptionType>, ValueField>[] : ValueType<Required<OptionType>, ValueField>[][];
|
|
61
|
+
export interface CascaderProps<OptionType extends DefaultOptionType = DefaultOptionType, ValueField extends keyof OptionType = keyof OptionType, Multiple extends boolean | React.ReactNode = false> extends BaseCascaderProps<OptionType, ValueField> {
|
|
62
|
+
checkable?: Multiple;
|
|
63
|
+
value?: GetValueType<OptionType, ValueField, Multiple>;
|
|
64
|
+
defaultValue?: GetValueType<OptionType, ValueField, Multiple>;
|
|
65
|
+
onChange?: (value: GetValueType<OptionType, ValueField, Multiple>, selectOptions: OptionType[]) => void;
|
|
66
|
+
}
|
|
67
|
+
export type SingleValueType = (string | number)[];
|
|
68
|
+
export type InternalValueType = SingleValueType | SingleValueType[];
|
|
69
|
+
export interface InternalFieldNames extends Required<FieldNames> {
|
|
70
|
+
key: string;
|
|
71
|
+
}
|
|
72
|
+
export type InternalCascaderProps = Omit<CascaderProps, 'onChange' | 'value' | 'defaultValue'> & {
|
|
73
|
+
value?: InternalValueType;
|
|
74
|
+
defaultValue?: InternalValueType;
|
|
75
|
+
onChange?: (value: InternalValueType, selectOptions: BaseOptionType[] | BaseOptionType[][]) => void;
|
|
76
|
+
};
|
|
77
|
+
export type CascaderRef = Omit<BaseSelectRef, 'scrollTo'>;
|
|
78
|
+
declare const Cascader: (<OptionType extends DefaultOptionType = DefaultOptionType, ValueField extends keyof OptionType = keyof OptionType, Multiple extends React.ReactNode = false>(props: CascaderProps<OptionType, ValueField, Multiple> & {
|
|
79
|
+
children?: React.ReactNode;
|
|
80
|
+
} & {
|
|
81
|
+
ref?: React.Ref<CascaderRef> | undefined;
|
|
82
|
+
}) => React.ReactElement) & {
|
|
83
|
+
displayName?: string | undefined;
|
|
84
|
+
SHOW_PARENT: typeof SHOW_PARENT;
|
|
85
|
+
SHOW_CHILD: typeof SHOW_CHILD;
|
|
86
|
+
Panel: typeof Panel;
|
|
87
|
+
};
|
|
88
|
+
export default Cascader;
|