blacklight-hierarchy 6.5.0 → 6.7.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: '0087020faf523fb8671351fa18c62b7d4f2bd09f254b24564a5a5d7aac9d5593'
4
- data.tar.gz: 6ffb7349402eea8340d105cc747d95d0089c94a552700f5f1106cb6fb069173a
3
+ metadata.gz: 141fa38233321f2397dfd254b51bc790f0be05647b5e3d6d907084999c73c6dc
4
+ data.tar.gz: d13151db84464e2c7485488e33b97fa455adf64823944e09fa40f41e4441cd7e
5
5
  SHA512:
6
- metadata.gz: 66d064cea30098266d2276b2806775a348250f8f1eb9bd27958018502589dbd6402bf18273ab1cd034e85a6747ef0fa74aee88e93d0d1bda71552284c656d192
7
- data.tar.gz: 685bd238b6bec0f0c41d2b3bbd831111734c3b472f5949e8f27b90f13ffa3c387784d486b617b4cab07ba5b16e490bd6584c94b0c20e557f0c0479a5697107d3
6
+ metadata.gz: 2bb3a06e042232ab2d95f68276692100e322723b99dc8b70c7f5dbdf28238b14e7fcaa5486becd5b95c7a97c0df5703614bac09fa75a61800e18ec47ae72891a
7
+ data.tar.gz: 024e46f594e967e271e57ee64f7cc0994a67ce0d7529625d422176feba5b5f7de62276774c2a3466e63795249e8d4a21525a158af6d7cf1e942ee94fbb8e0487
@@ -28,6 +28,10 @@ jobs:
28
28
  rails_version: "7.1.3.4"
29
29
  name: "Blacklight 7"
30
30
  blacklight_version: "7.38.0"
31
+ - ruby: "3.4"
32
+ rails_version: "8.0.2"
33
+ name: "Blacklight 9 beta"
34
+ blacklight_version: "9.0.0.beta2"
31
35
  env:
32
36
  BLACKLIGHT_VERSION: ${{ matrix.blacklight_version }}
33
37
  steps:
data/README.md CHANGED
@@ -100,13 +100,13 @@ config.add_facet_field 'tag_facet', sort: 'alpha', label: 'Tag', component: Blac
100
100
  ```
101
101
 
102
102
  ### Changing the icons
103
- We store our closed/open icons as the SASS variables `$b-h-closed-icon` and `$b-h-closed-icon` in `hierarchy.scss`. By default we use SVGs provided by the [Font Awesome](https://github.com/FortAwesome/Font-Awesome) library. To change the icon, reassign these SASS variables with new SVG code.
103
+ We store our closed/open icons as the CSS variables `--bl-h-closed-icon` and `--bl-h-closed-icon` in `hierarchy.css`. By default we use SVGs provided by the [Font Awesome](https://github.com/FortAwesome/Font-Awesome) library. To change the icon, reassign these CSS variables with new SVG code.
104
104
 
105
- ```scss
106
- /* app/assets/stylesheets/blacklight/hierarchy/hierarchy.scss */
105
+ ```css
106
+ /* app/assets/stylesheets/blacklight/hierarchy/hierarchy.css */
107
107
 
108
- // plus sign
109
- $b-h-closed-icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'><!--! Font Awesome Free 6.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc. --><path d='M200 344V280H136C122.7 280 112 269.3 112 256C112 242.7 122.7 232 136 232H200V168C200 154.7 210.7 144 224 144C237.3 144 248 154.7 248 168V232H312C325.3 232 336 242.7 336 256C336 269.3 325.3 280 312 280H248V344C248 357.3 237.3 368 224 368C210.7 368 200 357.3 200 344zM0 96C0 60.65 28.65 32 64 32H384C419.3 32 448 60.65 448 96V416C448 451.3 419.3 480 384 480H64C28.65 480 0 451.3 0 416V96zM48 96V416C48 424.8 55.16 432 64 432H384C392.8 432 400 424.8 400 416V96C400 87.16 392.8 80 384 80H64C55.16 80 48 87.16 48 96z'/></svg>") !default;
108
+ /* plus sign */
109
+ --bl-h-closed-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'%3e%3c!--! Font Awesome Free 6.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free %28Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License%29 Copyright 2022 Fonticons, Inc. --%3e%3cpath d='M200 344V280H136C122.7 280 112 269.3 112 256C112 242.7 122.7 232 136 232H200V168C200 154.7 210.7 144 224 144C237.3 144 248 154.7 248 168V232H312C325.3 232 336 242.7 336 256C336 269.3 325.3 280 312 280H248V344C248 357.3 237.3 368 224 368C210.7 368 200 357.3 200 344zM0 96C0 60.65 28.65 32 64 32H384C419.3 32 448 60.65 448 96V416C448 451.3 419.3 480 384 480H64C28.65 480 0 451.3 0 416V96zM48 96V416C48 424.8 55.16 432 64 432H384C392.8 432 400 424.8 400 416V96C400 87.16 392.8 80 384 80H64C55.16 80 48 87.16 48 96z'/%3e%3c/svg%3e");
110
110
  ```
