blacklight-frontend 7.10.0 → 7.21.2

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.
Files changed (45) hide show
  1. package/README.md +2 -4
  2. package/app/assets/images/blacklight/list.svg +1 -0
  3. package/app/assets/images/blacklight/logo.png +0 -0
  4. package/app/assets/images/blacklight/search.svg +1 -0
  5. package/app/assets/images/favicon.ico +0 -0
  6. package/app/assets/javascripts/blacklight/blacklight.js +54 -30
  7. package/app/assets/stylesheets/blacklight/_balanced_list.scss +2 -2
  8. package/app/assets/stylesheets/blacklight/_bootstrap_overrides.scss +1 -1
  9. package/app/assets/stylesheets/blacklight/_constraints.scss +8 -5
  10. package/app/assets/stylesheets/blacklight/_controls.scss +10 -1
  11. package/app/assets/stylesheets/blacklight/_facets.scss +5 -3
  12. package/app/assets/stylesheets/blacklight/_header.scss +6 -6
  13. package/app/assets/stylesheets/blacklight/_icons.scss +5 -1
  14. package/app/assets/stylesheets/blacklight/_pagination.scss +1 -1
  15. package/app/assets/stylesheets/blacklight/_twitter_typeahead.scss +1 -0
  16. package/app/assets/stylesheets/blacklight/blacklight_defaults.scss +5 -1
  17. package/app/javascript/blacklight/button_focus.js +1 -0
  18. package/app/javascript/blacklight/core.js +16 -3
  19. package/app/javascript/blacklight/modal.js +12 -6
  20. package/app/javascript/blacklight/search_context.js +5 -3
  21. package/package.json +9 -3
  22. package/CONTRIBUTING.md +0 -50
  23. package/Gemfile.lock +0 -374
  24. package/VERSION +0 -1
  25. package/app/builders/blacklight/action_builder.rb +0 -57
  26. package/app/components/blacklight/constraint_layout_component.html.erb +0 -23
  27. package/app/components/blacklight/constraint_layout_component.rb +0 -16
  28. package/app/components/blacklight/document_component.html.erb +0 -29
  29. package/app/components/blacklight/document_component.rb +0 -121
  30. package/app/components/blacklight/document_metadata_component.html.erb +0 -5
  31. package/app/components/blacklight/document_metadata_component.rb +0 -21
  32. package/app/components/blacklight/facet_field_component.html.erb +0 -25
  33. package/app/components/blacklight/facet_field_component.rb +0 -11
  34. package/app/components/blacklight/facet_field_list_component.html.erb +0 -18
  35. package/app/components/blacklight/facet_field_list_component.rb +0 -22
  36. package/app/components/blacklight/facet_field_no_layout_component.rb +0 -13
  37. package/app/components/blacklight/facet_item_component.rb +0 -120
  38. package/app/components/blacklight/facet_item_pivot_component.rb +0 -84
  39. package/app/components/blacklight/metadata_field_component.html.erb +0 -8
  40. package/app/components/blacklight/metadata_field_component.rb +0 -31
  41. package/app/components/blacklight/metadata_field_layout_component.html.erb +0 -2
  42. package/app/components/blacklight/metadata_field_layout_component.rb +0 -16
  43. package/app/values/blacklight/types.rb +0 -31
  44. package/config/i18n-tasks.yml +0 -17
  45. package/docker-compose.yml +0 -35
