material 0.9.14 → 0.9.16

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.16",
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
package/src/dialog.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import emitter from './module/emitter'
3
3
  import events from './module/events'
4
4
  import display from './mixin/display'
5
+ import * as css from './module/css'
5
6
 
6
7
  import Element from './element'
7
8
  import Text from './text'
@@ -55,7 +56,8 @@ class Dialog {
55
56
  this.element = this.element
56
57
 
57
58
  if (this.options.class !== 'dialog') {
58
- this.element.classList.add(this.options.class)
59
+ // console.log('css add', this.options.class)
60
+ css.add(this.element, this.options.class)
59
61
  }
60
62
 
61
63
  if (this.options.position) {
@@ -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
@@ -1,4 +1,13 @@
1
- const request = async (url, method = 'GET', body = null, headers = {}, signal = null, debug = false) => {
1
+ const request = async (
2
+ url,
3
+ method = 'GET',
4
+ body = null,
5
+ headers = {},
6
+ signal = null,
7
+ debug = false,
8
+ cache = 'no-store' // Adding cache parameter with a default value
9
+ ) => {
10
+ // console.trace('request')
2
11
  const defaultHeaders = {
3
12
  Accept: 'application/json',
4
13
  'Content-Type': 'application/json'
@@ -7,7 +16,8 @@ const request = async (url, method = 'GET', body = null, headers = {}, signal =
7
16
  const options = {
8
17
  method,
9
18
  headers: { ...defaultHeaders, ...headers },
10
- signal
19
+ signal,
20
+ cache // Including the cache option in the request
11
21
  }
12
22
 
13
23
  if (debug) {