material 0.9.14 → 0.9.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "material",
3
- "version": "0.9.14",
3
+ "version": "0.9.15",
4
4
  "description": "A lightweight implementation of Material Design Components for the web - ES6",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1,4 +1,5 @@
1
1
  import build from '../module/build'
2
+ import dom from '../module/dom'
2
3
 
3
4
  class Component {
4
5
  static base = 'component'
@@ -14,6 +15,25 @@ class Component {
14
15
 
15
16
  build(this)
16
17
  }
18
+
19
+ destroy () {
20
+ console.log('dest5roy')
21
+ if (this.options.transition && this.element) {
22
+ this.element.classList.remove('show')
23
+
24
+ if (this.underlay) {
25
+ this.underlay.classList.remove('show')
26
+ }
27
+
28
+ setTimeout(() => {
29
+ dom.destroy(this.element)
30
+ if (this.underlay) dom.destroy(this.underlay)
31
+ }, this.options.transition)
32
+ } else {
33
+ dom.destroy(this.element)
34
+ if (this.underlay) dom.destroy(this.underlay)
35
+ }
36
+ }
17
37
  }
18
38
 
19
39
  export default Component
@@ -25,6 +25,15 @@ class Control extends Component {
25
25
 
26
26
  return this
27
27
  }
28
+
29
+ destroy () {
30
+ // if (this.options.events) {
31
+ // events.detach(this.options.events, this)
32
+ // }
33
+
34
+ super.destroy()
35
+ this.emit?.('destroy')
36
+ }
28
37
  }
29
38
 
30
39
  export default Control
@@ -1,4 +1,5 @@
1
1
  import { create } from '../module/layout'
2
+ import clone from '../module/clone'
2
3
 
3
4
  export default {
4
5
  update (info) {
@@ -9,7 +10,7 @@ export default {
9
10
 
10
11
  updateInfo (info) {
11
12
  // console.log('update', info)
12
- this.dataStore[info._id] = info
13
+ this.dataStore[info._id] = clone(info)
13
14
 
14
15
  // update item in the list if visible
15
16
  const item = this.ui.body.querySelector('[data-id="' + info[this.dataId] + '"]')
@@ -12,6 +12,16 @@ const mediator = ((() => {
12
12
  return this
13
13
  }
14
14
 
15
+ const unsubscribe = function (store, fn) {
16
+ if (!mediator.stores[store]) {
17
+ return this
18
+ }
19
+
20
+ mediator.stores[store] = mediator.stores[store].filter(subscription => subscription.callback !== fn)
21
+
22
+ return this
23
+ }
24
+
15
25
  const publish = function (store, ...args) {
16
26
  // console.log('publish', store, args)
17
27
  if (!mediator.stores[store]) {
@@ -30,10 +40,12 @@ const mediator = ((() => {
30
40
  stores: {},
31
41
  publish,
32
42
  subscribe,
43
+ unsubscribe,
33
44
  installTo: function (obj) {
34
45
  obj.subscribe = subscribe
35
46
  obj.publish = publish
36
47
  },
48
+
37
49
  init: function (obj) {
38
50
  obj.subscribe = subscribe
39
51
  obj.publish = publish