beyond-rails 0.0.260 → 0.0.265

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: 4d17e55b168562da8ed9f3d501fecf52f5343e0ef1ef5695e3e37b1ff514c63e
4
- data.tar.gz: '09b3662f9ef5558f8383f7f02edce72081363a834d0200612b2b85d0fecc2eaf'
3
+ metadata.gz: 9fa71792acbc2210ebcf05fdeee2d1d24c79674c73530d106b267c2ecdd1f865
4
+ data.tar.gz: 67d1de4755f5f311e510ac0687007570cddd7b5232250881400b8eb978687b0d
5
5
  SHA512:
6
- metadata.gz: a0a1c0f73414bdb7b7968d27f4dbf940e0b16c2a5368d195924b6ccc683e77ef3b2bbcc206a66042d23241d7abfc8d117e6a286a1decd5f5ddeca47468fd7ad7
7
- data.tar.gz: b8460319d81cbc6d8a5f974450eeafb6d494e05ce4311e9e4b5a4afd5c981187f4581b82e4836a833d98a6a0e3c907a3263963a1a59bbe0c3a7b9882b3609269
6
+ metadata.gz: 6387d12405e74a62e999421ee5c51eceb3cdcdc0de2f2b259f225cc952f85285cc1536ed7e798e3cee48758d7cc7d910c5b7099da76adeee275bd520473461d7
7
+ data.tar.gz: 412df9e788a1647796cd264f26c9e260095d0cb5e72b0c9b5edd2df4ca174426c8edefe2144e5ac54ad876b81b3bab5fcab0122ba7c48b5c321e942b0917af53
@@ -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() {
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.260
4
+ version: 0.0.265
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-30 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