111
111
 
112
112
 
@@ -124,10 +124,6 @@ en:
124
124
  toggle_aria_label: Toggle call number section
125
125
  ```
126
126
 
127
- ### Javascript
128
-
129
- The javascript in this project requires jquery, but it's up to you to provide it in a way that best works for your project. You may consider the jquery-rails gem or if you use webpacker, you could use the jquery npm package.
130
-
131
127
  ## Caveats
132
128
 
133
129
  This code was ripped out of another project, and is still quite immature as a standalone project. Every effort has been made to make it as plug-and-play as possible, but it may stomp on Blacklight in unintended ways (e.g., ways that made sense in context of its former host app, but which aren't compatible with generic Blacklight). Proceed with caution, and report issues.
@@ -1,31 +1,31 @@
1
- Blacklight.onLoad(function(){
2
- Blacklight.do_hierarchical_facet_expand_contract_behavior();
3
- });
1
+ Blacklight.onLoad(() => Blacklight.do_hierarchical_facet_expand_contract_behavior())
4
2
 
5
- (function($) {
6
- Blacklight.do_hierarchical_facet_expand_contract_behavior = function() {
7
- $( Blacklight.do_hierarchical_facet_expand_contract_behavior.selector ).each (
8
- Blacklight.hierarchical_facet_expand_contract
9
- );
3
+ (() => {
4
+ Blacklight.do_hierarchical_facet_expand_contract_behavior = () => {
5
+ const elements = document.querySelectorAll(Blacklight.do_hierarchical_facet_expand_contract_behavior.selector)
6
+ elements.forEach(elem => Blacklight.hierarchical_facet_expand_contract(elem))
10
7
  }
11
- Blacklight.do_hierarchical_facet_expand_contract_behavior.selector = '[data-controller="b-h-collapsible"]';
12
- Blacklight.do_hierarchical_facet_expand_contract_behavior.handle = '[data-action="click->b-h-collapsible#toggle"]';
13
- Blacklight.do_hierarchical_facet_expand_contract_behavior.list = '[data-b-h-collapsible-target="list"]';
8
+ Blacklight.do_hierarchical_facet_expand_contract_behavior.selector = '[data-controller="b-h-collapsible"]'
9
+ Blacklight.do_hierarchical_facet_expand_contract_behavior.handle = '[data-action="click->b-h-collapsible#toggle"]'
10
+ Blacklight.do_hierarchical_facet_expand_contract_behavior.list = '[data-b-h-collapsible-target="list"]'
14
11
 
15
- Blacklight.hierarchical_facet_expand_contract = function() {
16
- var li = $(this);
17
- li.addClass('twiddle');
12
+ Blacklight.hierarchical_facet_expand_contract = (element) => {
13
+ element.classList.add('twiddle')
18
14
 
19
- $(Blacklight.do_hierarchical_facet_expand_contract_behavior.list, this).each(function() {
20
- if($('span.selected', this).length != 0){
21
- li.addClass('twiddle-open');
22
- li.children('.collapse').addClass('show');
15
+ const lists = element.querySelectorAll(Blacklight.do_hierarchical_facet_expand_contract_behavior.list)
16
+
17
+ lists.forEach((list) => {
18
+ if (list.querySelector('span.selected')) {
19
+ element.classList.add('twiddle-open')
20
+ const collapseElement = element.querySelector('.collapse')
21
+ if (collapseElement) {
22
+ collapseElement.classList.add('show')
23
+ }
23
24
  }
24
- });
25
+ })
25
26
 
26
27
  // attach the toggle behavior to the li tag
27
- li.children(Blacklight.do_hierarchical_facet_expand_contract_behavior.handle).click(function(e){
28
- li.toggleClass('twiddle-open');
29
- });
30
- };
31
- })(jQuery);
28
+ const handle = element.querySelector(Blacklight.do_hierarchical_facet_expand_contract_behavior.handle)
29
+ handle?.addEventListener('click', () => element.classList.toggle('twiddle-open'))
30
+ }
31
+ })()
@@ -0,0 +1,100 @@
1
+ :root {
2
+ --bl-h-remove-color: var(--bs-secondary-color);
3
+
4
+ /* plus sign */
5
+ --bl-h-closed-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'%3e%3c!--! Font Awesome Free 6.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free %28Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License%29 Copyright 2022 Fonticons, Inc. --%3e%3cpath d='M200 344V280H136C122.7 280 112 269.3 112 256C112 242.7 122.7 232 136 232H200V168C200 154.7 210.7 144 224 144C237.3 144 248 154.7 248 168V232H312C325.3 232 336 242.7 336 256C336 269.3 325.3 280 312 280H248V344C248 357.3 237.3 368 224 368C210.7 368 200 357.3 200 344zM0 96C0 60.65 28.65 32 64 32H384C419.3 32 448 60.65 448 96V416C448 451.3 419.3 480 384 480H64C28.65 480 0 451.3 0 416V96zM48 96V416C48 424.8 55.16 432 64 432H384C392.8 432 400 424.8 400 416V96C400 87.16 392.8 80 384 80H64C55.16 80 48 87.16 48 96z'/%3e%3c/svg%3e");
6
+
7
+ /* minus sign */
8
+ --bl-h-opened-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'%3e%3c!--! Font Awesome Free 6.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free %28Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License%29 Copyright 2022 Fonticons, Inc. --%3e%3cpath d='M312 232C325.3 232 336 242.7 336 256C336 269.3 325.3 280 312 280H136C122.7 280 112 269.3 112 256C112 242.7 122.7 232 136 232H312zM0 96C0 60.65 28.65 32 64 32H384C419.3 32 448 60.65 448 96V416C448 451.3 419.3 480 384 480H64C28.65 480 0 451.3 0 416V96zM48 96V416C48 424.8 55.16 432 64 432H384C392.8 432 400 424.8 400 416V96C400 87.16 392.8 80 384 80H64C55.16 80 48 87.16 48 96z'/%3e%3c/svg%3e");
9
+ }
10
+
11
+ .facet-hierarchy {
12
+ list-style-type: none;
13
+ padding-left: 0;
14
+ flex: 1 1 100%;
15
+ width: 100%;
16
+
17
+ ul {
18
+ list-style-type: none;
19
+ padding-left: 0.75rem;
20
+ flex: 1 1 100%;
21
+ width: 100%;
22
+ }
23
+
24
+ .facet-label {
25
+ flex: 1;
26
+ }
27
+
28
+ .facet-select {
29
+ flex: 1;
30
+ word-break: break-word;
31
+ }
32
+
33
+ .facet-count {
34
+ float: right;
35
+ flex: 0 0 auto;
36
+ padding-left: 0.5rem;
37
+ }
38
+
39
+ .toggle-handle {
40
+ border: 0;
41
+ margin: 0;
42
+ width: 1.5rem;
43
+ height: 1.5rem;
44
+ padding: 0;
45
+ vertical-align: top;
46
+ display: flex;
47
+ align-items: flex-start;
48
+
49
+ .closed,
50
+ .opened {
51
+ display: none;
52
+ }
53
+ }
54
+
55
+ .twiddle > .toggle-handle {
56
+ background-color: transparent;
57
+ }
58
+
59
+ .twiddle > .toggle-handle .toggle-icon {
60
+ background-position: center;
61
+ background-repeat: no-repeat;
62
+ margin-top: 0.25rem;
63
+ min-height: 1.1rem;
64
+ min-width: 1.1rem;
65
+ }
66
+
67
+ .twiddle > .toggle-handle .closed {
68
+ background-image: var(--bl-h-closed-icon);
69
+ display: inline-block;
70
+ }
71
+
72
+ .twiddle > .toggle-handle .opened {
73
+ display: none;
74
+ }
75
+
76
+ .twiddle-open > .toggle-handle .closed {
77
+ display: none;
78
+ }
79
+
80
+ .twiddle-open > .toggle-handle .opened {
81
+ background-image: var(--bl-h-opened-icon);
82
+ display: inline-block;
83
+ }
84
+
85
+ .h-node,
86
+ .h-leaf {
87
+ display: flex;
88
+ flex-wrap: wrap;
89
+ padding: 3px 0;
90
+ align-items: center;
91
+ }
92
+
93
+ .h-leaf {
94
+ padding-left: 1.5rem;
95
+ }
96
+
97
+ .remove {
98
+ color: var(--bl-h-remove-color);
99
+ }
100
+ }
@@ -2,7 +2,8 @@
2
2
 
3
3
  module Blacklight
4
4
  module Hierarchy
5
- class FacetFieldListComponent < Blacklight::FacetFieldListComponent
5
+ superklass = defined?(Blacklight::Facets::ListComponent) ? Blacklight::Facets::ListComponent : Blacklight::FacetFieldListComponent
6
+ class FacetFieldListComponent < superklass
6
7
  DELIMITER = '_'
7
8
 
8
9
  # @param [Blacklight::Configuration::FacetField] as defined in controller with config.add_facet_field (and with :partial => 'blacklight/hierarchy/facet_hierarchy')
@@ -1,8 +1,5 @@
1
1
  <span class="facet-label">
2
2
  <%= content_tag :span, label_value, id: id, class: 'selected' %>
3
3
  </span>
4
- <%= link_to(remove_href, class: 'remove') do %>
5
- <span class="remove-icon" aria-hidden="true">✖</span>
6
- <span class="sr-only"><%= t('blacklight.search.facets.selected.remove') %></span>
7
- <% end %>
4
+ <%= remove_link %>
8
5
  <%= render_facet_count %>
@@ -3,6 +3,7 @@
3
3
  module Blacklight
4
4
  module Hierarchy
5
5
  # Standard display of a SELECTED facet value, no link, special span with class, and 'remove' button.
6
+ # This is similar to Blacklight::Facet::SelectedValueComponent
6
7
  class SelectedQfacetValueComponent < QfacetValueComponent
7
8
  def initialize(field_name:, item:)
8
9
  @field_name = field_name
@@ -14,6 +15,13 @@ module Blacklight
14
15
  def remove_href
15
16
  helpers.search_action_path(helpers.search_state.filter(field_name).remove(item.qvalue).params)
16
17
  end
18
+
19
+ def remove_link
20
+ link_to(remove_href, class: "remove ps-2", rel: "nofollow") do
21
+ render(Blacklight::Icons::RemoveComponent.new(aria_hidden: true)) +
22
+ tag.span(t(:'blacklight.search.facets.selected.remove'), class: 'visually-hidden')
23
+ end
24
+ end
17
25
  end
18
26
  end
19
27
  end
@@ -1,5 +1,5 @@
1
1
  module Blacklight
2
2
  module Hierarchy
3
- VERSION = '6.5.0'.freeze
3
+ VERSION = '6.7.0'.freeze
4
4
  end
5
5
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blacklight-hierarchy",
3
- "version": "6.4.0",
3
+ "version": "6.7.0",
4
4
  "description": "[![Build Status](https://github.com/sul-dlss/blacklight-hierarchy/workflows/CI/badge.svg)](https://github.com/sul-dlss/blacklight-hierarchy/actions?query=branch%3Amain)",
5
5
  "main": "app/assets/javascripts/blacklight/hierarchy/hierarchy.js",
6
6
  "files": [
@@ -19,7 +19,6 @@
19
19
  "homepage": "https://github.com/sul-dlss/blacklight-hierarchy#readme",
20
20
  "devDependencies": {},
21
21
  "dependencies": {
22
- "blacklight-frontend": ">=7.1 || 8.0",
23
- "jquery": ">=3.0"
22
+ "blacklight-frontend": ">=7.1 <10.0.0"
24
23
  }
25
24
  }
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacklight-hierarchy
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.5.0
4
+ version: 6.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael B. Klein
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-04-04 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: blacklight
@@ -152,7 +152,7 @@ files:
152
152
  - Rakefile
153
153
  - app/assets/javascripts/blacklight/hierarchy/blacklight_hierarchy_controller.js
154
154
  - app/assets/javascripts/blacklight/hierarchy/hierarchy.js
155
- - app/assets/stylesheets/blacklight/hierarchy/hierarchy.scss
155
+ - app/assets/stylesheets/blacklight/hierarchy/hierarchy.css
156
156
  - app/components/blacklight/hierarchy/facet_field_component.html.erb
157
157
  - app/components/blacklight/hierarchy/facet_field_component.rb
158
158
  - app/components/blacklight/hierarchy/facet_field_list_component.html.erb
@@ -200,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
200
  - !ruby/object:Gem::Version
201
201
  version: '0'
202
202
  requirements: []
203
- rubygems_version: 3.6.3
203
+ rubygems_version: 3.6.9
204
204
  specification_version: 4
205
205
  summary: Hierarchical Facets for Blacklight
206
206
  test_files:
@@ -1,100 +0,0 @@
1
- // plus sign
2
- $b-h-closed-icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'><!--! Font Awesome Free 6.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc. --><path d='M200 344V280H136C122.7 280 112 269.3 112 256C112 242.7 122.7 232 136 232H200V168C200 154.7 210.7 144 224 144C237.3 144 248 154.7 248 168V232H312C325.3 232 336 242.7 336 256C336 269.3 325.3 280 312 280H248V344C248 357.3 237.3 368 224 368C210.7 368 200 357.3 200 344zM0 96C0 60.65 28.65 32 64 32H384C419.3 32 448 60.65 448 96V416C448 451.3 419.3 480 384 480H64C28.65 480 0 451.3 0 416V96zM48 96V416C48 424.8 55.16 432 64 432H384C392.8 432 400 424.8 400 416V96C400 87.16 392.8 80 384 80H64C55.16 80 48 87.16 48 96z'/></svg>") !default;
3
- // minus sign
4
- $b-h-opened-icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'><!--! Font Awesome Free 6.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc. --><path d='M312 232C325.3 232 336 242.7 336 256C336 269.3 325.3 280 312 280H136C122.7 280 112 269.3 112 256C112 242.7 122.7 232 136 232H312zM0 96C0 60.65 28.65 32 64 32H384C419.3 32 448 60.65 448 96V416C448 451.3 419.3 480 384 480H64C28.65 480 0 451.3 0 416V96zM48 96V416C48 424.8 55.16 432 64 432H384C392.8 432 400 424.8 400 416V96C400 87.16 392.8 80 384 80H64C55.16 80 48 87.16 48 96z'/></svg>") !default;
5
-
6
- $text-muted: #777 !default;
7
-
8
- :root {
9
- --text-muted: #{$text-muted};
10
- }
11
-
12
- .facet-hierarchy {
13
- list-style-type: none;
14
- padding-left: 0;
15
- flex: 1 1 100%;
16
- width: 100%;
17
-
18
- ul {
19
- list-style-type: none;
20
- padding-left: 0.75rem;
21
- flex: 1 1 100%;
22
- width: 100%;
23
- }
24
-
25
- .facet-label {
26
- flex: 1;
27
- }
28
-
29
- .facet-select {
30
- flex: 1;
31
- word-break: break-word;
32
- }
33
-
34
- .facet-count {
35
- float: right;
36
- flex: 0 0 auto;
37
- padding-left: 0.5rem;
38
- }
39
-
40
- .toggle-handle {
41
- border: 0;
42
- margin: 0;
43
- width: 1.5rem;
44
- height: 1.5rem;
45
- padding: 0;
46
- vertical-align: top;
47
- display: flex;
48
- align-items: flex-start;
49
-
50
- .closed,
51
- .opened {
52
- display: none;
53
- }
54
- }
55
-
56
- .twiddle > .toggle-handle {
57
- background-color: transparent;
58
- }
59
-
60
- .twiddle > .toggle-handle .toggle-icon {
61
- background-position: center;
62
- background-repeat: no-repeat;
63
- margin-top: 0.25rem;
64
- min-height: 1.1rem;
65
- min-width: 1.1rem;
66
- }
67
-
68
- .twiddle > .toggle-handle .closed {
69
- background-image: escape-svg($b-h-closed-icon);
70
- display: inline-block;
71
- }
72
-
73
- .twiddle > .toggle-handle .opened {
74
- display: none;
75
- }
76
-
77
- .twiddle-open > .toggle-handle .closed {
78
- display: none;
79
- }
80
-
81
- .twiddle-open > .toggle-handle .opened {
82
- background-image: escape-svg($b-h-opened-icon);
83
- display: inline-block;
84
- }
85
-
86
- .h-node,
87
- .h-leaf {
88
- display: flex;
89
- flex-wrap: wrap;
90
- padding: 3px 0;
91
- }
92
-
93
- .h-leaf {
94
- padding-left: 1.5rem;
95
- }
96
-
97
- .remove {
98
- color: var(--text-muted);
99
- }
100
- }