beyond-rails 0.0.259 → 0.0.264

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e03fe184dcca8afa039c779b645835e3ab424f10e59719a18bfcf3ed2f8a1879
4
- data.tar.gz: 405e4401b7199efcb2d60ff7f97c5a5944dfe728f7d13057b6a8a51dc618d09d
3
+ metadata.gz: c50569e664c1fcbed09ffbded0db57abcf311f9a04254dbd772cefbaafe04c2e
4
+ data.tar.gz: e2dc759c9069a62eb43b65864469b865f6812c7447772fc91e20531058746c25
5
5
  SHA512:
6
- metadata.gz: 38c4fcc741eaaa7cfbee14504022533b83a0ec31bd9f53b4e8c3a0be101ce422b2fbfdb51fbf2e6630014636acad13a02ccfc6c5f7bd91243e5af286923e359f
7
- data.tar.gz: 2557d50ab4980612f5e1c95dde716a82047c3f649a492be90340b8b873a4073489c1792191da9420f1763caa97f9a29be3388a2d24b25aecfe55d426a3568346
6
+ metadata.gz: 0b84f7ff5b00eb96a30fd9baf13b91be6e22dd10e3f521d89b33ba6e2b2dd403dceec22db65cf730bf78800a8596b15fdf9f69a7e1f79606e02e3aa551156cb8
7
+ data.tar.gz: 9bc478bdf05fe67768bddea72550587d0b5964ef2b20078a0779bd57a7c3bf239ad807cd361bb5dc2c71ce6fa7b25f5ac1ea18af26fea211d74a742649512314
@@ -107,6 +107,7 @@ export default class SearchDropdown {
107
107
  menu.dataset.place = this.place
108
108
  menu.dataset.align = this.align
109
109
  this.isMenuVisible = false
110
+ this.lastKeyword = null
110
111
  }
111
112
 
112
113
  showMenu() {
@@ -68,11 +68,11 @@ export default class TagInput {
68
68
  return nextWidth
69
69
  }
70
70
 
71
- shake() {
71
+ shake(duration = 500) {
72
72
  this.dom.classList.add('shake')
73
73
  setTimeout(() => {
74
74
  this.dom.classList.remove('shake')
75
- }, 500)
75
+ }, duration)
76
76
  }
77
77
 
78
78
  setTagAttrs(id, rows = [], options = {}) {
@@ -107,46 +107,63 @@ export default class TagInput {
107
107
  }
108
108
  }
109
109
 
110
- getTag(inputValue, options = {}) {
110
+ getTag(row) {
111
111
 
112
- const classname = options.classname ? ` ${options.classname}` : ''
112
+ this.id += 1
113
+
114
+ const id = this.id
115
+ const classname = row.classname ? ` ${row.classname}` : ''
113
116
  const tag = document.createElement('div')
114
117
 
115
118
  tag.className = 'tag' + classname
116
- tag.textContent = inputValue
119
+ tag.textContent = row.text
117
120
 
118
121
  const btn = document.createElement('button')
119
122
  btn.type = 'button'
120
123
 
121
124
  // https://wesbos.com/times-html-entity-close-button
122
125
  btn.textContent = '×'
123
- const handleBtnClick = () => {
126
+ const handleBtnClick = event => {
124
127
  this.tags = this.tags.filter(row => row.elem !== tag)
125
128
  btn.removeEventListener('click', handleBtnClick)
126
129
  tag.remove()
127
- this.change(this.tags.slice())
130
+
131
+ if (event) {
132
+ this.change({
133
+ type: 'remove',
134
+ removedId: id,
135
+ tags: this.tags.slice()
136
+ })
137
+ }
128
138
  }
129
139
  btn.addEventListener('click', handleBtnClick)
130
140
  tag.appendChild(btn)
131
- this.id += 1
132
141
 
133
- return { id: this.id, elem: tag, remove: handleBtnClick, options }
142
+ return { id, elem: tag, remove: handleBtnClick, ...row }
134
143
  }
135
144
 
136
145
  setTags(rows) {
146
+ this.tags.forEach(tag => tag.remove())
137
147
  const { dom, inputDiv } = this
138
- const tags = rows.map(row => this.getTag(row.text, row))
148
+ const tags = rows.map(row => this.getTag(row))
139
149
  tags.forEach(tag => {
140
150
  dom.insertBefore(tag.elem, inputDiv)
141
151
  })
142
152
  this.tags = tags
153
+ this.change({
154
+ type: 'set',
155
+ tags: this.tags.slice()
156
+ })
143
157
  }
144
158
 
145
- addTag(inputValue, options = {}) {
146
- const tag = this.getTag(inputValue, options)
159
+ addTag(row, type = 'add') {
160
+ const tag = this.getTag(row)
147
161
  this.tags.push(tag)
148
162
  this.dom.insertBefore(tag.elem, this.inputDiv)
149
- this.change(this.tags.slice())
163
+ this.change({
164
+ type,
165
+ tags: this.tags.slice()
166
+ })
150
167
  }
151
168
 
152
169
  async addTagIfNeeded() {
@@ -158,7 +175,9 @@ export default class TagInput {
158
175
  }
159
176
  input.value = ''
160
177
  suggestInput.value = ''
161
- this.addTag(inputValue, res)
178
+
179
+ const row = Object.assign({}, res, { text: inputValue })
180
+ this.addTag(row, 'input')
162
181
  }
163
182
 
164
183
  removeTagIfNeeded() {
@@ -33,19 +33,19 @@ h6 {
33
33
  }
34
34
 
35
35
  .txt-primary {
36
- color: $txt-color-primary;
36
+ color: $txt-color-primary !important;
37
37
  }
38
38
  .txt-secondary {
39
- color: $txt-color-secondary;
39
+ color: $txt-color-secondary !important;
40
40
  }
41
41
  .txt-success {
42
- color: $txt-color-success;
42
+ color: $txt-color-success !important;
43
43
  }
44
44
  .txt-warn {
45
- color: $txt-color-warn;
45
+ color: $txt-color-warn !important;
46
46
  }
47
47
  .txt-danger {
48
- color: $txt-color-danger;
48
+ color: $txt-color-danger !important;
49
49
  }
50
50
 
51
51
  .txt-white {
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.259
4
+ version: 0.0.264
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-27 00:00:00.000000000 Z
12
+ date: 2020-12-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sassc