beyond-rails 0.0.270 → 0.0.276

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: 7c96df07fe7ae22477b03cdaa6dd2f966dd483d11eabacc634fd2044be11a534
4
- data.tar.gz: ac13284fabfac310664793f94618c1d7c763137c23bb33c1ac4d8afe983e4d3e
3
+ metadata.gz: '0587787bc9b1b01ca9b6adfee2492dbd79f4a83b275df96ea58c90bde40e7d55'
4
+ data.tar.gz: 8ef857ab342e1d0935de5fef72c256ff684c57ecc53f3b26f219b8401b06972d
5
5
  SHA512:
6
- metadata.gz: 130618e8992dd06fa092f3f2314e39ead96119a5912b9723ada96bd64482d65d50d0933f9d47f417f2e6a8dfc0da0481adceb5435b565e1d0b5f48ebb0b86735
7
- data.tar.gz: 50067515dd03207b0323f6535d38d2d7a5e6d3ee2a16468382cd69482e9fb91013f7cfd62da5c739ece7938748e5b43a6946ece2e13758a646d55fab282d5aa3
6
+ metadata.gz: fa68191ab050166c130c418089b0127286b3998b61688ced221c0627ed055aa4a7f391273f74de49debeb13a3942ed209e47e5f17ad77e0bfa50e00d76a68a74
7
+ data.tar.gz: 07bbf67a42392542a4fb26532f4970ff47fce89b0c5c7458099fcc10fa6023bcc856064e9d21829ca246b64f1aa5f9d482bb045e21d6cd498fba8c195d41e44a
@@ -12,12 +12,13 @@ import {
12
12
  getDaysInMonth,
13
13
  getMonth,
14
14
  getYear,
15
- throttle,
15
+ isFuture,
16
16
  range,
17
17
  set,
18
18
  startOfDay,
19
19
  startOfMonth,
20
20
  subMonths,
21
+ throttle,
21
22
  toPixel,
22
23
  format
23
24
  } from '../utils'
