recurrence_ui 0.1.0 → 0.2.1
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/README.md +52 -4
- data/app/javascript/recurrence_ui/index.js +1 -14
- data/config/importmap.rb +4 -1
- data/lib/generators/recurrence_ui/install/install_generator.rb +30 -0
- data/lib/recurrence_ui/engine.rb +9 -34
- data/lib/recurrence_ui/version.rb +1 -1
- metadata +17 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3e6f3005d6cd808a8fe574323a864f24fb6c17936e0e162227787cbbcf07d5ce
|
|
4
|
+
data.tar.gz: 687543fd54f2ff1e9a6e867734b19baf01be6d111bee6a5ded59268c75a8c5ec
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1cb389646f40f9ec058b2f1c6cfa97f7986804a1c0751a3b815ff35c1468443df43334879476d17fe2546bb0a0b03be1b112b3be2e2e27756eb078f432a09e1b
|
|
7
|
+
data.tar.gz: 706ee82b13e5cd4e5208ed47060f70b6de1360c35a75ca44242bd3911af8e6727a2cd5cdc7bbe5cef82750c97afe376079aff243bc2935d8ba04afa622aa5f17
|
data/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Built on top of [ice_cube](https://github.com/ice-cube-ruby/ice_cube), it provides reusable UI components powered by [ViewComponent](https://viewcomponent.org/) and styled with Tailwind CSS.
|
|
6
6
|
|
|
7
|
-
[](https://rubygems.org/gems/recurrence_ui)
|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
|
9
9
|
|
|
10
10
|
## ✨ Features
|
|
@@ -107,11 +107,11 @@ Use the attribute names that match your application's database schema and the at
|
|
|
107
107
|
|
|
108
108
|
## 🎨 View Integration
|
|
109
109
|
|
|
110
|
-
Render the recurrence editor inside a Rails form using `RecurrenceUi::
|
|
110
|
+
Render the recurrence editor inside a Rails form using `RecurrenceUi::RecurrencePickerComponent`:
|
|
111
111
|
|
|
112
112
|
```erb
|
|
113
113
|
<%= form_with model: @event do |form| %>
|
|
114
|
-
<%= render RecurrenceUi::
|
|
114
|
+
<%= render RecurrenceUi::RecurrencePickerComponent.new(
|
|
115
115
|
form: form,
|
|
116
116
|
record: @event,
|
|
117
117
|
locale: params[:locale],
|
|
@@ -125,6 +125,46 @@ Render the recurrence editor inside a Rails form using `RecurrenceUi::FormContai
|
|
|
125
125
|
|
|
126
126
|
The `locale`, `time_zone`, and `week_start` options can be supplied dynamically when needed. If omitted, the component can use the applicable defaults provided by your integration.
|
|
127
127
|
|
|
128
|
+
Add required params to controller of your Model.
|
|
129
|
+
```erb
|
|
130
|
+
def event_params
|
|
131
|
+
params.require(:event).permit(
|
|
132
|
+
#other params
|
|
133
|
+
*Event.recurrence_permitted_params # add this with name of your Model
|
|
134
|
+
)
|
|
135
|
+
end
|
|
136
|
+
```
|
|
137
|
+
Configure gem:
|
|
138
|
+
```erb
|
|
139
|
+
# config/initializers/recurrence_ui.rb
|
|
140
|
+
require "recurrence_ui"
|
|
141
|
+
RecurrenceUi.configure do |config|
|
|
142
|
+
config.locale = :en # Default locale for all components of the gem (if no locale is passed to the component)
|
|
143
|
+
config.time_zone = "Asia/Tokyo" # Default time zone for all components of the gem (if no time_zone is passed to the component)
|
|
144
|
+
config.week_start = 1 # Week starts on Monday
|
|
145
|
+
|
|
146
|
+
# Configuration for the enabled rule types in the UI:
|
|
147
|
+
config.enabled_rule_types = %w[
|
|
148
|
+
never
|
|
149
|
+
weekly
|
|
150
|
+
daily
|
|
151
|
+
monthly_by_day_of_month
|
|
152
|
+
]
|
|
153
|
+
# All other options will be filtered out, and the order will be preserved as specified above.
|
|
154
|
+
# config.enabled_rule_types = %w[
|
|
155
|
+
# never
|
|
156
|
+
# daily
|
|
157
|
+
# weekly
|
|
158
|
+
# monthly_by_day_of_month
|
|
159
|
+
# monthly_by_weekday
|
|
160
|
+
# yearly_by_day_of_month
|
|
161
|
+
# yearly_by_weekday
|
|
162
|
+
# ]
|
|
163
|
+
end
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
128
168
|
## 🌍 Internationalization
|
|
129
169
|
|
|
130
170
|
Recurrence UI currently supports the following locales:
|
|
@@ -170,6 +210,13 @@ For example:
|
|
|
170
210
|
|
|
171
211
|
Use the CSS variables supported by the gem to customize the interface. The example above illustrates the approach; available tokens and theme selectors depend on the styles provided by your version of Recurrence UI.
|
|
172
212
|
|
|
213
|
+
## 🚀 Example Application
|
|
214
|
+
|
|
215
|
+
If you want to see `recurrence_ui` in action, check out the [rails-recurrence-ui-dummy](https://github.com/assoly/rails-recurrence-ui-dummy) repository. It demonstrates a fully configured Ruby on Rails application featuring:
|
|
216
|
+
- Database models with `HasRecurrence` integration.
|
|
217
|
+
- Form views using `ViewComponent` and Tailwind CSS.
|
|
218
|
+
- Initializer and internationalization (i18n) setup.
|
|
219
|
+
|
|
173
220
|
## 🤝 Contributing
|
|
174
221
|
|
|
175
222
|
Contributions, bug reports, and feature requests are welcome!
|
|
@@ -192,6 +239,7 @@ To get started:
|
|
|
192
239
|
4. Create a branch, make your changes, and open a pull request.
|
|
193
240
|
|
|
194
241
|
Please make sure your changes are covered by tests where appropriate.
|
|
242
|
+
|
|
195
243
|
## 🧪 Testing
|
|
196
244
|
|
|
197
245
|
*Note: The test suite is currently under active development. Contributions are very welcome!*
|
|
@@ -205,4 +253,4 @@ Please make sure your changes are covered by tests where appropriate.
|
|
|
205
253
|
|
|
206
254
|
## 📄 License
|
|
207
255
|
|
|
208
|
-
Recurrence UI is available under the [MIT License](https://opensource.org/licenses/MIT).
|
|
256
|
+
Recurrence UI is available under the [MIT License](https://opensource.org/licenses/MIT).
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import RecurrenceUiController from "
|
|
1
|
+
import RecurrenceUiController from "recurrence_ui/recurrence_ui_controller"
|
|
2
2
|
|
|
3
3
|
export function registerRecurrenceUiController(application) {
|
|
4
4
|
if (application) {
|
|
@@ -6,17 +6,4 @@ export function registerRecurrenceUiController(application) {
|
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
// Automatically register the controller if Stimulus is already initialized
|
|
10
|
-
if (typeof window !== "undefined") {
|
|
11
|
-
if (window.Stimulus) {
|
|
12
|
-
window.Stimulus.register("recurrence-ui", RecurrenceUiController)
|
|
13
|
-
} else {
|
|
14
|
-
document.addEventListener("DOMContentLoaded", () => {
|
|
15
|
-
if (window.Stimulus) {
|
|
16
|
-
window.Stimulus.register("recurrence-ui", RecurrenceUiController)
|
|
17
|
-
}
|
|
18
|
-
})
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
9
|
export { RecurrenceUiController }
|
data/config/importmap.rb
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
# config/importmap.rb in the recurrence_ui gem
|
|
2
2
|
pin "recurrence_ui", to: "recurrence_ui/index.js"
|
|
3
|
-
pin "recurrence_ui/recurrence_ui_controller", to: "recurrence_ui/recurrence_ui_controller.js"
|
|
3
|
+
pin "recurrence_ui/recurrence_ui_controller", to: "recurrence_ui/recurrence_ui_controller.js"
|
|
4
|
+
|
|
5
|
+
# Явно указываем Importmap, где лежат файлы гема на диске
|
|
6
|
+
pin_all_from File.expand_path("../app/javascript/recurrence_ui", __dir__), under: "recurrence_ui"
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# recurrence_ui/lib/generators/recurrence_ui/install/install_generator.rb
|
|
2
|
+
module RecurrenceUi
|
|
3
|
+
module Generators
|
|
4
|
+
class InstallGenerator < Rails::Generators::Base
|
|
5
|
+
source_root File.expand_path("templates", __dir__)
|
|
6
|
+
|
|
7
|
+
desc "Installs RecurrenceUi JavaScript integration into the application"
|
|
8
|
+
|
|
9
|
+
def register_controller
|
|
10
|
+
app_js_path = Rails.root.join("app/javascript/application.js")
|
|
11
|
+
|
|
12
|
+
if File.exist?(app_js_path)
|
|
13
|
+
unless File.read(app_js_path).include?("recurrence_ui")
|
|
14
|
+
append_to_file "app/javascript/application.js", <<~JS
|
|
15
|
+
|
|
16
|
+
// Register RecurrenceUi Stimulus controller
|
|
17
|
+
import { registerRecurrenceUiController } from "recurrence_ui"
|
|
18
|
+
registerRecurrenceUiController(application)
|
|
19
|
+
JS
|
|
20
|
+
say "Added RecurrenceUi registration to app/javascript/application.js", :green
|
|
21
|
+
else
|
|
22
|
+
say "RecurrenceUi is already registered in app/javascript/application.js", :yellow
|
|
23
|
+
end
|
|
24
|
+
else
|
|
25
|
+
say "Could not find app/javascript/application.js. Please register RecurrenceUi manually.", :red
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
data/lib/recurrence_ui/engine.rb
CHANGED
|
@@ -1,54 +1,29 @@
|
|
|
1
|
-
# recurrence_ui/lib/recurrence_ui/engine.rb
|
|
1
|
+
# file: recurrence_ui/lib/recurrence_ui/engine.rb
|
|
2
2
|
require "recurrence_ui"
|
|
3
3
|
|
|
4
4
|
module RecurrenceUi
|
|
5
5
|
class Engine < ::Rails::Engine
|
|
6
6
|
isolate_namespace RecurrenceUi
|
|
7
7
|
|
|
8
|
-
# 1.
|
|
9
|
-
initializer "recurrence_ui.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
# 2. Add importmap support for the gem
|
|
17
|
-
initializer "recurrence_ui.importmap", before: "importmap" do |app|
|
|
18
|
-
if app.config.respond_to?(:importmap)
|
|
19
|
-
app.config.importmap.paths << Engine.root.join("config/importmap.rb")
|
|
20
|
-
end
|
|
21
|
-
end
|
|
8
|
+
# 1. Add importmap support for the gem
|
|
9
|
+
#initializer "recurrence_ui.importmap", before: "importmap" do |app|
|
|
10
|
+
# if app.config.respond_to?(:importmap)
|
|
11
|
+
# app.config.importmap.paths << Engine.root.join("config/importmap.rb")
|
|
12
|
+
# end
|
|
13
|
+
#end
|
|
22
14
|
|
|
23
|
-
#
|
|
15
|
+
# 2. Assets (только стили и картинки, если нужны, т.к. JS обслуживает Importmap)
|
|
24
16
|
initializer "recurrence_ui.assets" do |app|
|
|
25
17
|
if app.config.respond_to?(:assets)
|
|
26
|
-
app.config.assets.paths << Engine.root.join("app/javascript")
|
|
27
|
-
app.config.assets.paths << Engine.root.join("app/assets/stylesheets")
|
|
28
18
|
app.config.assets.precompile += %w( recurrence_ui/application.css )
|
|
29
|
-
|
|
30
|
-
# Add files for precompilation
|
|
31
|
-
app.config.assets.precompile += %w(
|
|
32
|
-
recurrence_ui/index.js
|
|
33
|
-
recurrence_ui/recurrence_ui_controller.js
|
|
34
|
-
recurrence_ui.css
|
|
35
|
-
)
|
|
36
19
|
end
|
|
37
20
|
end
|
|
38
21
|
|
|
39
|
-
#
|
|
22
|
+
# 3. i18n locales
|
|
40
23
|
initializer "recurrence_ui.locales" do |app|
|
|
41
24
|
config.i18n.load_path += Dir[Engine.root.join("config", "locales", "*.{rb,yml}")]
|
|
42
25
|
end
|
|
43
26
|
|
|
44
|
-
# 5. Routes for debugging in development
|
|
45
|
-
initializer "recurrence_ui.append_routes" do |app|
|
|
46
|
-
app.routes.append do
|
|
47
|
-
if Rails.env.development?
|
|
48
|
-
get '/dev/recurrence_previews', to: 'recurrence_ui/dev/recurrence_previews#index'
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
27
|
# Add components to the global ViewComponent / ActionView search
|
|
53
28
|
config.to_prepare do
|
|
54
29
|
ApplicationController.helper(RecurrenceUi::Engine.helpers)
|
metadata
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: recurrence_ui
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Katerina German
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "~>"
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: '7.1'
|
|
20
17
|
- - ">="
|
|
21
18
|
- !ruby/object:Gem::Version
|
|
22
19
|
version: 7.1.0
|
|
20
|
+
- - "<"
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '9.0'
|
|
23
23
|
type: :runtime
|
|
24
24
|
prerelease: false
|
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
26
|
requirements:
|
|
27
|
-
- - "~>"
|
|
28
|
-
- !ruby/object:Gem::Version
|
|
29
|
-
version: '7.1'
|
|
30
27
|
- - ">="
|
|
31
28
|
- !ruby/object:Gem::Version
|
|
32
29
|
version: 7.1.0
|
|
30
|
+
- - "<"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '9.0'
|
|
33
33
|
- !ruby/object:Gem::Dependency
|
|
34
34
|
name: view_component
|
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -76,16 +76,22 @@ dependencies:
|
|
|
76
76
|
name: rails-i18n
|
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
|
78
78
|
requirements:
|
|
79
|
-
- - "
|
|
79
|
+
- - ">="
|
|
80
80
|
- !ruby/object:Gem::Version
|
|
81
81
|
version: '7.0'
|
|
82
|
+
- - "<"
|
|
83
|
+
- !ruby/object:Gem::Version
|
|
84
|
+
version: '9.0'
|
|
82
85
|
type: :runtime
|
|
83
86
|
prerelease: false
|
|
84
87
|
version_requirements: !ruby/object:Gem::Requirement
|
|
85
88
|
requirements:
|
|
86
|
-
- - "
|
|
89
|
+
- - ">="
|
|
87
90
|
- !ruby/object:Gem::Version
|
|
88
91
|
version: '7.0'
|
|
92
|
+
- - "<"
|
|
93
|
+
- !ruby/object:Gem::Version
|
|
94
|
+
version: '9.0'
|
|
89
95
|
- !ruby/object:Gem::Dependency
|
|
90
96
|
name: sqlite3
|
|
91
97
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -161,6 +167,7 @@ files:
|
|
|
161
167
|
- config/locales/recurrence_ui.ru.yml
|
|
162
168
|
- config/locales/recurrence_ui.uk.yml
|
|
163
169
|
- config/routes.rb
|
|
170
|
+
- lib/generators/recurrence_ui/install/install_generator.rb
|
|
164
171
|
- lib/generators/recurrence_ui/views_generator.rb
|
|
165
172
|
- lib/recurrence_ui.rb
|
|
166
173
|
- lib/recurrence_ui/configuration.rb
|