sn_filterable 3.0.0 → 3.1.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: 265365321d381ce4371540a33699f11987cba7cdf096e3b71f5798517a1d04a0
4
- data.tar.gz: 948c7c9116f02f9ce4a83965ffe45bd070ca9bf6ade2c450ab69e24ce651d0de
3
+ metadata.gz: 0d74adc6d01abe06d37822d2cd5f5edfd7392c8a6f3740a18e9f48f4b4c0f329
4
+ data.tar.gz: f39fe686a1719b5441a1704efc5cdf5b58ef65f853869eebd2883143d8e47919
5
5
  SHA512:
6
- metadata.gz: bfb96fa56c828cf878fe9540c9b1282d344ab9ea8b8c0b2d23f0e460213f0408a786b9e0ab6c1f4069065de0569ce75ad305d96e6af224ce516d23ed79e2af64
7
- data.tar.gz: a5917c2b0dc156d86ae2cee3333a91764159559f051c44cb73fa72dbe7f3680c0ce67671ed9c90ac268faa5a80462bdf2149dd27fad0d1d1b9119fd54b7d451b
6
+ metadata.gz: 9037df6e6b0927fa22d39fbc36ce57e9424e670cdd8fc1592ba6a4cbf26946b986ff7d57107eb15b6a47cf5fe8dd003d7165623873a3269f08396ecc84d05227
7
+ data.tar.gz: 295e52cfe405660bc79e5b297cd56fa2183bb4fbac127d167f8b810f027c9288e4ad0825f809553c290ca5faaf9ae45965a7fcb3fa4a3c1d98351bcd9afcd0a7
@@ -4,10 +4,10 @@ require_relative "base_component"
4
4
  class SnFilterable::BaseComponents::ButtonComponent < SnFilterable::BaseComponents::BaseComponent
5
5
  DEFAULT_BUTTON_TYPE = :default
6
6
  BUTTON_TYPE_MAPPINGS = {
7
- DEFAULT_BUTTON_TYPE => "shadow-sm border-gray-300 text-gray-700 bg-white hover:bg-gray-50 focus:ring-indigo-500",
8
- :primary => "shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 focus:ring-indigo-500",
9
- :danger => "border-transparent text-red-700 bg-red-100 hover:bg-red-200 focus:ring-red-500",
10
- :disabled => "shadow-sm border-gray-300 text-gray-700 bg-gray-200 cursor-default"
7
+ DEFAULT_BUTTON_TYPE => "shadow-sm border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600 focus:ring-violet-500 dark:focus:ring-violet-400",
8
+ :primary => "shadow-sm text-white bg-violet-600 dark:bg-violet-700 hover:bg-violet-700 dark:hover:bg-violet-600 focus:ring-violet-500 dark:focus:ring-violet-400",
9
+ :danger => "border-transparent text-red-700 dark:text-red-400 bg-red-100 dark:bg-red-900 hover:bg-red-200 dark:hover:bg-red-800 focus:ring-red-500 dark:focus:ring-red-400",
10
+ :disabled => "shadow-sm border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-400 bg-gray-200 dark:bg-gray-600 cursor-default"
11
11
  }.freeze
12
12
  BUTTON_TYPE_OPTIONS = BUTTON_TYPE_MAPPINGS.keys
13
13
 
@@ -56,7 +56,7 @@ class SnFilterable::BaseComponents::ButtonComponent < SnFilterable::BaseComponen
56
56
  end
57
57
 
58
58
  show_focus_ring = arguments[:show_focus_ring].nil? ? true : arguments[:show_focus_ring]
59
- focus_ring_class = show_focus_ring ? "focus:ring-2 focus:ring-offset-2" : ""
59
+ focus_ring_class = show_focus_ring ? "focus:ring-2 focus:ring-offset-2 dark:focus:ring-offset-gray-800" : ""
60
60
 
