beyond-rails 0.0.262 → 0.0.267

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1bd75f8f763821f105483e4945e1edb8236a972a55573ca1009e1d5fa0a3ae34
4
- data.tar.gz: db80bcb3ff53b3fb8afe1b23c9de8958e7c0bb94fded145b655f7789cbba5fb2
3
+ metadata.gz: ec9a44772db8cea73d2dbcee1266bcc9fe2225d8a05b7bbf3af6bb8c06a61fec
4
+ data.tar.gz: c077e2218952530a31f70945f4edbdb0f5fd99ca6e5200bc4ce2b45d8378e625
5
5
  SHA512:
6
- metadata.gz: 9f004f1c829cd3ba8b6f78b99840cc5ad684840d0e2b101103c864cc11fb7687f7b778bd897ad4109007cff292ad772fb7bdcdf20b2d8cedcfceef736188660d
7
- data.tar.gz: a7bef7f76f4a6f535b3f4dd532bdeaf586452a2a319336a8cf4865a503fc4a1f002da2d34c8f5ef388c39021061b6e4a761243894d980b46d34e2a2187316f9d
6
+ metadata.gz: 0ae6f42201d3d06c5a21e6b2822409771202780cbe69109696af7051c3562ad7d1feb63080e9fc9d6547abac740aebb615095cbe2cf7f4044e60c2364b0f6277
7
+ data.tar.gz: 382dea3264cfb9965d3c733d7bc3a1eaa8493ed0d43c79c40817142ffbddbb7ff412df449da9375d5a22cf6606c3a9b34ae1f064ea94c8458c9fe805b9a8ceaa
@@ -59,6 +59,7 @@ export default class Modal {
59
59
 
60
60
  if (this.isVisible && html) {
61
61
  this.replace(html)
62
+ this.modal.style.display = 'block'
62
63
  return this.triggerShowEventIfNeeded()
63
64
  }
64
65
 
@@ -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() {
@@ -12,7 +12,6 @@ export default class TagInput {
12
12
  this.validate = options.validate || (() => ({ isTag: true }))
13
13
  this.suggest = options.suggest || noop
14
14
  this.change = options.change || noop
15
- this.remove = options.remove || noop
16
15
  this.isComposing = false
17
16
  this.raf = raf
18
17
  this.id = 0
@@ -69,11 +68,11 @@ export default class TagInput {
69
68
  return nextWidth
70
69
  }
71
70
 
72
- shake() {
71
+ shake(duration = 500) {
73
72
  this.dom.classList.add('shake')
74
73
  setTimeout(() => {
75
74
  this.dom.classList.remove('shake')
76
- }, 500)
75
+ }, duration)
77
76
  }
78
77
 
79
78
  setTagAttrs(id, rows = [], options = {}) {
@@ -108,50 +107,63 @@ export default class TagInput {
108
107
  }
109
108
  }
110
109
 
111
- getTag(inputValue, options = {}) {
110
+ getTag(row) {
112
111
 
113
112
  this.id += 1
114
113
 
115
114
  const id = this.id
116
- const classname = options.classname ? ` ${options.classname}` : ''
115
+ const classname = row.classname ? ` ${row.classname}` : ''
117
116
  const tag = document.createElement('div')
118
117
 
119
118
  tag.className = 'tag' + classname
120
- tag.textContent = inputValue
119
+ tag.textContent = row.text
121
120
 
122
121
  const btn = document.createElement('button')
123
122
  btn.type = 'button'
124
123
 
125
124
  // https://wesbos.com/times-html-entity-close-button
126
125
  btn.textContent = '×'
127
- const handleBtnClick = () => {
126
+ const handleBtnClick = event => {
128
127
  this.tags = this.tags.filter(row => row.elem !== tag)
129
128
  btn.removeEventListener('click', handleBtnClick)
130
129
  tag.remove()
131
- this.remove(id)
132
- 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
+ }
133
138
  }
134
139
  btn.addEventListener('click', handleBtnClick)
135
140
  tag.appendChild(btn)
136
141
 
137
- return { id, elem: tag, remove: handleBtnClick, options }
142
+ return { id, elem: tag, remove: handleBtnClick, ...row }
138
143
  }
139
144
 
140
145
  setTags(rows) {
146
+ this.tags.forEach(tag => tag.remove())
141
147
  const { dom, inputDiv } = this
142
- const tags = rows.map(row => this.getTag(row.text, row))
148
+ const tags = rows.map(row => this.getTag(row))
143
149
  tags.forEach(tag => {
144
150
  dom.insertBefore(tag.elem, inputDiv)
145
151
  })
146
152
  this.tags = tags
147
- this.change(this.tags.slice())
153
+ this.change({
154
+ type: 'set',
155
+ tags: this.tags.slice()
156
+ })
148
157
  }
149
158
 
150
- addTag(inputValue, options = {}) {
151
- const tag = this.getTag(inputValue, options)
159
+ addTag(row, type = 'add') {
160
+ const tag = this.getTag(row)
152
161
  this.tags.push(tag)
153
162
  this.dom.insertBefore(tag.elem, this.inputDiv)
154
- this.change(this.tags.slice())
163
+ this.change({
164
+ type,
165
+ tags: this.tags.slice()
166
+ })
155
167
  }
156
168
 
157
169
  async addTagIfNeeded() {
@@ -163,7 +175,9 @@ export default class TagInput {
163
175
  }
164
176
  input.value = ''
165
177
  suggestInput.value = ''
166
- this.addTag(inputValue, res)
178
+
179
+ const row = Object.assign({}, res, { text: inputValue })
180
+ this.addTag(row, 'input')
167
181
  }
168
182
 
169
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.262
4
+ version: 0.0.267
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-12-01 00:00:00.000000000 Z
12
+ date: 2020-12-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sassc