anchor_view_components 0.43.0 → 0.44.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed9aaede95489205c325ca4ab6820458d84a5131d47aac172a0212f52fd4e228
4
- data.tar.gz: c1eee26d158f6e4276dbbce9813e89a43f06151980a76823a1f91ac6863956a0
3
+ metadata.gz: b272707b7b7780690e4bd12712dfae937b8fd30e97cc4eaf9ab86b15a83a9122
4
+ data.tar.gz: ef9c2b7c05ccbbc0e24ef552da216c0e502e6d57d83c1b5101c53b5e665912cc
5
5
  SHA512:
6
- metadata.gz: 18d8e1894f3e249b37e803df49fb741d550229242f80ed91279eeb3d06efa242146737a25d55320b2f15569ac3dae4f187e99bada58feb4b879523fd6be2435c
7
- data.tar.gz: 736ecc7b962bbafcf45e7f45af8a04f279f552eec2f2712aa115b23246a13ae0bc8dc44af958ea231bc470aad5f69e0001ddd7f45676278cb439c30e8ecc8569
6
+ metadata.gz: 2f0273735e483b4b93949b639ac1c76191fda722709efd043908bee522f853a9ae500d57a127b32bdab5f65232a3769755a98fce1cce4e082038d998f149c324
7
+ data.tar.gz: e27c29a51d263e4d55ec537515d18215ed280fc6f19df997cb9d4733c6ebc60c6495b80fd4679882b77e3cbea629249ed1f0284665453e8e01288179773308d7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.44.0
4
+
5
+ ### Minor Changes
6
+
7
+ - a9e927c: Removed the deprecated `tag` parameter from the Button component.
8
+ - 3f6ff7b: When a dialog is closed, any inner form error messages will be removed.
9
+ - e2941f0: Added a `supporting_text` slot to the `Page::Footer` component, which renders
10
+ text next to the buttons.
11
+
3
12
  ## 0.43.0
4
13
 
5
14
  ### Minor Changes
@@ -1,9 +1,8 @@
1
1
  <% results.each do |result| %>
2
2
  <%= tag.li(
3
- **merge_options(
4
- { data: result.data },
3
+ **merge_options(wrapper_options,
5
4
  class: "list-group-item",
6
- data: { autocomplete_value: result.value },
5
+ data: result.data.merge(autocomplete_value: result.value),
7
6
  role: "option",
8
7
  )
9
8
  ) do %>
@@ -3,10 +3,10 @@ module Anchor
3
3
  class ResultsComponent < Component
4
4
  Result = Data.define(:text, :value, :data)
5
5
 
6
- def initialize(data:)
6
+ def initialize(data:, **kwargs)
7
7
  @data = data
8
8
 
9
- super
9
+ super(**kwargs)
10
10
  end
11
11
 
12
12
  private
@@ -34,13 +34,11 @@ module Anchor
34
34
  warning: "text-warning",
35
35
  }.freeze
36
36
 
37
- def initialize(**kwargs)
38
- @icon = ICON_MAPPINGS[kwargs[:variant]] ||
39
- ICON_MAPPINGS[VARIANT_DEFAULT]
40
- @icon_variant = ICON_VARIANT_MAPPINGS[kwargs[:variant]] ||
41
- ICON_VARIANT_MAPPINGS[VARIANT_DEFAULT]
37
+ def initialize(variant: VARIANT_DEFAULT, **kwargs)
38
+ @icon = ICON_MAPPINGS[variant]
39
+ @icon_variant = ICON_VARIANT_MAPPINGS[variant]
42
40
 
43
- super
41
+ super(variant:, **kwargs)
44
42
  end
45
43
 
46
44
  private
@@ -35,7 +35,6 @@ module Anchor
35
35
  end
36
36
 
37
37
  def initialize(
38
- tag: nil,
39
38
  type: TYPE_DEFAULT,
40
39
  size: SIZE_DEFAULT,
41
40
  href: nil,
@@ -43,12 +42,6 @@ module Anchor
43
42
  full_width: false,
44
43
  **kwargs
45
44
  )
