recurrence_ui 0.3.2 → 0.3.3

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: '069d35c9479d4f10916502bc7e13e13db0b26a758b3ff8b41619d632918f78c2'
4
- data.tar.gz: f88fdf5a43cbbd18858f53ba8eb1592de132cc9ab5d711e38375322f4c3fdada
3
+ metadata.gz: 148ea1c9b90cf1ead7565260393624603281a68ffc349fd02b774721e65c1882
4
+ data.tar.gz: 64c351c8e924ef1676ca94e062061f03feb78d9c326c61f07168ba93d50d9859
5
5
  SHA512:
6
- metadata.gz: 72ac32f1763a7ef149adcc46356ed811e8dbd2c2b6dcd8e469631e902765f039ca170b2d7a183d8620a3df2d8dffb9f71f7eca1459794700e15c0d1469cd4c50
7
- data.tar.gz: d80d3ddd4307f2a0a45d59e03c915b91a76d24c68956b2ecd91966faa6ec46eea106cac44d8d302e9ec7aa3cefc31d305ef3935b5ec5eb6a786b59b66d685664
6
+ metadata.gz: 0bbe8d72c6582df4257859c890ecf354821f37603090a6bbcaf863ba77a3aaaac9bd7a5b95a1504804fa7c6887b99cbcfc2c5954e38bad573a33bf464f9dc6b2
7
+ data.tar.gz: 105e1e02dec4b660b8365939c752b0bb9373c553bcc363a987f7b19f25d689f31619814544f885c8a3df0afa20c361e76634033bee26b4e1d60c36877d85d022
data/README.md CHANGED
@@ -12,8 +12,8 @@ Built on top of [ice_cube](https://github.com/ice-cube-ruby/ice_cube), it provid
12
12
  - **Form integration:** Ready-to-use components for adding recurrence rule editors to model creation and editing forms.
13
13
  - **Human-readable descriptions:** Converts `ice_cube` recurrence rules into readable descriptions.
14
14
  - **Built-in internationalization:** Supports English (`en`), Russian (`ru`), Japanese (`ja`), Belarusian (`be`), and Ukrainian (`uk`).
15
- - **Extensible translations:** Add new locales using standard YAML translation files and configuration.
16
- - **Flexible time zones and week starts:** Configure time zones and the first day of the week. Values can be supplied through URL parameters, session data, user preferences, or application settings, depending on your integration.
15
+ - **Extensible translations:** Add new locales using standard YAML translation files.
16
+ - **Flexible time zones and week starts:** Configure time zones and the first day of the week.
17
17
  - **Customizable styles:** Adjust the color palette using CSS custom properties (design tokens).
18
18
  - **Light and dark themes:** Customize the appearance to match your application.
19
19
  - **Flexible model attribute mapping:** Use custom database column names for recurrence rules, time zones, durations, and event start and end times.
@@ -23,102 +23,154 @@ Built on top of [ice_cube](https://github.com/ice-cube-ruby/ice_cube), it provid
23
23
  Recurrence UI depends on the following components:
24
24
 
25
25
  - **Ruby on Rails** >= 8.0
26
- - **[ice_cube](https://github.com/ice-cube-ruby/ice_cube)** ~> 0.16 — recurrence rule management.
27
- - **[ViewComponent](https://viewcomponent.org/)** >= 2.0 — reusable, encapsulated UI components.
28
- - **Tailwind CSS ** >= 4.0 — styling, integrated through `tailwindcss-rails` or your host application's Tailwind CSS setup.
26
+ - **[ice_cube](https://github.com/ice-cube-ruby/ice_cube)** ~> 0.16
27
+ - **[ViewComponent](https://viewcomponent.org/)** >= 2.0
28
+ - **Tailwind CSS** >= 4.0
29
29
 
30
- ## Installation and configuration
30
+ Tailwind CSS can be integrated through `tailwindcss-rails` or your host application's existing Tailwind CSS setup.
31
31
 
32
- Add the gem to your application's `Gemfile`:
32
+ ## Installation and Configuration
33
+
34
+ ### 1. Add the gem
35
+
36
+ Add Recurrence UI to your application's `Gemfile`:
33
37
 
34
38
  ```ruby
35
39
  gem "recurrence_ui"
36
40
  ```
37
41
 
38
- Then install the dependencies:
42
+ Install the dependencies:
39
43
 
40
44
  ```bash
41
45
  bundle install
42
46
  ```
43
- ### Automatic Installation
44
47
 
45
- Run the installation generator to automatically create the initializer configuration and wire up the JavaScript components:
48
+ ### 2. Automatic Installation (Recommended)
49
+
50
+ Run the installation generator:
51
+
46
52
  ```bash
47
53
  bin/rails g recurrence_ui:install
48
54
  ```
49
- ### Manual Setup (Alternative)
50
55
 
51
- If you prefer to configure the gem manually:
52
- 1. Create an initializer at config/initializers/recurrence_ui.rb:
56
+ The generator configures the necessary integration with your Rails application:
57
+
58
+ - Registers the Recurrence UI Stimulus controller in your application's Stimulus application.
59
+ - Adds the Recurrence UI stylesheet to your application's stylesheets.
60
+ - Creates the configuration initializer with default settings, if applicable.
61
+
62
+ The gem's Engine automatically makes its JavaScript, CSS assets, and translations available to the host application.
63
+
64
+ No additional Importmap configuration or manual locale loading is required.
65
+
66
+ ### 3. Manual Installation (Alternative)
67
+
68
+ If you prefer to configure the integration yourself, follow these steps.
69
+
70
+ **Step 1. Create an initializer**
71
+
72
+ Create `config/initializers/recurrence_ui.rb`:
73
+
53
74
  ```ruby
54
- require "recurrence_ui"
55
75
  RecurrenceUi.configure do |config|
56
- # default locale, time_zone and week_start for all RecurrencePickerComponents in app
57
- # Could be redefined in RecurrencePickerComponent
76
+ # General settings
58
77
  config.locale = :en
59
78
  config.time_zone = "UTC"
60
79
  config.week_start = 1
61
- config.start_time = "06:00" # Default start time for events (if no start_time is passed to the component or column does not configured in model)
62
- config.end_time = "16:00" # Default end time for events (if no end_time is passed to the component or column does not configured in model)
63
- config.duration = 3600 # Default duration in seconds for events (if no duration is passed to the component or column does not configured in model)
64
-
65
- #---- This is default UI options for all RecurrencePickerComponents in app that could be redefined in RecurrencePickerComponent --- #
80
+
81
+ # Default event values
82
+ config.start_time = "09:00"
83
+ config.end_time = "17:00"
84
+ config.duration = 0
85
+
86
+ # UI options
66
87
  config.enabled_rule_types = %w[
67
- never
68
- daily
69
- weekly
70
- monthly_by_day_of_month
71
- monthly_by_weekday
72
- yearly_by_day_of_month
73
- yearly_by_weekday
74
- ]
75
- config.allow_multiple_rules = true # Show only one rule(false) or multyple rules (true)
76
- config.show_duration = true # Show/Hide duration fields in form
77
- config.show_start_date_time = true # Show/Hide start date and time fields in form
78
- config.show_time_zone = true # Show/Hide time zone in form
79
- config.show_end_date_time = false # Show/Hide end date and time fields in form
80
- config.show_exceptions = true # Show/Hide exceptions fields in form
81
- config.show_rdates = true # Show/Hide additional dates fields in form
82
- config.show_termination = true # Show/Hide termination fields in form
88
+ never
89
+ daily
90
+ weekly
91
+ monthly_by_day_of_month
92
+ monthly_by_weekday
93
+ yearly_by_day_of_month
94
+ yearly_by_weekday
95
+ ]
96
+
97
+ config.allow_multiple_rules = true
98
+
99
+ config.show_duration = true
100
+ config.show_start_date_time = true
101
+ config.show_time_zone = true
102
+ config.show_end_date_time = false
103
+ config.show_exceptions = true
104
+ config.show_rdates = true
105
+ config.show_termination = true
83
106
  end
84
107
  ```
85
- Available settings:
86
-
87
- - locale — the default interface locale, such as :en, :ru, :uk, :be, or :ja.
88
- - week_start — the first day of the week: 0 for Sunday or 1 for Monday.
89
- - time_zone — if record dosen't have this field uses: ActiveSupport::TimeZone[zone_name] || Time.zone || ActiveSupport::TimeZone[Rails.application.config.time_zone]
90
- - start_time — if record dosen't have this field uses DEFAULT_START_TIME = '09:00'.freeze from gem configuration.
91
- - duration — if record dosen't have this field uses DEFAULT_DURATION = 0 from gem configuration.
92
- - end_time — if record dosen't have this field uses DEFAULT_END_TIME = '17:00'.freeze
93
- - allow_multiple_rules — show only one rule (false) or multiple rules (true).
94
- - show_duration — show/hide duration fields in the form.
95
- - show_start_date_time — show/hide start date and time fields in the form.
96
- - show_time_zone — show/hide time zone in the form.
97
- - show_end_date_time — show/hide end date and time fields in the form.
98
- - show_exceptions — show/hide exceptions fields in the form.
99
- - show_rdates — show/hide additional dates fields in the form.
100
- - show_termination — show/hide termination fields in the form.
101
-
102
-
103
- 2. Import JavaScript: Add the following import to your application's main JavaScript file (app/javascript/application.js):
108
+
109
+ **Step 2. Register the Stimulus controller**
110
+
111
+ Register the Recurrence UI controller in your application's Stimulus setup.
112
+
113
+ For example, in `app/javascript/controllers/index.js`:
114
+
104
115
  ```javascript
105
- import "recurrence_ui"
116
+ import RecurrenceUiController from "recurrence_ui"
117
+
118
+ application.register("recurrence-ui", RecurrenceUiController)
106
119
  ```
107
- 3. Import styles: For Tailwind CSS v4, add the style imports to your stylesheet (e.g., app/assets/stylesheets/application.tailwind.css):
120
+
121
+ Use the controller's actual import path and identifier provided by the gem.
122
+
123
+ **Step 3. Import the stylesheet**
124
+
125
+ For Tailwind CSS v4, add the following imports to your application's stylesheet, for example `app/assets/stylesheets/application.tailwind.css`:
108
126
 
109
127
  ```css
110
128
  @import "tailwindcss";
111
129
  @import "recurrence_ui/application.css";
112
130
  ```
113
131
 
114
- Make sure the stylesheet is included in your application's asset pipeline and that your Tailwind CSS setup is compatible with the gem's styles.
132
+ Make sure the stylesheet is included in your application's asset pipeline.
133
+
134
+ **Note:** Importmap paths, JavaScript assets, and locale files are provided by the gem's Engine. You do not need to configure them manually.
115
135
 
136
+ ## Configuration
116
137
 
117
- ### Model Integration
138
+ Recurrence UI can be configured globally through `config/initializers/recurrence_ui.rb`.
139
+
140
+ The following settings are available:
141
+
142
+ ### General settings
143
+
144
+ | Setting | Description |
145
+ |---|---|
146
+ | `locale` | Default interface locale (`:en`, `:ru`, `:uk`, `:be`, `:ja`). |
147
+ | `time_zone` | Default time zone. |
148
+ | `week_start` | First day of the week: `0` for Sunday or `1` for Monday. |
149
+ | `start_time` | Default event start time. |
150
+ | `end_time` | Default event end time. |
151
+ | `duration` | Default event duration in seconds. |
152
+
153
+ ### UI settings
154
+
155
+ | Setting | Description |
156
+ |---|---|
157
+ | `enabled_rule_types` | Recurrence rule types available in the editor. |
158
+ | `allow_multiple_rules` | Allows multiple recurrence rules when `true`. |
159
+ | `show_duration` | Shows or hides duration fields. |
160
+ | `show_start_date_time` | Shows or hides start date and time fields. |
161
+ | `show_time_zone` | Shows or hides the time zone field. |
162
+ | `show_end_date_time` | Shows or hides end date and time fields. |
163
+ | `show_exceptions` | Shows or hides exception dates. |
164
+ | `show_rdates` | Shows or hides additional recurrence dates. |
165
+ | `show_termination` | Shows or hides recurrence termination settings. |
166
+
167
+ Component-level options can override the global configuration where supported.
168
+
169
+ ## Model Integration
118
170
 
119
171
  Include `RecurrenceUi::HasRecurrence` in your model and configure the mapping between the gem's attributes and your database columns.
120
- If you dont configure some fields for your model, they will not connect to your base.
121
- But some of them could uses default value if not configured. Could be redefined for all app in config/initializers/recurrence_ui.rb such as time_zone, start_time, duration and end_time.
172
+
173
+ The recurrence rules attribute is required. Other attributes are optional and can be configured according to your application's database schema.
122
174
 
123
175
  For example:
124
176
 
@@ -126,10 +178,10 @@ For example:
126
178
  class Event < ApplicationRecord
127
179
  include RecurrenceUi::HasRecurrence
128
180
 
129
- has_recurrence rules: :recurring_rules, # This column is needed for gem,
130
- start_time: :start_at, # others - optional. Format:
131
- end_time: :end_at, # name_in_gem: :name_in_your_db_schema
132
- time_zone: :time_zone, # for default values see Configuration
181
+ has_recurrence rules: :recurring_rules,
182
+ start_time: :start_at,
183
+ end_time: :end_at,
184
+ time_zone: :time_zone,
133
185
  duration: :duration
134
186
  end
135
187
  ```
@@ -145,51 +197,52 @@ class Task < ApplicationRecord
145
197
  end
146
198
  ```
147
199
 
148
- Use the attribute names that match your application's database schema and the attributes supported by your model integration.
200
+ The mapping format is:
149
201
 
150
- Add required params to controller of your Model.
151
- ```erb
152
- def event_params
153
- params.require(:event).permit(
154
- #other params of your model
155
- *Event.recurrence_permitted_params # add this with name of your Model
156
- )
157
- end
202
+ ```ruby
203
+ gem_attribute: :database_column
158
204
  ```
159
205
 
206
+ If an optional attribute is not configured, the gem can use its applicable default value where supported.
207
+
208
+ ### Strong Parameters
160
209
 
161
- ### View Integration
210
+ Add the recurrence parameters to your controller's permitted parameters:
211
+
212
+ ```ruby
213
+ def event_params
214
+ params.require(:event).permit(
215
+ # Other model parameters
216
+ *Event.recurrence_permitted_params
217
+ )
218
+ end
219
+ ```
220
+
221
+ ## View Integration
162
222
 
163
223
  Render the recurrence editor inside a Rails form using `RecurrenceUi::RecurrencePickerComponent`:
164
224
 
165
225
  ```erb
166
226
  <%= form_with model: @event do |form| %>
167
- <%= render RecurrenceUi::RecurrencePickerComponent.new(
168
- form: form,
169
- record: @event,
170
- allow_multiple_rules: true,
171
- show_duration: true,
172
- show_start_date_time: true,
173
- show_time_zone: true,
174
- show_end_date_time: true,
175
- show_exceptions: true,
176
- show_rdates: true,
177
- show_termination: true,
178
- locale: params[:locale],
179
- time_zone: params[:time_zone],
180
- week_start: params[:week_start]
181
- )
182
- %>
227
+ <%= render RecurrenceUi::RecurrencePickerComponent.new(
228
+ form: form,
229
+ record: @event,
230
+ locale: params[:locale],
231
+ time_zone: params[:time_zone],
232
+ week_start: params[:week_start]
233
+ ) %>
183
234
 
184
235
  <%= form.submit "Save" %>
185
236
  <% end %>
186
237
  ```
187
238
 
188
- 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.
239
+ The component uses the application's global configuration by default.
240
+
241
+ You can also override supported component options when rendering it.
189
242
 
190
243
  ## Internationalization
191
244
 
192
- Recurrence UI currently supports the following locales:
245
+ Recurrence UI currently supports:
193
246
 
194
247
  - English (`en`)
195
248
  - Russian (`ru`)
@@ -204,18 +257,16 @@ You can extend the interface with additional translations.
204
257
  For example, to add German (`de`):
205
258
 
206
259
  1. Create a translation file named `config/locales/recurrence_ui.de.yml` in your application.
207
- 2. Add the required translation keys, including the relevant labels, actions, duration descriptions, and other interface strings.
208
- 3. Configure the new locale or pass it dynamically through your application's request parameters.
260
+ 2. Add the required translation keys, following the structure of the gem's existing locale files.
261
+ 3. Use the new locale through your application's I18n configuration or pass it to the component.
209
262
 
210
- Make sure the translation file follows the structure expected by the gem's existing locale files.
263
+ The gem's Engine makes its built-in translations available automatically.
211
264
 
212
265
  ## Themes and Customization
213
266
 
214
267
  Recurrence UI uses CSS custom properties (design tokens) to control its color palette.
215
268
 
216
- You can override these properties in your application's stylesheet to match your brand or customize the appearance of the interface.
217
-
218
- For example:
269
+ You can override these properties in your application's stylesheet:
219
270
 
220
271
  ```css
221
272
  :root {
@@ -230,14 +281,17 @@ For example:
230
281
  }
231
282
  ```
232
283
 
233
- 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.
284
+ Use the CSS variables supported by the gem to customize its appearance.
234
285
 
235
286
  ## Example Application
236
287
 
237
- 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:
288
+ To see Recurrence UI in action, check out the [rails-recurrence-ui-dummy](https://github.com/assoly/rails-recurrence-ui-dummy) repository.
289
+
290
+ It demonstrates a fully configured Ruby on Rails application featuring:
291
+
238
292
  - Database models with `HasRecurrence` integration.
239
- - Form views using `ViewComponent` and Tailwind CSS.
240
- - Initializer and internationalization (i18n) setup.
293
+ - Form views using ViewComponent and Tailwind CSS.
294
+ - Initializer and internationalization setup.
241
295
 
242
296
  ## Contributing
243
297
 
@@ -264,15 +318,15 @@ Please make sure your changes are covered by tests where appropriate.
264
318
 
265
319
  ## Testing
266
320
 
267
- *Note: The test suite is currently under active development. Contributions are very welcome!*
321
+ The test suite is currently under active development. Contributions are very welcome!
268
322
 
269
323
  ### Planned Test Suite
270
324
 
271
325
  - [ ] **Models & Concerns (`HasRecurrence`):** Test attribute mapping, JSON parsing, virtual form attributes, and `IceCube::Schedule` generation.
272
- - [ ] **Formatter Service (`RecurrenceFormatterService`):** Validate human-readable summaries, smart date/time deduplication, and month declensions.
273
- - [ ] **Internationalization (I18n):** Automated checks to ensure all locales (`en`, `ru`, `uk`, `be`, `ja`) share a consistent translation key structure.
274
- - [ ] **ViewComponents:** Test proper rendering and Stimulus data-attribute bindings for form components.
326
+ - [ ] **Formatter Service:** Validate human-readable summaries, smart date/time deduplication, and month declensions.
327
+ - [ ] **Internationalization (I18n):** Automated checks to ensure all locales share a consistent translation key structure.
328
+ - [ ] **ViewComponents:** Test proper rendering and Stimulus data-attribute bindings.
275
329
 
276
- ## 📄 License
330
+ ## License
277
331
 
278
- Recurrence UI is available under the [MIT License](https://opensource.org/licenses/MIT).
332
+ 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) {
@@ -1,4 +1,5 @@
1
1
  <%# app/views/recurrence_ui/_start_at.html.erb %>
2
+ <% default_start_time = rec_ui.start_time || RecurrenceUi.config.resolved_start_time %>
2
3
  <div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
3
4
 
4
5
  <!-- 1. Дата и время начала (всегда на одной строке, не тянутся) -->
@@ -11,7 +12,7 @@
11
12
  data: { "#{identifier}_target": "startDate",
12
13
  action: "change->#{identifier}#calculateEndDateFromDuration" } %>
13
14
  <%= form.time_field :form_start_time,
14
- value: form.object.start_time_in_zone(:event)&.strftime('%H:%M') || RecurrenceUi::RecurrencePickerComponent::DEFAULT_START_TIME.strftime('%H:%M'),
15
+ value: form.object.start_time_in_zone(:event)&.strftime('%H:%M') || default_start_time,
15
16
  class: "rui-input w-24 shrink-0",
16
17
  data: { "#{identifier}_target": "startTime",
17
18
  action: "change->#{identifier}#calculateEndDateFromDuration" }
@@ -3,53 +3,48 @@ module RecurrenceUi
3
3
  class InstallGenerator < Rails::Generators::Base
4
4
  source_root File.expand_path("templates", __dir__)
5
5
 
6
- desc "Installs RecurrenceUi importmap, JS controller registration, and Tailwind CSS styles"
7
-
8
- def add_importmap_pin
9
- importmap_file = "config/importmap.rb"
10
- if File.exist?(importmap_file)
11
- pin_code = "\npin \"recurrence_ui\", to: \"recurrence_ui/index.js\"\n"
12
- if File.read(importmap_file).include?("recurrence_ui")
13
- say "RecurrenceUi pin already exists in #{importmap_file}", :blue
14
- else
15
- append_to_file importmap_file, pin_code
16
- say "Added recurrence_ui pin to #{importmap_file}", :green
17
- end
18
- else
19
- say "Could not find #{importmap_file}. Importmap configuration skipped.", :yellow
20
- end
21
- end
6
+ desc "Installs RecurrenceUi Stimulus controller registration and Tailwind CSS styles"
22
7
 
23
8
  def register_controller
24
- app_js_paths = [
25
- Rails.root.join("app/javascript/application.js"),
26
- Rails.root.join("app/javascript/packs/application.js")
27
- ]
9
+ say "1. Installing RecurrenceUi Stimulus controller registration", :green
10
+
11
+ app_js_path = Rails.root.join("app/javascript/application.js")
12
+
13
+ unless File.exist?(app_js_path)
14
+ say "Could not find app/javascript/application.js. Please register RecurrenceUi manually.", :red
15
+ return
16
+ end
17
+
18
+ content = File.read(app_js_path)
19
+ additions = []
20
+
21
+ application_import = 'import { application } from "controllers/application"'
22
+ recurrence_import = 'import { registerRecurrenceUiController } from "recurrence_ui"'
23
+ recurrence_registration = "registerRecurrenceUiController(application)"
24
+
25
+ unless content.include?(application_import)
26
+ additions << application_import
27
+ end
28
28
 
29
- target_js = app_js_paths.find { |path| File.exist?(path) }
30
-
31
- if target_js
32
- content = File.read(target_js)
33
-
34
- if content.include?("recurrence_ui")
35
- say "RecurrenceUi is already registered in #{target_js.relative_path_from(Rails.root)}", :blue
36
- else
37
- append_to_file target_js, <<~JS
38
-
39
- // Register RecurrenceUi Stimulus controller
40
- import { registerRecurrenceUiController } from "recurrence_ui"
41
- if (typeof window.Stimulus !== "undefined") {
42
- registerRecurrenceUiController(window.Stimulus)
43
- }
44
- JS
45
- say "Added RecurrenceUi registration to #{target_js.relative_path_from(Rails.root)}", :green
46
- end
29
+ unless content.include?(recurrence_import)
30
+ additions << recurrence_import
31
+ end
32
+
33
+ unless content.include?(recurrence_registration)
34
+ additions << recurrence_registration
35
+ end
36
+
37
+ if additions.empty?
38
+ say "RecurrenceUi controller is already registered", :blue
47
39
  else
48
- say "Could not find application.js. Please register RecurrenceUi manually.", :red
40
+ append_to_file app_js_path, "\n\n#{additions.join("\n")}\n"
41
+ say "Added RecurrenceUi controller registration to application.js", :green
49
42
  end
50
43
  end
51
44
 
52
45
  def register_styles
46
+ say "2. Installing RecurrenceUi Tailwind CSS styles", :green
47
+
53
48
  tailwind_css_paths = [
54
49
  Rails.root.join("app/assets/tailwind/application.css"),
55
50
  Rails.root.join("app/assets/stylesheets/application.tailwind.css"),
@@ -58,23 +53,26 @@ module RecurrenceUi
58
53
 
59
54
  target_css = tailwind_css_paths.find { |path| File.exist?(path) }
60
55
 
61
- if target_css
62
- content = File.read(target_css)
63
- import_line = '@import "recurrence_ui/application.css";'
64
-
65
- if content.include?(import_line)
66
- say "RecurrenceUi styles import already exists in #{target_css.relative_path_from(Rails.root)}", :blue
67
- else
68
- if content.include?('@import "tailwindcss";')
69
- inject_into_file target_css, "\n#{import_line}", after: '@import "tailwindcss";'
70
- else
71
- prepend_to_file target_css, "#{import_line}\n"
72
- end
73
- say "Added RecurrenceUi styles import to #{target_css.relative_path_from(Rails.root)}", :green
74
- end
56
+ unless target_css
57
+ say 'Tailwind CSS file not found. Please add `@import "recurrence_ui/application.css";` manually.', :yellow
58
+ return
59
+ end
60
+
61
+ content = File.read(target_css)
62
+ import_line = '@import "recurrence_ui/application.css";'
63
+
64
+ if content.include?(import_line)
65
+ say "RecurrenceUi styles are already imported in #{target_css.relative_path_from(Rails.root)}", :blue
66
+ return
67
+ end
68
+
69
+ if content.include?('@import "tailwindcss";')
70
+ inject_into_file target_css, "\n#{import_line}", after: '@import "tailwindcss";'
75
71
  else
76
- say "Tailwind CSS file not found. Please add `@import \"recurrence_ui/application.css\";` manually.", :yellow
72
+ prepend_to_file target_css, "#{import_line}\n"
77
73
  end
74
+
75
+ say "Added RecurrenceUi styles import to #{target_css.relative_path_from(Rails.root)}", :green
78
76
  end
79
77
  end
80
78
  end
@@ -1,32 +1,33 @@
1
- # file: recurrence_ui/lib/recurrence_ui/engine.rb
2
1
  require "recurrence_ui"
3
2
 
4
3
  module RecurrenceUi
5
4
  class Engine < ::Rails::Engine
6
5
  isolate_namespace RecurrenceUi
7
6
 
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
14
-
15
- # 2. Assets (только стили и картинки, если нужны, т.к. JS обслуживает Importmap)
7
+ # Assets: JavaScript and CSS
16
8
  initializer "recurrence_ui.assets" do |app|
17
9
  if app.config.respond_to?(:assets)
18
- app.config.assets.precompile += %w( recurrence_ui/application.css )
10
+ app.config.assets.paths << root.join("app/javascript")
11
+ app.config.assets.precompile += %w(recurrence_ui/application.css)
19
12
  end
20
13
  end
21
14
 
22
- # 3. i18n locales
15
+ # Importmap
16
+ initializer "recurrence_ui.importmap", before: "importmap" do |app|
17
+ app.config.importmap.paths << root.join("config/importmap.rb")
18
+ app.config.importmap.cache_sweepers << root.join("app/javascript")
19
+ end
20
+
21
+ # I18n locales
23
22
  initializer "recurrence_ui.locales" do |app|
24
- app.config.i18n.load_path += Dir[Engine.root.join("config", "locales", "*.{rb,yml}")]
23
+ app.config.i18n.load_path += Dir[
24
+ root.join("config", "locales", "*.{rb,yml}")
25
+ ]
25
26
  end
26
27
 
27
- # Add components to the global ViewComponent / ActionView search
28
+ # ViewComponent / ActionView helpers
28
29
  config.to_prepare do
29
30
  ApplicationController.helper(RecurrenceUi::Engine.helpers)
30
31
  end
31
32
  end
32
- end
33
+ end
@@ -1,3 +1,3 @@
1
1
  module RecurrenceUi
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recurrence_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
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-10 00:00:00.000000000 Z
11
+ date: 2026-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails