material 0.9.0 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +24 -10
- package/package.json +1 -1
- package/scripts/doccoAssistant.js +25 -0
- package/src/appbar.js +2 -4
- package/src/badge.js +6 -13
- package/src/button.js +10 -18
- package/src/calendar.js +23 -48
- package/src/card.js +2 -4
- package/src/checkbox.js +2 -7
- package/src/class/component.js +19 -0
- package/src/class/control.js +33 -0
- package/src/component.js +7 -41
- package/src/datehour.js +2 -4
- package/src/dialog.js +3 -5
- package/src/drawer.js +12 -12
- package/src/element.js +16 -20
- package/src/file.js +6 -4
- package/src/form/build.js +2 -2
- package/src/form.js +9 -22
- package/src/icon.js +6 -34
- package/src/image.js +1 -3
- package/src/item.js +3 -3
- package/src/link.js +1 -3
- package/src/list/build.js +2 -2
- package/src/list/render.js +5 -7
- package/src/list/select.js +4 -2
- package/src/list/update.js +2 -2
- package/src/list.js +12 -13
- package/src/loader.js +4 -7
- package/src/loading.js +2 -8
- package/src/map.js +27 -32
- package/src/menu.js +2 -2
- package/src/mixin/build.js +68 -0
- package/src/mixin/emitter.js +0 -2
- package/src/module/build.js +51 -46
- package/src/module/clone.js +15 -0
- package/src/module/dot.js +15 -9
- package/src/module/events.js +2 -0
- package/src/module/layout.js +75 -0
- package/src/module/merge.js +22 -0
- package/src/navigation.js +4 -3
- package/src/progress.js +9 -24
- package/src/search.js +3 -2
- package/src/select.js +2 -2
- package/src/selecter.js +5 -4
- package/src/selector.js +23 -41
- package/src/slider.js +33 -55
- package/src/snackbar.js +1 -1
- package/src/switch.js +1 -1
- package/src/switcher.js +1 -1
- package/src/tabs.js +12 -19
- package/src/tabview.js +1 -1
- package/src/text.js +2 -4
- package/src/textfield.js +1 -3
- package/src/toolbar.js +6 -20
- package/src/tooltip.js +14 -24
- package/src/tree.js +10 -14
- package/src/view/build.js +2 -2
- package/src/view.js +2 -2
- package/src/divider.js +0 -60
- package/src/layout.js +0 -106
package/src/form.js
CHANGED
|
@@ -5,31 +5,18 @@ import events from './module/events'
|
|
|
5
5
|
import controller from './mixin/controller'
|
|
6
6
|
|
|
7
7
|
// import component
|
|
8
|
-
import
|
|
8
|
+
import { create } from './module/layout'
|
|
9
9
|
|
|
10
|
-
const defaults = {
|
|
11
|
-
prefix: 'material',
|
|
12
|
-
class: 'form',
|
|
13
|
-
tag: 'div',
|
|
14
|
-
controls: ['textfield', 'checkbox', 'slider', 'switch']
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Form class
|
|
19
|
-
*
|
|
20
|
-
* @class
|
|
21
|
-
* @return {Class} This class instance
|
|
22
|
-
*/
|
|
23
10
|
class Form {
|
|
24
|
-
static
|
|
11
|
+
static defaults = {
|
|
12
|
+
prefix: 'material',
|
|
13
|
+
class: 'form',
|
|
14
|
+
tag: 'div',
|
|
15
|
+
controls: ['textfield', 'checkbox', 'slider', 'switch']
|
|
16
|
+
}
|
|
25
17
|
|
|
26
|
-
/**
|
|
27
|
-
* Constructor
|
|
28
|
-
* @param {Object} options - Component options
|
|
29
|
-
* @return {Object} Class instance
|
|
30
|
-
*/
|
|
31
18
|
constructor (options) {
|
|
32
|
-
this.options = Object.assign({}, defaults, options || {})
|
|
19
|
+
this.options = Object.assign({}, Form.defaults, options || {})
|
|
33
20
|
|
|
34
21
|
this.init()
|
|
35
22
|
this.build()
|
|
@@ -78,7 +65,7 @@ class Form {
|
|
|
78
65
|
// complete layout options
|
|
79
66
|
this.options.root = this.element
|
|
80
67
|
|
|
81
|
-
this.layout =
|
|
68
|
+
this.layout = create(this.options.layout, this.element)
|
|
82
69
|
|
|
83
70
|
this._initControls(this.layout.controls)
|
|
84
71
|
|
package/src/icon.js
CHANGED
|
@@ -1,27 +1,13 @@
|
|
|
1
1
|
import insert from './mixin/insert'
|
|
2
2
|
import * as css from './module/css'
|
|
3
3
|
|
|
4
|
-
var defaults = {
|
|
5
|
-
prefix: 'material',
|
|
6
|
-
class: 'icon',
|
|
7
|
-
tag: 'div'
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* The item class is used for example as item list
|
|
12
|
-
*
|
|
13
|
-
* @class
|
|
14
|
-
* @extends {Component}
|
|
15
|
-
* @return {Object} The class instance
|
|
16
|
-
* @example new Item(object);
|
|
17
|
-
*/
|
|
18
4
|
class Icon {
|
|
19
|
-
static
|
|
5
|
+
static defaults = {
|
|
6
|
+
prefix: 'material',
|
|
7
|
+
class: 'icon',
|
|
8
|
+
tag: 'div'
|
|
9
|
+
}
|
|
20
10
|
|
|
21
|
-
/**
|
|
22
|
-
* init
|
|
23
|
-
* @return {Object} The class options
|
|
24
|
-
*/
|
|
25
11
|
constructor (options) {
|
|
26
12
|
this.init(options)
|
|
27
13
|
this.build()
|
|
@@ -29,20 +15,11 @@ class Icon {
|
|
|
29
15
|
return this
|
|
30
16
|
}
|
|
31
17
|
|
|
32
|
-
/**
|
|
33
|
-
* [init description]
|
|
34
|
-
* @param {?} options [description]
|
|
35
|
-
* @return {?} [description]
|
|
36
|
-
*/
|
|
37
18
|
init (options) {
|
|
38
|
-
this.options = Object.assign({}, defaults, options || {})
|
|
19
|
+
this.options = Object.assign({}, Icon.defaults, options || {})
|
|
39
20
|
Object.assign(this, insert)
|
|
40
21
|
}
|
|
41
22
|
|
|
42
|
-
/**
|
|
43
|
-
* Build function for item
|
|
44
|
-
* @return {Object} This class instance
|
|
45
|
-
*/
|
|
46
23
|
build (options) {
|
|
47
24
|
options = options || this.options
|
|
48
25
|
|
|
@@ -66,11 +43,6 @@ class Icon {
|
|
|
66
43
|
}
|
|
67
44
|
}
|
|
68
45
|
|
|
69
|
-
/**
|
|
70
|
-
* Get or set text value of the element
|
|
71
|
-
* @param {string} value The text to set
|
|
72
|
-
* @returns {*}
|
|
73
|
-
*/
|
|
74
46
|
set (value) {
|
|
75
47
|
if (value) {
|
|
76
48
|
if (this.element.innerText) {
|
package/src/image.js
CHANGED
package/src/item.js
CHANGED
package/src/link.js
CHANGED
package/src/list/build.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import scrollbar from '../module/scrollbar'
|
|
2
2
|
import dataset from '../module/dataset'
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { create } from '../module/layout'
|
|
5
5
|
import Virtual from './virtual'
|
|
6
6
|
import Loading from '../loading'
|
|
7
7
|
|
|
@@ -30,7 +30,7 @@ export default {
|
|
|
30
30
|
dataset(this.element, this.options.data)
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
this.layout =
|
|
33
|
+
this.layout = create(this.options.layout.main, this.element)
|
|
34
34
|
this.ui = this.layout.component
|
|
35
35
|
|
|
36
36
|
// prepare loading
|
package/src/list/render.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import Element from '../element'
|
|
2
|
-
import
|
|
2
|
+
import { create } from '../module/layout'
|
|
3
3
|
|
|
4
4
|
import dot from '../module/dot'
|
|
5
5
|
|
|
6
6
|
export default {
|
|
7
7
|
|
|
8
|
-
render (list
|
|
8
|
+
render (list) {
|
|
9
9
|
// console.log('render', list)
|
|
10
10
|
this.virtual.set(list)
|
|
11
11
|
|
|
@@ -38,8 +38,6 @@ export default {
|
|
|
38
38
|
class: 'item'
|
|
39
39
|
})
|
|
40
40
|
|
|
41
|
-
// console.log('---', this.id)
|
|
42
|
-
|
|
43
41
|
if (this.id && this.id === info[this.dataId]) {
|
|
44
42
|
element.classList.add('selected')
|
|
45
43
|
}
|
|
@@ -53,13 +51,13 @@ export default {
|
|
|
53
51
|
const item = info[this.options.itemSwitch]
|
|
54
52
|
|
|
55
53
|
if (this.options.layout.item[item]) {
|
|
56
|
-
layout =
|
|
54
|
+
layout = create(this.options.layout.item[item], element)
|
|
57
55
|
} else {
|
|
58
|
-
layout =
|
|
56
|
+
layout = create(this.options.layout.item.base, element)
|
|
59
57
|
}
|
|
60
58
|
} else {
|
|
61
59
|
const itemName = this.options.itemName || 'item'
|
|
62
|
-
layout =
|
|
60
|
+
layout = create(this.options.layout[itemName], element)
|
|
63
61
|
}
|
|
64
62
|
|
|
65
63
|
// console.log('translate', layout)
|
package/src/list/select.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import clone from '../module/clone'
|
|
2
|
+
|
|
1
3
|
export default {
|
|
2
4
|
select (item, silent) {
|
|
3
5
|
// console.log('select', item.dataset.id)
|
|
@@ -42,11 +44,11 @@ export default {
|
|
|
42
44
|
},
|
|
43
45
|
|
|
44
46
|
getInfoById (id) {
|
|
45
|
-
return
|
|
47
|
+
return clone(this.dataStore[id])
|
|
46
48
|
},
|
|
47
49
|
|
|
48
50
|
getSelectedInfo () {
|
|
49
|
-
return
|
|
51
|
+
return clone(this.dataStore[this.id])
|
|
50
52
|
},
|
|
51
53
|
|
|
52
54
|
getItemById (id, silent) {
|
package/src/list/update.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { create } from '../module/layout'
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
4
|
update (info) {
|
|
@@ -53,7 +53,7 @@ export default {
|
|
|
53
53
|
const item = this.ui.body.querySelector('[data-id="' + info[this.dataId] + '"]')
|
|
54
54
|
if (item) {
|
|
55
55
|
item.innerHTML = ''
|
|
56
|
-
const layout =
|
|
56
|
+
const layout = create(this.options.layout.item, item)
|
|
57
57
|
|
|
58
58
|
this.renderInfo(layout, info)
|
|
59
59
|
}
|
package/src/list.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import * as css from './module/css'
|
|
2
2
|
|
|
3
|
-
const defaults = {
|
|
4
|
-
className: 'text',
|
|
5
|
-
tag: 'span',
|
|
6
|
-
seprator: ' | '
|
|
7
|
-
}
|
|
8
|
-
|
|
9
3
|
class List {
|
|
10
|
-
static
|
|
4
|
+
static defaults = {
|
|
5
|
+
className: 'text',
|
|
6
|
+
tag: 'span',
|
|
7
|
+
seprator: ' | '
|
|
8
|
+
}
|
|
11
9
|
|
|
12
10
|
constructor (options) {
|
|
13
|
-
this.
|
|
14
|
-
|
|
11
|
+
this.init(options)
|
|
15
12
|
this.build()
|
|
13
|
+
}
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
init (otions) {
|
|
16
|
+
this.options = { ...List.defaults, ...options }
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
build () {
|
|
@@ -37,9 +36,9 @@ class List {
|
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
set (list) {
|
|
40
|
-
|
|
39
|
+
let text = ''
|
|
41
40
|
|
|
42
|
-
for (
|
|
41
|
+
for (let i = 0; i < list.length; i++) {
|
|
43
42
|
if (i < list.length - 1) {
|
|
44
43
|
text = text + list[i] + this.options.seprator
|
|
45
44
|
} else {
|
|
@@ -50,7 +49,7 @@ class List {
|
|
|
50
49
|
// console.log('set', text)
|
|
51
50
|
if (text === undefined) return
|
|
52
51
|
|
|
53
|
-
|
|
52
|
+
const label = this.options.label || ''
|
|
54
53
|
|
|
55
54
|
this.element.innerHTML = label + text
|
|
56
55
|
|
package/src/loader.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
class Loader {
|
|
2
|
-
static uid = "material-loader";
|
|
3
|
-
|
|
4
2
|
static defaults = {
|
|
5
3
|
class: 'loader'
|
|
6
4
|
}
|
|
7
5
|
|
|
8
6
|
constructor (options) {
|
|
9
|
-
this.
|
|
10
|
-
|
|
11
|
-
// Object.assign(this, mediator, build)
|
|
12
|
-
|
|
7
|
+
this.init(options)
|
|
13
8
|
this.build()
|
|
9
|
+
}
|
|
14
10
|
|
|
15
|
-
|
|
11
|
+
init (options) {
|
|
12
|
+
this.options = { ...Loader.defaults, ...options }
|
|
16
13
|
}
|
|
17
14
|
|
|
18
15
|
build () {
|
package/src/loading.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import build from './
|
|
1
|
+
import build from './mixin/build'
|
|
2
2
|
|
|
3
3
|
class Loading {
|
|
4
|
-
static uid = "material-loading";
|
|
5
|
-
|
|
6
|
-
static isComponent () {
|
|
7
|
-
return true
|
|
8
|
-
}
|
|
9
|
-
|
|
10
4
|
static defaults = {
|
|
11
5
|
class: 'loading',
|
|
12
6
|
tag: 'div',
|
|
@@ -24,7 +18,7 @@ class Loading {
|
|
|
24
18
|
}
|
|
25
19
|
|
|
26
20
|
init (options) {
|
|
27
|
-
this.options =
|
|
21
|
+
this.options = { ...Loading.defaults, ...options }
|
|
28
22
|
Object.assign(this, build)
|
|
29
23
|
}
|
|
30
24
|
|
package/src/map.js
CHANGED
|
@@ -13,42 +13,37 @@ import mode from './map/mode'
|
|
|
13
13
|
import select from './map/select'
|
|
14
14
|
import focus from './map/focus'
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
['root.mousedown', 'mouseDown'],
|
|
18
|
-
['root.mouseup', 'mouseUp'],
|
|
19
|
-
['root.mousemove', 'mouseMove'],
|
|
20
|
-
['root.mouseleave', 'mouseLeave'],
|
|
21
|
-
['root.mouseout', 'mouseOut'],
|
|
22
|
-
['root.click', 'mouseClick'],
|
|
23
|
-
['root.touchStart', 'mouseClick']
|
|
24
|
-
]
|
|
25
|
-
|
|
26
|
-
const defaults = {
|
|
27
|
-
class: 'worldmap',
|
|
28
|
-
tag: 'main',
|
|
29
|
-
zoom: 0.3,
|
|
30
|
-
isocodes: [],
|
|
31
|
-
mode: 'unique',
|
|
32
|
-
path: '/dist/map/',
|
|
33
|
-
pinchZoom: {
|
|
34
|
-
maxZoom: 128,
|
|
35
|
-
minZoom: 3,
|
|
36
|
-
setOffsetsOnce: true,
|
|
37
|
-
verticalPadding: 64,
|
|
38
|
-
horizontalPadding: 64,
|
|
39
|
-
tapZoomFactor: 0
|
|
40
|
-
}
|
|
41
|
-
}
|
|
16
|
+
// Depracted
|
|
42
17
|
|
|
43
18
|
class Map {
|
|
44
|
-
static
|
|
19
|
+
static defaults = {
|
|
20
|
+
class: 'worldmap',
|
|
21
|
+
tag: 'main',
|
|
22
|
+
zoom: 0.3,
|
|
23
|
+
isocodes: [],
|
|
24
|
+
mode: 'unique',
|
|
25
|
+
path: '/dist/map/',
|
|
26
|
+
pinchZoom: {
|
|
27
|
+
maxZoom: 128,
|
|
28
|
+
minZoom: 3,
|
|
29
|
+
setOffsetsOnce: true,
|
|
30
|
+
verticalPadding: 64,
|
|
31
|
+
horizontalPadding: 64,
|
|
32
|
+
tapZoomFactor: 0
|
|
33
|
+
},
|
|
34
|
+
events: [
|
|
35
|
+
['root.mousedown', 'mouseDown'],
|
|
36
|
+
['root.mouseup', 'mouseUp'],
|
|
37
|
+
['root.mousemove', 'mouseMove'],
|
|
38
|
+
['root.mouseleave', 'mouseLeave'],
|
|
39
|
+
['root.mouseout', 'mouseOut'],
|
|
40
|
+
['root.click', 'mouseClick'],
|
|
41
|
+
['root.touchStart', 'mouseClick']
|
|
42
|
+
]
|
|
43
|
+
}
|
|
45
44
|
|
|
46
|
-
/**
|
|
47
|
-
* Constructor component options
|
|
48
|
-
* @return {Object} Class instance
|
|
49
|
-
*/
|
|
50
45
|
constructor (options) {
|
|
51
|
-
this.options =
|
|
46
|
+
this.options = { ...Map.defaults, ...options }
|
|
52
47
|
|
|
53
48
|
Object.assign(
|
|
54
49
|
this, emitter, init, build, viewport, mouse,
|
package/src/menu.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import EventEmitter from './mixin/emitter'
|
|
2
2
|
// menu related modules
|
|
3
|
-
import build from './
|
|
3
|
+
import build from './mixin/build'
|
|
4
4
|
import events from './module/events'
|
|
5
5
|
import display from './mixin/display'
|
|
6
6
|
import position from './mixin/position'
|
|
@@ -41,7 +41,7 @@ class Menu extends EventEmitter {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
init (options) {
|
|
44
|
-
this.options =
|
|
44
|
+
this.options = { ...Menu.defaults, ...options }
|
|
45
45
|
Object.assign(this, build, display, position)
|
|
46
46
|
|
|
47
47
|
this.menus = []
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import * as css from '../module/css'
|
|
2
|
+
import dataset from '../module/dataset'
|
|
3
|
+
|
|
4
|
+
import { create } from '../module/layout'
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
build () {
|
|
8
|
+
this.element = document.createElement(this.options.tag || 'div')
|
|
9
|
+
|
|
10
|
+
const defaults = this.constructor.defaults || {}
|
|
11
|
+
|
|
12
|
+
if (defaults.base) css.add(this.element, defaults.base)
|
|
13
|
+
if (defaults.class) css.add(this.element, defaults.class)
|
|
14
|
+
|
|
15
|
+
if (this.options.class !== defaults.class) {
|
|
16
|
+
css.add(this.element, this.options.class)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (this.options.data) {
|
|
20
|
+
dataset(this.element, this.options.data)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (this.options.base === 'view' || this.options.base === 'app') {
|
|
24
|
+
this.container = this.options.container || document.body
|
|
25
|
+
} else {
|
|
26
|
+
this.container = this.options.container
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (this.container) this.appendTo(this.container)
|
|
30
|
+
|
|
31
|
+
if (this.options.layout) {
|
|
32
|
+
this.layout = create(this.options.layout, this.element)
|
|
33
|
+
this.ui = this.layout.component
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
this.ui = this.ui || {}
|
|
37
|
+
|
|
38
|
+
if (this.options.icon) this.buildIcon()
|
|
39
|
+
if (this.options.label) this.buildLabel()
|
|
40
|
+
|
|
41
|
+
if (this.options.show === true && this.show) this.show()
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
buildLabel () {
|
|
45
|
+
if (!this.options.label) return
|
|
46
|
+
|
|
47
|
+
this.ui.label = document.createElement('label')
|
|
48
|
+
this.ui.label.classList.add('label')
|
|
49
|
+
this.ui.label.innerHTML = this.options.label
|
|
50
|
+
|
|
51
|
+
this.element.appendChild(this.ui.label)
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
buildIcon () {
|
|
55
|
+
if (!this.options.icon) return
|
|
56
|
+
|
|
57
|
+
this.ui.icon = document.createElement('i')
|
|
58
|
+
this.ui.icon.classList.add('icon')
|
|
59
|
+
this.ui.icon.innerHTML = this.options.icon
|
|
60
|
+
|
|
61
|
+
this.element.appendChild(this.ui.icon)
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
appendTo (container) {
|
|
65
|
+
// console.log('appendTo', container)
|
|
66
|
+
container.appendChild(this.element)
|
|
67
|
+
}
|
|
68
|
+
}
|
package/src/mixin/emitter.js
CHANGED
package/src/module/build.js
CHANGED
|
@@ -1,67 +1,72 @@
|
|
|
1
1
|
import * as css from './css'
|
|
2
2
|
import dataset from './dataset'
|
|
3
|
+
import { create } from '../module/layout'
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Builds a UI component instance.
|
|
7
|
+
* @param {object} instance - The component instance to build.
|
|
8
|
+
*/
|
|
9
|
+
const build = (instance) => {
|
|
10
|
+
const { tag = 'div', class: customClass, data, base, container, schema, icon, label, show } = instance.options
|
|
11
|
+
const { defaults = {} } = instance.constructor
|
|
5
12
|
|
|
6
|
-
|
|
7
|
-
build () {
|
|
8
|
-
this.element = document.createElement(this.options.tag || 'div')
|
|
13
|
+
instance.element = document.createElement(tag)
|
|
9
14
|
|
|
10
|
-
|
|
15
|
+
if (defaults.base) css.add(instance.element, defaults.base)
|
|
16
|
+
if (defaults.class) css.add(instance.element, defaults.class)
|
|
11
17
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (this.options.class !== defaults.class) {
|
|
16
|
-
css.add(this.element, this.options.class)
|
|
17
|
-
}
|
|
18
|
+
if (customClass !== defaults.class) {
|
|
19
|
+
css.add(instance.element, customClass)
|
|
20
|
+
}
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
if (data) {
|
|
23
|
+
dataset(instance.element, data)
|
|
24
|
+
}
|
|
22
25
|
|
|
23
|
-
|
|
24
|
-
this.container = this.options.container || document.body
|
|
25
|
-
} else {
|
|
26
|
-
this.container = this.options.container
|
|
27
|
-
}
|
|
26
|
+
setupContainer(instance, base, container)
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
if (schema) {
|
|
29
|
+
setupLayout(instance, schema)
|
|
30
|
+
}
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
this.layout = new Layout(this.options.layout, this.element)
|
|
33
|
-
this.ui = this.layout.component
|
|
34
|
-
}
|
|
32
|
+
instance.ui = instance.ui || {}
|
|
35
33
|
|
|
36
|
-
|
|
34
|
+
if (icon) buildIcon(instance)
|
|
35
|
+
if (label) buildLabel(instance)
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
if (show === true && instance.show) instance.show()
|
|
38
|
+
}
|
|
40
39
|
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
const setupContainer = (instance, base, container) => {
|
|
41
|
+
instance.container = (base === 'view' || base === 'app') ? container || document.body : container
|
|
42
|
+
if (instance.container) instance.container.appendChild(instance.element)
|
|
43
|
+
}
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
const setupLayout = (instance, schema) => {
|
|
46
|
+
instance.layout = create(schema, instance.element)
|
|
47
|
+
instance.ui = instance.layout.component
|
|
48
|
+
}
|
|
46
49
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
function buildLabel ({ ui, options, element }) {
|
|
51
|
+
const { label } = options
|
|
52
|
+
if (!label) return
|
|
50
53
|
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
ui.label = document.createElement('label')
|
|
55
|
+
ui.label.classList.add('label')
|
|
56
|
+
ui.label.innerHTML = label
|
|
53
57
|
|
|
54
|
-
|
|
55
|
-
|
|
58
|
+
element.appendChild(ui.label)
|
|
59
|
+
}
|
|
56
60
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
61
|
+
function buildIcon ({ ui, options, element }) {
|
|
62
|
+
const { icon } = options
|
|
63
|
+
if (!icon) return
|
|
60
64
|
|
|
61
|
-
|
|
62
|
-
|
|
65
|
+
ui.icon = document.createElement('i')
|
|
66
|
+
ui.icon.classList.add('icon')
|
|
67
|
+
ui.icon.innerHTML = icon
|
|
63
68
|
|
|
64
|
-
|
|
65
|
-
container.appendChild(this.element)
|
|
66
|
-
}
|
|
69
|
+
element.appendChild(ui.icon)
|
|
67
70
|
}
|
|
71
|
+
|
|
72
|
+
export default build
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const deepClone = obj => {
|
|
2
|
+
if (typeof obj !== 'object' || obj === null) {
|
|
3
|
+
return obj // Return the value if obj is not an object
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
const clone = Array.isArray(obj) ? [] : {}
|
|
7
|
+
|
|
8
|
+
Object.entries(obj).forEach(([key, value]) => {
|
|
9
|
+
clone[key] = deepClone(value)
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
return clone
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default deepClone
|
package/src/module/dot.js
CHANGED
|
@@ -17,16 +17,22 @@
|
|
|
17
17
|
* // flatComplex is now { 'a': [{ b: 1 }, { c: 2 }], 'd': [Date Object] }
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
function dot (obj) {
|
|
21
|
+
const res = {}
|
|
22
|
+
function recurse (obj, current) {
|
|
23
|
+
for (const key in obj) {
|
|
24
|
+
const value = obj[key]
|
|
25
|
+
const newKey = (current ? current + '.' + key : key)
|
|
26
|
+
if (value && typeof value === 'object') {
|
|
27
|
+
recurse(value, newKey)
|
|
28
|
+
} else {
|
|
29
|
+
res[newKey] = value
|
|
30
|
+
}
|
|
27
31
|
}
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
recurse(obj)
|
|
35
|
+
return res
|
|
30
36
|
}
|
|
31
37
|
|
|
32
38
|
export default dot
|