beyond-rails 0.0.251 → 0.0.256
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 +47 -20
- 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: c3e85d9b4c8f791f8ed1eb1bac8a68f71ca189301734451410d1da2628cf49e9
|
4
|
+
data.tar.gz: fb6e1b6de1b7703918a39e5f426bcfad2cc743fbb5c9534878e86ba3f635586d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7408a3297619f390240197b29e768e9a37ad7c3377072470edafdbc29762d8bbd3b146f14808417ea1f16258c79e0cf30d2b09f0581ff4f755beb2c20422a5b0
|
7
|
+
data.tar.gz: 90c1d93650ecdfa61be3ea6e4d37c8bbe81804748fb9233cb5bf48fbfa6fde4ff555f2a5ffcd2f9d5409c3dd0f142dd2a944fa2ddede8cb5780400bd75eaa029
|
@@ -75,26 +75,41 @@ export default class TagInput {
|
|
75
75
|
}, 500)
|
76
76
|
}
|
77
77
|
|
78
|
-
|
78
|
+
setTagAttrs(id, rows = [], options = {}) {
|
79
79
|
const tag = this.tags.find(tag => tag.id === id)
|
80
80
|
if (! tag) {
|
81
81
|
return
|
82
82
|
}
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
83
|
+
const { elem } = tag
|
84
|
+
const { timeout } = options
|
85
|
+
|
86
|
+
if (this.timer) {
|
87
|
+
clearTimeout(this.timer)
|
88
|
+
this.timer = null
|
89
|
+
}
|
90
|
+
else {
|
91
|
+
this.oldAttrs = rows.map(row => elem.getAttribute(row.name))
|
92
|
+
}
|
93
|
+
|
94
|
+
rows.forEach(row => {
|
95
|
+
elem.setAttribute(row.name, row.value)
|
96
|
+
})
|
97
|
+
|
98
|
+
if (timeout) {
|
99
|
+
this.timer = setTimeout(() => {
|
100
|
+
if (document.body.contains(elem)) {
|
101
|
+
const { oldAttrs } = this
|
102
|
+
rows.forEach((row, i) => {
|
103
|
+
elem.setAttribute(row.name, oldAttrs[i])
|
104
|
+
})
|
105
|
+
}
|
106
|
+
}, timeout)
|
93
107
|
}
|
94
108
|
}
|
95
109
|
|
96
|
-
|
97
|
-
|
110
|
+
getTag(inputValue, options = {}) {
|
111
|
+
|
112
|
+
const classname = options.classname ? ` ${options.classname}` : ''
|
98
113
|
const tag = document.createElement('div')
|
99
114
|
|
100
115
|
tag.className = 'tag' + classname
|
@@ -113,10 +128,25 @@ export default class TagInput {
|
|
113
128
|
}
|
114
129
|
btn.addEventListener('click', handleBtnClick)
|
115
130
|
tag.appendChild(btn)
|
116
|
-
|
117
131
|
this.id += 1
|
118
|
-
|
119
|
-
this.
|
132
|
+
|
133
|
+
return { id: this.id, elem: tag, remove: handleBtnClick, options }
|
134
|
+
}
|
135
|
+
|
136
|
+
setTags(rows) {
|
137
|
+
const { dom, inputDiv } = this
|
138
|
+
const tags = rows.map(row => this.getTag(row.text, row))
|
139
|
+
tags.forEach(tag => {
|
140
|
+
dom.insertBefore(tag.elem, inputDiv)
|
141
|
+
})
|
142
|
+
this.tags = tags
|
143
|
+
}
|
144
|
+
|
145
|
+
addTag(inputValue, options = {}) {
|
146
|
+
const tag = this.getTag(inputValue, options)
|
147
|
+
this.tags.push(tag)
|
148
|
+
this.dom.insertBefore(tag.elem, this.inputDiv)
|
149
|
+
this.change(this.tags.slice())
|
120
150
|
}
|
121
151
|
|
122
152
|
async addTagIfNeeded() {
|
@@ -126,12 +156,9 @@ export default class TagInput {
|
|
126
156
|
if (! res.isTag) {
|
127
157
|
return this.shake()
|
128
158
|
}
|
129
|
-
this.addTag(inputValue, res)
|
130
|
-
|
131
159
|
input.value = ''
|
132
160
|
suggestInput.value = ''
|
133
|
-
|
134
|
-
this.change(this.tags.slice())
|
161
|
+
this.addTag(inputValue, res)
|
135
162
|
}
|
136
163
|
|
137
164
|
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.256
|
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
|