material 0.7.1 → 0.7.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/README.md +1 -5
- package/dist/demo-bundle.js +2281 -2
- package/dist/demo-bundle.js.map +7 -1
- package/dist/demo.js +13 -13
- package/esbuild.js +22 -0
- package/esbuild.watch.js +25 -0
- package/package.json +7 -20
- package/src/badge.js +1 -1
- package/src/button.js +50 -100
- package/src/calendar.js +53 -53
- package/src/card.js +1 -1
- package/src/checkbox.js +5 -53
- package/src/datehour.js +7 -7
- package/src/dialog.js +5 -5
- package/src/divider.js +1 -1
- package/src/drawer.js +1 -17
- package/src/element/attribute.js +7 -10
- package/src/element/build.js +6 -7
- package/src/element/create.js +3 -6
- package/src/element/event.js +2 -2
- package/src/element/insert.js +6 -17
- package/src/element/observer.js +22 -0
- package/src/element/offset.js +2 -2
- package/src/element/style.js +12 -12
- package/src/element.js +2 -2
- package/src/field/email.js +9 -44
- package/src/field/image.js +17 -51
- package/src/file.js +1 -1
- package/src/form/build.js +7 -7
- package/src/form/controller.js +8 -8
- package/src/form/create.js +1 -1
- package/src/form/data.js +9 -9
- package/src/form/delete.js +1 -1
- package/src/form/render.js +9 -9
- package/src/form/set.js +1 -1
- package/src/form/submit.js +6 -6
- package/src/form/update.js +3 -3
- package/src/form/verify.js +4 -4
- package/src/form.js +9 -9
- package/src/icon.js +4 -4
- package/src/image.js +7 -7
- package/src/item.js +1 -1
- package/src/layout.js +14 -14
- package/src/link.js +1 -1
- package/src/list/build.js +8 -8
- package/src/list/click.js +3 -3
- package/src/list/filter.js +11 -11
- package/src/list/image.js +3 -3
- package/src/list/render.js +15 -15
- package/src/list/request.js +7 -7
- package/src/list/search.js +9 -9
- package/src/list/select.js +18 -18
- package/src/list/status.js +1 -1
- package/src/list/update.js +6 -6
- package/src/list/virtual.js +20 -20
- package/src/list/virtual.new.js +5 -5
- package/src/list.js +8 -8
- package/src/map/build.js +2 -2
- package/src/map/countries.js +8 -8
- package/src/map/display.js +13 -13
- package/src/map/focus.js +7 -7
- package/src/map/select.js +2 -2
- package/src/map/set.js +3 -3
- package/src/map/viewport.js +11 -11
- package/src/menu.js +12 -12
- package/src/mixin/control.js +3 -3
- package/src/mixin/controller.js +5 -5
- package/src/mixin/create.js +1 -1
- package/src/mixin/display.js +1 -1
- package/src/mixin/events.js +4 -16
- package/src/mixin/focus.js +1 -1
- package/src/mixin/icon.js +2 -2
- package/src/mixin/init.js +2 -2
- package/src/mixin/insert.js +5 -5
- package/src/mixin/label.js +2 -2
- package/src/mixin/settings.js +5 -5
- package/src/module/attach.js +35 -49
- package/src/module/attributes.js +2 -2
- package/src/module/build.js +7 -10
- package/src/module/classify.js +4 -4
- package/src/module/controller.js +5 -32
- package/src/module/css.js +12 -84
- package/src/module/dataset.js +1 -1
- package/src/module/dom.js +8 -3
- package/src/module/dot.js +4 -4
- package/src/module/emitter.js +1 -1
- package/src/module/event.js +2 -2
- package/src/module/events.js +29 -35
- package/src/module/extract.js +10 -10
- package/src/module/last.js +18 -0
- package/src/module/mediator.js +1 -13
- package/src/module/object.js +4 -4
- package/src/module/observer.js +43 -16
- package/src/module/remove.js +10 -10
- package/src/module/ripple.js +19 -24
- package/src/module/scrollbar.js +10 -14
- package/src/module/smoothscroll.js +5 -9
- package/src/module/utils.js +14 -23
- package/src/module/viewport.js +5 -5
- package/src/progress.js +1 -9
- package/src/search.js +24 -29
- package/src/select.js +6 -6
- package/src/selecter.js +39 -39
- package/src/selector.js +3 -3
- package/src/skin/material/component/navigation.sass +9 -1
- package/src/slider.js +1 -1
- package/src/snackbar.js +8 -7
- package/src/switch.js +1 -1
- package/src/switcher.js +15 -15
- package/src/tabs.js +4 -5
- package/src/tabview.js +26 -46
- package/src/text.js +1 -1
- package/src/textfield.js +1 -1
- package/src/toolbar.js +12 -12
- package/src/tooltip.js +7 -7
- package/src/tree.js +10 -66
- package/src/view/build.js +2 -2
- package/src/view/dataset.js +1 -1
- package/src/view.js +9 -74
- package/rollup.config.js +0 -34
- package/src/element/ripple.js +0 -90
- package/src/module/addclass.js +0 -16
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const observer = {
|
|
2
|
+
insert: (element, cb) => {
|
|
3
|
+
var observer = new MutationObserver((mutations) => {
|
|
4
|
+
if (document.contains(element)) {
|
|
5
|
+
if (typeof cb === 'function' && !element.classList.contains('inserted')) {
|
|
6
|
+
cb()
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
observer.disconnect()
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
observer.observe(document, {
|
|
14
|
+
attributes: false,
|
|
15
|
+
childList: true,
|
|
16
|
+
characterData: false,
|
|
17
|
+
subtree: true
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default observer
|
package/src/element/offset.js
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
import style from './style'
|
|
8
8
|
|
|
9
9
|
function offset (element, prop) {
|
|
10
|
-
|
|
10
|
+
const rect = element.getBoundingClientRect()
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
const offset = {
|
|
13
13
|
top: Math.round(rect.top),
|
|
14
14
|
right: Math.round(rect.right),
|
|
15
15
|
bottom: Math.round(rect.bottom),
|
package/src/element/style.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* @module component/style
|
|
4
4
|
*/
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
isIterable,
|
|
7
|
+
isLiteralObject,
|
|
8
|
+
isArray,
|
|
9
|
+
each
|
|
10
10
|
} from '../module/utils'
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -18,14 +18,14 @@ import {
|
|
|
18
18
|
function get (element, style) {
|
|
19
19
|
// console.log('get', element, style);
|
|
20
20
|
// get array of elements
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
for (
|
|
21
|
+
if (isArray(style)) {
|
|
22
|
+
const css = {}
|
|
23
|
+
for (const i in list) {
|
|
24
24
|
css[list[i]] = this.get(element, list[i])
|
|
25
25
|
}
|
|
26
26
|
return css
|
|
27
27
|
} else {
|
|
28
|
-
|
|
28
|
+
let computedStyle
|
|
29
29
|
|
|
30
30
|
if (typeof window.getComputedStyle === 'function') { // normal browsers
|
|
31
31
|
computedStyle = window.getComputedStyle(element)
|
|
@@ -49,16 +49,16 @@ function get (element, style) {
|
|
|
49
49
|
* @param {?} style [description]
|
|
50
50
|
*/
|
|
51
51
|
function set (element, style) {
|
|
52
|
-
if (
|
|
53
|
-
|
|
52
|
+
if (isIterable(element) && _isLiteralObject(style)) {
|
|
53
|
+
each(element, function (e) {
|
|
54
54
|
set(e, style)
|
|
55
55
|
})
|
|
56
56
|
return element
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
if (
|
|
59
|
+
if (isLiteralObject(style)) {
|
|
60
60
|
// console.log('style', element, style);
|
|
61
|
-
for (
|
|
61
|
+
for (const i in style) {
|
|
62
62
|
element.style[i] = style[i]
|
|
63
63
|
}
|
|
64
64
|
return style
|
package/src/element.js
CHANGED
|
@@ -6,7 +6,7 @@ class Element {
|
|
|
6
6
|
constructor (options) {
|
|
7
7
|
this.options = Object.assign({}, options || {})
|
|
8
8
|
// console.log('element options', options)
|
|
9
|
-
|
|
9
|
+
const element = document.createElement(this.options.tag || 'div')
|
|
10
10
|
delete this.options.tag
|
|
11
11
|
|
|
12
12
|
if (options.html) element.innerHTML = this.options.html
|
|
@@ -17,7 +17,7 @@ class Element {
|
|
|
17
17
|
|
|
18
18
|
if (options.id) element.setAttribute('id', options.id)
|
|
19
19
|
|
|
20
|
-
for (
|
|
20
|
+
for (const property in this.options) {
|
|
21
21
|
if (this.options.hasOwnProperty(property)) {
|
|
22
22
|
element.setAttribute(property, this.options[property])
|
|
23
23
|
}
|
package/src/field/email.js
CHANGED
|
@@ -1,53 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import build from '../module/build'
|
|
2
2
|
|
|
3
|
-
const defaults = {
|
|
4
|
-
prefix: 'material',
|
|
5
|
-
class: 'email'
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Base class for all ui components
|
|
10
|
-
* @class
|
|
11
|
-
* @param {Object} options - The component options
|
|
12
|
-
* @return {Object} The class Instance
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Class representing a UI Container. Can add components.
|
|
17
|
-
*
|
|
18
|
-
* @extends Component
|
|
19
|
-
* @return {parent} The class instance
|
|
20
|
-
* @example new Container({
|
|
21
|
-
* container: document.body
|
|
22
|
-
* });
|
|
23
|
-
*/
|
|
24
3
|
class EmailLink {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
* @return {Object} Class instance
|
|
29
|
-
*/
|
|
30
|
-
constructor (options) {
|
|
31
|
-
this.options = Object.assign({}, defaults, options || {})
|
|
4
|
+
static defaults = {
|
|
5
|
+
class: 'email'
|
|
6
|
+
}
|
|
32
7
|
|
|
8
|
+
constructor (options) {
|
|
9
|
+
this.init(options)
|
|
33
10
|
this.build()
|
|
34
|
-
|
|
35
|
-
return this
|
|
36
11
|
}
|
|
37
12
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
*/
|
|
42
|
-
build () {
|
|
43
|
-
this.element = document.createElement('a')
|
|
44
|
-
this.element.classList.add('email')
|
|
45
|
-
|
|
46
|
-
if (this.options.container) {
|
|
47
|
-
this.options.container.appendChild(this.element)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return this
|
|
13
|
+
init (options) {
|
|
14
|
+
this.options = { ...Button.defaults, ...options }
|
|
15
|
+
Object.assign(this, build)
|
|
51
16
|
}
|
|
52
17
|
|
|
53
18
|
set (email) {
|
package/src/field/image.js
CHANGED
|
@@ -1,71 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
import build from '../module/build'
|
|
2
2
|
|
|
3
|
-
const defaults = {
|
|
4
|
-
class: 'image',
|
|
5
|
-
format: 'thumb'
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Class representing an image.
|
|
10
|
-
*
|
|
11
|
-
* @extends Image
|
|
12
|
-
* @return {parent} The class instance
|
|
13
|
-
* @example new Image({
|
|
14
|
-
* src: {
|
|
15
|
-
* filename: 'image.png',
|
|
16
|
-
* url: 'exmaple.com/image/'
|
|
17
|
-
* format: ['thumbs/', 'medium/', 'large/'],
|
|
18
|
-
* },
|
|
19
|
-
* container: document.body
|
|
20
|
-
* });
|
|
21
|
-
*/
|
|
22
3
|
class Image {
|
|
23
4
|
static isImage () {
|
|
24
5
|
return true
|
|
25
6
|
}
|
|
26
|
-
/**
|
|
27
|
-
* Constructor
|
|
28
|
-
* @param {Object} options - Component options
|
|
29
|
-
* @return {Object} Class instance
|
|
30
|
-
*/
|
|
31
|
-
constructor (options) {
|
|
32
|
-
// console.log('options', options)
|
|
33
|
-
this.options = Object.assign({}, defaults, options || {})
|
|
34
7
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
8
|
+
static defaults = {
|
|
9
|
+
class: 'image',
|
|
10
|
+
format: 'thumb'
|
|
38
11
|
}
|
|
39
12
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
build () {
|
|
45
|
-
this.element = document.createElement('div')
|
|
46
|
-
this.element.classList.add(this.options.class)
|
|
47
|
-
|
|
48
|
-
if (this.options.container) {
|
|
49
|
-
this.options.container.appendChild(this.element)
|
|
50
|
-
}
|
|
13
|
+
constructor (options) {
|
|
14
|
+
this.init(options)
|
|
15
|
+
this.build()
|
|
16
|
+
}
|
|
51
17
|
|
|
52
|
-
|
|
18
|
+
init (options) {
|
|
19
|
+
this.options = { ...Image.defaults, ...options }
|
|
20
|
+
Object.assign(this, build)
|
|
53
21
|
}
|
|
54
22
|
|
|
55
23
|
set (src, asset) {
|
|
56
|
-
console.log('set', src, asset)
|
|
57
|
-
|
|
58
24
|
asset = asset || {}
|
|
59
25
|
|
|
60
26
|
if (!src) return
|
|
61
27
|
|
|
62
|
-
|
|
28
|
+
let url = src.url
|
|
63
29
|
|
|
64
30
|
if (src.format) {
|
|
65
|
-
|
|
31
|
+
let format = this.sanitize(src.format)
|
|
66
32
|
|
|
67
33
|
if (format.length > 0) {
|
|
68
|
-
|
|
34
|
+
const index = format.indexOf(this.options.format)
|
|
69
35
|
if (index === -1) {
|
|
70
36
|
format = src.format[0] + '/'
|
|
71
37
|
} else {
|
|
@@ -80,9 +46,9 @@ class Image {
|
|
|
80
46
|
}
|
|
81
47
|
|
|
82
48
|
sanitize (formats) {
|
|
83
|
-
|
|
84
|
-
for (
|
|
85
|
-
|
|
49
|
+
const a = []
|
|
50
|
+
for (let i = 0; i < formats.length; i++) {
|
|
51
|
+
const format = formats[i].replace(/\/$/, '')
|
|
86
52
|
a.push(format)
|
|
87
53
|
}
|
|
88
54
|
|
package/src/file.js
CHANGED
package/src/form/build.js
CHANGED
|
@@ -71,11 +71,11 @@ export default {
|
|
|
71
71
|
extractFile (object) {
|
|
72
72
|
this.file = {}
|
|
73
73
|
|
|
74
|
-
for (
|
|
74
|
+
for (const property in object) {
|
|
75
75
|
if (object.hasOwnProperty(property)) {
|
|
76
|
-
|
|
76
|
+
const files = property.split(/\./)
|
|
77
77
|
if (files[0] === 'file' && files[1] !== undefined) {
|
|
78
|
-
|
|
78
|
+
const name = property.substr(5, property.length)
|
|
79
79
|
|
|
80
80
|
this.file[name] = object[property]
|
|
81
81
|
}
|
|
@@ -89,12 +89,12 @@ export default {
|
|
|
89
89
|
this.field = {}
|
|
90
90
|
this.fields = []
|
|
91
91
|
|
|
92
|
-
for (
|
|
92
|
+
for (const property in object) {
|
|
93
93
|
if (object.hasOwnProperty(property)) {
|
|
94
|
-
|
|
94
|
+
const infos = property.split(/\./)
|
|
95
95
|
|
|
96
96
|
if (infos[0] === 'info' && infos[1] !== undefined) {
|
|
97
|
-
|
|
97
|
+
const name = property.substr(5, property.length)
|
|
98
98
|
// console.log('field', name, property)
|
|
99
99
|
this.fields.push(name)
|
|
100
100
|
this.field[name] = object[property]
|
|
@@ -105,7 +105,7 @@ export default {
|
|
|
105
105
|
|
|
106
106
|
clean () {
|
|
107
107
|
// console.log('clean', this.info)
|
|
108
|
-
for (
|
|
108
|
+
for (const member in this.info) {
|
|
109
109
|
delete this.info[member]
|
|
110
110
|
}
|
|
111
111
|
|
package/src/form/controller.js
CHANGED
|
@@ -6,13 +6,13 @@ export default {
|
|
|
6
6
|
|
|
7
7
|
this.disableControls()
|
|
8
8
|
|
|
9
|
-
for (
|
|
9
|
+
for (const field in this.field) {
|
|
10
10
|
if (this.field.hasOwnProperty(field)) {
|
|
11
11
|
this.bindControl(this.field[field])
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
for (
|
|
15
|
+
for (const file in this.file) {
|
|
16
16
|
if (this.file.hasOwnProperty(file)) {
|
|
17
17
|
this.bindControl(this.file[file])
|
|
18
18
|
}
|
|
@@ -29,9 +29,9 @@ export default {
|
|
|
29
29
|
},
|
|
30
30
|
|
|
31
31
|
updateClassMode (mode) {
|
|
32
|
-
|
|
32
|
+
const modes = ['read', 'create', 'update']
|
|
33
33
|
|
|
34
|
-
for (
|
|
34
|
+
for (let i = 0; i < modes.length; i++) {
|
|
35
35
|
this.form.classList.remove(modes[i] + '-mode')
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -64,11 +64,11 @@ export default {
|
|
|
64
64
|
|
|
65
65
|
enableControls () {
|
|
66
66
|
// console.log('enableControls')
|
|
67
|
-
|
|
67
|
+
const controls = this.options.controls || ['submit', 'cancel']
|
|
68
68
|
|
|
69
69
|
if (controls === null) return
|
|
70
70
|
|
|
71
|
-
for (
|
|
71
|
+
for (let i = 0; i < controls.length; i++) {
|
|
72
72
|
if (this.ui[controls[i]] && this.ui[controls[i]].enable) {
|
|
73
73
|
this.ui[controls[i]].enable()
|
|
74
74
|
}
|
|
@@ -77,11 +77,11 @@ export default {
|
|
|
77
77
|
|
|
78
78
|
disableControls () {
|
|
79
79
|
// console.log('disableControls')
|
|
80
|
-
|
|
80
|
+
const controls = this.options.controls || ['submit', 'cancel']
|
|
81
81
|
|
|
82
82
|
if (controls === null) return
|
|
83
83
|
|
|
84
|
-
for (
|
|
84
|
+
for (let i = 0; i < controls.length; i++) {
|
|
85
85
|
if (this.ui[controls[i]] && this.ui[controls[i]].disable) {
|
|
86
86
|
this.ui[controls[i]].disable()
|
|
87
87
|
}
|
package/src/form/create.js
CHANGED
package/src/form/data.js
CHANGED
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
initData () {
|
|
6
6
|
// console.log('submit', this.mode)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
const data = new FormData()
|
|
9
9
|
|
|
10
10
|
if (this.mode !== 'create') {
|
|
11
11
|
this.appendSysinfo(data)
|
|
@@ -18,10 +18,10 @@ export default {
|
|
|
18
18
|
},
|
|
19
19
|
|
|
20
20
|
appendSysinfo (data) {
|
|
21
|
-
|
|
22
|
-
for (
|
|
21
|
+
const sys = this.options.sysinfo
|
|
22
|
+
for (let i = 0; i < sys.length; i++) {
|
|
23
23
|
// console.log('sys', sys[i], this.info[sys[i]])
|
|
24
|
-
|
|
24
|
+
let name = sys[i]
|
|
25
25
|
if (sys[i] === '_id') name = 'id'
|
|
26
26
|
|
|
27
27
|
data.append(name, this.info[sys[i]])
|
|
@@ -31,14 +31,14 @@ export default {
|
|
|
31
31
|
},
|
|
32
32
|
|
|
33
33
|
appendFields (data) {
|
|
34
|
-
for (
|
|
34
|
+
for (const field in this.field) {
|
|
35
35
|
// console.log('field', field)
|
|
36
36
|
if (this.field.hasOwnProperty(field)) {
|
|
37
37
|
// console.log('check field', field)
|
|
38
|
-
|
|
38
|
+
const value = this.field[field].get()
|
|
39
39
|
if (value !== null) {
|
|
40
40
|
if (this.mode === 'update' && this.options.update && this.options.update.modifiedOnly) {
|
|
41
|
-
|
|
41
|
+
const modified = this.isModified(field, value)
|
|
42
42
|
if (modified) {
|
|
43
43
|
data.append(field, value)
|
|
44
44
|
}
|
|
@@ -54,7 +54,7 @@ export default {
|
|
|
54
54
|
|
|
55
55
|
appendFiles (data) {
|
|
56
56
|
// console.log('appendFiles', this.file)
|
|
57
|
-
for (
|
|
57
|
+
for (const file in this.file) {
|
|
58
58
|
// console.log('this file', this.file, this.file[file].input)
|
|
59
59
|
// console.log('file', file, this.file[file])
|
|
60
60
|
if (this.file.hasOwnProperty(file) && this.file[file].input && this.file[file].input.value) {
|
|
@@ -66,7 +66,7 @@ export default {
|
|
|
66
66
|
},
|
|
67
67
|
|
|
68
68
|
isModified (field, value) {
|
|
69
|
-
|
|
69
|
+
const initial = byString(this.info, field)
|
|
70
70
|
|
|
71
71
|
if (typeof initial === 'number') {
|
|
72
72
|
value = Number(value)
|
package/src/form/delete.js
CHANGED
package/src/form/render.js
CHANGED
|
@@ -4,9 +4,9 @@ export default {
|
|
|
4
4
|
render (object, option) {
|
|
5
5
|
// console.log('render', object)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const info = dot(object)
|
|
8
8
|
|
|
9
|
-
for (
|
|
9
|
+
for (const file in this.file) {
|
|
10
10
|
if (this.file.hasOwnProperty(file)) {
|
|
11
11
|
this.file[file].reset()
|
|
12
12
|
}
|
|
@@ -16,12 +16,12 @@ export default {
|
|
|
16
16
|
|
|
17
17
|
if (!info) return
|
|
18
18
|
|
|
19
|
-
for (
|
|
19
|
+
for (const field in this.field) {
|
|
20
20
|
if (this.field.hasOwnProperty(field)) {
|
|
21
21
|
// console.log('field type', field, this.field[field])
|
|
22
22
|
if (this.field[field] &&
|
|
23
23
|
this.field[field].set) {
|
|
24
|
-
|
|
24
|
+
const value = this.objectValueByDotKey(object, field)
|
|
25
25
|
// console.log('value', value)
|
|
26
26
|
this.field[field].set(value, true)
|
|
27
27
|
}
|
|
@@ -31,18 +31,18 @@ export default {
|
|
|
31
31
|
this.emit('rendered')
|
|
32
32
|
|
|
33
33
|
// won't stay here
|
|
34
|
-
if (option === 'create' && this.field
|
|
35
|
-
this.focusNameOnRender(this.field
|
|
34
|
+
if (option === 'create' && this.field.name) {
|
|
35
|
+
this.focusNameOnRender(this.field.name)
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
|
|
39
39
|
objectValueByDotKey (object, dotkey) {
|
|
40
40
|
// console.log('objectValueByDotKey', object, dotkey)
|
|
41
|
-
|
|
41
|
+
const keys = dotkey.split(/\./)
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
let value = Object.assign({}, object)
|
|
44
44
|
|
|
45
|
-
for (
|
|
45
|
+
for (let i = 0; i < keys.length; i++) {
|
|
46
46
|
if (value !== undefined) {
|
|
47
47
|
value = value[keys[i]]
|
|
48
48
|
}
|
package/src/form/set.js
CHANGED
package/src/form/submit.js
CHANGED
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
ev.preventDefault()
|
|
5
5
|
// console.log('submit', this.mode)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const data = this.initData()
|
|
8
8
|
|
|
9
9
|
// console.log('data', data)
|
|
10
10
|
|
|
@@ -18,7 +18,7 @@ export default {
|
|
|
18
18
|
},
|
|
19
19
|
|
|
20
20
|
setMethod (formData) {
|
|
21
|
-
|
|
21
|
+
let method = 'PUT'
|
|
22
22
|
if (this.mode === 'create') {
|
|
23
23
|
method = 'POST'
|
|
24
24
|
}
|
|
@@ -26,15 +26,15 @@ export default {
|
|
|
26
26
|
if (this.fetch) {
|
|
27
27
|
// console.log('formData', formData.keys())
|
|
28
28
|
this.fetch({
|
|
29
|
-
method
|
|
30
|
-
formData
|
|
29
|
+
method,
|
|
30
|
+
formData
|
|
31
31
|
})
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
if (this.action) {
|
|
35
35
|
this.action({
|
|
36
|
-
method
|
|
37
|
-
formData
|
|
36
|
+
method,
|
|
37
|
+
formData
|
|
38
38
|
})
|
|
39
39
|
}
|
|
40
40
|
}
|
package/src/form/update.js
CHANGED
|
@@ -5,11 +5,11 @@ export default {
|
|
|
5
5
|
options = options || {}
|
|
6
6
|
|
|
7
7
|
// console.log('mode', this.mode)
|
|
8
|
-
|
|
8
|
+
const method = options.method ||
|
|
9
9
|
this.options[this.mode].method ||
|
|
10
10
|
'put'
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
const action = options.action ||
|
|
13
13
|
this.options[this.mode].action ||
|
|
14
14
|
this.options.action
|
|
15
15
|
|
|
@@ -18,7 +18,7 @@ export default {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
fetch(action, {
|
|
21
|
-
method
|
|
21
|
+
method,
|
|
22
22
|
body: data
|
|
23
23
|
}).then((resp) => {
|
|
24
24
|
// console.log('resp', resp)
|
package/src/form/verify.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
verify () {
|
|
3
|
-
|
|
3
|
+
const list = this.options.require
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
let ok = true
|
|
6
6
|
|
|
7
|
-
for (
|
|
8
|
-
|
|
7
|
+
for (let i = 0; i < list.length; i++) {
|
|
8
|
+
const field = this.ui['info.' + list[i]]
|
|
9
9
|
|
|
10
10
|
if (!this.layout.get(list[i]).get()) {
|
|
11
11
|
field.element.classList.add('textfield-error')
|
package/src/form.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import insert from './element/insert'
|
|
2
|
-
import css from './module/css'
|
|
2
|
+
import * as css from './module/css'
|
|
3
3
|
import emitter from './module/emitter'
|
|
4
4
|
import attach from './module/attach'
|
|
5
5
|
import controller from './mixin/controller'
|
|
@@ -68,7 +68,7 @@ class Form {
|
|
|
68
68
|
* @return {Object} This class instance
|
|
69
69
|
*/
|
|
70
70
|
build () {
|
|
71
|
-
|
|
71
|
+
const tag = this.options.tag || 'div'
|
|
72
72
|
|
|
73
73
|
this.element = document.createElement(tag)
|
|
74
74
|
css.add(this.element, this.options.prefix + '-' + this.options.class)
|
|
@@ -99,8 +99,8 @@ class Form {
|
|
|
99
99
|
|
|
100
100
|
this.key = this.key || {}
|
|
101
101
|
|
|
102
|
-
for (
|
|
103
|
-
|
|
102
|
+
for (let i = 0; i < controls.length; i++) {
|
|
103
|
+
const control = controls[i]
|
|
104
104
|
// control.setAttribute('data-key', control.name);
|
|
105
105
|
|
|
106
106
|
this.key[control.name] = control
|
|
@@ -126,9 +126,9 @@ class Form {
|
|
|
126
126
|
* @return {?} [description]
|
|
127
127
|
*/
|
|
128
128
|
initControl (key, section) {
|
|
129
|
-
|
|
129
|
+
const name = key.name || 'undefined'
|
|
130
130
|
|
|
131
|
-
|
|
131
|
+
const control = this.render(key)
|
|
132
132
|
|
|
133
133
|
if (control) {
|
|
134
134
|
this.key[name] = control
|
|
@@ -179,15 +179,15 @@ class Form {
|
|
|
179
179
|
*/
|
|
180
180
|
parseInfo (obj, name, i) {
|
|
181
181
|
// console.log('parseInfo', obj, name, 'level ' + i);
|
|
182
|
-
|
|
182
|
+
let level = i || 0
|
|
183
183
|
level = level + 1
|
|
184
|
-
|
|
184
|
+
let key
|
|
185
185
|
|
|
186
186
|
if (obj instanceof Object) {
|
|
187
187
|
for (key in obj) {
|
|
188
188
|
if (obj.hasOwnProperty(key)) {
|
|
189
189
|
// recursive call to scan property
|
|
190
|
-
|
|
190
|
+
let n = null
|
|
191
191
|
if (name) {
|
|
192
192
|
n = name + '.' + key
|
|
193
193
|
} else {
|
package/src/icon.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import insert from './mixin/insert'
|
|
2
|
-
import css from './module/css'
|
|
2
|
+
import * as css from './module/css'
|
|
3
3
|
|
|
4
4
|
var defaults = {
|
|
5
5
|
prefix: 'material',
|
|
@@ -54,10 +54,10 @@ class Icon {
|
|
|
54
54
|
this.element = this.element || {}
|
|
55
55
|
|
|
56
56
|
this.element = document.createElement(tag)
|
|
57
|
-
|
|
57
|
+
{ add }.add(this.element, this.options.prefix + '-' + this.options.class)
|
|
58
58
|
|
|
59
|
-
if (options.
|
|
60
|
-
//
|
|
59
|
+
if (options.{ add }) { { add }.add(this.element, options.{ add }) }
|
|
60
|
+
// { add }.add(this.element, this.options.class + '-adjust');
|
|
61
61
|
|
|
62
62
|
if (this.options.container) {
|
|
63
63
|
this.insert(this.options.container)
|