46
- if tag
47
- ActiveSupport::Deprecation.warn(
48
- "`tag` is now set automatically and should no longer be used."
49
- )
50
- end
51
-
52
45
  @type = fetch_or_fallback(TYPE_OPTIONS, type, TYPE_DEFAULT)
53
46
  @size = SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size,
54
47
  SIZE_DEFAULT)]
@@ -16,7 +16,7 @@ module Anchor
16
16
  .merge(class: classes)
17
17
  .reject { |_, v| deep_blank?(v) }
18
18
 
19
- super
19
+ super # rubocop:disable Anchor/AvoidImplicitSuper
20
20
  end
21
21
 
22
22
  private
@@ -10,6 +10,7 @@
10
10
  ],
11
11
  data: {
12
12
  controller: "dialog",
13
+ action: "close->dialog#reset",
13
14
  testid: title_id,
14
15
  },
15
16
  })) do %>
@@ -8,4 +8,12 @@ export default class extends Controller<HTMLDialogElement> {
8
8
  close(): void {
9
9
  this.element.close();
10
10
  }
11
+
12
+ reset(): void {
13
+ this.#resetErrorMessages();
14
+ }
15
+
16
+ #resetErrorMessages(): void {
17
+ this.element.querySelectorAll("[data-error='true']").forEach((element) => element.remove());
18
+ }
11
19
  }
@@ -10,7 +10,7 @@ module Anchor
10
10
  def initialize(href:, **kwargs)
11
11
  @href = href
12
12
 
13
- super
13
+ super(**kwargs)
14
14
  end
15
15
 
16
16
  attr_reader :href
@@ -1,10 +1,11 @@
1
1
  <%= tag.footer(**merge_options(wrapper_options,
2
2
  class: class_names(
3
3
  Anchor::PageComponent::HORIZONTAL_PADDING_CLASS,
4
- "py-5 flex justify-end gap-4 border-t bg-white border-subdued sticky bottom-0",
4
+ "py-5 flex items-center justify-end gap-4 border-t bg-white border-subdued sticky bottom-0",
5
5
  ),
6
6
  data: { testid: "page-footer" }),
7
7
  ) do %>
8
+ <%= supporting_text %>
8
9
  <%= delete_button unless done_button? %>
9
10
  <%= cancel_button unless done_button? %>
10
11
  <%= save_button unless done_button? %>
@@ -34,6 +34,14 @@ module Anchor
34
34
  **kwargs
35
35
  )
36
36
  }
37
+
38
+ renders_one :supporting_text, lambda { |supporting_text, **kwargs|
39
+ anchor_text(
40
+ supporting_text,
41
+ class: "text-secondary",
42
+ **kwargs
43
+ )
44
+ }
37
45
  end
38
46
  end
39
47
  end
@@ -1,5 +1,5 @@
1
1
  module Anchor
2
2
  module ViewComponents
3
- VERSION = "0.43.0".freeze
3
+ VERSION = "0.44.0".freeze
4
4
  end
5
5
  end
