material 0.8.0 → 0.8.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "material",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
4
4
  "description": "A lightweight implementation of Material Design Components for the web - ES6",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/src/list/add.js CHANGED
@@ -1,14 +1,24 @@
1
1
 
2
2
  export default {
3
3
  add (info, context) {
4
- // console.log('list add', info)
4
+ // console.log('list add', info)
5
5
 
6
6
  if (!this.dataStore) return
7
- context = context || null
7
+ context = context !== undefined ? context : null
8
8
 
9
9
  this.dataList = this.dataList || []
10
10
 
11
- if (context === 'bottom') {
11
+ if (typeof context === 'number') {
12
+ if (this.data) {
13
+ this.data.splice(context, 0, info)
14
+ } else {
15
+ console.log('error no data')
16
+ }
17
+
18
+ if (this.dataList) {
19
+ this.dataList.splice(context, 0, info[this.dataId])
20
+ }
21
+ } else if (context === 'bottom') {
12
22
  if (this.data) { this.data.push(info) }
13
23
  if (this.dataList) { this.dataList.push(info[this.dataId]) }
14
24
  } else {
@@ -30,9 +40,12 @@ export default {
30
40
  this.virtual.update(this.data)
31
41
  }
32
42
 
43
+ this.emit('added', info, context)
44
+
33
45
  // this.ui.body.scrollTo(0, this.ui.body.scrollTop + 1)
34
46
  // this.ui.body.scrollTo(0, this.ui.body.scrollTop - 1)
35
47
 
36
48
  return info
37
49
  }
50
+
38
51
  }
@@ -20,7 +20,6 @@ class Collection {
20
20
  }
21
21
 
22
22
  get (page, size, more) {
23
- 7
24
23
  // console.log('fetch', page, size, more)
25
24
  if (more !== true) {
26
25
  this.page = 1
@@ -21,7 +21,7 @@ const request = async (url, method = 'GET', body = null, headers = {}, signal =
21
21
  try {
22
22
  const response = await fetch(url, options)
23
23
  if (!response.ok) {
24
- throw new Error(`Network response was not ok! ${response.status}`)
24
+ // console.log('Error', response)
25
25
  }
26
26
 
27
27
  // Determine response type based on 'Accept' header
@@ -31,8 +31,11 @@ const request = async (url, method = 'GET', body = null, headers = {}, signal =
31
31
  return await response.json()
32
32
  }
33
33
  } catch (error) {
34
- console.error('There has been a problem with your fetch operation:', error)
35
- return { error }
34
+ if (headers.Accept === 'text/xml') {
35
+ throw error
36
+ } else {
37
+ throw { error }
38
+ }
36
39
  }
37
40
  }
38
41