funicular-datepicker 0.1.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d95ca094c408765d950bfdbcb1af695783998e7d1a7f64a334f46dfe7fb1dae
4
- data.tar.gz: 54c5927016a32b382ba639c3542e60da0bcd625d4aefdc02a311bb9670cb7901
3
+ metadata.gz: 0cccdef7050f58fdae30fccc488a56e5015674d0e1fe00f1639f5fdad238fc67
4
+ data.tar.gz: 394fa0df64acc89c947c36bae88c621f435373f977bfb0098346cfc1f00e2e27
5
5
  SHA512:
6
- metadata.gz: c37569a0336ec47423b204692d129537afe7f81ac4492d7ed19921899ed98440b5d1d05aea86ebc4f0d514f854d755894c1609d726cad485c67df9159490da45
7
- data.tar.gz: 8ddb59f662b6a631fd3e5775ee4bd9a486e79116d90e01f5f4acf4e05e0ffe7dc366506f02c928d222ca2f448df623912f1dc4083c9941446aace39e67958323
6
+ metadata.gz: 43936b1c205fcd1e365e9d591a8628c0475a59b38731a162dd6c4dbbb90b4173475f8bcaf9bd10cf154a84f4547aa060b97fdf7711266bc967dc5cab323ec334
7
+ data.tar.gz: 3c27d85680a4002065382787fd8b8a003f4e178a802b6fcd6b921915ac77b4b6a747e7d16ff1ef3747c98ec5b47195371cb07842070cd5b1ade266fafd613d53
data/README.md CHANGED
@@ -13,6 +13,7 @@ end
13
13
  ```ruby
14
14
  component(
15
15
  Funicular::Plugins::DatePicker::Component,
16
+ name: "birthday",
16
17
  value: state.birthday,
17
18
  input_class: "birthday-input",
18
19
  button_class: "birthday-calendar-button",
@@ -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.view_year,
24
- view_month: month || state.view_month
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.view_month == 1
34
- patch(view_year: state.view_year - 1, view_month: 12)
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.view_month - 1)
36
+ patch(view_month: state[:view_month] - 1)
37
37
  end
38
38
  end
39
39
 
40
40
  def next_month
41
- if state.view_month == 12
42
- patch(view_year: state.view_year + 1, view_month: 1)
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.view_month + 1)
44
+ patch(view_month: state[:view_month] + 1)
45
45
  end
46
46
  end
47
47
 
@@ -55,26 +55,27 @@ class DatePickerComponent < Funicular::Component
55
55
  end
56
56
 
57
57
  def select_day(day)
58
- value = date_string(state.view_year, state.view_month, day)
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
+ name: props[:name],
68
69
  value: props[:value].to_s,
69
70
  placeholder: props[:placeholder] || "YYYY-MM-DD",
70
71
  class: props[:input_class] || "funicular-date-picker__input",
71
72
  oninput: :handle_input,
72
73
  onfocus: -> { open_calendar }
73
74
  )
74
- button(type: "button", class: button_class, onclick: -> { open_calendar }) { "Calendar" }
75
+ h.button(type: "button", class: button_class, onclick: -> { open_calendar }) { "Calendar" }
75
76
  end
76
77
 
77
- render_calendar if state.calendar_open
78
+ render_calendar(h) if state[:calendar_open]
78
79
  end
79
80
  end
80
81
 
@@ -84,31 +85,31 @@ class DatePickerComponent < Funicular::Component
84
85
  props[:button_class] || "funicular-date-picker__button"
85
86
  end
86
87
 
87
- def render_calendar
88
- div(class: "funicular-date-picker__panel") do
89
- div(class: "funicular-date-picker__header") do
90
- button(type: "button", class: "funicular-date-picker__nav", onclick: -> { prev_month }) { "<" }
91
- div(class: "funicular-date-picker__month") do
92
- "#{MONTH_NAMES[state.view_month - 1]} #{state.view_year}"
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]}"
93
94
  end
94
- button(type: "button", class: "funicular-date-picker__nav", onclick: -> { next_month }) { ">" }
95
+ h.button(type: "button", class: "funicular-date-picker__nav", onclick: -> { next_month }) { ">" }
95
96
  end
96
97
 
97
- div(class: "funicular-date-picker__grid") do
98
+ h.div(class: "funicular-date-picker__grid") do
98
99
  WEEKDAYS.each do |day|
99
- div(class: "funicular-date-picker__weekday") { day }
100
+ h.div(class: "funicular-date-picker__weekday") { day }
100
101
  end
101
102
 
102
- first_weekday(state.view_year, state.view_month).times do
103
- 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") { "" }
104
105
  end
105
106
 
106
107
  selected_year, selected_month, selected_day = parse_date(props[:value])
107
- (1..days_in_month(state.view_year, state.view_month)).each do |day|
108
- selected = selected_year == state.view_year &&
109
- selected_month == state.view_month &&
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] &&
110
111
  selected_day == day
111
- button(
112
+ h.button(
112
113
  type: "button",
113
114
  class: selected ? "funicular-date-picker__day funicular-date-picker__day--selected" : "funicular-date-picker__day",
114
115
  onclick: -> { select_day(day) }
@@ -118,9 +119,9 @@ class DatePickerComponent < Funicular::Component
118
119
  end
119
120
  end
120
121
 
121
- div(class: "funicular-date-picker__footer") do
122
- button(type: "button", class: "funicular-date-picker__footer_button", onclick: -> { clear }) { "Clear" }
123
- 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" }
124
125
  end
125
126
  end
126
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.1.1
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