material 0.7.0 → 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.
Files changed (148) hide show
  1. package/README.md +1 -5
  2. package/dist/demo-bundle.js +2281 -2
  3. package/dist/demo-bundle.js.map +7 -1
  4. package/dist/demo.js +13 -13
  5. package/esbuild.js +22 -0
  6. package/esbuild.watch.js +25 -0
  7. package/form.js +27 -0
  8. package/index.js +59 -58
  9. package/list.js +35 -0
  10. package/package.json +8 -17
  11. package/src/appbar.js +7 -204
  12. package/src/badge.js +27 -0
  13. package/src/button.js +127 -177
  14. package/src/calendar.js +53 -55
  15. package/src/card.js +1 -3
  16. package/src/checkbox.js +5 -55
  17. package/src/component.js +0 -2
  18. package/src/container.js +0 -2
  19. package/src/datehour.js +38 -0
  20. package/src/dialog.js +104 -151
  21. package/src/divider.js +1 -3
  22. package/src/drawer.js +1 -19
  23. package/src/element/attribute.js +7 -10
  24. package/src/element/build.js +6 -7
  25. package/src/element/create.js +3 -6
  26. package/src/element/event.js +2 -2
  27. package/src/element/insert.js +6 -17
  28. package/src/element/observer.js +22 -0
  29. package/src/element/offset.js +2 -2
  30. package/src/element/style.js +12 -12
  31. package/src/element.js +2 -2
  32. package/src/field/email.js +9 -44
  33. package/src/field/image.js +17 -51
  34. package/src/{control/file.js → file.js} +15 -45
  35. package/src/form/build.js +7 -7
  36. package/src/form/controller.js +8 -8
  37. package/src/form/create.js +1 -1
  38. package/src/form/data.js +9 -9
  39. package/src/form/delete.js +1 -1
  40. package/src/form/render.js +9 -9
  41. package/src/form/set.js +1 -1
  42. package/src/form/submit.js +6 -6
  43. package/src/form/update.js +3 -3
  44. package/src/form/verify.js +6 -6
  45. package/src/form.js +9 -11
  46. package/src/icon.js +4 -6
  47. package/src/image.js +39 -106
  48. package/src/item.js +1 -3
  49. package/src/layout.js +14 -14
  50. package/src/{control/link.js → link.js} +13 -32
  51. package/src/list/build.js +10 -10
  52. package/src/list/click.js +3 -3
  53. package/src/list/collection.js +1 -1
  54. package/src/list/filter.js +11 -11
  55. package/src/list/image.js +3 -3
  56. package/src/list/render.js +15 -15
  57. package/src/list/request.js +8 -8
  58. package/src/list/search.js +12 -12
  59. package/src/list/select.js +18 -18
  60. package/src/list/status.js +1 -1
  61. package/src/list/update.js +6 -6
  62. package/src/list/virtual.js +20 -20
  63. package/src/list/virtual.new.js +5 -5
  64. package/src/list.js +29 -217
  65. package/src/loading.js +73 -0
  66. package/src/map/build.js +2 -2
  67. package/src/map/countries.js +8 -8
  68. package/src/map/display.js +13 -13
  69. package/src/map/focus.js +7 -7
  70. package/src/map/select.js +2 -2
  71. package/src/map/set.js +3 -3
  72. package/src/map/viewport.js +11 -11
  73. package/src/menu.js +59 -115
  74. package/src/mixin/control.js +3 -3
  75. package/src/mixin/controller.js +5 -5
  76. package/src/mixin/create.js +1 -1
  77. package/src/mixin/display.js +1 -2
  78. package/src/mixin/events.js +4 -16
  79. package/src/mixin/focus.js +1 -1
  80. package/src/mixin/icon.js +2 -2
  81. package/src/mixin/init.js +2 -2
  82. package/src/mixin/insert.js +7 -29
  83. package/src/mixin/label.js +2 -2
  84. package/src/mixin/settings.js +5 -5
  85. package/src/module/attach.js +35 -49
  86. package/src/{control/module → module}/attributes.js +4 -4
  87. package/src/module/build.js +12 -12
  88. package/src/module/classify.js +4 -4
  89. package/src/module/controller.js +5 -32
  90. package/src/module/css.js +12 -84
  91. package/src/module/dataset.js +1 -1
  92. package/src/module/dom.js +8 -3
  93. package/src/module/dot.js +4 -4
  94. package/src/module/emitter.js +1 -1
  95. package/src/module/event.js +2 -2
  96. package/src/module/events.js +29 -35
  97. package/src/module/extract.js +10 -10
  98. package/src/module/last.js +18 -0
  99. package/src/module/mediator.js +1 -13
  100. package/src/module/object.js +4 -4
  101. package/src/module/observer.js +43 -16
  102. package/src/module/remove.js +10 -10
  103. package/src/module/ripple.js +19 -24
  104. package/src/module/scrollbar.js +10 -14
  105. package/src/module/smoothscroll.js +5 -9
  106. package/src/module/utils.js +14 -23
  107. package/src/module/viewport.js +5 -5
  108. package/src/navigation.js +19 -0
  109. package/src/progress.js +1 -11
  110. package/src/search.js +66 -0
  111. package/src/select.js +58 -273
  112. package/src/{control/selecter.js → selecter.js} +42 -42
  113. package/src/selector.js +3 -3
  114. package/src/skin/material/component/navigation.sass +9 -0
  115. package/src/skin/material/control/button.sass +10 -0
  116. package/src/slider.js +1 -3
  117. package/src/snackbar.js +72 -50
  118. package/src/switch.js +111 -103
  119. package/src/{control/switcher.js → switcher.js} +28 -31
  120. package/src/tabs.js +4 -5
  121. package/src/tabview.js +26 -46
  122. package/src/text.js +25 -74
  123. package/src/textfield.js +97 -234
  124. package/src/toolbar.js +12 -12
  125. package/src/tooltip.js +7 -7
  126. package/src/tree.js +10 -66
  127. package/src/view/build.js +2 -2
  128. package/src/view/dataset.js +1 -1
  129. package/src/view.js +9 -74
  130. package/rollup.config.js +0 -34
  131. package/src/banner.js +0 -231
  132. package/src/control/button.js +0 -239
  133. package/src/control/button.new.js +0 -190
  134. package/src/control/datehour.js +0 -65
  135. package/src/control/dialog.js +0 -175
  136. package/src/control/image.js +0 -92
  137. package/src/control/list.js +0 -67
  138. package/src/control/loading.js +0 -128
  139. package/src/control/menu.js +0 -85
  140. package/src/control/module/addclass.js +0 -16
  141. package/src/control/search.js +0 -98
  142. package/src/control/select.js +0 -130
  143. package/src/control/snackbar.js +0 -91
  144. package/src/control/switch.js +0 -272
  145. package/src/control/text.js +0 -70
  146. package/src/control/textfield.js +0 -177
  147. package/src/element/ripple.js +0 -90
  148. package/src/tabs/setup.js +0 -0
