recurrence_ui 0.1.0 → 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: 0bee415e6501824704878be6a6acfe7cdc9104e396f66fa5d0b614471c0d9dfb
4
- data.tar.gz: 4706be40250b8c0989e1ac2154e605afbe79519a0e61987011a40bb49b06b1c6
3
+ metadata.gz: 3df8d60f0c4274076f2e881c01637bae82eb69fa93f487142ba2d266baf08d5f
4
+ data.tar.gz: 0dc39c04c65ada3574d5dc65bf94b9ba3bd85360c3fcdeaed01286940a2392ef
5
5
  SHA512:
6
- metadata.gz: 83c2b16faa7ef0132180e172aa0cd9cd0b3e6e2ab2823bdf8efbf73b0ef1941f8c759355830783e386bd28d86c5805daabcf6583274f327fd66d526b967f7de2
7
- data.tar.gz: 2e08ac188d8d9fcdedbdeae3b99471c0b44b2368946aab1d71b9e7ffdd43744356338a954d1f1e2001b56da2b2bafd027523ebf3e71ea8cd8472aba6e54d6fb2
6
+ metadata.gz: 93d48bf14b7ca821735df60e1daf8b2ea1fa96ad3c3c149ee5c7e07a3b43eb73e9c13a271b07f38bb34529d6caf0df7daf17ef65e3e301f9d7611ecfed9babe8
7
+ data.tar.gz: e228889d001f2cc4cfb99635ac6d2c97d565ea300dcecdd0f019a5624bb8ae6f1437a1a73f30247b34b54ca161416a35edf403c688e1dae2adcf369498d6bcf9
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
- [![Gem Version](https://badge.fury.io/rb/recurrence_ui.svg)](https://badge.fury.io/rb/recurrence_ui)
7
+ [![Gem Version](https://img.shields.io/gem/v/recurrence_ui.svg)](https://rubygems.org/gems/recurrence_ui)
8
8
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](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::FormContainerComponent`:
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::FormContainerComponent.new(
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 "./recurrence_ui_controller"
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,27 @@
1
+ # recurrence_ui/lib/generators/recurrence_ui/install_generator.rb
2
+ module RecurrenceUi
3
+ class InstallGenerator < Rails::Generators::Base
4
+ desc "Installs RecurrenceUi JavaScript integration into the application"
5
+
6
+ def register_controller
7
+ app_js_path = Rails.root.join("app/javascript/application.js")
8
+
9
+ if File.exist?(app_js_path)
10
+ # Проверяем, не добавлен ли уже импорт, чтобы не дублировать
11
+ unless File.read(app_js_path).include?("recurrence_ui")
12
+ append_to_file "app/javascript/application.js", <<~JS
13
+
14
+ // Register RecurrenceUi Stimulus controller
15
+ import { registerRecurrenceUiController } from "recurrence_ui"
16
+ registerRecurrenceUiController(application)
17
+ JS
18
+ say "Added RecurrenceUi registration to app/javascript/application.js", :green
19
+ else
20
+ say "RecurrenceUi is already registered in app/javascript/application.js", :yellow
21
+ end
22
+ else
23
+ say "Could not find app/javascript/application.js. Please register RecurrenceUi manually.", :red
24
+ end
25
+ end
26
+ end
27
+ end
@@ -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. Tailwind CSS v3 paths
9
- initializer "recurrence_ui.tailwindcss" do |app|
10
- if app.config.respond_to?(:tailwindcss)
11
- app.config.tailwindcss.content_paths << Engine.root.join("app/components/**/*.{erb,haml,html,slim,rb}").to_s
12
- app.config.tailwindcss.content_paths << Engine.root.join("app/views/**/*.{erb,haml,html,slim,rb}").to_s
13
- end
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
- # 3. Assets and precompilation of ONLY the necessary files
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
- # 4. i18n locales
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)
@@ -1,3 +1,3 @@
1
1
  module RecurrenceUi
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
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.0
4
+ version: 0.2.0
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-10-27 00:00:00.000000000 Z
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_generator.rb
164
171
  - lib/generators/recurrence_ui/views_generator.rb
165
172
  - lib/recurrence_ui.rb
166
173
  - lib/recurrence_ui/configuration.rb