@@ -1,18 +0,0 @@
1
- <%= render(@layout.new(facet_field: @facet_field)) do |component| %>
2
- <% component.with(:label) do %>
3
- <%= @facet_field.label %>
4
- <% end %>
5
- <% component.with(:body) do %>
6
- <ul class="facet-values list-unstyled">
7
- <%= render_facet_limit_list @facet_field.paginator, @facet_field.key %>
8
- </ul>
9
- <%# backwards compatibility, ugh %>
10
- <% if @layout == Blacklight::FacetFieldNoLayoutComponent && !@facet_field.in_modal? && @facet_field.modal_path %>
11
- <div class="more_facets">
12
- <%= link_to t("more_#{@facet_field.key}_html", scope: 'blacklight.search.facets', default: :more_html, field_name: @facet_field.label),
13
- @facet_field.modal_path,
14
- data: { blacklight_modal: 'trigger' } %>
15
- </div>
16
- <% end %>
17
- <% end %>
18
- <% end %>
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Blacklight
4
- class FacetFieldListComponent < ::ViewComponent::Base
5
- def initialize(facet_field:, layout: nil)
6
- @facet_field = facet_field
7
- @layout = layout == false ? FacetFieldNoLayoutComponent : Blacklight::FacetFieldComponent
8
- end
9
-
10
- # Here for backwards compatibility only.
11
- # @private
12
- def render_facet_limit_list(*args)
13
- Deprecation.silence(Blacklight::FacetsHelperBehavior) do
14
- @view_context.render_facet_limit_list(*args)
15
- end
16
- end
17
-
18
- def render?
19
- @facet_field.paginator.items.any?
20
- end
21
- end
22
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Blacklight
4
- class FacetFieldNoLayoutComponent < ::ViewComponent::Base
5
- with_content_areas :label, :body
6
-
7
- def initialize(**); end
8
-
9
- def call
10
- body
11
- end
12
- end
13
- end
@@ -1,120 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Blacklight
4
- class FacetItemComponent < ::ViewComponent::Base
5
- with_collection_parameter :facet_item
6
-
7
- def initialize(facet_item:, wrapping_element: 'li', suppress_link: false)
8
- @facet_item = facet_item
9
- @label = facet_item.label
10
- @hits = facet_item.hits
11
- @href = facet_item.href
12
- @selected = facet_item.selected?
13
- @wrapping_element = wrapping_element
14
- @suppress_link = suppress_link
15
- end
16
-
17
- def call
18
- # if the downstream app has overridden the helper methods we'd usually call,
19
- # use the helpers to preserve compatibility
20
- content = if overridden_helper_methods?
21
- content_from_legacy_view_helper
22
- elsif @selected
23
- render_selected_facet_value
24
- else
25
- render_facet_value
26
- end
27
-
28
- return if content.blank?
29
- return content unless @wrapping_element
30
-
31
- content_tag @wrapping_element, content
32
- end
33
-
34
- # This is a little shim to let us call the render methods below outside the
35
- # usual component rendering cycle (for backward compatibility)
36
- # @private
37
- # @deprecated
38
- def with_view_context(view_context)
39
- @view_context = view_context
40
- self
41
- end
42
-
43
- # Check if the downstream application has overridden these methods
44
- # @deprecated
45
- # @private
46
- def overridden_helper_methods?
47
- return false if explicit_component_configuration?
48
-
49
- @view_context.method(:render_facet_item).owner != Blacklight::FacetsHelperBehavior ||
50
- @view_context.method(:render_facet_value).owner != Blacklight::FacetsHelperBehavior ||
51
- @view_context.method(:render_selected_facet_value).owner != Blacklight::FacetsHelperBehavior
52
- end
53
-
54
- # Call out to the helper method equivalent of this component
55
- # @deprecated
56
- # @private
57
- def content_from_legacy_view_helper
58
- Deprecation.warn('Calling out to the #render_facet_item helper for backwards compatibility.')
59
- Deprecation.silence(Blacklight::FacetsHelperBehavior) do
60
- @view_context.render_facet_item(@facet_item.facet_field, @facet_item.facet_item)
61
- end
62
- end
63
-
64
- ##
65
- # Standard display of a facet value in a list. Used in both _facets sidebar
66
- # partial and catalog/facet expanded list. Will output facet value name as
67
- # a link to add that to your restrictions, with count in parens.
68
- #
69
- # @param [Blacklight::Solr::Response::Facets::FacetField] facet_field
70
- # @param [Blacklight::Solr::Response::Facets::FacetItem] item
71
- # @param [Hash] options
72
- # @option options [Boolean] :suppress_link display the facet, but don't link to it
73
- # @return [String]
74
- # @private
75
- def render_facet_value
76
- tag.span(class: "facet-label") do
77
- link_to_unless(@suppress_link, @label, @href, class: "facet-select")
78
- end + render_facet_count
79
- end
80
-
81
- ##
82
- # Standard display of a SELECTED facet value (e.g. without a link and with a remove button)
83
- # @see #render_facet_value
84
- # @param [Blacklight::Solr::Response::Facets::FacetField] facet_field
85
- # @param [String] item
86
- # @private
87
- def render_selected_facet_value
88
- tag.span(class: "facet-label") do
89
- tag.span(@label, class: "selected") +
90
- # remove link
91
- link_to(@href, class: "remove") do
92
- tag.span('✖', class: "remove-icon") +
93
- tag.span('[remove]', class: 'sr-only')
94
- end
95
- end + render_facet_count(classes: ["selected"])
96
- end
97
-
98
- ##
99
- # Renders a count value for facet limits. Can be over-ridden locally
100
- # to change style. And can be called by plugins to get consistent display.
101
- #
102
- # @param [Integer] num number of facet results
103
- # @param [Hash] options
104
- # @option options [Array<String>] an array of classes to add to count span.
105
- # @return [String]
106
- # @private
107
- def render_facet_count(options = {})
108
- return @view_context.render_facet_count(@hits, options) unless @view_context.method(:render_facet_count).owner == Blacklight::FacetsHelperBehavior || explicit_component_configuration?
109
-
110
- classes = (options[:classes] || []) << "facet-count"
111
- tag.span(t('blacklight.search.facets.count', number: number_with_delimiter(@hits)), class: classes)
112
- end
113
-
114
- private
115
-
116
- def explicit_component_configuration?
117
- @facet_item.facet_config.item_component.present?
118
- end
119
- end
120
- end
@@ -1,84 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Blacklight
4
- # Render facet items and any subtree
5
- class FacetItemPivotComponent < ::ViewComponent::Base
6
- # Somewhat arbitrary number; the only important thing is that
7
- # it is bigger than the number of leaf nodes in any collapsing
8
- # pivot facet on the page.
9
- ID_COUNTER_MAX = 2**20 - 1
10
-
11
- # Mint a (sufficiently) unique identifier, so we can associate
12
- # the expand/collapse control with labels
13
- def self.mint_id
14
- @id_counter = ((@id_counter || 0) + 1) % ID_COUNTER_MAX
15
-
16
- # We convert the ID to hex for markup compactness
17
- @id_counter.to_s(16)
18
- end
19
-
20
- with_collection_parameter :facet_item
21
-
22
- def initialize(facet_item:, wrapping_element: 'li', suppress_link: false, collapsing: nil)
23
- @facet_item = facet_item
24
- @wrapping_element = wrapping_element
25
- @suppress_link = suppress_link
26
- @collapsing = collapsing.nil? ? facet_item.facet_config.collapsing : collapsing
27
- @icons = { show: '⊞', hide: '⊟' }.merge(facet_item.facet_config.icons || {})
28
- end
29
-
30
- def call
31
- facet = Blacklight::FacetItemComponent.new(facet_item: @facet_item, wrapping_element: nil, suppress_link: @suppress_link)
32
-
33
- id = "h-#{self.class.mint_id}" if @collapsing && has_items?
34
-
35
- content_tag @wrapping_element, role: 'treeitem' do
36
- concat facet_toggle_button(id) if has_items? && @collapsing
37
- concat content_tag('span', render_component(facet), class: "facet-values #{'facet-leaf-node' if has_items? && @collapsing}", id: id && "#{id}_label")
38
-
39
- if has_items?
40
- concat(content_tag('ul', class: "pivot-facet list-unstyled #{'collapse' if @collapsing}", id: id, role: 'group') do
41
- render_component(
42
- self.class.with_collection(
43
- @facet_item.items.map { |i| facet_item_presenter(i) }
44
- )
45
- )
46
- end)
47
- end
48
- end
49
- end
50
-
51
- private
52
-
53
- def has_items?
54
- @facet_item.items.present?
55
- end
56
-
57
- def facet_toggle_button(id)
58
- content_tag 'button', class: 'btn facet-toggle-handle collapsed',
59
- data: { toggle: 'collapse', target: "##{id}" },
60
- aria: { expanded: false, controls: id, describedby: "#{id}_label" } do
61
- concat toggle_icon(:show)
62
- concat toggle_icon(:hide)
63
- end
64
- end
65
-
66
- def toggle_icon(type)
67
- content_tag 'span', class: type do
68
- concat @icons[type]
69
- concat content_tag('span', t(type, scope: 'blacklight.search.facets.pivot'), class: 'sr-only')
70
- end
71
- end
72
-
73
- # This is a little convoluted in Blacklight 7 in order to maintain backwards-compat
74
- # with overrides of deprecated helpers. In 8.x, we can just call Component#render_in
75
- # and call it a day
76
- def render_component(component)
77
- @view_context.render(component)
78
- end
79
-
80
- def facet_item_presenter(facet_item)
81
- Blacklight::FacetItemPresenter.new(facet_item, @facet_item.facet_config, @view_context, @facet_item.facet_field, @facet_item.search_state)
82
- end
83
- end
84
- end
@@ -1,8 +0,0 @@
1
- <%= render(@layout.new(field: @field)) do |component| %>
2
- <% component.with(:label) do %>
3
- <%= label %>
4
- <% end %>
5
- <% component.with(:value) do %>
6
- <%= @field.render %>
7
- <% end %>
8
- <% end %>
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Blacklight
4
- class MetadataFieldComponent < ::ViewComponent::Base
5
- with_collection_parameter :field
6
-
7
- # @param field [Blacklight::FieldPresenter]
8
- # @param layout [Blacklight::MetadataFieldLayoutComponent] alternate layout component to use
9
- # @param show [Boolean] are we showing only a single document (vs a list of search results); used for backwards-compatibility
10
- def initialize(field:, layout: nil, show: false)
11
- @field = field
12
- @layout = layout || Blacklight::MetadataFieldLayoutComponent
13
- @show = show
14
- end
15
-
16
- # @private
17
- def label
18
- Deprecation.silence(Blacklight::BlacklightHelperBehavior) do
19
- if @show
20
- @view_context.render_document_show_field_label @field.document, label: @field.label, field: @field.key
21
- else
22
- @view_context.render_index_field_label @field.document, label: @field.label, field: @field.key
23
- end
24
- end
25
- end
26
-
27
- def render?
28
- @field.render_field?
29
- end
30
- end
31
- end
@@ -1,2 +0,0 @@
1
- <dt class="blacklight-<%= @key %> <%= @label_class %>"><%= label %></dt>
2
- <dd class="blacklight-<%= @key %> <%= @value_class %>"><%= value %></dd>
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Blacklight
4
- class MetadataFieldLayoutComponent < ::ViewComponent::Base
5
- with_collection_parameter :field
6
- with_content_areas :label, :value
7
-
8
- # @param field [Blacklight::FieldPresenter]
9
- def initialize(field:, label_class: 'col-md-3', value_class: 'col-md-9')
10
- @field = field
11
- @key = @field.key.parameterize
12
- @label_class = label_class
13
- @value_class = value_class
14
- end
15
- end
16
- end
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Blacklight
4
- # These are data types that blacklight can use to coerce values from the index
5
- module Types
6
- class Array
7
- def self.coerce(input)
8
- ::Array.wrap(input)
9
- end
10
- end
11
-
12
- class String
13
- def self.coerce(input)
14
- ::Array.wrap(input).first
15
- end
16
- end
17
-
18
- class Date
19
- def self.coerce(input)
20
- field = String.coerce(input)
21
- return if field.blank?
22
-
23
- begin
24
- ::Date.parse(field)
25
- rescue ArgumentError
26
- Rails.logger.info "Unable to parse date: #{field.first.inspect}"
27
- end
28
- end
29
- end
30
- end
31
- end
@@ -1,17 +0,0 @@
1
- # i18n-tasks finds and manages missing and unused translations: https://github.com/glebm/i18n-tasks
2
- base_locale: en
3
- locales: [ar, de, es, fr, hu, it, nl, pt-BR, sq, zh]
4
- data:
5
- read:
6
- - config/locales/%{locale}.yml
7
- - config/locales/**/*.%{locale}.yml
8
-
9
- yaml:
10
- write:
11
- line_width: -1
12
- search:
13
- paths:
14
- - app/
15
- exclude:
16
- - app/assets/images
17
- - app/assets/fonts
@@ -1,35 +0,0 @@
1
- version: "3.7"
2
-
3
- services:
4
- app:
5
- build:
6
- context: .
7
- dockerfile: .docker/app/Dockerfile
8
- args:
9
- - ALPINE_RUBY_VERSION
10
- volumes:
11
- - .:/app
12
- depends_on:
13
- - solr
14
- ports:
15
- - "3000:3000"
16
- environment:
17
- - SOLR_URL # Set via environment variable or use default defined in .env file
18
- - RAILS_VERSION # Set via environment variable or use default defined in .env file
19
-
20
- solr:
21
- environment:
22
- - SOLR_PORT # Set via environment variable or use default defined in .env file
23
- - SOLR_VERSION # Set via environment variable or use default defined in .env file
24
- image: "solr:${SOLR_VERSION}"
25
- volumes:
26
- - $PWD/lib/generators/blacklight/templates/solr/conf:/opt/solr/conf
27
- ports:
28
- - "${SOLR_PORT}:8983"
29
- entrypoint:
30
- - docker-entrypoint.sh
31
- - solr-precreate
32
- - blacklight-core
33
- - /opt/solr/conf
34
- - "-Xms256m"
35
- - "-Xmx512m"