@@ -12,12 +12,13 @@ const settings = {
12
12
}
13
13
</style>
14
14
<div id="custom"></div>
15
+ <hr />
15
16
<div id="searchbox"></div>
16
17
<div id="hits"></div>
17
18
` ,
18
19
preamble : /* JS */ `
19
20
import 'instantsearch.css/themes/satellite-min.css';
20
- import algoliasearch from 'algoliasearch/lite';
21
+ import { liteClient as algoliasearch } from 'algoliasearch/lite';
21
22
import instantsearch from 'instantsearch.js';
22
23
import { history } from 'instantsearch.js/es/lib/routers';
23
24
import { searchBox, hits } from 'instantsearch.js/es/widgets';
@@ -32,30 +33,30 @@ const settings = {
32
33
routing: {
33
34
router: history({
34
35
cleanUrlOnDispose: false,
35
- })
36
- }
36
+ }),
37
+ },
37
38
});
38
39
39
40
search.addWidgets([
40
- ...createWidgets(document.querySelector('#custom')),
41
+ ...createWidgets(() =>
42
+ document.querySelector('#custom').appendChild(document.createElement('div'))
43
+ ),
41
44
searchBox({
42
45
container: '#searchbox',
43
46
}),
44
47
hits({
45
48
container: '#hits',
46
49
templates: {
47
- item: (hit, { components }) => components.Highlight({ attribute: 'name', hit }),
50
+ item: (hit, { components }) =>
51
+ components.Highlight({ attribute: 'name', hit }),
48
52
},
49
53
}),
50
54
]);
51
55
52
56
search.start();
53
57
` ,
54
58
dependencies : {
55
- // TODO: use current version somehow, both locally and in the built website
56
- 'instantsearch.js' : 'latest' ,
57
- 'instantsearch.css' : 'latest' ,
58
- algoliasearch : 'latest' ,
59
+ algoliasearch : '5.1.1' ,
59
60
} ,
60
61
filename : '/widget.ts' ,
61
62
} ,
@@ -72,7 +73,7 @@ const settings = {
72
73
import 'instantsearch.css/themes/satellite-min.css';
73
74
import React from "react";
74
75
import { createRoot } from "react-dom/client";
75
- import algoliasearch from "algoliasearch/lite";
76
+ import { liteClient as algoliasearch } from "algoliasearch/lite";
76
77
import { history } from "instantsearch.js/es/lib/routers";
77
78
import { InstantSearch, SearchBox, Hits, Highlight } from "react-instantsearch";
78
79
import { widgets } from "./widget.tsx";
@@ -91,6 +92,7 @@ const settings = {
91
92
}}
92
93
>
93
94
{widgets}
95
+ <hr />
94
96
<SearchBox />
95
97
<Hits hitComponent={Hit}/>
96
98
</InstantSearch>
@@ -101,11 +103,9 @@ const settings = {
101
103
}
102
104
` ,
103
105
dependencies : {
104
- react : 'latest' ,
105
- 'react-dom' : 'latest' ,
106
- algoliasearch : 'latest' ,
107
- 'instantsearch.css' : 'latest' ,
108
- 'react-instantsearch' : 'latest' ,
106
+ react : '18.2.0' ,
107
+ 'react-dom' : '18.2.0' ,
108
+ algoliasearch : '5.1.1' ,
109
109
} ,
110
110
filename : '/widget.tsx' ,
111
111
} ,
@@ -121,7 +121,7 @@ const settings = {
121
121
preamble : `
122
122
import "instantsearch.css/themes/satellite-min.css";
123
123
import Vue from "vue";
124
- import algoliasearch from "algoliasearch/lite";
124
+ import { liteClient as algoliasearch } from "algoliasearch/lite";
125
125
import { history } from "instantsearch.js/es/lib/routers";
126
126
import { AisInstantSearch, AisHits, AisSearchBox } from "vue-instantsearch/vue2/es";
127
127
import Widget from "./Widget.vue";
@@ -149,15 +149,13 @@ const settings = {
149
149
}
150
150
},
151
151
},
152
- [h(Widget), h(AisSearchBox), h(AisHits)]
152
+ [h(Widget), h('hr'), h( AisSearchBox), h(AisHits)]
153
153
),
154
154
}).$mount("#app");
155
155
` ,
156
156
dependencies : {
157
- vue : '2' ,
158
- algoliasearch : 'latest' ,
159
- 'instantsearch.css' : 'latest' ,
160
- 'vue-instantsearch' : 'latest' ,
157
+ vue : '2.7.14' ,
158
+ algoliasearch : '5.1.1' ,
161
159
} ,
162
160
filename : '/Widget.vue' ,
163
161
} ,
@@ -166,9 +164,14 @@ const settings = {
166
164
export default function Sandbox ( {
167
165
code,
168
166
flavor,
167
+ modules,
169
168
} : {
170
169
code : string ;
171
170
flavor : 'react' | 'js' | 'vue' ;
171
+ modules : {
172
+ files : Record < string , string > ;
173
+ dependencies : Record < string , string > ;
174
+ } ;
172
175
} ) {
173
176
const { preamble, html, filename, dependencies } = settings [ flavor ] ;
174
177
return (
@@ -184,12 +187,17 @@ export default function Sandbox({
184
187
[ filename ] : {
185
188
code,
186
189
} ,
190
+ ...modules . files ,
187
191
} }
188
192
customSetup = { {
189
- dependencies,
193
+ dependencies : {
194
+ ...dependencies ,
195
+ ...modules . dependencies ,
196
+ } ,
190
197
entry : '/index.js' ,
191
198
} }
192
199
options = { {
200
+ editorHeight : 500 ,
193
201
activeFile : filename ,
194
202
showNavigator : true ,
195
203
} }
0 commit comments