beyond-rails 0.0.263 → 0.0.268

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: c68a62a7a7cb119c6c0b31ec428dca33fd34fafd15f78a57351a5f504c39bb54
4
- data.tar.gz: 936f0f2f04b0340ac662e096688d517165628bbcd8bcd97d31c37c935f06a844
3
+ metadata.gz: a80d33b12a4f62600a763bcf01d21cd3e68cbd279e26c35c0ba87c995875c4fa
4
+ data.tar.gz: 1722caa06e09243aaec6dfc4e09f81bdd48e70245d9bb548709cd39809eb6c2c
5
5
  SHA512:
6
- metadata.gz: 4540fa5e0475f803440896c5506207749ed03c85d84422a3640e1511fc1bec599b8f1914d7d0d1f678dee1aecf0b017870074f240ec61854d030871e3dc364cc
7
- data.tar.gz: f5e971151429d2113f35ec0fcc7c89250d16571470a8ca534a8d0729f29016caa859556fe2b2555840755e900e3797f5cc0a5241e7ad6177baa169d34c3fa173
6
+ metadata.gz: 95830b23c996b9f04bebd8d8a0f0a4907d6c974f3eb0e9e24eb80bae26f8ad3a142743ace98ff3be2381126b449d34ad84e4dc8d1a0ded6d5bd0752947b6fda6
7
+ data.tar.gz: ed4b9a8faa36c1718ccfbdd15a55f8f04109179abaaddc5120ee037029632e577534f61f475acc8355f857f9c6cb700db18b01df0725ac1cff3342d373f4a4d3
@@ -59,6 +59,8 @@ export default class Modal {
59
59
 
60
60
  if (this.isVisible && html) {
61
61
  this.replace(html)
62
+ this.modal.classList.add('js-active')
63
+ this.modal.style.display = 'block'
62
64
  return this.triggerShowEventIfNeeded()
63
65
  }
64
66
 
@@ -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.263
4
+ version: 0.0.268
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-03 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