-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (27 loc) · 890 Bytes
/
index.js
File metadata and controls
33 lines (27 loc) · 890 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
26
27
28
29
30
31
32
33
var assert = require('assert')
var convert = require('object-array-converter')
var isObject = require('is-object')
var isArray = require('isarray')
var html = require('bel')
var createList = require('./list')
var createForm = require('./form')
module.exports = function createEditor (options) {
options = options || {}
return function renderEditor (params) {
assert.ok(params.items || isObject(params.items), 'list-editor: params.items is required and must be an array or object')
var list = createList(params)
var form = createForm(params)
var items
if (isArray(params.items)) {
params.items = convert.toObject(params.items)
params.showKeys = false
} else {
params.showKeys = true
}
console.log('renderEditor', params.items)
return html`<div class="list-editor">
${list(params)}
${form(params)}
</div>`
}
}