beyond-rails 0.0.271 → 0.0.277

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: 01dd97cd11c2e48ea6e8418c073f9ca5ca91e311873309f7651e4174c00e2c84
4
- data.tar.gz: 6e6598b62c2149288f16856521ad20a397c8fdb127698c7e56d7dcbcc8baa498
3
+ metadata.gz: '086454b869902332316514def36675eca9a02b1419aa38c2ba5c7f73682e6d3d'
4
+ data.tar.gz: 5ee5a23161b56ca2a0e803fc3cd76629dc25a7dc5a66edb96d2040ad53924a52
5
5
  SHA512:
6
- metadata.gz: 12da64daa3b927b0b6a4d3f7bfac9803211926a2f6973362271576e2ef8c4e6cd6818ec118ddd4e525a709e595e0c6eafe5847114c42449c06dd48a7fe78bb7a
7
- data.tar.gz: 2e571a176fc54d6fd755d15d4a974b20cc808b2c7bc2673426f4ec74e3f0c0bb65fe5aeb7a14ab580c473fc09fecb3c794302750ccec5c905733ea4ef5a06876
6
+ metadata.gz: d7a89928221e3d295e0aa26a941f76eb4386f040cdd246a9c201591d023f0da5865dcb901d0ef494d51c5dd4396b955a0eb684eae543c96bdfe223a036ca3038
7
+ data.tar.gz: 832963f43c75f4273baf79b426601e65606026ec8a8cef035a5782ba9711732305f779bd78ed79e56b119a74f16c066ae921faff304234d5c890b2f7c6f31972
@@ -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
  }
@@ -26,6 +26,7 @@ export default class SearchDropdown {
26
26
  this.offsetTop = options.offsetTop || 0
27
27
  this.offsetLeft = options.offsetLeft || 0
28
28
  this.noDataMsg = options.noDataMsg || '沒有資料'
29
+ this.getFloatedTargetPos = options.getFloatedTargetPos || getFloatedTargetPos
29
30
  this.isMenuVisible = false
30
31
  this.lastKeyword = null
31
32
  this.selectedIndex = 0
@@ -164,7 +165,7 @@ export default class SearchDropdown {
164
165
 
165
166
  adjustMenuPos() {
166
167
  const { menu, dom, offset, offsetLeft, offsetTop } = this
167
- const { pos, place, align } = getFloatedTargetPos({
168
+ const { pos, place, align } = this.getFloatedTargetPos({
168
169
  src: dom,
169
170
  target: menu,
170
171
  place: this.place,
@@ -247,17 +248,10 @@ export default class SearchDropdown {
247
248
  return Array.from(this.menuContent.querySelectorAll('[data-item]'))
248
249
  }
249
250
 
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
251
+ findClickedItem(target) {
252
+ const index = this.getMenuItemEls()
253
+ .findIndex(item => (target === item) || (item.contains(target)))
254
+ return this.items[index]
261
255
  }
262
256
 
263
257
  isInputFocused() {
@@ -248,7 +248,7 @@ export default class TagInput {
248
248
 
249
249
  destroy() {
250
250
  this.tags.forEach(tag => tag.remove())
251
- this.inputDiv.remove()
251
+ this.inputDiv && this.inputDiv.remove()
252
252
  this.canvas = null
253
253
  this.input = null
254
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,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beyond-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.271
4
+ version: 0.0.277
5
5
  platform: ruby
6
6
  authors:
7
7
  - kmsheng
8
8
  - Eddie Li
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-12-15 00:00:00.000000000 Z
12
+ date: 2021-01-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sassc
@@ -93,7 +93,7 @@ dependencies:
93
93
  - - ">="
94
94
  - !ruby/object:Gem::Version
95
95
  version: 3.3.0
96
- description:
96
+ description:
97
97
  email: kmsh3ng@gmail.com
98
98
  executables: []
99
99
  extensions: []
@@ -273,7 +273,7 @@ homepage: https://superlanding.github.io/beyond/
273
273
  licenses:
274
274
  - MIT
275
275
  metadata: {}
276
- post_install_message:
276
+ post_install_message:
277
277
  rdoc_options: []
278
278
  require_paths:
279
279
  - lib
@@ -288,8 +288,8 @@ 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
292
- signing_key:
291
+ rubygems_version: 3.0.3
292
+ signing_key:
293
293
  specification_version: 4
294
294
  summary: beyond is a collection of frontend components which aims for admin website.
295
295
  test_files: []