@@ -46,6 +47,7 @@ export default class DateMenu {
46
47
  this.endDate = endDate
47
48
  this.hoveredCellData = null
48
49
  this.options = options
50
+ this.noFuture = options.noFuture || false
49
51
  this.tz = options.tz || DEFAULT_TIMEZONE
50
52
  this.locale = options.locale || DEFAULT_LOCALE
51
53
  this.captionPattern = options.captionPattern || 'yyyy MMMM'
@@ -74,7 +76,7 @@ export default class DateMenu {
74
76
 
75
77
  getTableRows(date) {
76
78
 
77
- const { startDate, endDate } = this
79
+ const { noFuture, startDate, endDate } = this
78
80
 
79
81
  const daysInMonth = getDaysInMonth(date)
80
82
  const firstDateOfMonth = startOfMonth(date)
@@ -118,6 +120,7 @@ export default class DateMenu {
118
120
  isStartDate: dateEq(initialStartDate, d),
119
121
  isEndDate: dateEq(initialEndDate, d),
120
122
  isSelected: (resCompareStart <= 0) && (resCompareEnd >= 0),
123
+ isDisabled: noFuture && isFuture(d),
121
124
  isToday: (today === formatDate(d)),
122
125
  day
123
126
  }
@@ -191,6 +194,9 @@ export default class DateMenu {
191
194
  if (row.type === CELL_TYPE_EMPTY) {
192
195
  return '<td></td>'
193
196
  }
197
+ if (row.isDisabled) {
198
+ return `<td class="cell js-disabled">${row.day}</td>`
199
+ }
194
200
  if (row.isStartDate || row.isEndDate) {
195
201
  return `<td class="cell selected-ex" data-date-table-cell>${row.day}</td>`
196
202
  }
@@ -63,7 +63,12 @@ export default class Datepicker {
63
63
  this.focused = true
64
64
  this.clearInputStatus()
65
65
  this.dateInput.setActive(true)
66
- this.dateMenu.setDate({ date: this.menuDate })
66
+
67
+ this.dateMenu.setDate({
68
+ date: this.menuDate,
69
+ startDate: this.date
70
+ })
71
+
67
72
  this.dateMenu.show(this.dom)
68
73
  this.timeMenu && this.timeMenu.hide()
69
74
  }
@@ -88,7 +93,8 @@ export default class Datepicker {
88
93
  return
89
94
  }
90
95
 
91
- const res = parse(value, dateInput.datePattern, date)
96
+ const res = parse(value, dateInput.datePattern, date || new Date())
97
+
92
98
  this.nextDate = null
93
99
  if (res.toString() === 'Invalid Date') {
94
100
  return dateInput.setDanger(true)
@@ -107,16 +113,17 @@ export default class Datepicker {
107
113
  handleDateInputBlur() {
108
114
  const { nextDate, date, dateInput } = this
109
115
 
110
- if (date === null) {
116
+ if ((date === null) && (nextDate === null)) {
111
117
  dateInput.setDate(null)
112
118
  this.timeInput && this.timeInput.setDate(null)
113
119
  this._blurTimer = setTimeout(() => this.emitChange(), 50)
114
120
  }
115
121
  else if (nextDate) {
116
122
  this.date = nextDate
123
+ this.menuDate = nextDate
117
124
  dateInput.setDate(nextDate)
118
- this.dateMenu.setDate({ startDate: nextDate })
119
125
  this.nextDate = null
126
+ this.emitChange()
120
127
  }
121
128
  else {
122
129
  dateInput.setDate(date)
@@ -16,6 +16,7 @@ export default class PieChart {
16
16
  this.total = 0
17
17
 
18
18
  this.options = options
19
+ this.labelVisible = isDef(options.labelVisible) ? options.labelVisible : true
19
20
  this.height = options.height
20
21
  this.width = options.width
21
22
  this.padding = isDef(options.padding) ? options.padding : 30
@@ -236,8 +237,10 @@ export default class PieChart {
236
237
  this.total = data.reduce((t, row) => t + row.value, 0)
237
238
  this.data = this.setAngles(data)
238
239
  this.raf(() => {
239
- const labels = this.data.map(row => row.label)
240
- this.drawLabels(labels, this.styles)
240
+ if (this.labelVisible) {
241
+ const labels = this.data.map(row => row.label)
242
+ this.drawLabels(labels, this.styles)
243
+ }
241
244
  this.draw()
242
245
  })
243
246
  }
@@ -247,17 +247,10 @@ export default class SearchDropdown {
247
247
  return Array.from(this.menuContent.querySelectorAll('[data-item]'))
248
248
  }
249
249
 
250
- findClickedItem(target, parent) {
251
- const rows = this.getMenuItemEls()
252
- let node = target
253
- while (node.parentNode !== parent) {
254
- if (node.dataset && ('item' in node.dataset)) {
255
- const index = rows.findIndex(row => row === node)
256
- return this.items[index]
257
- }
258
- node = node.parentNode
259
- }
260
- return null
250
+ findClickedItem(target) {
251
+ const index = this.getMenuItemEls()
252
+ .findIndex(item => (target === item) || (item.contains(target)))
253
+ return this.items[index]
261
254
  }
262
255
 
263
256
  isInputFocused() {
@@ -170,6 +170,11 @@ export default class TagInput {
170
170
  const { input, suggestInput } = this
171
171
  const inputValue = suggestInput.value || input.value
172
172
  const res = await this.validate(inputValue)
173
+ if (res.clear) {
174
+ input.value = ''
175
+ suggestInput.value = ''
176
+ return
177
+ }
173
178
  if (! res.isTag) {
174
179
  return this.shake()
175
180
  }
@@ -243,7 +248,7 @@ export default class TagInput {
243
248
 
244
249
  destroy() {
245
250
  this.tags.forEach(tag => tag.remove())
246
- this.inputDiv.remove()
251
+ this.inputDiv && this.inputDiv.remove()
247
252
  this.canvas = null
248
253
  this.input = null
249
254
  this.suggestInput = null
@@ -70,6 +70,10 @@
70
70
  border-style: solid;
71
71
  border-color: #e3e8ee;
72
72
  }
73
+ &.cell.js-disabled {
74
+ opacity: .4;
75
+ cursor: not-allowed;
76
+ }
73
77
  &.cell.today {
74
78
  background-color: #fffef4;
75
79
  }
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.270
4
+ version: 0.0.276
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-14 00:00:00.000000000 Z
12
+ date: 2021-01-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sassc
@@ -288,7 +288,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
288
288
  - !ruby/object:Gem::Version
289
289
  version: '0'
290
290
  requirements: []
291
- rubygems_version: 3.0.8
291
+ rubygems_version: 3.0.9
292
292
  signing_key:
293
293
  specification_version: 4
294
294
  summary: beyond is a collection of frontend components which aims for admin website.