-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathindex.js
More file actions
25 lines (21 loc) · 752 Bytes
/
index.js
File metadata and controls
25 lines (21 loc) · 752 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import DatePlugin from './bundled/DateInput'
const bundledPlugins = [DatePlugin];
class ScalarInputPluginManager {
constructor(plugins = [], enableBundledPlugins = false) {
let enabledPlugins = plugins;
if (enableBundledPlugins) {
// ensure bundled plugins are the last plugins checked.
enabledPlugins.push(...bundledPlugins);
}
this.plugins = enabledPlugins;
}
process(arg, styleConfig, onChangeHandler) {
// plugins are provided in order, the first matching plugin will be used.
const handler = this.plugins.find(plugin => plugin.canProcess(arg));
if (handler) {
return handler.render(arg, styleConfig, onChangeHandler);
}
return null;
}
}
export default ScalarInputPluginManager;