@@ -1,33 +1,22 @@
1
- 'use strict'
2
-
3
1
  import dom from '../module/dom'
4
2
 
5
- /**
6
- * insert element into dom
7
- * @param {HTMLElement} element [description]
8
- * @param {HTMLElement} container [description]
9
- * @param {string} context [description]
10
- * @return {?} [description]
11
- */
12
- function insert (element, container, context) {
3
+ const insert = (element, container, context = 'bottom') => {
13
4
  if (!element || !container) return
14
5
 
15
6
  element = element.root || element
16
7
  container = container.root || container
17
8
 
18
- context = context || 'bottom'
19
-
20
- var contexts = ['top', 'bottom', 'after', 'before']
21
- var methods = ['prepend', 'append', 'after', 'before']
9
+ const contexts = ['top', 'bottom', 'after', 'before']
10
+ const methods = ['prepend', 'append', 'after', 'before']
22
11
 
23
- var index = contexts.indexOf(context)
12
+ const index = contexts.indexOf(context)
24
13
  if (index === -1) {
25
14
  return
26
15
  }
27
16
 
28
- var method = methods[index]
17
+ const method = methods[index]
29
18
 
30
- // insert component element to the dom tree using dom
19
+ // Insert component element to the DOM tree using dom
31
20
  dom[method](container, element)
32
21
 
33
22
  return element
@@ -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
@@ -7,9 +7,9 @@
7
7
  import style from './style'
8
8
 
9
9
  function offset (element, prop) {
10
- var rect = element.getBoundingClientRect()
10
+ const rect = element.getBoundingClientRect()
11
11
 
12
- var offset = {
12
+ const offset = {
13
13
  top: Math.round(rect.top),
14
14
  right: Math.round(rect.right),
15
15
  bottom: Math.round(rect.bottom),
@@ -3,10 +3,10 @@
3
3
  * @module component/style
4
4
  */
5
5
  import {
6
- _isIterable,
7
- _isLiteralObject,
8
- _isArray,
9
- _each
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 (_isArray(style)) {
22
- var css = {}
23
- for (var i in list) {
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
- var computedStyle
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 (_isIterable(element) && _isLiteralObject(style)) {
53
- _each(element, function (e) {
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 (_isLiteralObject(style)) {
59
+ if (isLiteralObject(style)) {
60
60
  // console.log('style', element, style);
61
- for (var i in style) {
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
- var element = document.createElement(this.options.tag || 'div')
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 (var property in this.options) {
20
+ for (const property in this.options) {
21
21
  if (this.options.hasOwnProperty(property)) {
22
22
  element.setAttribute(property, this.options[property])
23
23
  }
@@ -1,53 +1,18 @@
1
- 'use strict'
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
- * Constructor
27
- * @param {Object} options - Component options
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
- * Build Method
40
- * @return {Object} This class instance
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) {
@@ -1,71 +1,37 @@
1
- 'use strict'
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
- this.build()
36
-
37
- return this
8
+ static defaults = {
9
+ class: 'image',
10
+ format: 'thumb'
38
11
  }
39
12
 
40
- /**
41
- * Build Method
42
- * @return {Object} This class instance
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
- return this
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
- var url = src.url
28
+ let url = src.url
63
29
 
64
30
  if (src.format) {
65
- var format = this.sanitize(src.format)
31
+ let format = this.sanitize(src.format)
66
32
 
67
33
  if (format.length > 0) {
68
- var index = format.indexOf(this.options.format)
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
- var a = []
84
- for (var i = 0; i < formats.length; i++) {
85
- var format = formats[i].replace(/\/$/, '')
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
 
@@ -1,56 +1,26 @@
1
- import emitter from '../module/emitter'
2
- import dataset from '../view/dataset'
3
- import attributes from './module/attributes'
1
+ import EventEmitter from './mixin/emitter'
4
2
 
5
- const defaults = {
6
- class: 'file',
7
- attributes: ['name', 'accept', 'required', 'disabled', 'multiple']
8
- }
3
+ import build from './module/build'
4
+ import dataset from './module/dataset'
5
+ import attributes from './module/attributes'
9
6
 
10
7
  class File {
11
- /**
12
- * Constructor
13
- * @param {Object} options - Component options
14
- * @return {Object} Class instance
15
- */
16
- constructor (options) {
17
- this.options = Object.assign({}, defaults, options || {})
18
- Object.assign(this, emitter)
19
-
20
- this.build()
21
- this.attach()
22
-
23
- return this
8
+ static defaults = {
9
+ class: 'file',
10
+ attributes: ['name', 'accept', 'required', 'disabled', 'multiple']
24
11
  }
25
12
 
26
- /**
27
- * Build Method
28
- * @return {Object} This class instance
29
- */
30
- build () {
31
- this.element = document.createElement('div')
32
- this.element.classList.add('file')
33
-
34
- if (this.options.class !== 'file') {
35
- this.element.classList.add(this.options.class)
36
- }
37
-
13
+ constructor (options) {
14
+ this.init(options)
15
+ this.build()
38
16
  this.buildLabel()
39
17
  this.buildInput()
18
+ this.attach()
19
+ }
40
20
 
41
- if (this.options.data) {
42
- dataset(this.element, this.options.data)
43
- }
44
-
45
- if (this.options.focus) {
46
- this.input.focus()
47
- }
48
-
49
- if (this.options.container) {
50
- this.options.container.appendChild(this.element)
51
- }
52
-
53
- return this
21
+ init (options) {
22
+ this.options = Object.assign({}, File.defaults, options || {})
23
+ Object.assign(this, build)
54
24
  }
55
25
 
56
26
  buildLabel () {
package/src/form/build.js CHANGED
@@ -71,11 +71,11 @@ export default {
71
71
  extractFile (object) {
72
72
  this.file = {}
73
73
 
74
- for (var property in object) {
74
+ for (const property in object) {
75
75
  if (object.hasOwnProperty(property)) {
76
- var files = property.split(/\./)
76
+ const files = property.split(/\./)
77
77
  if (files[0] === 'file' && files[1] !== undefined) {
78
- var name = property.substr(5, property.length)
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 (var property in object) {
92
+ for (const property in object) {
93
93
  if (object.hasOwnProperty(property)) {
94
- var infos = property.split(/\./)
94
+ const infos = property.split(/\./)
95
95
 
96
96
  if (infos[0] === 'info' && infos[1] !== undefined) {
97
- var name = property.substr(5, property.length)
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 (var member in this.info) {
108
+ for (const member in this.info) {
109
109
  delete this.info[member]
110
110
  }
111
111
 
@@ -6,13 +6,13 @@ export default {
6
6
 
7
7
  this.disableControls()
8
8
 
9
- for (var field in this.field) {
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 (var file in this.file) {
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
- var modes = ['read', 'create', 'update']
32
+ const modes = ['read', 'create', 'update']
33
33
 
34
- for (var i = 0; i < modes.length; i++) {
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
- var controls = this.options.controls || ['submit', 'cancel']
67
+ const controls = this.options.controls || ['submit', 'cancel']
68
68
 
69
69
  if (controls === null) return
70
70
 
71
- for (var i = 0; i < controls.length; i++) {
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
- var controls = this.options.controls || ['submit', 'cancel']
80
+ const controls = this.options.controls || ['submit', 'cancel']
81
81
 
82
82
  if (controls === null) return
83
83
 
84
- for (var i = 0; i < controls.length; i++) {
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
  }
@@ -6,7 +6,7 @@ export default {
6
6
 
7
7
  this.clean()
8
8
 
9
- var info = this.options.create.info || { name: 'New Item' }
9
+ const info = this.options.create.info || { name: 'New Item' }
10
10
 
11
11
  console.log('info', info)
12
12
 
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
- var data = new FormData()
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
- var sys = this.options.sysinfo
22
- for (var i = 0; i < sys.length; i++) {
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
- var name = sys[i]
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 (var field in this.field) {
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
- var value = this.field[field].get()
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
- var modified = this.isModified(field, value)
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 (var file in this.file) {
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
- var initial = byString(this.info, field)
69
+ const initial = byString(this.info, field)
70
70
 
71
71
  if (typeof initial === 'number') {
72
72
  value = Number(value)
@@ -20,7 +20,7 @@ export default {
20
20
  this.setMode('delete')
21
21
  fetch(this.options.action, {
22
22
  headers: {
23
- 'Accept': 'application/json',
23
+ Accept: 'application/json',
24
24
  'Content-Type': 'application/json'
25
25
  },
26
26
  body: JSON.stringify({
@@ -4,9 +4,9 @@ export default {
4
4
  render (object, option) {
5
5
  // console.log('render', object)
6
6
 
7
- var info = dot(object)
7
+ const info = dot(object)
8
8
 
9
- for (var file in this.file) {
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 (var field in this.field) {
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
- var value = this.objectValueByDotKey(object, field)
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['name']) {
35
- this.focusNameOnRender(this.field['name'])
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
- var keys = dotkey.split(/\./)
41
+ const keys = dotkey.split(/\./)
42
42
 
43
- var value = Object.assign({}, object)
43
+ let value = Object.assign({}, object)
44
44
 
45
- for (var i = 0; i < keys.length; i++) {
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
@@ -13,7 +13,7 @@ export default {
13
13
  // this.render(info)
14
14
  fetch(this.options.action + id, {
15
15
  headers: {
16
- 'Accept': 'application/json'
16
+ Accept: 'application/json'
17
17
  },
18
18
  method: 'GET'
19
19
  }).then((resp) => {
@@ -4,7 +4,7 @@ export default {
4
4
  ev.preventDefault()
5
5
  // console.log('submit', this.mode)
6
6
 
7
- var data = this.initData()
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
- var method = 'PUT'
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: method,
30
- formData: formData
29
+ method,
30
+ formData
31
31
  })
32
32
  }
33
33
 
34
34
  if (this.action) {
35
35
  this.action({
36
- method: method,
37
- formData: formData
36
+ method,
37
+ formData
38
38
  })
39
39
  }
40
40
  }
@@ -5,11 +5,11 @@ export default {
5
5
  options = options || {}
6
6
 
7
7
  // console.log('mode', this.mode)
8
- var method = options.method ||
8
+ const method = options.method ||
9
9
  this.options[this.mode].method ||
10
10
  'put'
11
11
 
12
- var action = options.action ||
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: method,
21
+ method,
22
22
  body: data
23
23
  }).then((resp) => {
24
24
  // console.log('resp', resp)