view_primitives 0.1.1 → 0.1.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: 3bef69fa2796d5fec3caefbc2030477efadbe97cb28542e54b6f015edb3196de
4
- data.tar.gz: a85bd022df50687b09ad134173dd76e264c66a7b24a4df8eff09918794a209cb
3
+ metadata.gz: c95b5b096babd8416b53c83c883124d89f992814d19ef7d262c731abc9ac5ffa
4
+ data.tar.gz: 16744aa30b37e6bad9995dc8e792b5fdbe28300555577aab8361db78f4cc4e6f
5
5
  SHA512:
6
- metadata.gz: 424be22b1983a620253005a43f6598043553603eb6822de5c28b8bf10a49181039c3c5165f33ced82da6266af526422824b88ae7d0f7adad1d139e0fd695cf26
7
- data.tar.gz: a3c8c3a237183d849329f998ad3c0d276fde2873db327d24d091ceeeff503518ba0ca20e3512c8683dc5ded47e13fd97066a16b62131e6923cea050f40a4e9f4
6
+ metadata.gz: 5b588f79626af5d772a3616518198def45d7e918ff703fb937ce32ff17cc78edc135452b22243c2b14e878f6076149ea647cb93f65113deb88ca70dc96e99417
7
+ data.tar.gz: 18f9fca991217855a0c169ca9b8d8c44cbca7f31e5e642f851b366e71b43ddc5960afcc4145e197dd1e50e7885001dc351cfe4cc96134a08c22fcde6f8e5df8c
data/CHANGELOG.md CHANGED
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.1.3] - 2026-06-04
11
+
12
+ ### Fixed
13
+
14
+ - `AddGenerator` template files for `form_field`, `input_otp`, and `qr_code` contained unescaped ERB tags (`<%= %>` / `<% %>`) inside Ruby comments; the stricter ERB parser in Ruby 4.0 raised `SyntaxError` when processing these `.tt` files, making those three components impossible to generate; fixed by escaping the comment-only tags as `<%%=` / `<%%`
15
+
16
+ ## [0.1.2] - 2026-06-04
17
+
18
+ ### Fixed
19
+
20
+ - `InstallGenerator#verify_ui_inflection` checked `"ui/button".camelize` which can never equal `"UI::ButtonComponent"`, causing the warning to fire unconditionally even when inflections were correctly configured; fixed to check `"ui/button_component".camelize`
21
+ - `InstallGenerator#inject_css_import` used `String#include?` to detect `@import "tailwindcss"` (matches with or without semicolon) but passed `after: "@import \"tailwindcss\"\n"` (no semicolon) to `inject_into_file`; the anchor mismatch left the entry point unchanged ("File unchanged!") on Tailwind CSS v4 projects that use `@import "tailwindcss";`; fixed by probing for all four variants (double/single quotes × with/without semicolon) and passing the exact matching line as the anchor
22
+
10
23
  ## [0.1.1] - 2026-06-01
11
24
 
12
25
  ### Fixed
@@ -4,9 +4,9 @@ module UI
4
4
  # Wraps a label + input + optional hint and error message into a consistent field layout.
5
5
  #
6
6
  # Usage:
7
- # <%= ui :form_field, label: "Email", error: @user.errors[:email].first do %>
8
- # <%= ui :input, type: "email", name: "user[email]", id: "user_email" %>
9
- # <% end %>
7
+ # <%%= ui :form_field, label: "Email", error: @user.errors[:email].first do %>
8
+ # <%%= ui :input, type: "email", name: "user[email]", id: "user_email" %>
9
+ # <%% end %>
10
10
  class FormFieldComponent < ApplicationComponent
11
11
  def initialize(label: nil, hint: nil, error: nil, required: false, **html_attrs)
12
12
  @label = label
@@ -6,7 +6,7 @@ module UI
6
6
  # Renders N individual single-character inputs that auto-advance on entry.
7
7
  #
8
8
  # Usage:
9
- # <%= ui :input_otp, length: 6, name: "otp" %>
9
+ # <%%= ui :input_otp, length: 6, name: "otp" %>
10
10
 
11
11
  CELL_CLS = "h-12 w-10 rounded-md border border-input bg-transparent text-center text-lg font-medium " \
12
12
  "shadow-xs transition-[color,box-shadow] outline-none " \
@@ -8,9 +8,9 @@ module UI
8
8
  # 1. src: — pass a pre-rendered image URL (e.g. from an API or Rails asset)
9
9
  # 2. Block — pass raw SVG or HTML generated by a gem such as rqrcode:
10
10
  #
11
- # <%= ui :qr_code, size: 200 do %>
12
- # <%= RQRCode::QRCode.new("https://example.com").as_svg(viewbox: true).html_safe %>
13
- # <% end %>
11
+ # <%%= ui :qr_code, size: 200 do %>
12
+ # <%%= RQRCode::QRCode.new("https://example.com").as_svg(viewbox: true).html_safe %>
13
+ # <%% end %>
14
14
 
15
15
  WRAPPER_CLS = "inline-flex items-center justify-center overflow-hidden rounded-lg bg-white p-3"
16
16
 
@@ -38,6 +38,18 @@ module ViewPrimitives
38
38
  File.exist?(File.join(destination_root, dir))
39
39
  end
40
40
  end
41
+
42
+ # Returns the exact line (including newline) that inject_into_file should anchor after,
43
+ # or nil if no tailwindcss @import is present. Checks with and without semicolons so
44
+ # the after: anchor always matches what the file actually contains.
45
+ def tailwind_import_anchor(content)
46
+ [
47
+ "@import \"tailwindcss\";\n",
48
+ "@import \"tailwindcss\"\n",
49
+ "@import 'tailwindcss';\n",
50
+ "@import 'tailwindcss'\n"
51
+ ].find { |anchor| content.include?(anchor) }
52
+ end
41
53
  end
42
54
  end
43
55
  end
@@ -10,7 +10,7 @@ module ViewPrimitives
10
10
  source_root File.expand_path("templates", __dir__)
11
11
 
12
12
  def verify_ui_inflection
13
- return if "ui/button".camelize == "UI::ButtonComponent"
13
+ return if "ui/button_component".camelize == "UI::ButtonComponent"
14
14
 
15
15
  say "\n Warning: ActiveSupport inflection for `UI` is not configured.", :yellow
16
16
  say " ViewPrimitives expects `ui/button` to resolve to `UI::ButtonComponent`.", :yellow
@@ -52,10 +52,9 @@ module ViewPrimitives
52
52
 
53
53
  import_line = "@import \"#{css_import_path}\";\n"
54
54
 
55
- if entry_content.include?('@import "tailwindcss"')
56
- inject_into_file entry, import_line, after: "@import \"tailwindcss\"\n"
57
- elsif entry_content.include?("@import 'tailwindcss'")
58
- inject_into_file entry, import_line, after: "@import 'tailwindcss'\n"
55
+ anchor = tailwind_import_anchor(entry_content)
56
+ if anchor
57
+ inject_into_file entry, import_line, after: anchor
59
58
  else
60
59
  append_to_file entry, "\n#{import_line}"
61
60
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ViewPrimitives
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: view_primitives
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Poimtsev
@@ -261,7 +261,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
261
261
  - !ruby/object:Gem::Version
262
262
  version: '0'
263
263
  requirements: []
264
- rubygems_version: 4.0.12
264
+ rubygems_version: 4.0.10
265
265
  specification_version: 4
266
266
  summary: Primitive view components and helpers for Rails applications
267
267
  test_files: []