61
61
  @arguments[:classes] = class_names(
62
62
  "inline-flex items-center border rounded-md #{focus_ring_class} focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed",
@@ -1,10 +1,18 @@
1
- <%= content_tag :fieldset, class: "w-full text-xs lg:text-sm app-word-break",
1
+ <%= content_tag :fieldset,
2
+ class: "w-full text-xs lg:text-sm app-word-break dark:bg-gray-800",
2
3
  "x-data": { open: @open }.to_json do %>
3
- <button class="flex border-b justify-between w-full px-4 py-3 font-medium text-left text-gray-900 transition-colors hover:bg-gray-200 rounded-sm focus:outline-none focus-visible:ring focus-visible:ring-gray-500 focus-visible:ring-opacity-75" type="button" @click="open = !open">
4
+ <legend><%= @title %></legend>
5
+ <button class="flex border-b dark:border-gray-700 justify-between w-full px-4 py-3 font-medium text-left text-gray-900 dark:text-white transition-colors hover:bg-gray-200 dark:hover:bg-gray-700 rounded-sm focus:outline-none focus-visible:ring focus-visible:ring-gray-500 dark:focus-visible:ring-gray-400 focus-visible:ring-opacity-75"
6
+ type="button"
7
+ @click="open = !open">
4
8
  <span><%= @title %></span>
5
- <%= heroicon "chevron-down", options: { class: "transform w-5 h-5 text-gray-500 transition ease-out", ":class": "open && 'rotate-180'"} %>
9
+ <%= heroicon "chevron-down",
10
+ options: {
11
+ class: "transform w-5 h-5 text-gray-500 dark:text-gray-400 transition ease-out",
12
+ ":class": "open && 'rotate-180'"
13
+ } %>
6
14
  </button>
7
- <div class="pb-2 text-gray-500" x-show="open" x-cloak>
15
+ <div class="pb-2 text-gray-500 dark:text-gray-400" x-show="open" x-cloak>
8
16
  <%= filter %>
9
17
  <%= content %>
10
18
  </div>
@@ -1,25 +1,26 @@
1
1
  <% unless @known_filters.empty? %>
2
- <div class="relative app-filter-chips-content bg-gray-50 -mx-8 mt-4" x-data="filteringChipContainer" x-init="updateSidebarGap()">
2
+ <div class="relative app-filter-chips-content bg-gray-50 dark:bg-gray-700 -mx-8 mt-4" x-data="filteringChipContainer" x-init="updateSidebarGap()">
3
3
  <div class="mx-auto py-3 px-4 flex items-center px-4 sm:px-6 lg:px-8">
4
- <h3 class="sm:pr-0 text-xs font-semibold uppercase tracking-wide text-gray-500">
4
+ <h3 class="sm:pr-0 text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-300">
5
5
  <span>Filters</span>
6
6
  <span class="sr-only">, active</span>
7
7
  </h3>
8
8
 
9
- <div aria-hidden="true" class="w-px h-5 bg-gray-300 block ml-2 sm:ml-4"></div>
9
+ <div aria-hidden="true" class="w-px h-5 bg-gray-300 dark:bg-gray-500 block ml-2 sm:ml-4"></div>
10
10
 
11
11
  <div class="ml-2 sm:ml-4 flex-1">
12
12
  <div class="app-filter-chips-container -m-1 flex flex-wrap items-center">
13
13
  <% @known_filters.each do |filter| %>
14
- <span class="app-filter-chip m-1 inline-flex rounded-full border border-gray-200 items-center py-1.5 pl-3 pr-2 text-xs sm:text-sm font-medium bg-white text-gray-900" x-data>
14
+ <span class="app-filter-chip m-1 inline-flex rounded-full border border-gray-200 dark:border-gray-600 items-center py-1.5 pl-3 pr-2 text-xs sm:text-sm font-medium bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-300" x-data>
15
15
  <span><%= filter[:name] %></span>
16
16
  <%= content_tag :a,
17
17
  href: filter[:multi] ? remove_sub_filter_url(@filtered, filter[:parent], filter[:value], url: @url) : remove_filter_url(@filtered, filter[:parent], url: @url),
18
- class: "flex-shrink-0 ml-1 h-4 w-4 p-1 rounded-full inline-flex text-gray-400 hover:bg-gray-200 hover:text-gray-500",
18
+ class: "flex-shrink-0 ml-1 h-4 w-4 p-1 rounded-full inline-flex text-gray-400 hover:bg-gray-200 hover:text-gray-500 dark:hover:bg-gray-600 dark:hover:text-gray-300",
19
19
  "x-data": "filteringChip(#{filter.to_json})",
20
20
  "@click": "$event.preventDefault(); onClick()" do %>
21
21
  <span class="sr-only">Remove filter for Objects</span>
22
22
  <svg class="h-2 w-2" stroke="currentColor" fill="none" viewBox="0 0 8 8">
23
+ <title>Remove filter for Objects</title>
23
24
  <path stroke-linecap="round" stroke-width="1.5" d="M1 1l6 6m0-6L1 7" />
24
25
  </svg>
25
26
  <% end %>
@@ -28,7 +29,11 @@
28
29
  </div>
29
30
  </div>
30
31
  <div class="pl-2 sm:pl-6">
31
- <%= link_to t("shared.filterable.clear_all"), clear_filter_url(@filtered, url: @url), class: "text-sm text-gray-500", "x-data": "filteringClear", "@click": "$event.preventDefault(); onClick()" %>
32
+ <%= link_to t("shared.filterable.clear_all"),
33
+ clear_filter_url(@filtered, url: @url),
34
+ class: "text-sm text-gray-500 dark:text-gray-300 hover:text-gray-700 dark:hover:text-gray-100",
35
+ "x-data": "filteringClear",
36
+ "@click": "$event.preventDefault(); onClick()" %>
32
37
  </div>
33
38
  </div>
34
39
  </div>
@@ -1,12 +1,9 @@
1
1
  <% @filter[:filters].each_with_index do |sub_filter, index| %>
2
- <div class="relative flex items-start px-4 transition-colors hover:bg-gray-200 text-gray-700 hover:text-gray-900">
3
- <div class="min-w-0 flex-1 flex-grow">
4
- <%= content_tag :label, sub_filter[:name], class: "block py-2 pr-4 text-gray-600 select-none w-full cursor-pointer", for: "filter-#{@filter[:filter_name]}-#{index}" %>
5
- </div>
2
+ <div class="relative flex items-start px-4 transition-colors hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white">
6
3
  <div class="my-2 flex items-center">
7
4
  <% if @filter[:multi] %>
8
5
  <%= content_tag :input, "",
9
- class: "focus:ring-purple-400 cursor-pointer h-5 w-5 text-purple-500 bg-purple-100 border-0 rounded",
6
+ class: "focus:ring-purple-400 dark:focus:ring-purple-600 cursor-pointer h-5 w-5 text-purple-500 dark:text-purple-400 bg-purple-100 dark:bg-purple-900 border-0 rounded",
10
7
  type: "checkbox",
11
8
  name: "filter[#{@filter[:filter_name]}][]",
12
9
  value: sub_filter[:value],
@@ -17,7 +14,7 @@
17
14
  %>
18
15
  <% else %>
19
16
  <%= content_tag :input, "",
20
- class: "focus:ring-purple-400 cursor-pointer h-5 w-5 text-purple-500 bg-purple-100 border-0",
17
+ class: "focus:ring-purple-400 dark:focus:ring-purple-600 cursor-pointer h-5 w-5 text-purple-500 dark:text-purple-400 bg-purple-100 dark:bg-purple-900 border-0",
21
18
  type: "radio",
22
19
  name: "filter[#{@filter[:filter_name]}]",
23
20
  value: sub_filter[:value],
@@ -28,5 +25,11 @@
28
25
  %>
29
26
  <% end %>
30
27
  </div>
28
+ <div class="min-w-0 flex-1 flex-grow">
29
+ <%= content_tag :label,
30
+ sub_filter[:name],
31
+ class: "block py-2 pr-4 text-gray-600 dark:text-gray-400 select-none w-full cursor-pointer",
32
+ for: "filter-#{@filter[:filter_name]}-#{index}" %>
33
+ </div>
31
34
  </div>
32
- <% end %>
35
+ <% end %>
@@ -1,5 +1,5 @@
1
1
  <% url = @url || url_for %>
2
- <div x-data="{ filteringForm: $refs.filtering_form, entireComponenet: $el, filtersLoading: false, filtersPopupOpen: false, sidebarGapTarget: null }">
2
+ <div x-data="{ filteringForm: $refs.filtering_form, entireComponenet: $el, filtersLoading: false, filtersPopupOpen: false, sidebarGapTarget: null }" class="dark:bg-gray-800 dark:text-white">
3
3
  <%= content_tag :form,
4
4
  "x-ref": "filtering_form",
5
5
  "action": url,
@@ -26,32 +26,32 @@
26
26
  <% if @show_sidebar %>
27
27
  <div class="mt-16 h-full pointer-events-auto">
28
28
  <div class="h-full" x-init="sidebarGapTarget = $el">
29
- <div x-show="filtersPopupOpen" class="fixed top-0 left-0 right-0 bottom-0 z-10 sm:z-0 bg-gray-600 bg-opacity-75 sm:hidden" @click="filtersPopupOpen = false" x-cloak></div>
30
- <div x-show="filtersPopupOpen" class="fixed bottom-0 h-2/3 z-10 sm:z-0 left-0 w-full bg-white pt-4 sm:sticky sm:!block row-span-2 shrink-0 mr-4 self-start sm:top-16 lg:w-64 sm:w-52 sm:pt-2 sm:pb-6 sm:overflow-y-auto sm:h-[70vh] sm:max-h-[calc(100vh_-_5rem)]" x-cloak>
29
+ <div x-show="filtersPopupOpen" class="fixed top-0 left-0 right-0 bottom-0 z-10 sm:z-0 bg-gray-600 bg-opacity-75 dark:bg-gray-900 dark:bg-opacity-75 sm:hidden" @click="filtersPopupOpen = false" x-cloak></div>
30
+ <div x-show="filtersPopupOpen" class="fixed bottom-0 h-2/3 z-10 sm:z-0 left-0 w-full bg-white dark:bg-gray-800 pt-4 sm:sticky sm:!block row-span-2 shrink-0 mr-4 self-start sm:top-16 lg:w-64 sm:w-52 sm:pt-2 sm:pb-6 sm:overflow-y-auto sm:h-[70vh] sm:max-h-[calc(100vh_-_5rem)]" x-cloak>
31
31
  <div class="absolute top-0 right-0 -mt-12 mb-2 mr-2" x-show="filtersPopupOpen">
32
- <button type="button" class="ml-1 flex items-center justify-center h-10 w-10 rounded-full focus:outline-none focus:ring-2 focus:ring-inset focus:ring-white" @click="filtersPopupOpen = false">
32
+ <button type="button" class="ml-1 flex items-center justify-center h-10 w-10 rounded-full focus:outline-none focus:ring-2 focus:ring-inset focus:ring-white dark:focus:ring-gray-600" @click="filtersPopupOpen = false">
33
33
  <span class="sr-only">Close filters</span>
34
- <%= heroicon "x-mark", variant: :outline, options: { class: "h-6 w-6 text-grey-500" } %>
34
+ <%= heroicon "x-mark", variant: :outline, options: { class: "h-6 w-6 text-grey-500 dark:text-gray-400" } %>
35
35
  </button>
36
36
  </div>
37
- <div name="Filter Options" role="menu" aria-orientation="vertical" aria-labelledby="options-menu" class="overflow-y-auto max-h-full">
37
+ <div name="Filter Options" role="menu" aria-orientation="vertical" aria-label="options-menu" class="overflow-y-auto max-h-full">
38
38
  <% @filters.each do |filter| %>
39
39
  <%= render SnFilterable::CategoryComponent.new(title: filter[:title], open: @filtered.queries.dig("filter", filter.try(:[], :filter_name)).present?) do |c| %>
40
- <% c.filter(filtered: @filtered, filter: filter) %>
40
+ <% c.with_filter(filtered: @filtered, filter: filter) %>
41
41
  <% end %>
42
42
  <% end %>
43
43
  <%= render SnFilterable::CategoryComponent.new(title: t("shared.filterable.results_per_page"), open: @filtered.queries.dig("per").present?) do %>
44
44
  <fieldset class="pt-2" x-data="{ wasInteracted: false }">
45
45
  <% ([@filtered.items.default_per_page] | [10, 25, 50]).sort.each do |value| %>
46
- <div class="relative flex items-start px-4 transition-colors hover:bg-gray-200 text-gray-700 hover:text-gray-900">
46
+ <div class="relative flex items-start px-4 transition-colors hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white">
47
47
  <div class="min-w-0 flex-1 flex-grow">
48
- <%= content_tag :label, value, class: "block py-2 pr-4 text-gray-600 select-none w-full cursor-pointer", for: "per-#{value}" %>
48
+ <%= content_tag :label, value, class: "block py-2 pr-4 text-gray-600 dark:text-gray-400 select-none w-full cursor-pointer", for: "per-#{value}" %>
49
49
  </div>
50
50
  <div class="my-2 flex items-center">
51
51
  <% selected_explcitly = value == @filtered.queries["per"].to_i %>
52
52
  <% selected_by_default = @filtered.queries["per"].blank? && value == @filtered.items.default_per_page %>
53
53
  <%= content_tag :input, "",
54
- class: "focus:ring-purple-400 cursor-pointer h-5 w-5 text-purple-500 bg-purple-100 border-0",
54
+ class: "focus:ring-purple-400 dark:focus:ring-purple-600 cursor-pointer h-5 w-5 text-purple-500 dark:text-purple-400 bg-purple-100 dark:bg-purple-900 border-0",
55
55
  type: "radio",
56
56
  id: "per-#{value}",
57
57
  "x-data": { iteracted: selected_explcitly }.to_json,
@@ -1,9 +1,9 @@
1
1
  <div class="mt-1 relative rounded-md shadow-sm">
2
2
  <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
3
- <%= heroicon "magnifying-glass", options: { class: "h-5 w-5 text-gray-400" } %>
3
+ <%= heroicon "magnifying-glass", options: { class: "h-5 w-5 text-gray-400 dark:text-gray-500" } %>
4
4
  </div>
5
5
  <%= content_tag :input, "",
6
- class: "focus:ring-indigo-500 focus:border-indigo-500 block w-full pl-10 sm:text-sm border-gray-300 rounded-md",
6
+ class: "focus:ring-violet-500 focus:border-violet-500 block w-full pl-10 sm:text-sm border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-300 placeholder-gray-500 dark:placeholder-gray-400",
7
7
  placeholder: "Search...",
8
8
  type: "search",
9
9
  ":name": "hasValue && `filter[#{@filter_name}]`",
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SnFilterable
4
- VERSION = "3.0.0"
4
+ VERSION = "3.1.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sn_filterable
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - IBM Skills Network
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-05-08 00:00:00.000000000 Z
10
+ date: 2025-03-03 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: heroicon
@@ -44,14 +43,14 @@ dependencies:
44
43
  requirements:
45
44
  - - "~>"
46
45
  - !ruby/object:Gem::Version
47
- version: '2'
46
+ version: '3'
48
47
  type: :runtime
49
48
  prerelease: false
50
49
  version_requirements: !ruby/object:Gem::Requirement
51
50
  requirements:
52
51
  - - "~>"
53
52
  - !ruby/object:Gem::Version
54
- version: '2'
53
+ version: '3'
55
54
  - !ruby/object:Gem::Dependency
56
55
  name: turbo-rails
57
56
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +71,14 @@ dependencies:
72
71
  requirements:
73
72
  - - "~>"
74
73
  - !ruby/object:Gem::Version
75
- version: '2'
74
+ version: '3'
76
75
  type: :runtime
77
76
  prerelease: false
78
77
  version_requirements: !ruby/object:Gem::Requirement
79
78
  requirements:
80
79
  - - "~>"
81
80
  - !ruby/object:Gem::Version
82
- version: '2'
81
+ version: '3'
83
82
  - !ruby/object:Gem::Dependency
84
83
  name: pg
85
84
  requirement: !ruby/object:Gem::Requirement
@@ -235,7 +234,7 @@ dependencies:
235
234
  - !ruby/object:Gem::Version
236
235
  version: '2'
237
236
  description: This gem adds a ViewComponent powered filtering component for searching
238
- and filtering your PostgreSQL data.
237
+ and filtering your PostgreSQL or MySQL data.
239
238
  email:
240
239
  - Skills.Network@ibm.com
241
240
  executables: []
@@ -272,7 +271,6 @@ metadata:
272
271
  homepage_uri: https://github.com/ibm-skills-network/sn_filterable
273
272
  source_code_uri: https://github.com/ibm-skills-network/sn_filterable
274
273
  changelog_uri: https://github.com/ibm-skills-network/sn_filterable/releases
275
- post_install_message:
276
274
  rdoc_options: []
277
275
  require_paths:
278
276
  - lib
@@ -287,8 +285,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
287
285
  - !ruby/object:Gem::Version
288
286
  version: '0'
289
287
  requirements: []
290
- rubygems_version: 3.4.6
291
- signing_key:
288
+ rubygems_version: 3.6.2
292
289
  specification_version: 4
293
290
  summary: Skills Network - Item filtering component
294
291
  test_files: []