funicular-datepicker 0.1.2 → 0.2.0
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/lib/components/date_picker_component.rb +33 -33
- metadata +16 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0cccdef7050f58fdae30fccc488a56e5015674d0e1fe00f1639f5fdad238fc67
|
|
4
|
+
data.tar.gz: 394fa0df64acc89c947c36bae88c621f435373f977bfb0098346cfc1f00e2e27
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 43936b1c205fcd1e365e9d591a8628c0475a59b38731a162dd6c4dbbb90b4173475f8bcaf9bd10cf154a84f4547aa060b97fdf7711266bc967dc5cab323ec334
|
|
7
|
+
data.tar.gz: 3c27d85680a4002065382787fd8b8a003f4e178a802b6fcd6b921915ac77b4b6a747e7d16ff1ef3747c98ec5b47195371cb07842070cd5b1ade266fafd613d53
|
|
@@ -20,8 +20,8 @@ class DatePickerComponent < Funicular::Component
|
|
|
20
20
|
year, month, = parse_date(props[:value])
|
|
21
21
|
patch(
|
|
22
22
|
calendar_open: true,
|
|
23
|
-
view_year: year || state
|
|
24
|
-
view_month: month || state
|
|
23
|
+
view_year: year || state[:view_year],
|
|
24
|
+
view_month: month || state[:view_month]
|
|
25
25
|
)
|
|
26
26
|
end
|
|
27
27
|
|
|
@@ -30,18 +30,18 @@ class DatePickerComponent < Funicular::Component
|
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def prev_month
|
|
33
|
-
if state
|
|
34
|
-
patch(view_year: state
|
|
33
|
+
if state[:view_month] == 1
|
|
34
|
+
patch(view_year: state[:view_year] - 1, view_month: 12)
|
|
35
35
|
else
|
|
36
|
-
patch(view_month: state
|
|
36
|
+
patch(view_month: state[:view_month] - 1)
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def next_month
|
|
41
|
-
if state
|
|
42
|
-
patch(view_year: state
|
|
41
|
+
if state[:view_month] == 12
|
|
42
|
+
patch(view_year: state[:view_year] + 1, view_month: 1)
|
|
43
43
|
else
|
|
44
|
-
patch(view_month: state
|
|
44
|
+
patch(view_month: state[:view_month] + 1)
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
47
|
|
|
@@ -55,15 +55,15 @@ class DatePickerComponent < Funicular::Component
|
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
def select_day(day)
|
|
58
|
-
value = date_string(state
|
|
58
|
+
value = date_string(state[:view_year], state[:view_month], day)
|
|
59
59
|
emit_change(value)
|
|
60
60
|
patch(calendar_open: false)
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
-
def render
|
|
64
|
-
div(class: "funicular-date-picker") do
|
|
65
|
-
div(class: "funicular-date-picker__input_row") do
|
|
66
|
-
input(
|
|
63
|
+
def render(h)
|
|
64
|
+
h.div(class: "funicular-date-picker") do
|
|
65
|
+
h.div(class: "funicular-date-picker__input_row") do
|
|
66
|
+
h.input(
|
|
67
67
|
type: "text",
|
|
68
68
|
name: props[:name],
|
|
69
69
|
value: props[:value].to_s,
|
|
@@ -72,10 +72,10 @@ class DatePickerComponent < Funicular::Component
|
|
|
72
72
|
oninput: :handle_input,
|
|
73
73
|
onfocus: -> { open_calendar }
|
|
74
74
|
)
|
|
75
|
-
button(type: "button", class: button_class, onclick: -> { open_calendar }) { "Calendar" }
|
|
75
|
+
h.button(type: "button", class: button_class, onclick: -> { open_calendar }) { "Calendar" }
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
-
render_calendar if state
|
|
78
|
+
render_calendar(h) if state[:calendar_open]
|
|
79
79
|
end
|
|
80
80
|
end
|
|
81
81
|
|
|
@@ -85,31 +85,31 @@ class DatePickerComponent < Funicular::Component
|
|
|
85
85
|
props[:button_class] || "funicular-date-picker__button"
|
|
86
86
|
end
|
|
87
87
|
|
|
88
|
-
def render_calendar
|
|
89
|
-
div(class: "funicular-date-picker__panel") do
|
|
90
|
-
div(class: "funicular-date-picker__header") do
|
|
91
|
-
button(type: "button", class: "funicular-date-picker__nav", onclick: -> { prev_month }) { "<" }
|
|
92
|
-
div(class: "funicular-date-picker__month") do
|
|
93
|
-
"#{MONTH_NAMES[state
|
|
88
|
+
def render_calendar(h)
|
|
89
|
+
h.div(class: "funicular-date-picker__panel") do
|
|
90
|
+
h.div(class: "funicular-date-picker__header") do
|
|
91
|
+
h.button(type: "button", class: "funicular-date-picker__nav", onclick: -> { prev_month }) { "<" }
|
|
92
|
+
h.div(class: "funicular-date-picker__month") do
|
|
93
|
+
"#{MONTH_NAMES[state[:view_month] - 1]} #{state[:view_year]}"
|
|
94
94
|
end
|
|
95
|
-
button(type: "button", class: "funicular-date-picker__nav", onclick: -> { next_month }) { ">" }
|
|
95
|
+
h.button(type: "button", class: "funicular-date-picker__nav", onclick: -> { next_month }) { ">" }
|
|
96
96
|
end
|
|
97
97
|
|
|
98
|
-
div(class: "funicular-date-picker__grid") do
|
|
98
|
+
h.div(class: "funicular-date-picker__grid") do
|
|
99
99
|
WEEKDAYS.each do |day|
|
|
100
|
-
div(class: "funicular-date-picker__weekday") { day }
|
|
100
|
+
h.div(class: "funicular-date-picker__weekday") { day }
|
|
101
101
|
end
|
|
102
102
|
|
|
103
|
-
first_weekday(state
|
|
104
|
-
div(class: "funicular-date-picker__empty") { "" }
|
|
103
|
+
first_weekday(state[:view_year], state[:view_month]).times do
|
|
104
|
+
h.div(class: "funicular-date-picker__empty") { "" }
|
|
105
105
|
end
|
|
106
106
|
|
|
107
107
|
selected_year, selected_month, selected_day = parse_date(props[:value])
|
|
108
|
-
(1..days_in_month(state
|
|
109
|
-
selected = selected_year == state
|
|
110
|
-
selected_month == state
|
|
108
|
+
(1..days_in_month(state[:view_year], state[:view_month])).each do |day|
|
|
109
|
+
selected = selected_year == state[:view_year] &&
|
|
110
|
+
selected_month == state[:view_month] &&
|
|
111
111
|
selected_day == day
|
|
112
|
-
button(
|
|
112
|
+
h.button(
|
|
113
113
|
type: "button",
|
|
114
114
|
class: selected ? "funicular-date-picker__day funicular-date-picker__day--selected" : "funicular-date-picker__day",
|
|
115
115
|
onclick: -> { select_day(day) }
|
|
@@ -119,9 +119,9 @@ class DatePickerComponent < Funicular::Component
|
|
|
119
119
|
end
|
|
120
120
|
end
|
|
121
121
|
|
|
122
|
-
div(class: "funicular-date-picker__footer") do
|
|
123
|
-
button(type: "button", class: "funicular-date-picker__footer_button", onclick: -> { clear }) { "Clear" }
|
|
124
|
-
button(type: "button", class: "funicular-date-picker__footer_button", onclick: -> { close_calendar }) { "Close" }
|
|
122
|
+
h.div(class: "funicular-date-picker__footer") do
|
|
123
|
+
h.button(type: "button", class: "funicular-date-picker__footer_button", onclick: -> { clear }) { "Clear" }
|
|
124
|
+
h.button(type: "button", class: "funicular-date-picker__footer_button", onclick: -> { close_calendar }) { "Close" }
|
|
125
125
|
end
|
|
126
126
|
end
|
|
127
127
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: funicular-datepicker
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- HASUMI Hitoshi
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
-
dependencies:
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: funicular
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: 0.3.0
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: 0.3.0
|
|
12
26
|
description: A Funicular date picker component packaged as a Ruby-script CRubygem.
|
|
13
27
|
email:
|
|
14
28
|
- hasumikin@gmail.com
|