PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 2.25.0
Block Animations, Motion & Scroll Effects – Ghost Kit v2.25.0
3.7.2 3.7.1 3.7.0 3.6.1 trunk 1.6.3 2.25.0 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.6.0
ghostkit / gutenberg / components / select / index.js

index.js in Block Animations, Motion & Scroll Effects – Ghost Kit 2.25.0, at gutenberg/components/select/index.js

71 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * External dependencies
3 */
4 import Select from 'react-select';
5 import selectStyles from 'gutenberg-react-select-styles';
6 import classnames from 'classnames/dedupe';
7 import { AutoSizer, List } from 'react-virtualized';
8
9 /**
10 * WordPress dependencies
11 */
12 const { Component } = wp.element;
13
14 const rowHeight = 26;
15
16 function MenuList(props) {
17 const { children, maxHeight } = props;
18
19 if (!children.length) {
20 return null;
21 }
22
23 return (
24 <AutoSizer disableHeight>
25 {({ width }) => {
26 return (
27 <List
28 height={maxHeight}
29 rowCount={children.length}
30 rowHeight={rowHeight}
31 // eslint-disable-next-line react/no-unstable-nested-components
32 rowRenderer={({ index, key, style }) => {
33 return (
34 <div key={key} style={style}>
35 {children[index]}
36 </div>
37 );
38 }}
39 width={width}
40 />
41 );
42 }}
43 </AutoSizer>
44 );
45 }
46
47 /**
48 * Component Class
49 */
50 export default class SelectComponent extends Component {
51 render() {
52 const props = {
53 ...(this.props.grouped
54 ? {
55 groupHeaderHeight: 50,
56 }
57 : {}),
58 ...this.props,
59 };
60
61 return (
62 <Select
63 styles={selectStyles}
64 components={{ MenuList }}
65 {...props}
66 className={classnames(props.className, 'ghostkit-control-select')}
67 />
68 );
69 }
70 }
71