anchor_view_components 0.44.0 → 0.45.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b272707b7b7780690e4bd12712dfae937b8fd30e97cc4eaf9ab86b15a83a9122
4
- data.tar.gz: ef9c2b7c05ccbbc0e24ef552da216c0e502e6d57d83c1b5101c53b5e665912cc
3
+ metadata.gz: e70ad5e5ff2eb34b41352d913159bfa0baae9417393ce24007ef061a7eae1c8a
4
+ data.tar.gz: 4245d65fc162e270dc8d4711b17159d1ef271eb8b283c6d75ed4d59b77faf1cf
5
5
  SHA512:
6
- metadata.gz: 2f0273735e483b4b93949b639ac1c76191fda722709efd043908bee522f853a9ae500d57a127b32bdab5f65232a3769755a98fce1cce4e082038d998f149c324
7
- data.tar.gz: e27c29a51d263e4d55ec537515d18215ed280fc6f19df997cb9d4733c6ebc60c6495b80fd4679882b77e3cbea629249ed1f0284665453e8e01288179773308d7
6
+ metadata.gz: 383e4c7e44d61c1346d192fbe0fb6362b112b97854f87a98f7ea506ea2a5cd9449c68c4d80cd77020d2ad950d69e652e81b9b46980fb5cdc8c8a2c9c484bb485
7
+ data.tar.gz: cff07e92d9e67bb1d8228eea11d950cbef4420505c6f349203d3bcd3dd98c9d80ac7a0cd51f80980da60aadf1403fd797d5bc9420e2555ae12592c094ba080ce
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.45.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 73f1bd0: Reverted commit b050620b45f0ef6e73cfae2d2fe106c4831e7587, which was causing issues with some forms in the BuoyRails app.
8
+
9
+ ## 0.45.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 2cf21ed: Add more-horiz icon
14
+ - 2d2c3e6: Added a AssistiveTechNotifications component for notifying assistive tech users of changes that might otherwise only be presented visually. The output is two [ARIA live regions][aria-live-regions]—one `polite`, the other `assertive`—and is meant to be placed in an application’s layout so that it’s rendered on every page. Also provided, is the component’s public JavaScript function, `notifyAssistiveTech`, so that applications can easily send messages to these two live regions.
15
+
16
+ [aria-live-regions]: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions
17
+
3
18
  ## 0.44.0
4
19
 
5
20
  ### Minor Changes
@@ -0,0 +1,6 @@
1
+ <!-- Source: Iconoir, added via `bin/add_icon` -->
2
+ <svg width="24" height="24" stroke-width="1.5" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
3
+ <path d="M17 19C15.8954 19 15 18.1046 15 17C15 15.8954 15.8954 15 17 15C18.1046 15 19 15.8954 19 17C19 18.1046 18.1046 19 17 19Z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
4
+ <path d="M7 9C5.89543 9 5 8.10457 5 7C5 5.89543 5.89543 5 7 5C8.10457 5 9 5.89543 9 7C9 8.10457 8.10457 9 7 9Z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
5
+ <path d="M19 5L5 19" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
6
+ </svg>
@@ -10,6 +10,7 @@ import ToastController from "./toast_controller";
10
10
  import ToggleController from "./toggle_controller";
11
11
  import TypeaheadSelectController from "./typeahead_select_controller";
12
12
  import { Application } from "@hotwired/stimulus";
13
+ import { notifyAssistiveTech } from "./assistive_tech_notifications_component";
13
14
 
14
15
  export function registerAnchorControllers(application: Application) {
15
16
  application.register("autocomplete", AutocompleteController);
@@ -31,4 +32,5 @@ export {
31
32
  ToastController,
32
33
  ToggleController,
33
34
  TypeaheadSelectController,
35
+ notifyAssistiveTech,
34
36
  };
@@ -0,0 +1,23 @@
1
+ <%= tag.div(
2
+ **merge_options(
3
+ wrapper_options,
4
+ aria: {
5
+ atomic: true,
6
+ live: "polite",
7
+ },
8
+ class: "sr-only",
9
+ id: "js-assistive-tech-notifications",
10
+ ),
11
+ ) %>
12
+
13
+ <%= tag.div(
14
+ **merge_options(
15
+ wrapper_options,
16
+ aria: {
17
+ atomic: true,
18
+ live: "assertive",
19
+ },
20
+ class: "sr-only",
21
+ id: "js-assistive-tech-notifications-assertive",
22
+ ),
23
+ ) %>
@@ -0,0 +1,4 @@
1
+ module Anchor
2
+ class AssistiveTechNotificationsComponent < Component
3
+ end
4
+ end
@@ -0,0 +1,15 @@
1
+ export function notifyAssistiveTech(message: string, assertive = false) {
2
+ const liveRegionId = assertive
3
+ ? "js-assistive-tech-notifications-assertive"
4
+ : "js-assistive-tech-notifications";
5
+ const liveRegion = document.getElementById(liveRegionId);
6
+
7
+ if (liveRegion) {
8
+ liveRegion.textContent = message;
9
+ } else {
10
+ console.warn(
11
+ `Could not find #${liveRegionId}.`,
12
+ "Make sure to include `anchor_assistive_tech_notifications` in your Rails layout.",
13
+ );
14
+ }
15
+ }
@@ -1,2 +1,3 @@
1
1
  en:
2
+ assistive_tech_notification: Copied
2
3
  copy_to_clipboard: Copy to Clipboard
@@ -4,7 +4,7 @@
4
4
  action: "click->copy-to-clipboard#copy",
5
5
  controller: "copy-to-clipboard",
6
6
  copy_to_clipboard_text_to_copy_value: value,
7
- copy_to_clipboard_hidden_class: "hidden",
7
+ copy_to_clipboard_assistive_tech_notification_value: t(".assistive_tech_notification"),
8
8
  },
