beyond-rails 0.0.166 → 0.0.171
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/js/components/Datepicker.js +4 -0
- data/src/js/components/Dropdown.js +4 -0
- data/src/js/components/Timepicker.js +131 -0
- data/src/js/index.js +2 -0
- data/src/sass/_main.scss +8 -0
- data/src/sass/components/_form.scss +3 -0
- data/src/sass/components/_input.scss +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b84dbd1920d2a65c0435e41614a3ddf98649ee787afc7e8f69d4e5c72f436d83
|
4
|
+
data.tar.gz: 575de4b1d3e26e92f1b8d1e6dd78dcb1e65473f009fe9b1c33d66be189afaffb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b0ed1fc46eeb29dae5fd2f8055dddc168102071b47f745a990c30c143baf65f5694df46770d8a97721dd8bf469ff73d130907e8dcabf016f0fa8ac3fa0c5487
|
7
|
+
data.tar.gz: 6b2f28021ed4a0e68309aada0c81ce3ac94b41ebce2c7916ff81f322e36b917a397ca5ad29b2788a71b967646804c5b6a74e8c807101df886b43dfb8c117b331
|
@@ -24,6 +24,7 @@ export default class Datepicker {
|
|
24
24
|
this.menuDate = (timestamp === null) ? toDate(new Date()) : toDate(this.date)
|
25
25
|
this.focused = false
|
26
26
|
this.nextDate = null
|
27
|
+
this.backdropMode = options.backdropMode || 'auto'
|
27
28
|
this.init()
|
28
29
|
}
|
29
30
|
|
@@ -225,6 +226,9 @@ export default class Datepicker {
|
|
225
226
|
this.focused = false
|
226
227
|
return
|
227
228
|
}
|
229
|
+
if (this.backdropMode === 'manual') {
|
230
|
+
return
|
231
|
+
}
|
228
232
|
if ((! dateMenu.isVisible) && (timeMenu && (! timeMenu.isVisible))) {
|
229
233
|
return
|
230
234
|
}
|
@@ -15,6 +15,7 @@ export default class Dropdown {
|
|
15
15
|
this.align = null
|
16
16
|
this.defaultTextNode = this.getDefaultTextNode(dom, options.textIndex)
|
17
17
|
this.defaultText = this.defaultTextNode ? this.defaultTextNode.textContent.trim() : ''
|
18
|
+
this.backdropMode = options.backdropMode || 'auto'
|
18
19
|
this.init()
|
19
20
|
}
|
20
21
|
|
@@ -121,6 +122,9 @@ export default class Dropdown {
|
|
121
122
|
if (! this.isMenuVisible) {
|
122
123
|
return
|
123
124
|
}
|
125
|
+
if (this.backdropMode === 'manual') {
|
126
|
+
return
|
127
|
+
}
|
124
128
|
// is backdrop
|
125
129
|
if ((event.target !== this.dom) && (! this.dom.contains(event.target))) {
|
126
130
|
this.hideMenu()
|
@@ -0,0 +1,131 @@
|
|
1
|
+
import parse from 'date-fns/parse'
|
2
|
+
import set from 'date-fns/set'
|
3
|
+
import noop from 'lodash.noop'
|
4
|
+
import TimeInput from './TimeInput'
|
5
|
+
import TimeMenu from './TimeMenu'
|
6
|
+
import supportDom from '../helpers/supportDom'
|
7
|
+
import { DEFAULT_TIMEZONE } from '../consts'
|
8
|
+
import dateToTimestamp from '@superlanding/datetotimestamp'
|
9
|
+
import timestampToDate from '@superlanding/timestamptodate'
|
10
|
+
|
11
|
+
@supportDom
|
12
|
+
export default class Timepicker {
|
13
|
+
|
14
|
+
constructor(dom, timestamp, options = {}) {
|
15
|
+
this.dom = dom
|
16
|
+
this.options = options
|
17
|
+
this.options.change = options.change || noop
|
18
|
+
this.tz = options.tz || DEFAULT_TIMEZONE
|
19
|
+
|
20
|
+
this.date = (timestamp === null) ? null : timestampToDate(timestamp)
|
21
|
+
this.focused = false
|
22
|
+
this.backdropMode = options.backdropMode || 'auto'
|
23
|
+
this.init()
|
24
|
+
}
|
25
|
+
|
26
|
+
init() {
|
27
|
+
this.timeInput = new TimeInput(
|
28
|
+
this.dom,
|
29
|
+
this.date,
|
30
|
+
this.options
|
31
|
+
)
|
32
|
+
this.timeMenu = new TimeMenu()
|
33
|
+
this.addEvents()
|
34
|
+
}
|
35
|
+
|
36
|
+
clearInputStatus() {
|
37
|
+
this.timeInput.clearStatus()
|
38
|
+
}
|
39
|
+
|
40
|
+
handleTimeInputFocus() {
|
41
|
+
const { timeInput } = this
|
42
|
+
this.focused = true
|
43
|
+
this.clearInputStatus()
|
44
|
+
timeInput.setActive(true)
|
45
|
+
this.timeMenu.show({ src: this.dom, date: timeInput.date })
|
46
|
+
}
|
47
|
+
|
48
|
+
handleTimeInputKeyUp(event) {
|
49
|
+
const { date, timeInput } = this
|
50
|
+
const { value } = event.target
|
51
|
+
|
52
|
+
if ((! timeInput.required) && (value === '')) {
|
53
|
+
this.nextDate = null
|
54
|
+
return
|
55
|
+
}
|
56
|
+
const res = parse(event.target.value, timeInput.timePattern, date)
|
57
|
+
this.nextDate = null
|
58
|
+
|
59
|
+
if (res.toString() === 'Invalid Date') {
|
60
|
+
return timeInput.setDanger(true)
|
61
|
+
}
|
62
|
+
timeInput.setDanger(false)
|
63
|
+
this.nextDate = res
|
64
|
+
}
|
65
|
+
|
66
|
+
handleTimeInputBlur() {
|
67
|
+
const { nextDate, date, timeInput } = this
|
68
|
+
|
69
|
+
if (nextDate) {
|
70
|
+
this.date = nextDate
|
71
|
+
timeInput.setDate(nextDate)
|
72
|
+
this.nextDate = null
|
73
|
+
}
|
74
|
+
else if (date) {
|
75
|
+
timeInput.setDate(date)
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
emitChange() {
|
80
|
+
const { date } = this
|
81
|
+
this.options.change({
|
82
|
+
date,
|
83
|
+
timestamp: dateToTimestamp(date)
|
84
|
+
})
|
85
|
+
}
|
86
|
+
|
87
|
+
hide() {
|
88
|
+
this.focused = false
|
89
|
+
this.clearInputStatus()
|
90
|
+
this.timeMenu.hide()
|
91
|
+
}
|
92
|
+
|
93
|
+
addEvents() {
|
94
|
+
|
95
|
+
this.timeInput.on('focus', () => this.handleTimeInputFocus())
|
96
|
+
this.timeInput.on('keyup', event => this.handleTimeInputKeyUp(event))
|
97
|
+
this.timeInput.on('blur', () => this.handleTimeInputBlur())
|
98
|
+
|
99
|
+
this.timeMenu.on('click', (event, res) => {
|
100
|
+
if (this.date === null) {
|
101
|
+
this.date = set(new Date(), { hours: res.hour, minutes: res.minute })
|
102
|
+
}
|
103
|
+
else {
|
104
|
+
this.date = set(this.date, { hours: res.hour, minutes: res.minute })
|
105
|
+
}
|
106
|
+
this.timeInput.setDate(this.date)
|
107
|
+
this.timeMenu.hide()
|
108
|
+
this.clearInputStatus()
|
109
|
+
this.emitChange()
|
110
|
+
})
|
111
|
+
|
112
|
+
this.addEvent(document, 'click', event => {
|
113
|
+
if (this.focused) {
|
114
|
+
this.focused = false
|
115
|
+
return
|
116
|
+
}
|
117
|
+
if (this.backdropMode === 'manual') {
|
118
|
+
return
|
119
|
+
}
|
120
|
+
if (event.target === this.dom) {
|
121
|
+
return
|
122
|
+
}
|
123
|
+
this.hide()
|
124
|
+
})
|
125
|
+
}
|
126
|
+
|
127
|
+
destroy() {
|
128
|
+
this.timeInput.destroy()
|
129
|
+
this.timeMenu.destroy()
|
130
|
+
}
|
131
|
+
}
|
data/src/js/index.js
CHANGED
@@ -17,6 +17,7 @@ import Navbar from './components/Navbar'
|
|
17
17
|
import Radio from './components/Radio'
|
18
18
|
import SearchDropdown from './components/SearchDropdown'
|
19
19
|
import Sidebar from './components/Sidebar'
|
20
|
+
import Timepicker from './components/Timepicker'
|
20
21
|
import Tabbox from './components/Tabbox'
|
21
22
|
import Toast from './components/Toast'
|
22
23
|
import Tooltip from './components/Tooltip'
|
@@ -38,6 +39,7 @@ export {
|
|
38
39
|
Radio,
|
39
40
|
SearchDropdown,
|
40
41
|
Sidebar,
|
42
|
+
Timepicker,
|
41
43
|
Tabbox,
|
42
44
|
Toast,
|
43
45
|
Tooltip,
|
data/src/sass/_main.scss
CHANGED
@@ -122,6 +122,9 @@ $color-active: #5469d4;
|
|
122
122
|
-webkit-overflow-scrolling: touch;
|
123
123
|
}
|
124
124
|
|
125
|
+
.align-left {
|
126
|
+
text-align: left;
|
127
|
+
}
|
125
128
|
.align-right {
|
126
129
|
text-align: right;
|
127
130
|
}
|
@@ -140,3 +143,8 @@ $color-active: #5469d4;
|
|
140
143
|
clip-path: inset(50%);
|
141
144
|
border: 0;
|
142
145
|
}
|
146
|
+
|
147
|
+
input[type=file], /* FF, IE7+, chrome (except button) */
|
148
|
+
input[type=file]::-webkit-file-upload-button { /* chromes and blink button */
|
149
|
+
cursor: pointer;
|
150
|
+
}
|
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.
|
4
|
+
version: 0.0.171
|
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-05
|
12
|
+
date: 2020-06-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sassc
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- src/js/components/Tabbox.js
|
113
113
|
- src/js/components/TimeInput.js
|
114
114
|
- src/js/components/TimeMenu.js
|
115
|
+
- src/js/components/Timepicker.js
|
115
116
|
- src/js/components/Toast.js
|
116
117
|
- src/js/components/ToastItem.js
|
117
118
|
- src/js/components/Tooltip.js
|