Skip to content

Commit 5bb3964

Browse files
add new example and fix rollup config
1 parent fbc5815 commit 5bb3964

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

example/index.html

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<title>myPage</title>
5+
<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
6+
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
7+
<script crossorigin src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
8+
<Link href="../style/react-custom-search-list.css" rel="stylesheet" type="text/css"/>
9+
<script crossorigin src="https://unpkg.com/@popperjs/core@2/dist/umd/popper.js"></script>
10+
<script src="../dist/react-custom-search-list.umd.js"></script>
11+
12+
<body>
13+
14+
<div id="root"></div>
15+
16+
<script type="text/babel">
17+
const ReactCustomSearchList = window.ReactCustomSearchList?.default || window.ReactCustomSearchList;
18+
const Welcome = function Welcome(props) {
19+
const [value, setValue] = React.useState('');
20+
return (<ReactCustomSearchList fullWidth={true}
21+
value={value}
22+
corner={false}
23+
theme="panel"
24+
onChange={(e) => setValue(e.target.value)}
25+
onClear={() => setValue('')}>
26+
<ul>
27+
<li><button onClick={() => alert('button click')}>Option A</button></li>
28+
<li>Option B</li>
29+
<li>Option C</li>
30+
</ul>
31+
</ReactCustomSearchList>);
32+
};
33+
34+
ReactDOM.render(<Welcome />, document.getElementById('root'));
35+
</script>
36+
37+
</body>
38+
39+
</html>

rollup.config.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ const Config = ({
1919
globals: {
2020
'react-dom': 'ReactDOM',
2121
react: 'React',
22+
'@popperjs/core/lib/popper-lite': 'Popper',
23+
'@popperjs/core/lib/modifiers/flip': 'Popper.flip',
24+
'@popperjs/core/lib/modifiers/preventOverflow': 'Popper.preventOverflow',
25+
'@popperjs/core/lib/modifiers/computeStyles': 'Popper.computeStyles',
2226
},
2327
sourcemap: true,
2428
banner:
@@ -40,7 +44,7 @@ const Config = ({
4044
return _plugins;
4145
})(),
4246
external: function (id) {
43-
return /prop-types$|react$|react-dom$|.test.js$|.js.snap$|.css$/g.test(id);
47+
return /^@popperjs|prop-types$|react$|react-dom$|.test.js$|.js.snap$|.css$/g.test(id);
4448
},
4549
};
4650
},

0 commit comments

Comments
 (0)