beyond-rails 0.0.250 → 0.0.255
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.
- checksums.yaml +4 -4
- data/src/js/components/TagInput.js +46 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68c18389bc3fc3c322900aa4f5fb6883b68cb5255fc26bf3ed8ab257f55b22b6
|
4
|
+
data.tar.gz: d52ea6b4f1d3aee55fdf7e3d1b539c2128187158116af66eabca5dc3d40b328a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6af46b3f2c22d2aa4f2ba797071df8b0216923ec5943983293b68d3d6b5f393e7882a73ead03045add7489ca8caaf48a6460f8ea9e84287153c4f02cfb7a3602
|
7
|
+
data.tar.gz: bdacd91a41fd9cb6739253ae8639ef1340425822191287203896ccb4fb30b80215799cf36e98cbcb631cd72e057dacd89560d89789c3fc60423c7f5109cb0f07
|
@@ -14,6 +14,7 @@ export default class TagInput {
|
|
14
14
|
this.change = options.change || noop
|
15
15
|
this.isComposing = false
|
16
16
|
this.raf = raf
|
17
|
+
this.id = 0
|
17
18
|
this.tags = []
|
18
19
|
this.init()
|
19
20
|
}
|
@@ -74,8 +75,33 @@ export default class TagInput {
|
|
74
75
|
}, 500)
|
75
76
|
}
|
76
77
|
|
77
|
-
|
78
|
-
const
|
78
|
+
setTagAttrs(id, rows = [], options = {}) {
|
79
|
+
const tag = this.tags.find(tag => tag.id === id)
|
80
|
+
if (! tag) {
|
81
|
+
return
|
82
|
+
}
|
83
|
+
const { elem } = tag
|
84
|
+
const { timeout } = options
|
85
|
+
const oldAttrs = rows.map(row => elem.getAttribute(row.name))
|
86
|
+
|
87
|
+
rows.forEach(row => {
|
88
|
+
elem.setAttribute(row.name, row.value)
|
89
|
+
})
|
90
|
+
|
91
|
+
if (timeout) {
|
92
|
+
setTimeout(() => {
|
93
|
+
if (document.body.contains(elem)) {
|
94
|
+
rows.forEach((row, i) => {
|
95
|
+
elem.setAttribute(row.name, oldAttrs[i])
|
96
|
+
})
|
97
|
+
}
|
98
|
+
}, timeout)
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
getTag(inputValue, options = {}) {
|
103
|
+
|
104
|
+
const classname = options.classname ? ` ${options.classname}` : ''
|
79
105
|
const tag = document.createElement('div')
|
80
106
|
|
81
107
|
tag.className = 'tag' + classname
|
@@ -94,9 +120,25 @@ export default class TagInput {
|
|
94
120
|
}
|
95
121
|
btn.addEventListener('click', handleBtnClick)
|
96
122
|
tag.appendChild(btn)
|
123
|
+
this.id += 1
|
97
124
|
|
98
|
-
this.
|
99
|
-
|
125
|
+
return { id: this.id, elem: tag, remove: handleBtnClick, options }
|
126
|
+
}
|
127
|
+
|
128
|
+
setTags(rows) {
|
129
|
+
const { dom, inputDiv } = this
|
130
|
+
const tags = rows.map(row => this.getTag(row.text, row))
|
131
|
+
tags.forEach(tag => {
|
132
|
+
dom.insertBefore(tag.elem, inputDiv)
|
133
|
+
})
|
134
|
+
this.tags = tags
|
135
|
+
}
|
136
|
+
|
137
|
+
addTag(inputValue, options = {}) {
|
138
|
+
const tag = this.getTag(inputValue, options)
|
139
|
+
this.tags.push(tag)
|
140
|
+
this.dom.insertBefore(tag.elem, this.inputDiv)
|
141
|
+
this.change(this.tags.slice())
|
100
142
|
}
|
101
143
|
|
102
144
|
async addTagIfNeeded() {
|
@@ -110,8 +152,6 @@ export default class TagInput {
|
|
110
152
|
|
111
153
|
input.value = ''
|
112
154
|
suggestInput.value = ''
|
113
|
-
|
114
|
-
this.change(this.tags.slice())
|
115
155
|
}
|
116
156
|
|
117
157
|
removeTagIfNeeded() {
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beyond-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.255
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kmsheng
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-11-
|
12
|
+
date: 2020-11-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sassc
|