beyond-rails 0.0.245 → 0.0.250
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 +4 -4
- data/src/font/beyond.eot +0 -0
- data/src/font/beyond.svg +2 -0
- data/src/font/beyond.ttf +0 -0
- data/src/font/beyond.woff +0 -0
- data/src/font/beyond.woff2 +0 -0
- data/src/js/components/MonthInput.js +75 -0
- data/src/js/components/MonthMenu.js +276 -0
- data/src/js/components/Monthpicker.js +92 -0
- data/src/js/index.js +4 -0
- data/src/js/utils/index.js +12 -0
- data/src/sass/_beyond.scss +1 -0
- data/src/sass/components/_form.scss +1 -1
- data/src/sass/components/_icon.scss +6 -0
- data/src/sass/components/_month-menu.scss +74 -0
- data/src/sass/components/_table.scss +2 -2
- metadata +11 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 322787a4c8946f84a187c1d8a6f61ae484e197a5295c872f63aa5cbc7ed43f91
|
4
|
+
data.tar.gz: 64d4fd67dd0c18f3441e3bc09d5d57c4ccb518e2368c5318a7654a025c97a7e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 787409b5d76b822cc1cb20494c71892c48a4277edc0de48f70ccaba4180ccb473f4c88d09cb988015cf3355c9a0e3f48e48f09a439edeb76f5266c104e6f7e11
|
7
|
+
data.tar.gz: db95d7c2437ddebab2e7da69ce48c88fc612b4fc72784ec83cc800ed138339fff8db27a54cc7b8743d2c3175066748b6c069b41832d063dd30bb0feec98a1b3d
|
data/src/font/beyond.eot
CHANGED
Binary file
|
data/src/font/beyond.svg
CHANGED
@@ -142,4 +142,6 @@
|
|
142
142
|
<glyph unicode="" glyph-name="expand" d="M511.868-65.382h-0.845c-14.249 0.040-27.086 6.057-36.136 15.676-0.801 0.713-1.585 1.457-2.35 2.231l-343.999 348.25c-19.309 19.548-19.115 51.047 0.432 70.356s51.047 19.115 70.356-0.432l262.305-265.547 1.213 575.831c0.058 27.476 22.379 49.703 49.855 49.645s49.703-22.379 49.645-49.855l-1.215-576.566 263.564 266.512c19.32 19.536 50.82 19.712 70.356 0.391s19.712-50.82 0.391-70.356l-347.473-351.359c-9.914-10.025-23.035-14.952-36.101-14.777v0zM143.131 880c-16.089 0-29.131 17.909-29.131 40s13.042 40 29.131 40h737.738c16.089 0 29.131-17.909 29.131-40s-13.042-40-29.131-40h-737.738z" />
|
143
143
|
<glyph unicode="" glyph-name="shrink" d="M511.868 733.382c13.066 0.174 26.187-4.752 36.101-14.777l347.473-351.359c19.32-19.536 19.145-51.036-0.391-70.356s-51.036-19.145-70.356 0.391l-263.564 266.512 1.215-576.566c0.058-27.476-22.169-49.797-49.645-49.855s-49.797 22.169-49.855 49.646l-1.213 575.831-262.305-265.547c-19.309-19.548-50.808-19.741-70.356-0.432s-19.741 50.808-0.432 70.356l343.999 348.25c0.765 0.774 1.548 1.518 2.35 2.231 9.050 9.619 21.887 15.636 36.136 15.676h0.845zM143.131 880c-16.089 0-29.131 17.909-29.131 40s13.042 40 29.131 40h737.738c16.089 0 29.131-17.909 29.131-40s-13.042-40-29.131-40h-737.738z" />
|
144
144
|
<glyph unicode="" glyph-name="brush-alt" d="M895.693 940.743c39.535 21.353 73.331 18.001 101.388-10.056s31.529-61.973 10.415-101.747c-143.315-175.012-239.296-288.064-287.944-339.154-72.972-76.635-157.854-139.003-163.736-133.121-6.569 6.569-118.875 118.875-132.999 132.999 0 0-26.317 11.172 133.364 163.493 106.454 101.547 219.625 197.409 339.512 287.586zM354.82 430.539c43.447-43.447 87.986-87.092 133.617-130.937 0.461-110.050-52.691-190.068-159.457-240.055s-216.426 4.111-328.98 162.293c77.634-4.996 125.092 4.308 142.375 27.91 26.195 35.773 7.996 84.241 73.273 146.441 36.047 34.348 107.648 34.348 139.172 34.348z" />
|
145
|
+
<glyph unicode="" glyph-name="bug" d="M1024 384v64h-193.29c-5.862 72.686-31.786 139.026-71.67 192.25h161.944l70.060 280.24-62.090 15.522-57.94-231.76h-174.68c-0.892 0.694-1.796 1.374-2.698 2.056 6.71 19.502 10.362 40.422 10.362 62.194 0.002 105.76-85.958 191.498-191.998 191.498s-192-85.738-192-191.5c0-21.772 3.65-42.692 10.362-62.194-0.9-0.684-1.804-1.362-2.698-2.056h-174.68l-57.94 231.76-62.090-15.522 70.060-280.24h161.944c-39.884-53.222-65.806-119.562-71.668-192.248h-193.29v-64h193.37c3.802-45.664 15.508-88.812 33.638-127.75h-123.992l-70.060-280.238 62.090-15.524 57.94 231.762h112.354c58.692-78.032 147.396-127.75 246.66-127.75s187.966 49.718 246.662 127.75h112.354l57.94-231.762 62.090 15.524-70.060 280.238h-123.992c18.13 38.938 29.836 82.086 33.636 127.75h193.37z" />
|
146
|
+
<glyph unicode="" glyph-name="target1" d="M1024 512h-100.924c-27.64 178.24-168.836 319.436-347.076 347.076v100.924h-128v-100.924c-178.24-27.64-319.436-168.836-347.076-347.076h-100.924v-128h100.924c27.64-178.24 168.836-319.436 347.076-347.076v-100.924h128v100.924c178.24 27.64 319.436 168.836 347.076 347.076h100.924v128zM792.822 512h-99.762c-19.284 54.55-62.51 97.778-117.060 117.060v99.762c107.514-24.49 192.332-109.31 216.822-216.822zM512 384c-35.346 0-64 28.654-64 64s28.654 64 64 64c35.346 0 64-28.654 64-64s-28.654-64-64-64zM448 728.822v-99.762c-54.55-19.282-97.778-62.51-117.060-117.060h-99.762c24.49 107.512 109.31 192.332 216.822 216.822zM231.178 384h99.762c19.282-54.55 62.51-97.778 117.060-117.060v-99.762c-107.512 24.49-192.332 109.308-216.822 216.822zM576 167.178v99.762c54.55 19.284 97.778 62.51 117.060 117.060h99.762c-24.49-107.514-109.308-192.332-216.822-216.822z" />
|
145
147
|
</font></defs></svg>
|
data/src/font/beyond.ttf
CHANGED
Binary file
|
data/src/font/beyond.woff
CHANGED
Binary file
|
data/src/font/beyond.woff2
CHANGED
Binary file
|
@@ -0,0 +1,75 @@
|
|
1
|
+
import { DEFAULT_TIMEZONE } from '../consts'
|
2
|
+
import supportDom from '../decorators/supportDom'
|
3
|
+
import isTouchDevice from '../utils/isTouchDevice'
|
4
|
+
import { format } from '../utils'
|
5
|
+
|
6
|
+
@supportDom
|
7
|
+
export default class MonthInput {
|
8
|
+
|
9
|
+
constructor(dom, date, options = {}) {
|
10
|
+
this.active = false
|
11
|
+
this.danger = false
|
12
|
+
this.dom = dom
|
13
|
+
this.date = date
|
14
|
+
this.options = options
|
15
|
+
this.tz = options.tz || DEFAULT_TIMEZONE
|
16
|
+
this.datePattern = options.datePattern || 'yyyy/MM'
|
17
|
+
this.init()
|
18
|
+
}
|
19
|
+
|
20
|
+
focus() {
|
21
|
+
this.dom.focus()
|
22
|
+
}
|
23
|
+
|
24
|
+
init() {
|
25
|
+
this.initInput()
|
26
|
+
this.addEvents()
|
27
|
+
}
|
28
|
+
|
29
|
+
initInput() {
|
30
|
+
const { dom } = this
|
31
|
+
if (this.date) {
|
32
|
+
dom.value = this.format(this.date)
|
33
|
+
}
|
34
|
+
if (! dom.hasAttribute('placeholder')) {
|
35
|
+
dom.setAttribute('placeholder', this.datePattern.toUpperCase())
|
36
|
+
}
|
37
|
+
if (isTouchDevice()) {
|
38
|
+
dom.setAttribute('readonly', 'readonly')
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
format(date) {
|
43
|
+
return format(date, this.datePattern, { timezone: this.tz })
|
44
|
+
}
|
45
|
+
|
46
|
+
setDate(date) {
|
47
|
+
this.date = date
|
48
|
+
this.dom.value = date ? this.format(date) : ''
|
49
|
+
}
|
50
|
+
|
51
|
+
setActive(active) {
|
52
|
+
this.active = active
|
53
|
+
const func = active ? 'add' : 'remove'
|
54
|
+
this.dom.classList[func]('active')
|
55
|
+
}
|
56
|
+
|
57
|
+
setDanger(danger) {
|
58
|
+
this.danger = danger
|
59
|
+
const func = danger ? 'add' : 'remove'
|
60
|
+
this.dom.classList[func]('danger')
|
61
|
+
}
|
62
|
+
|
63
|
+
clearStatus() {
|
64
|
+
this.setActive(false)
|
65
|
+
this.setDanger(false)
|
66
|
+
}
|
67
|
+
|
68
|
+
addEvents() {
|
69
|
+
const { dom } = this
|
70
|
+
this.addEvent(dom, 'click', event => this.fire('click', event))
|
71
|
+
this.addEvent(dom, 'focus', event => this.fire('focus', event))
|
72
|
+
this.addEvent(dom, 'keyup', event => this.fire('keyup', event))
|
73
|
+
this.addEvent(dom, 'blur', event => this.fire('blur', event))
|
74
|
+
}
|
75
|
+
}
|
@@ -0,0 +1,276 @@
|
|
1
|
+
import supportDom from '../decorators/supportDom'
|
2
|
+
import getFloatedTargetPos from '../utils/getFloatedTargetPos'
|
3
|
+
import isTouchDevice from '../utils/isTouchDevice'
|
4
|
+
import { DEFAULT_TIMEZONE, DEFAULT_LOCALE } from '../consts'
|
5
|
+
import {
|
6
|
+
chunk,
|
7
|
+
format,
|
8
|
+
range,
|
9
|
+
isFuture,
|
10
|
+
setYear,
|
11
|
+
setMonth,
|
12
|
+
getYear,
|
13
|
+
getMonth,
|
14
|
+
addYears,
|
15
|
+
toPixel,
|
16
|
+
subYears,
|
17
|
+
noop
|
18
|
+
} from '../utils'
|
19
|
+
|
20
|
+
@supportDom
|
21
|
+
export default class MonthMenu {
|
22
|
+
|
23
|
+
constructor(options = {}) {
|
24
|
+
const { dom, date } = options
|
25
|
+
this.container = dom
|
26
|
+
this.date = date
|
27
|
+
this.menuDate = this.date || new Date()
|
28
|
+
this.options = options
|
29
|
+
this.tz = options.tz || DEFAULT_TIMEZONE
|
30
|
+
this.locale = options.locale || DEFAULT_LOCALE
|
31
|
+
this.noFuture = options.noFuture || true
|
32
|
+
this.change = options.change || noop
|
33
|
+
this.isVisible = false
|
34
|
+
this.loopIndex = 0
|
35
|
+
this.init()
|
36
|
+
}
|
37
|
+
|
38
|
+
init() {
|
39
|
+
this.addMenu()
|
40
|
+
this.addEvents()
|
41
|
+
}
|
42
|
+
|
43
|
+
renderTableContent() {
|
44
|
+
const { date, menuDate, locale, noFuture } = this
|
45
|
+
|
46
|
+
const currentYear = date ? getYear(date) : null
|
47
|
+
const currentMonth = date ? getMonth(date) : null
|
48
|
+
|
49
|
+
return chunk(range(0, 12), 3)
|
50
|
+
.map(months => {
|
51
|
+
const tds = months.map(month => {
|
52
|
+
const d = setMonth(menuDate, month)
|
53
|
+
const text = format(d, 'MMM', { locale })
|
54
|
+
|
55
|
+
const isCurrentMonth = (currentYear === getYear(d)) && (currentMonth === getMonth(d))
|
56
|
+
|
57
|
+
let classname = 'cell'
|
58
|
+
|
59
|
+
if (isCurrentMonth) {
|
60
|
+
classname = 'cell selected-ex'
|
61
|
+
}
|
62
|
+
else if (noFuture && isFuture(d)) {
|
63
|
+
classname = 'cell js-disabled'
|
64
|
+
}
|
65
|
+
|
66
|
+
return `<td class="${classname}" data-month-td="${month}">${text}</td>`
|
67
|
+
}).join('')
|
68
|
+
return `<tr>${tds}</tr>`
|
69
|
+
})
|
70
|
+
.join('')
|
71
|
+
}
|
72
|
+
|
73
|
+
updateTableContent() {
|
74
|
+
this.table.innerHTML = this.renderTableContent()
|
75
|
+
}
|
76
|
+
|
77
|
+
addMenu() {
|
78
|
+
const { container } = this
|
79
|
+
const dom = document.createElement('div')
|
80
|
+
dom.classList.add('month-menu')
|
81
|
+
|
82
|
+
if (container) {
|
83
|
+
dom.classList.add('static')
|
84
|
+
}
|
85
|
+
const title = getYear(this.menuDate)
|
86
|
+
dom.innerHTML = `
|
87
|
+
<div class="month-menu-content">
|
88
|
+
<div class="month-menu-caption">
|
89
|
+
<button class="month-menu-caption-btn"
|
90
|
+
type="button"
|
91
|
+
data-prev-month-btn>
|
92
|
+
<i class="icon-chevron-left"></i>
|
93
|
+
</button>
|
94
|
+
<div data-month-menu-title>${title}</div>
|
95
|
+
<button class="month-menu-caption-btn"
|
96
|
+
type="button"
|
97
|
+
data-next-month-btn>
|
98
|
+
<i class="icon-chevron-right"></i>
|
99
|
+
</button>
|
100
|
+
</div>
|
101
|
+
<table class="month-menu-table"
|
102
|
+
data-month-table>
|
103
|
+
${this.renderTableContent()}
|
104
|
+
</table>
|
105
|
+
</div>
|
106
|
+
`
|
107
|
+
if (container) {
|
108
|
+
container.appendChild(dom)
|
109
|
+
}
|
110
|
+
else {
|
111
|
+
document.body.appendChild(dom)
|
112
|
+
}
|
113
|
+
this.menuTitle = dom.querySelector('[data-month-menu-title]')
|
114
|
+
this.prevBtn = dom.querySelector('[data-prev-month-btn]')
|
115
|
+
this.nextBtn = dom.querySelector('[data-next-month-btn]')
|
116
|
+
this.table = dom.querySelector('[data-month-table]')
|
117
|
+
this.dom = dom
|
118
|
+
}
|
119
|
+
|
120
|
+
setTitle(date) {
|
121
|
+
this.menuTitle.textContent = getYear(date)
|
122
|
+
}
|
123
|
+
|
124
|
+
addYear(year = 1) {
|
125
|
+
this.menuDate = addYears(this.menuDate, year)
|
126
|
+
this.setTitle(this.menuDate)
|
127
|
+
this.updateTableContent()
|
128
|
+
}
|
129
|
+
|
130
|
+
addYearLoop() {
|
131
|
+
const duration = (this.loopIndex === 0) ? 500 : 100
|
132
|
+
this.addYearTimer = setTimeout(() => {
|
133
|
+
this.loopIndex += 1
|
134
|
+
const year = parseInt((this.loopIndex / 5) + 1, 10)
|
135
|
+
this.addYear(year)
|
136
|
+
this.addYearLoop()
|
137
|
+
}, duration)
|
138
|
+
}
|
139
|
+
|
140
|
+
clearAddYearLoop() {
|
141
|
+
clearTimeout(this.addYearTimer)
|
142
|
+
this.loopIndex = 0
|
143
|
+
}
|
144
|
+
|
145
|
+
subYear(year = 1) {
|
146
|
+
this.menuDate = subYears(this.menuDate, year)
|
147
|
+
this.setTitle(this.menuDate)
|
148
|
+
this.updateTableContent()
|
149
|
+
}
|
150
|
+
|
151
|
+
subYearLoop() {
|
152
|
+
const duration = (this.loopIndex === 0) ? 500 : 100
|
153
|
+
this.subYearTimer = setTimeout(() => {
|
154
|
+
this.loopIndex += 1
|
155
|
+
const year = parseInt((this.loopIndex / 5) + 1, 10)
|
156
|
+
const currentYear = getYear(this.menuDate)
|
157
|
+
if ((currentYear - year) > 0) {
|
158
|
+
this.subYear(year)
|
159
|
+
this.subYearLoop()
|
160
|
+
}
|
161
|
+
}, duration)
|
162
|
+
}
|
163
|
+
|
164
|
+
clearSubYearLoop() {
|
165
|
+
clearTimeout(this.subYearTimer)
|
166
|
+
this.loopIndex = 0
|
167
|
+
}
|
168
|
+
|
169
|
+
stop(event) {
|
170
|
+
event.preventDefault()
|
171
|
+
event.stopPropagation()
|
172
|
+
}
|
173
|
+
|
174
|
+
addEvents() {
|
175
|
+
const isTouch = isTouchDevice()
|
176
|
+
const downEvent = isTouch ? 'touchstart' : 'mousedown'
|
177
|
+
|
178
|
+
this.addEvent(this.prevBtn, downEvent, event => {
|
179
|
+
this.stop(event)
|
180
|
+
const currentYear = getYear(this.menuDate)
|
181
|
+
if ((currentYear - 1) <= 0) {
|
182
|
+
return
|
183
|
+
}
|
184
|
+
this.subYear()
|
185
|
+
this.subYearLoop()
|
186
|
+
})
|
187
|
+
|
188
|
+
this.addEvent(this.nextBtn, 'click', event => event.stopPropagation())
|
189
|
+
this.addEvent(this.prevBtn, 'click', event => event.stopPropagation())
|
190
|
+
|
191
|
+
this.addEvent(this.nextBtn, downEvent, event => {
|
192
|
+
this.stop(event)
|
193
|
+
this.addYear()
|
194
|
+
this.addYearLoop()
|
195
|
+
})
|
196
|
+
|
197
|
+
const upEvent = isTouch ? 'touchend' : 'mouseup'
|
198
|
+
this.addEvent(this.prevBtn, upEvent, event => {
|
199
|
+
this.stop(event)
|
200
|
+
this.clearSubYearLoop()
|
201
|
+
})
|
202
|
+
this.addEvent(this.nextBtn, upEvent, event => {
|
203
|
+
this.stop(event)
|
204
|
+
this.clearAddYearLoop()
|
205
|
+
})
|
206
|
+
|
207
|
+
this.addEvent(this.table, 'click', event => {
|
208
|
+
this.stop(event)
|
209
|
+
const { target } = event
|
210
|
+
if ('monthTd' in target.dataset) {
|
211
|
+
const year = getYear(this.menuDate)
|
212
|
+
const month = parseInt(target.dataset.monthTd, 10)
|
213
|
+
|
214
|
+
if (target.classList.contains('js-disabled')) {
|
215
|
+
return
|
216
|
+
}
|
217
|
+
|
218
|
+
if (! this.date) {
|
219
|
+
this.date = new Date(this.menuDate.getTime())
|
220
|
+
}
|
221
|
+
|
222
|
+
this.date = setYear(this.date, year)
|
223
|
+
this.date = setMonth(this.date, month)
|
224
|
+
this.updateTableContent()
|
225
|
+
this.emitChange()
|
226
|
+
}
|
227
|
+
})
|
228
|
+
}
|
229
|
+
|
230
|
+
setDate(date) {
|
231
|
+
this.date = date
|
232
|
+
this.menuDate = date
|
233
|
+
this.setTitle(date)
|
234
|
+
this.updateTableContent()
|
235
|
+
}
|
236
|
+
|
237
|
+
emitChange() {
|
238
|
+
this.change(this.date)
|
239
|
+
}
|
240
|
+
|
241
|
+
pos(src) {
|
242
|
+
const { dom } = this
|
243
|
+
const { pos } = getFloatedTargetPos({
|
244
|
+
src,
|
245
|
+
target: dom,
|
246
|
+
place: 'bottom',
|
247
|
+
align: 'left',
|
248
|
+
offset: 4
|
249
|
+
})
|
250
|
+
dom.style.left = toPixel(pos.left)
|
251
|
+
dom.style.top = toPixel(pos.top)
|
252
|
+
}
|
253
|
+
|
254
|
+
show(src) {
|
255
|
+
const { dom } = this
|
256
|
+
dom.style.display = 'block'
|
257
|
+
if (src) {
|
258
|
+
this.pos(src)
|
259
|
+
}
|
260
|
+
dom.style.opacity = 1
|
261
|
+
this.isVisible = true
|
262
|
+
}
|
263
|
+
|
264
|
+
hide() {
|
265
|
+
this.dom.style.display = 'none'
|
266
|
+
this.isVisible = false
|
267
|
+
}
|
268
|
+
|
269
|
+
destroy() {
|
270
|
+
this.menuTitle = null
|
271
|
+
this.prevBtn = null
|
272
|
+
this.nextBtn = null
|
273
|
+
this.table = null
|
274
|
+
this.dom.remove()
|
275
|
+
}
|
276
|
+
}
|
@@ -0,0 +1,92 @@
|
|
1
|
+
import MonthInput from './MonthInput'
|
2
|
+
import MonthMenu from './MonthMenu'
|
3
|
+
import supportDom from '../decorators/supportDom'
|
4
|
+
import { DEFAULT_TIMEZONE } from '../consts'
|
5
|
+
import { noop, parse } from '../utils'
|
6
|
+
|
7
|
+
@supportDom
|
8
|
+
export default class Monthpicker {
|
9
|
+
|
10
|
+
constructor(dom, options = {}) {
|
11
|
+
this.dom = dom
|
12
|
+
this.tz = options.tz || DEFAULT_TIMEZONE
|
13
|
+
this.date = options.date
|
14
|
+
this.menuDate = this.date
|
15
|
+
|
16
|
+
this.options = options
|
17
|
+
this.backdropMode = options.backdropMode || 'auto'
|
18
|
+
this.noFuture = options.noFuture || true
|
19
|
+
this.change = options.change || noop
|
20
|
+
this.init()
|
21
|
+
}
|
22
|
+
|
23
|
+
init() {
|
24
|
+
const { dom } = this
|
25
|
+
this.monthInput = new MonthInput(
|
26
|
+
dom.querySelector('[data-month]'),
|
27
|
+
this.date,
|
28
|
+
this.options
|
29
|
+
)
|
30
|
+
this.monthMenu = new MonthMenu({
|
31
|
+
date: this.menuDate,
|
32
|
+
change: date => {
|
33
|
+
this.monthInput.setDate(date)
|
34
|
+
this.monthInput.clearStatus()
|
35
|
+
this.monthMenu.hide()
|
36
|
+
},
|
37
|
+
noFuture: this.noFuture
|
38
|
+
})
|
39
|
+
this.addEvents()
|
40
|
+
}
|
41
|
+
|
42
|
+
handleMonthInputFocus() {
|
43
|
+
const { monthInput } = this
|
44
|
+
monthInput.clearStatus()
|
45
|
+
monthInput.setActive(true)
|
46
|
+
this.monthMenu.show(this.dom)
|
47
|
+
}
|
48
|
+
|
49
|
+
handleMonthInputKeyUp(event) {
|
50
|
+
const { monthInput } = this
|
51
|
+
const { value } = event.target
|
52
|
+
const res = parse(value, monthInput.datePattern, this.date)
|
53
|
+
|
54
|
+
if (res.toString() === 'Invalid Date') {
|
55
|
+
monthInput.setDanger(true)
|
56
|
+
this.nextDate = null
|
57
|
+
}
|
58
|
+
else {
|
59
|
+
monthInput.setDanger(false)
|
60
|
+
this.nextDate = res
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
handleMonthInputBlur() {
|
65
|
+
if (this.nextDate) {
|
66
|
+
this.date = this.nextDate
|
67
|
+
this.menuDate = this.date
|
68
|
+
this.monthMenu.setDate(this.menuDate)
|
69
|
+
this.nextDate = null
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
addEvents() {
|
74
|
+
const { monthInput } = this
|
75
|
+
monthInput.on('focus', () => this.handleMonthInputFocus())
|
76
|
+
monthInput.on('click', event => event.stopPropagation())
|
77
|
+
monthInput.on('keyup', event => this.handleMonthInputKeyUp(event))
|
78
|
+
monthInput.on('blur', () => this.handleMonthInputBlur())
|
79
|
+
|
80
|
+
if (this.backdropMode === 'auto') {
|
81
|
+
this.addEvent(document, 'click', () => {
|
82
|
+
this.monthMenu.hide()
|
83
|
+
this.monthInput.clearStatus()
|
84
|
+
})
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
destroy() {
|
89
|
+
this.monthInput.destroy()
|
90
|
+
this.monthMenu.destroy()
|
91
|
+
}
|
92
|
+
}
|
data/src/js/index.js
CHANGED
@@ -14,6 +14,8 @@ import DateTimeRanger from './components/DateTimeRanger'
|
|
14
14
|
import Datepicker from './components/Datepicker'
|
15
15
|
import Dropdown from './components/Dropdown'
|
16
16
|
import LineChart from './components/LineChart'
|
17
|
+
import Monthpicker from './components/Monthpicker'
|
18
|
+
import MonthMenu from './components/MonthMenu'
|
17
19
|
import Menu from './components/Menu'
|
18
20
|
import Modal from './components/Modal'
|
19
21
|
import Navbar from './components/Navbar'
|
@@ -51,6 +53,8 @@ export {
|
|
51
53
|
Datepicker,
|
52
54
|
Dropdown,
|
53
55
|
LineChart,
|
56
|
+
Monthpicker,
|
57
|
+
MonthMenu,
|
54
58
|
Menu,
|
55
59
|
Modal,
|
56
60
|
Navbar,
|
data/src/js/utils/index.js
CHANGED
@@ -9,6 +9,8 @@ import toPixel from '@superlanding/topixel'
|
|
9
9
|
// date-fns
|
10
10
|
import addDays from 'date-fns/addDays'
|
11
11
|
import addMonths from 'date-fns/addMonths'
|
12
|
+
import subYears from 'date-fns/subYears'
|
13
|
+
import addYears from 'date-fns/addYears'
|
12
14
|
import compareAsc from 'date-fns/compareAsc'
|
13
15
|
import endOfDay from 'date-fns/endOfDay'
|
14
16
|
import endOfMonth from 'date-fns/endOfMonth'
|
@@ -18,16 +20,20 @@ import getHours from 'date-fns/getHours'
|
|
18
20
|
import getMinutes from 'date-fns/getMinutes'
|
19
21
|
import getMonth from 'date-fns/getMonth'
|
20
22
|
import getSeconds from 'date-fns/getSeconds'
|
23
|
+
import setYear from 'date-fns/setYear'
|
21
24
|
import getYear from 'date-fns/getYear'
|
22
25
|
import parse from 'date-fns/parse'
|
23
26
|
import set from 'date-fns/set'
|
27
|
+
import setMonth from 'date-fns/setMonth'
|
24
28
|
import startOfDay from 'date-fns/startOfDay'
|
25
29
|
import startOfMonth from 'date-fns/startOfMonth'
|
26
30
|
import subMonths from 'date-fns/subMonths'
|
27
31
|
import toDate from 'date-fns/toDate'
|
32
|
+
import isFuture from 'date-fns/isFuture'
|
28
33
|
import { format } from 'date-fns-tz'
|
29
34
|
|
30
35
|
// lodash
|
36
|
+
import chunk from 'lodash.chunk'
|
31
37
|
import debounce from 'lodash.debounce'
|
32
38
|
import isFunction from 'lodash.isfunction'
|
33
39
|
import noop from 'lodash.noop'
|
@@ -50,6 +56,8 @@ export {
|
|
50
56
|
// date-fns
|
51
57
|
addDays,
|
52
58
|
addMonths,
|
59
|
+
addYears,
|
60
|
+
subYears,
|
53
61
|
compareAsc,
|
54
62
|
endOfDay,
|
55
63
|
endOfMonth,
|
@@ -59,16 +67,20 @@ export {
|
|
59
67
|
getMinutes,
|
60
68
|
getMonth,
|
61
69
|
getSeconds,
|
70
|
+
setYear,
|
62
71
|
getYear,
|
63
72
|
parse,
|
64
73
|
set,
|
74
|
+
setMonth,
|
65
75
|
startOfDay,
|
66
76
|
startOfMonth,
|
67
77
|
subMonths,
|
68
78
|
toDate,
|
79
|
+
isFuture,
|
69
80
|
format,
|
70
81
|
|
71
82
|
// lodash
|
83
|
+
chunk,
|
72
84
|
debounce,
|
73
85
|
isFunction,
|
74
86
|
noop,
|
data/src/sass/_beyond.scss
CHANGED
@@ -26,6 +26,7 @@
|
|
26
26
|
@import './components/_checkbox';
|
27
27
|
@import './components/_date-input';
|
28
28
|
@import './components/_date-menu';
|
29
|
+
@import './components/_month-menu';
|
29
30
|
@import './components/_date-time-ranger';
|
30
31
|
@import './components/_datepicker';
|
31
32
|
@import './components/_dropdown';
|
@@ -0,0 +1,74 @@
|
|
1
|
+
.month-menu {
|
2
|
+
display: none;
|
3
|
+
position: absolute;
|
4
|
+
box-shadow: 0 0 0 1px rgba(136, 152, 170, .1),
|
5
|
+
0 15px 35px 0 rgba(49, 49, 93, .1),
|
6
|
+
0 5px 15px 0 rgba(0, 0, 0, .08);
|
7
|
+
background-color: #fff;
|
8
|
+
white-space: nowrap;
|
9
|
+
&.static {
|
10
|
+
display: inline-block;
|
11
|
+
position: static;
|
12
|
+
}
|
13
|
+
.month-menu-content {
|
14
|
+
display: inline-block;
|
15
|
+
position: relative;
|
16
|
+
padding: 0 14px 14px 14px;
|
17
|
+
width: 252px;
|
18
|
+
}
|
19
|
+
.month-menu-caption {
|
20
|
+
display: flex;
|
21
|
+
justify-content: space-between;
|
22
|
+
font-size: 15px;
|
23
|
+
color: #3c4257;
|
24
|
+
text-align: center;
|
25
|
+
height: 50px;
|
26
|
+
line-height: 50px;
|
27
|
+
}
|
28
|
+
.month-menu-caption-btn {
|
29
|
+
border: 0;
|
30
|
+
background-color: transparent;
|
31
|
+
display: block;
|
32
|
+
@include size(50px);
|
33
|
+
|
34
|
+
.icon-chevron-left,
|
35
|
+
.icon-chevron-right {
|
36
|
+
font-size: 12px;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
.month-menu-table {
|
40
|
+
font-size: 14px;
|
41
|
+
width: 100%;
|
42
|
+
margin-top: 2px;
|
43
|
+
th, td {
|
44
|
+
padding: 3px;
|
45
|
+
}
|
46
|
+
td {
|
47
|
+
text-align: center;
|
48
|
+
&.cell {
|
49
|
+
background-color: #f7fafc;
|
50
|
+
cursor: pointer;
|
51
|
+
border-width: 1px;
|
52
|
+
border-style: solid;
|
53
|
+
border-color: #e3e8ee;
|
54
|
+
}
|
55
|
+
&.cell.today {
|
56
|
+
background-color: #fffef4;
|
57
|
+
}
|
58
|
+
&.cell.selected {
|
59
|
+
background-color: #6c8eef;
|
60
|
+
color: #fff;
|
61
|
+
border-color: #6c8eef;
|
62
|
+
}
|
63
|
+
&.cell.js-disabled {
|
64
|
+
opacity: .4;
|
65
|
+
cursor: not-allowed;
|
66
|
+
}
|
67
|
+
&.cell.selected-ex {
|
68
|
+
background-color: #5469d4;
|
69
|
+
color: #fff;
|
70
|
+
border-color: #5469d4;
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
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.
|
4
|
+
version: 0.0.250
|
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-11-
|
12
|
+
date: 2020-11-19 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: []
|
@@ -139,6 +139,9 @@ files:
|
|
139
139
|
- src/js/components/LineChart.js
|
140
140
|
- src/js/components/Menu.js
|
141
141
|
- src/js/components/Modal.js
|
142
|
+
- src/js/components/MonthInput.js
|
143
|
+
- src/js/components/MonthMenu.js
|
144
|
+
- src/js/components/Monthpicker.js
|
142
145
|
- src/js/components/Navbar.js
|
143
146
|
- src/js/components/PieChart.js
|
144
147
|
- src/js/components/Radio.js
|
@@ -235,6 +238,7 @@ files:
|
|
235
238
|
- src/sass/components/_list.scss
|
236
239
|
- src/sass/components/_mega-menu.scss
|
237
240
|
- src/sass/components/_modal.scss
|
241
|
+
- src/sass/components/_month-menu.scss
|
238
242
|
- src/sass/components/_nav.scss
|
239
243
|
- src/sass/components/_navbar.scss
|
240
244
|
- src/sass/components/_pagination.scss
|
@@ -269,7 +273,7 @@ homepage: https://superlanding.github.io/beyond/
|
|
269
273
|
licenses:
|
270
274
|
- MIT
|
271
275
|
metadata: {}
|
272
|
-
post_install_message:
|
276
|
+
post_install_message:
|
273
277
|
rdoc_options: []
|
274
278
|
require_paths:
|
275
279
|
- lib
|
@@ -284,8 +288,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
284
288
|
- !ruby/object:Gem::Version
|
285
289
|
version: '0'
|
286
290
|
requirements: []
|
287
|
-
rubygems_version: 3.0.
|
288
|
-
signing_key:
|
291
|
+
rubygems_version: 3.0.8
|
292
|
+
signing_key:
|
289
293
|
specification_version: 4
|
290
294
|
summary: beyond is a collection of frontend components which aims for admin website.
|
291
295
|
test_files: []
|