@@ -0,0 +1,23 @@
1
+ module Anchor
2
+ class AvoidImplicitSuper < RuboCop::Cop::Cop
3
+ MSG = "Avoid implicit `super` calls. Prefer `super(**kwargs)`, " \
4
+ "`super()`, or a mix of explicit/implicit arguments, e.g. " \
5
+ "`super(id:, title:, **kwargs)`.".freeze
6
+
7
+ def_node_matcher :initialize_with_implicit_super?, <<~PATTERN
8
+ (def :initialize _ (begin ... $`zsuper ...))
9
+ PATTERN
10
+
11
+ def on_def(node)
12
+ return unless (zsuper = initialize_with_implicit_super?(node))
13
+
14
+ add_offense(zsuper, message:)
15
+ end
16
+
17
+ private
18
+
19
+ def message
20
+ MSG
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,21 @@
1
+ <% invalid_user = FakeUser.new(name: "").tap(&:validate) %>
2
+
3
+ <%= anchor_dialog(
4
+ id: "my-dialog",
5
+ title: "Dialog Title",
6
+ ) do |dialog| %>
7
+ <% dialog.with_show_button_content("Open dialog") %>
8
+
9
+ <% dialog.with_body do %>
10
+ <%= anchor_form_with(model: invalid_user, url: false, id: 'a-form') do |form| %>
11
+ <%= form.label(:name) %>
12
+ <%= form.text_field(:name, required: true) %>
13
+ <%= form.error_message_for(:name) %>
14
+ <% end %>
15
+ <% end %>
16
+
17
+ <% dialog.with_footer do %>
18
+ <%= anchor_button("Cancel", data: { action: "dialog#close" }) %>
19
+ <%= anchor_button("Save", variant: :primary, type: :submit, form: 'a-form') %>
20
+ <% end %>
21
+ <% end %>
@@ -16,6 +16,8 @@ module Anchor
16
16
  end
17
17
  end
18
18
 
19
+ def with_form; end
20
+
19
21
  def with_footer; end
20
22
 
21
23
  def positioned_right; end
@@ -0,0 +1,24 @@
1
+ <%= anchor_page do |page| %>
2
+ <% page.with_header do |header| %>
3
+ <% header.with_breadcrumbs do |breadcrumbs| %>
4
+ <% breadcrumbs.with_item(href: "#").with_content("Breadcrumb 1") %>
5
+ <% breadcrumbs.with_item(href: "").with_content("Breadcrumb 2") %>
6
+ <% end %>
7
+ <% header.with_title("Page title") %>
8
+ <% end %>
9
+ <% page.with_body do |body| %>
10
+ <%= anchor_form_with(url: false, id: "form") do |form| %>
11
+ <%= tag.div class: "max-w-sm" do %>
12
+ <%= form.label :name, "Name" %>
13
+ <%= form.text_field(
14
+ :name,
15
+ ) %>
16
+ <% end %>
17
+ <% end %>
18
+ <% end %>
19
+ <% page.with_footer do |footer| %>
20
+ <% footer.with_cancel_button(href: "#") %>
21
+ <% footer.with_save_button(form: "form") %>
22
+ <% footer.with_supporting_text("Optional text") %>
23
+ <% end %>
24
+ <% end %>
@@ -15,5 +15,7 @@ module Anchor
15
15
  def with_done_button; end
16
16
 
17
17
  def with_cancel_and_save_buttons; end
18
+
19
+ def with_supporting_text_and_buttons; end
18
20
  end
19
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anchor_view_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.43.0
4
+ version: 0.44.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Buoy Software
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-04 00:00:00.000000000 Z
11
+ date: 2024-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -191,6 +191,7 @@ files:
191
191
  - lib/anchor/view_components/svg_resolver.rb
192
192
  - lib/anchor/view_components/version.rb
193
193
  - lib/anchor_view_components.rb
194
+ - lib/cops/anchor/avoid_implicit_super.rb
194
195
  - previews/anchor/action_menu_component_preview.rb
195
196
  - previews/anchor/action_menu_component_preview/autoplacement.html.erb
196
197
  - previews/anchor/action_menu_component_preview/custom_trigger.html.erb
@@ -209,6 +210,7 @@ files:
209
210
  - previews/anchor/dialog_component_preview/positioned_right.html.erb
210
211
  - previews/anchor/dialog_component_preview/with_custom_show_button.html.erb
211
212
  - previews/anchor/dialog_component_preview/with_footer.html.erb
213
+ - previews/anchor/dialog_component_preview/with_form.html.erb
212
214
  - previews/anchor/filter_component_preview.rb
213
215
  - previews/anchor/forms_preview.rb
214
216
  - previews/anchor/icon_component_preview.rb
@@ -223,6 +225,7 @@ files:
223
225
  - previews/anchor/page_component_preview/with_done_button.html.erb
224
226
  - previews/anchor/page_component_preview/with_page_header_custom_content.html.erb
225
227
  - previews/anchor/page_component_preview/with_search.html.erb
228
+ - previews/anchor/page_component_preview/with_supporting_text_and_buttons.html.erb
226
229
  - previews/anchor/panel_component_preview.rb
227
230
  - previews/anchor/panel_component_preview/with_banner.html.erb
228
231
  - previews/anchor/preview.rb