9
9
  class: "bg-transparent",
10
10
  type: "button",
@@ -15,7 +15,7 @@
15
15
  ) %>
16
16
  <%= anchor_icon(
17
17
  icon: "check",
18
- classes: "hidden",
18
+ hidden: true,
19
19
  data: { copy_to_clipboard_target: "successIcon"},
20
20
  ) %>
21
21
  <% end %>
@@ -1,26 +1,28 @@
1
1
  import { Controller } from "@hotwired/stimulus";
2
+ import { notifyAssistiveTech } from "./assistive_tech_notifications_component";
2
3
 
3
4
  export default class extends Controller<HTMLDivElement> {
4
5
  static targets = [ "initialIcon", "successIcon"];
5
- static classes = [ "hidden" ]
6
+ static values = {
7
+ assistiveTechNotification: String,
8
+ notificationDelay: { type: Number, default: 1500 },
9
+ textToCopy: String,
10
+ };
6
11
 
7
12
  declare readonly initialIconTarget: SVGElement;
8
13
  declare readonly successIconTarget: SVGElement;
9
14
  declare readonly notificationDelayValue: number;
10
15
  declare readonly hiddenClass: string;
11
16
  declare readonly textToCopyValue: string;
17
+ declare readonly assistiveTechNotificationValue: string;
12
18
  declare readonly hasTextToCopyValue: boolean;
13
19
 
14
- static values = {
15
- notificationDelay: { type: Number, default: 1500 },
16
- textToCopy: String,
17
- };
18
-
19
20
  copy(): void {
20
21
  if (this.hasTextToCopyValue) {
21
22
  navigator.clipboard.writeText(this.textToCopyValue);
22
23
  }
23
24
  this.toggleIcons();
25
+ notifyAssistiveTech(this.assistiveTechNotificationValue);
24
26
 
25
27
  setTimeout(() => {
26
28
  this.toggleIcons();
@@ -28,7 +30,7 @@ export default class extends Controller<HTMLDivElement> {
28
30
  }
29
31
 
30
32
  toggleIcons(): void {
31
- this.initialIconTarget.classList.toggle(this.hiddenClass);
32
- this.successIconTarget.classList.toggle(this.hiddenClass);
33
+ this.initialIconTarget.toggleAttribute("hidden");
34
+ this.successIconTarget.toggleAttribute("hidden");
33
35
  }
34
36
  }
@@ -1,7 +1,11 @@
1
1
  <%= tag.div(
2
2
  **merge_options(wrapper_options, {
3
3
  class: "toast",
4
- data: { controller: "toast", testid: test_id },
4
+ data: {
5
+ controller: "toast",
6
+ toast_assistive_tech_notification_value: assistive_tech_notification,
7
+ testid: test_id,
8
+ },
5
9
  popover: "manual",
6
10
  })
7
11
  ) do %>
@@ -25,6 +25,10 @@ module Anchor
25
25
  content?
26
26
  end
27
27
 
28
+ def assistive_tech_notification
29
+ strip_tags(content)
30
+ end
31
+
28
32
  def test_id
29
33
  wrapper_options.dig(:data, :testid) || "toast"
30
34
  end
@@ -1,11 +1,14 @@
1
1
  import { Controller } from "@hotwired/stimulus";
2
+ import { notifyAssistiveTech } from "./assistive_tech_notifications_component";
2
3
 
3
4
  export default class extends Controller<HTMLDivElement> {
4
5
  static values = {
6
+ assistiveTechNotification: String,
5
7
  hideDelay: { type: Number, default: 3000 },
6
8
  showDelay: { type: Number, default: 200 },
7
9
  };
8
10
 
11
+ declare assistiveTechNotificationValue: string;
9
12
  declare hideDelayValue: number
10
13
  declare showDelayValue: number
11
14
 
@@ -17,6 +20,8 @@ export default class extends Controller<HTMLDivElement> {
17
20
  setTimeout(() => {
18
21
  this.element.remove();
19
22
  }, this.hideDelayValue);
23
+
24
+ notifyAssistiveTech(this.assistiveTechNotificationValue);
20
25
  }
21
26
 
22
27
  disconnect(): void {
@@ -132,7 +132,7 @@ module Anchor
132
132
  starting_icon: options.delete(:starting_icon),
133
133
  ending_icon: options.delete(:ending_icon)
134
134
  ) do |component|
135
- super attribute, component.options.merge(options)
135
+ super(attribute, component.options.merge(options))
136
136
  end
137
137
  end
138
138
 
@@ -144,7 +144,7 @@ module Anchor
144
144
  starting_icon: options.delete(:starting_icon),
145
145
  ending_icon: options.delete(:ending_icon)
146
146
  ) do |component|
147
- super attribute, component.options.merge(options)
147
+ super(attribute, component.options.merge(options))
148
148
  end
149
149
  end
150
150
 
@@ -2,6 +2,7 @@ module Anchor
2
2
  module ViewHelper
3
3
  ANCHOR_HELPERS = %i[
4
4
  action_menu
5
+ assistive_tech_notifications
5
6
  autocomplete/results
6
7
  badge
7
8
  banner
@@ -1,5 +1,5 @@
1
1
  module Anchor
2
2
  module ViewComponents
3
- VERSION = "0.44.0".freeze
3
+ VERSION = "0.45.1".freeze
4
4
  end
5
5
  end
@@ -0,0 +1,10 @@
1
+ <%= anchor_text do %>
2
+ This component is visually hidden, by design. Inspect the page source and look
3
+ for the two
4
+ <%= anchor_link(
5
+ "ARIA live regions",
6
+ href: "https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions",
7
+ ) %>:
8
+ <code>div#js-assistive-tech-notifications</code>
9
+ and <code>div#js-assistive-tech-notifications-assertive</code>.
10
+ <% end %>
@@ -0,0 +1,5 @@
1
+ module Anchor
2
+ class AssistiveTechNotificationsComponentPreview < Preview
3
+ def default; end
4
+ end
5
+ end
@@ -1,20 +1,11 @@
1
- <%= anchor_form_with url: false, method: :get do |form| %>
2
- <%= form.search_field :search, placeholder: "Search…",
3
- starting_icon: :search %>
4
- <%= form.text_field :search, placeholder: "Search…",
5
- ending_icon: :calendar %>
6
- <%= form.text_field :search, placeholder: "Search…", starting_icon: :search,
7
- ending_icon: :calendar %>
8
- <%= form.number_field(
9
- :amount,
10
- placeholder: "0.00",
11
- starting_icon: :dollar,
12
- step: 0.01
13
- ) %>
14
- <%= form.number_field(
15
- :amount,
16
- placeholder: "0",
17
- ending_icon: :dollar,
18
- step: 1
19
- ) %>
1
+ <%= anchor_form_with url: false do |form| %>
2
+ <%= tag.div do %>
3
+ <%= form.label :price %>
4
+ <%= form.text_field :price, inputmode: :numeric, starting_icon: "dollar" %>
5
+ <% end %>
6
+
7
+ <%= tag.div do %>
8
+ <%= form.label :discount %>
9
+ <%= form.text_field :discount, inputmode: :numeric, ending_icon: "percentage" %>
10
+ <% end %>
20
11
  <% 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.44.0
4
+ version: 0.45.1
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-08 00:00:00.000000000 Z
11
+ date: 2024-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -69,6 +69,7 @@ files:
69
69
  - app/assets/images/icons/nav-arrow-left.svg
70
70
  - app/assets/images/icons/nav-arrow-right.svg
71
71
  - app/assets/images/icons/paste-clipboard.svg
72
+ - app/assets/images/icons/percentage.svg
72
73
  - app/assets/images/icons/plus.svg
73
74
  - app/assets/images/icons/search.svg
74
75
  - app/assets/images/icons/warning-circle.svg
@@ -82,6 +83,9 @@ files:
82
83
  - app/components/anchor/action_menu_component.html.erb
83
84
  - app/components/anchor/action_menu_component.rb
84
85
  - app/components/anchor/anchor_view_components.ts
86
+ - app/components/anchor/assistive_tech_notifications_component.html.erb
87
+ - app/components/anchor/assistive_tech_notifications_component.rb
88
+ - app/components/anchor/assistive_tech_notifications_component.ts
85
89
  - app/components/anchor/autocomplete/results_component.html.erb
86
90
  - app/components/anchor/autocomplete/results_component.rb
87
91
  - app/components/anchor/autocomplete_component.en.yml
@@ -196,6 +200,8 @@ files:
196
200
  - previews/anchor/action_menu_component_preview/autoplacement.html.erb
197
201
  - previews/anchor/action_menu_component_preview/custom_trigger.html.erb
198
202
  - previews/anchor/action_menu_component_preview/opens_a_dialog.html.erb
203
+ - previews/anchor/assistive_tech_notifications_component_preview.rb
204
+ - previews/anchor/assistive_tech_notifications_component_preview/default.html.erb
199
205
  - previews/anchor/badge_component_preview.rb
200
206
  - previews/anchor/banner_component_preview.rb
201
207
  - previews/anchor/banner_component_preview/body_only.html.erb