pagy 43.4.3 → 43.5.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 +4 -4
- data/apps/calendar.ru +1 -1
- data/apps/demo.ru +2 -2
- data/apps/keynav+root_key.ru +1 -1
- data/apps/keynav.ru +3 -3
- data/apps/keyset.ru +3 -3
- data/apps/keyset_sequel.ru +2 -2
- data/apps/rails.ru +2 -2
- data/apps/repro.ru +3 -3
- data/config/pagy.rb +4 -4
- data/javascripts/pagy.js +20 -12
- data/javascripts/pagy.min.js +1 -1
- data/javascripts/pagy.mjs +18 -10
- data/lib/pagy/classes/calendar/calendar.rb +6 -8
- data/lib/pagy/classes/calendar/unit.rb +10 -10
- data/lib/pagy/classes/exceptions.rb +3 -3
- data/lib/pagy/classes/keyset/adapters/active_record.rb +6 -8
- data/lib/pagy/classes/keyset/adapters/sequel.rb +9 -12
- data/lib/pagy/classes/keyset/keynav.rb +6 -6
- data/lib/pagy/classes/keyset/keyset.rb +7 -8
- data/lib/pagy/classes/offset/countless.rb +5 -10
- data/lib/pagy/classes/offset/offset.rb +2 -1
- data/lib/pagy/classes/offset/search.rb +1 -1
- data/lib/pagy/classes/request.rb +4 -1
- data/lib/pagy/deprecated.rb +84 -0
- data/lib/pagy/modules/abilities/configurable.rb +1 -7
- data/lib/pagy/modules/abilities/countable.rb +1 -2
- data/lib/pagy/modules/abilities/linkable.rb +6 -5
- data/lib/pagy/modules/abilities/rangeable.rb +1 -2
- data/lib/pagy/modules/console.rb +1 -1
- data/lib/pagy/modules/i18n/i18n.rb +1 -1
- data/lib/pagy/modules/searcher.rb +0 -1
- data/lib/pagy/next.rb +25 -0
- data/lib/pagy/tasks/sync.rb +1 -0
- data/lib/pagy/toolbox/helpers/anchor_tags.rb +0 -2
- data/lib/pagy/toolbox/helpers/bootstrap/input_nav_js.rb +0 -1
- data/lib/pagy/toolbox/helpers/bootstrap/previous_next_html.rb +0 -1
- data/lib/pagy/toolbox/helpers/bootstrap/series_nav.rb +0 -1
- data/lib/pagy/toolbox/helpers/bootstrap/series_nav_js.rb +0 -1
- data/lib/pagy/toolbox/helpers/bulma/input_nav_js.rb +0 -1
- data/lib/pagy/toolbox/helpers/bulma/previous_next_html.rb +0 -1
- data/lib/pagy/toolbox/helpers/bulma/series_nav.rb +0 -1
- data/lib/pagy/toolbox/helpers/bulma/series_nav_js.rb +0 -1
- data/lib/pagy/toolbox/helpers/headers_hash.rb +1 -1
- data/lib/pagy/toolbox/helpers/info_tag.rb +2 -2
- data/lib/pagy/toolbox/helpers/input_nav_js.rb +0 -1
- data/lib/pagy/toolbox/helpers/limit_tag_js.rb +3 -4
- data/lib/pagy/toolbox/helpers/loaders.rb +1 -1
- data/lib/pagy/toolbox/helpers/page_url.rb +0 -1
- data/lib/pagy/toolbox/helpers/series_nav.rb +0 -1
- data/lib/pagy/toolbox/helpers/series_nav_js.rb +0 -1
- data/lib/pagy/toolbox/helpers/support/a_lambda.rb +2 -3
- data/lib/pagy/toolbox/helpers/support/data_pagy_attribute.rb +0 -1
- data/lib/pagy/toolbox/helpers/support/nav_aria_label_attribute.rb +0 -2
- data/lib/pagy/toolbox/helpers/support/series.rb +2 -2
- data/lib/pagy/toolbox/helpers/support/wrap_input_nav_js.rb +1 -2
- data/lib/pagy/toolbox/helpers/support/wrap_series_nav.rb +1 -2
- data/lib/pagy/toolbox/helpers/support/wrap_series_nav_js.rb +3 -3
- data/lib/pagy/toolbox/helpers/urls_hash.rb +0 -1
- data/lib/pagy/toolbox/paginators/calendar.rb +1 -1
- data/lib/pagy/toolbox/paginators/countish.rb +0 -1
- data/lib/pagy/toolbox/paginators/countless.rb +0 -1
- data/lib/pagy/toolbox/paginators/elasticsearch_rails.rb +2 -3
- data/lib/pagy/toolbox/paginators/keynav_js.rb +0 -2
- data/lib/pagy/toolbox/paginators/keyset.rb +0 -1
- data/lib/pagy/toolbox/paginators/meilisearch.rb +0 -1
- data/lib/pagy/toolbox/paginators/method.rb +1 -1
- data/lib/pagy/toolbox/paginators/offset.rb +0 -1
- data/lib/pagy/toolbox/paginators/searchkick.rb +0 -1
- data/lib/pagy/toolbox/paginators/typesense_rails.rb +0 -1
- data/lib/pagy.rb +6 -16
- metadata +5 -4
- data/sig/pagy.rbs +0 -315
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
class Pagy
|
|
4
4
|
protected
|
|
5
5
|
|
|
6
|
-
# Label for any page. Allow the customization of the output
|
|
7
6
|
def page_label(page, **options)
|
|
8
7
|
return page.to_s unless calendar?
|
|
9
8
|
|
|
@@ -11,8 +10,8 @@ class Pagy
|
|
|
11
10
|
localize(starting_time_for(page.to_i), **options) # page could be a string
|
|
12
11
|
end
|
|
13
12
|
|
|
14
|
-
# Return a performance optimized lambda to generate the anchor tag
|
|
15
|
-
# Benchmarked on a 20 link nav: it is ~22x faster and uses ~18x less memory than rails' link_to
|
|
13
|
+
# Return a performance optimized lambda to generate the anchor tag.
|
|
14
|
+
# Benchmarked on a 20 link nav: it is ~22x faster and uses ~18x less memory than rails' link_to.
|
|
16
15
|
def a_lambda(anchor_string: @options[:anchor_string], **)
|
|
17
16
|
left, right = %(<a href="#{compose_page_url(PAGE_TOKEN, **)}"#{
|
|
18
17
|
%( #{anchor_string}) if anchor_string}).split(PAGE_TOKEN, 2)
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Relegate internal functions. Make overriding navs easier.
|
|
4
3
|
class Pagy
|
|
5
4
|
private
|
|
6
5
|
|
|
7
|
-
# Compose the aria label attribute for the nav
|
|
8
6
|
def nav_aria_label_attribute(aria_label: nil)
|
|
9
7
|
aria_label ||= I18n.translate('pagy.aria_label.nav', count: @last)
|
|
10
8
|
%(aria-label="#{aria_label}")
|
|
@@ -5,7 +5,7 @@ class Pagy
|
|
|
5
5
|
|
|
6
6
|
protected
|
|
7
7
|
|
|
8
|
-
#
|
|
8
|
+
# The array of page numbers and :gap e.g. [1, :gap, 8, "9", 10, :gap, 36]
|
|
9
9
|
def series(slots: @options[:slots] || SERIES_SLOTS, compact: @options[:compact], **)
|
|
10
10
|
raise OptionError.new(self, :slots, 'to be an Integer >= 0', slots) unless slots.is_a?(Integer) && slots >= 0
|
|
11
11
|
return [] if slots.zero?
|
|
@@ -14,7 +14,7 @@ class Pagy
|
|
|
14
14
|
if slots >= @last
|
|
15
15
|
series.push(*1..@last)
|
|
16
16
|
else
|
|
17
|
-
half = (slots - 1) / 2 # the left half
|
|
17
|
+
half = (slots - 1) / 2 # even slots makes the left half shorter by 1
|
|
18
18
|
start = if @page <= half # @page in the first half
|
|
19
19
|
1
|
|
20
20
|
elsif @page > (@last - slots + half) # @page in the last half
|
|
@@ -4,11 +4,10 @@ require_relative 'nav_aria_label_attribute'
|
|
|
4
4
|
require_relative 'data_pagy_attribute'
|
|
5
5
|
require_relative 'a_lambda' # inherited use
|
|
6
6
|
|
|
7
|
-
# Relegate internal functions. Make overriding navs easier.
|
|
8
7
|
class Pagy
|
|
9
8
|
private
|
|
10
9
|
|
|
11
|
-
#
|
|
10
|
+
# Common input_nav_js logic
|
|
12
11
|
def wrap_input_nav_js(html, nav_classes, id: nil, aria_label: nil, **)
|
|
13
12
|
%(<nav#{%( id="#{id}") if id} class="#{nav_classes}" #{
|
|
14
13
|
nav_aria_label_attribute(aria_label:)} #{
|
|
@@ -5,11 +5,10 @@ require_relative 'nav_aria_label_attribute'
|
|
|
5
5
|
require_relative 'data_pagy_attribute'
|
|
6
6
|
require_relative 'a_lambda' # inherited use
|
|
7
7
|
|
|
8
|
-
# Relegate internal functions. Make overriding navs easier.
|
|
9
8
|
class Pagy
|
|
10
9
|
private
|
|
11
10
|
|
|
12
|
-
#
|
|
11
|
+
# Common series_nav logic
|
|
13
12
|
def wrap_series_nav(html, nav_classes, id: nil, aria_label: nil, **)
|
|
14
13
|
data = %( #{data_pagy_attribute(:k, @update)}) if keynav?
|
|
15
14
|
|
|
@@ -9,7 +9,7 @@ require_relative 'a_lambda' # inherited use
|
|
|
9
9
|
class Pagy
|
|
10
10
|
private
|
|
11
11
|
|
|
12
|
-
#
|
|
12
|
+
# The reverse-sorted array of widths, series, and labels generated from the :steps hash.
|
|
13
13
|
# If :steps is false it will use the single {0 => @options[:slots]} length
|
|
14
14
|
def sequels(steps: @options[:steps] || { 0 => @options[:slots] || SERIES_SLOTS }, **)
|
|
15
15
|
raise OptionError.new(self, :steps, 'to define the 0 width', steps) unless steps.key?(0)
|
|
@@ -18,7 +18,7 @@ class Pagy
|
|
|
18
18
|
[widths, series, page_labels(series)]
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
# Support
|
|
21
|
+
# Support the Calendar API
|
|
22
22
|
def page_labels(series)
|
|
23
23
|
return unless calendar?
|
|
24
24
|
|
|
@@ -27,7 +27,7 @@ class Pagy
|
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
#
|
|
30
|
+
# Common series_nav_js logic
|
|
31
31
|
def wrap_series_nav_js(tokens, nav_classes, id: nil, aria_label: nil, **)
|
|
32
32
|
sequels = sequels(**)
|
|
33
33
|
nav_classes = "pagy-rjs #{nav_classes}" if sequels[0].size > 1
|
|
@@ -4,7 +4,7 @@ class Pagy
|
|
|
4
4
|
module CalendarPaginator
|
|
5
5
|
module_function
|
|
6
6
|
|
|
7
|
-
# Take a collection and a
|
|
7
|
+
# Take a collection and a config Hash and return [calendar, pagy, results]
|
|
8
8
|
def paginate(context, collection, config)
|
|
9
9
|
context.instance_eval do
|
|
10
10
|
allowed_options = Calendar::UNITS + %i[offset disabled request]
|
|
@@ -6,7 +6,6 @@ class Pagy
|
|
|
6
6
|
module ElasticsearchRailsPaginator
|
|
7
7
|
module_function
|
|
8
8
|
|
|
9
|
-
# Paginate from the search object
|
|
10
9
|
def paginate(search, options)
|
|
11
10
|
if search.is_a?(Search::Arguments) # Active mode
|
|
12
11
|
|
|
@@ -33,7 +32,7 @@ class Pagy
|
|
|
33
32
|
end
|
|
34
33
|
end
|
|
35
34
|
|
|
36
|
-
#
|
|
35
|
+
# Support different versions of ElasticsearchRails
|
|
37
36
|
def pagination_params_from(response_object)
|
|
38
37
|
definition = response_object.search.definition
|
|
39
38
|
definition = definition.to_hash if definition.respond_to?(:to_hash)
|
|
@@ -45,7 +44,7 @@ class Pagy
|
|
|
45
44
|
[from, size]
|
|
46
45
|
end
|
|
47
46
|
|
|
48
|
-
#
|
|
47
|
+
# Support different versions of ElasticsearchRails
|
|
49
48
|
def total_count_from(response_object)
|
|
50
49
|
total = response_object.instance_eval do
|
|
51
50
|
respond_to?(:response) ? response['hits']['total'] : raw_response['hits']['total']
|
|
@@ -6,8 +6,6 @@ class Pagy
|
|
|
6
6
|
module KeynavJsPaginator
|
|
7
7
|
module_function
|
|
8
8
|
|
|
9
|
-
# Return the Pagy::Keyset::Keynav instance and paginated records.
|
|
10
|
-
# Fall back to :countless if the :page has no client data.
|
|
11
9
|
def paginate(set, options)
|
|
12
10
|
page = options[:request].resolve_page(force_integer: false) # allow nil
|
|
13
11
|
|
|
@@ -4,7 +4,6 @@ class Pagy
|
|
|
4
4
|
module KeysetPaginator
|
|
5
5
|
module_function
|
|
6
6
|
|
|
7
|
-
# Return Pagy::Keyset instance and paginated records
|
|
8
7
|
def paginate(set, options)
|
|
9
8
|
options[:page] ||= options[:request].resolve_page(force_integer: false) # allow nil
|
|
10
9
|
options[:limit] = options[:request].resolve_limit
|
|
@@ -29,7 +29,7 @@ class Pagy
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
options[:root_key] = 'page' if options[:jsonapi] # enforce 'page' root_key for JSON:API
|
|
32
|
-
options[:request] ||= request #
|
|
32
|
+
options[:request] ||= request # custom request Hash or self.request
|
|
33
33
|
options[:request] = Request.new(options) # Pagy::Request
|
|
34
34
|
|
|
35
35
|
Pagy.const_get(paginators[paginator]).paginate(*arguments)
|
data/lib/pagy.rb
CHANGED
|
@@ -7,10 +7,9 @@ require_relative 'pagy/modules/abilities/linkable'
|
|
|
7
7
|
require_relative 'pagy/modules/abilities/configurable'
|
|
8
8
|
require_relative 'pagy/toolbox/helpers/loaders'
|
|
9
9
|
|
|
10
|
-
# Top superclass
|
|
11
|
-
# noinspection RubyMismatchedArgumentType
|
|
10
|
+
# Top superclass
|
|
12
11
|
class Pagy
|
|
13
|
-
VERSION = '43.
|
|
12
|
+
VERSION = '43.5.0'
|
|
14
13
|
ROOT = Pathname.new(__dir__).parent.freeze
|
|
15
14
|
DEFAULT = { limit: 20, limit_key: 'limit', page_key: 'page' }.freeze
|
|
16
15
|
PAGE_TOKEN = EscapedValue.new('P ')
|
|
@@ -34,12 +33,6 @@ class Pagy
|
|
|
34
33
|
|
|
35
34
|
OPTIONS = {} # rubocop:disable Style/MutableConstant
|
|
36
35
|
|
|
37
|
-
def self.options
|
|
38
|
-
OPTIONS.tap do
|
|
39
|
-
warn "[PAGY] 'Pagy.options' is deprecated: use 'Pagy::OPTIONS directly'"
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
36
|
extend Configurable
|
|
44
37
|
include Linkable
|
|
45
38
|
include HelperLoader
|
|
@@ -48,7 +41,7 @@ class Pagy
|
|
|
48
41
|
|
|
49
42
|
protected
|
|
50
43
|
|
|
51
|
-
#
|
|
44
|
+
# Instance identity methods, overridden by the respective classes
|
|
52
45
|
def offset? = false
|
|
53
46
|
def countless? = false
|
|
54
47
|
def calendar? = false
|
|
@@ -56,7 +49,7 @@ class Pagy
|
|
|
56
49
|
def keyset? = false
|
|
57
50
|
def keynav? = false
|
|
58
51
|
|
|
59
|
-
#
|
|
52
|
+
# Validate presence and min value of options
|
|
60
53
|
def assign_and_check(name_min)
|
|
61
54
|
name_min.each do |name, min|
|
|
62
55
|
value = @options[name]
|
|
@@ -71,11 +64,6 @@ class Pagy
|
|
|
71
64
|
|
|
72
65
|
# Merge all the DEFAULT constants of the class hierarchy with the options
|
|
73
66
|
def assign_options(**options)
|
|
74
|
-
if options.key?(:max_pages)
|
|
75
|
-
warn "[PAGY] the ':max_pages' option is deprecated: " \
|
|
76
|
-
'use https://ddnexus.github.io/pagy/guides/how-to/#paginate-only-max-records instead.'
|
|
77
|
-
end
|
|
78
|
-
|
|
79
67
|
@request = options.delete(:request) # internal object
|
|
80
68
|
default = {}
|
|
81
69
|
current = self.class
|
|
@@ -95,3 +83,5 @@ class Pagy
|
|
|
95
83
|
include NumericHelperLoader
|
|
96
84
|
end
|
|
97
85
|
end
|
|
86
|
+
|
|
87
|
+
require_relative ENV['PAGY_NEXT'] == 'true' ? 'pagy/next' : 'pagy/deprecated'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pagy
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 43.
|
|
4
|
+
version: 43.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Domizio Demichelis
|
|
@@ -98,6 +98,7 @@ files:
|
|
|
98
98
|
- lib/pagy/classes/request.rb
|
|
99
99
|
- lib/pagy/cli.rb
|
|
100
100
|
- lib/pagy/console.rb
|
|
101
|
+
- lib/pagy/deprecated.rb
|
|
101
102
|
- lib/pagy/modules/abilities/configurable.rb
|
|
102
103
|
- lib/pagy/modules/abilities/countable.rb
|
|
103
104
|
- lib/pagy/modules/abilities/linkable.rb
|
|
@@ -115,6 +116,7 @@ files:
|
|
|
115
116
|
- lib/pagy/modules/i18n/p11n/polish.rb
|
|
116
117
|
- lib/pagy/modules/i18n/p11n/west_slavic.rb
|
|
117
118
|
- lib/pagy/modules/searcher.rb
|
|
119
|
+
- lib/pagy/next.rb
|
|
118
120
|
- lib/pagy/tasks/sync.rb
|
|
119
121
|
- lib/pagy/toolbox/helpers/anchor_tags.rb
|
|
120
122
|
- lib/pagy/toolbox/helpers/bootstrap/input_nav_js.rb
|
|
@@ -191,7 +193,6 @@ files:
|
|
|
191
193
|
- locales/zh-CN.yml
|
|
192
194
|
- locales/zh-HK.yml
|
|
193
195
|
- locales/zh-TW.yml
|
|
194
|
-
- sig/pagy.rbs
|
|
195
196
|
- stylesheets/pagy-tailwind.css
|
|
196
197
|
- stylesheets/pagy.css
|
|
197
198
|
homepage: https://github.com/ddnexus/pagy
|
|
@@ -211,14 +212,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
211
212
|
requirements:
|
|
212
213
|
- - ">="
|
|
213
214
|
- !ruby/object:Gem::Version
|
|
214
|
-
version: '3.
|
|
215
|
+
version: '3.3'
|
|
215
216
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
216
217
|
requirements:
|
|
217
218
|
- - ">="
|
|
218
219
|
- !ruby/object:Gem::Version
|
|
219
220
|
version: '0'
|
|
220
221
|
requirements: []
|
|
221
|
-
rubygems_version: 4.0.
|
|
222
|
+
rubygems_version: 4.0.6
|
|
222
223
|
specification_version: 4
|
|
223
224
|
summary: "Pagy \U0001F438 The Leaping Gem!"
|
|
224
225
|
test_files: []
|
data/sig/pagy.rbs
DELETED
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
# sig/pagy.rbs
|
|
2
|
-
|
|
3
|
-
class Pagy
|
|
4
|
-
VERSION: String
|
|
5
|
-
ROOT: Pathname
|
|
6
|
-
OPTIONS: options
|
|
7
|
-
|
|
8
|
-
# @deprecated Use `Pagy::OPTIONS` instead
|
|
9
|
-
def self.options: () -> options
|
|
10
|
-
|
|
11
|
-
# @deprecated Use `sync(:javascript, ...)` instead
|
|
12
|
-
def self.sync_javascript: (String destination, *String targets) -> void
|
|
13
|
-
|
|
14
|
-
def self.sync: (Symbol resource, String destination, *String targets) -> void
|
|
15
|
-
def self.dev_tools: (?wand_scale: Integer) -> String
|
|
16
|
-
def self.translate_with_the_slower_i18n_gem!: () -> void
|
|
17
|
-
|
|
18
|
-
class Offset < Pagy
|
|
19
|
-
attr_reader offset: Integer
|
|
20
|
-
attr_reader count: Integer
|
|
21
|
-
attr_reader from: Integer
|
|
22
|
-
attr_reader to: Integer
|
|
23
|
-
attr_reader previous: Integer?
|
|
24
|
-
attr_reader next: Integer?
|
|
25
|
-
attr_reader last: Integer
|
|
26
|
-
|
|
27
|
-
alias pages last
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
class Countish < Offset
|
|
31
|
-
end
|
|
32
|
-
class Countless < Offset
|
|
33
|
-
attr_reader last: Integer?
|
|
34
|
-
end
|
|
35
|
-
class Keyset < Pagy
|
|
36
|
-
class ActiveRecord < Keyset
|
|
37
|
-
end
|
|
38
|
-
class Sequel < Keyset
|
|
39
|
-
end
|
|
40
|
-
class Keynav < Keyset
|
|
41
|
-
class ActiveRecord < Keyset
|
|
42
|
-
end
|
|
43
|
-
class Sequel < Keyset
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
attr_reader records: Array[untyped]
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
class Calendar < ::Hash[Symbol, Calendar::Unit]
|
|
51
|
-
def self.localize_with_rails_i18n_gem: (*Symbol locales) -> void
|
|
52
|
-
|
|
53
|
-
def showtime: () -> ActiveSupport::TimeWithZone
|
|
54
|
-
def url_at: (ActiveSupport::TimeWithZone time, **url_opts) -> String
|
|
55
|
-
|
|
56
|
-
class Unit < Pagy
|
|
57
|
-
attr_reader order: Symbol
|
|
58
|
-
attr_reader from: ActiveSupport::TimeWithZone
|
|
59
|
-
attr_reader to: ActiveSupport::TimeWithZone
|
|
60
|
-
attr_reader previous: Integer?
|
|
61
|
-
attr_reader last: Integer
|
|
62
|
-
alias pages last
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
class Year < Unit
|
|
66
|
-
end
|
|
67
|
-
class Quarter < Unit
|
|
68
|
-
end
|
|
69
|
-
class Month < Unit
|
|
70
|
-
end
|
|
71
|
-
class Week < Unit
|
|
72
|
-
end
|
|
73
|
-
class Day < Unit
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
class SearchBase < Offset
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
class ElasticsearchRails < SearchBase
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
class Meilisearch < SearchBase
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
class Searchkick < SearchBase
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
class TypesenseRails < SearchBase
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
module Search
|
|
93
|
-
class Arguments < Array[untyped]
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
def pagy_search: (*untyped arguments, untyped) -> Search::Arguments
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
class Method
|
|
100
|
-
interface _Collection
|
|
101
|
-
def offset: (Integer offset) -> _Collection
|
|
102
|
-
def limit: (Integer limit) -> _Collection
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
type collection = _Collection | Array[untyped]
|
|
107
|
-
|
|
108
|
-
def pagy: (:offset, collection collection, **offset_opts options) -> [Offset, collection]
|
|
109
|
-
| (:countless, collection collection, **countless_opts options) -> [Countless, collection]
|
|
110
|
-
| (:countish, collection collection, **countish_opts options) -> [Countish, collection]
|
|
111
|
-
|
|
112
|
-
| (:keyset, ::ActiveRecord::Relation[untyped] set, **keyset_opts options) -> [Keyset::ActiveRecord, Array[::ActiveRecord::Base[untyped]]]
|
|
113
|
-
| (:keyset, ::Sequel::Dataset[untyped] set, **keyset_opts options) -> [Keyset::Sequel, Array[::Sequel::Model[untyped]]]
|
|
114
|
-
|
|
115
|
-
| (:keynav_js, ::ActiveRecord::Relation[untyped] set, **keyset_opts options) -> [Keyset::Keynav::ActiveRecord, Array[::ActiveRecord::Base[untyped]]]
|
|
116
|
-
| (:keynav_js, ::Sequel::Dataset[untyped] set, **keyset_opts options) -> [Keyset::Keynav::Sequel, Array[::Sequel::Model[untyped]]]
|
|
117
|
-
|
|
118
|
-
| (:calendar, _Collection collection, **calendar_config) -> [Calendar, Offset, _Collection]
|
|
119
|
-
|
|
120
|
-
| (:elasticsearch_rails, Search::Arguments, **search_opts options) -> [ElasticsearchRails, untyped]
|
|
121
|
-
| (:elasticsearch_rails, untyped search, **search_opts options) -> ElasticsearchRails
|
|
122
|
-
|
|
123
|
-
| (:meilisearch, Search::Arguments, **search_opts options) -> [Meilisearch, untyped]
|
|
124
|
-
| (:meilisearch, untyped search, **search_opts options) -> Meilisearch
|
|
125
|
-
|
|
126
|
-
| (:searchkick, Search::Arguments, **search_opts options) -> [Searchkick, untyped]
|
|
127
|
-
| (:searchkick, untyped search, **search_opts options) -> Searchkick
|
|
128
|
-
|
|
129
|
-
| (:typesense_rails, Search::Arguments, **search_opts options) -> [TypesenseRails, untyped]
|
|
130
|
-
| (:typesense_rails, untyped search, **search_opts options) -> TypesenseRails
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
# Helper methods
|
|
134
|
-
def data_hash: (**data_opts) -> pagy_data_hash
|
|
135
|
-
def headers_hash: (**headers_opts) -> Hash[String, String]
|
|
136
|
-
def urls_hash: (**url_opts) -> Hash[Symbol, String]
|
|
137
|
-
|
|
138
|
-
def page_url: (:first | :current | :page | :previous | :next | :last | Integer page, **url_opts) -> String
|
|
139
|
-
def next_tag: (String? text, **anchor_tags_opts) -> String
|
|
140
|
-
|
|
141
|
-
module NumericHelpers
|
|
142
|
-
def series_nav: (?Symbol? style, **series_nav_opts) -> String
|
|
143
|
-
def series_nav_js: (?Symbol? style, **series_nav_js_opts) -> String
|
|
144
|
-
def input_nav_js: (?Symbol? style, **nav_opts) -> String
|
|
145
|
-
|
|
146
|
-
def previous_tag: (String? text, **anchor_tags_opts) -> String
|
|
147
|
-
def limit_tag_js: (?id: String?, ?item_name: String?, **url_opts) -> String
|
|
148
|
-
def info_tag: (?id: String?, ?item_name: String?) -> String
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
##### OPTIONS #####
|
|
152
|
-
|
|
153
|
-
type url_opts = {
|
|
154
|
-
?fragment: String,
|
|
155
|
-
?absolute: bool,
|
|
156
|
-
?path: String,
|
|
157
|
-
?querify: Proc,
|
|
158
|
-
?jsonapi: bool,
|
|
159
|
-
?root_key: String,
|
|
160
|
-
?page_key: String,
|
|
161
|
-
?limit_key: String,
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
##### Paginator Options #####
|
|
165
|
-
|
|
166
|
-
type paginator_opts = url_opts & {
|
|
167
|
-
?page: Integer,
|
|
168
|
-
?limit: Integer,
|
|
169
|
-
?max_pages: Integer,
|
|
170
|
-
?client_max_limit: Integer,
|
|
171
|
-
?request: _RackRequest | request_hash
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
type offset_opts = paginator_opts & {
|
|
175
|
-
?count: Integer,
|
|
176
|
-
?count_over: bool,
|
|
177
|
-
?raise_range_error: bool
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
type countish_opts = offset_opts & {
|
|
181
|
-
?ttl: Integer,
|
|
182
|
-
?epoch: Integer
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
type countless_opts = offset_opts & {
|
|
186
|
-
?headless: bool
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
type unit_opts = paginator_opts & {
|
|
190
|
-
?slots: Integer,
|
|
191
|
-
?compact: bool,
|
|
192
|
-
?format: String,
|
|
193
|
-
?order: Symbol
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
type calendar_config = {
|
|
197
|
-
?year: unit_opts,
|
|
198
|
-
?quarter: unit_opts,
|
|
199
|
-
?month: unit_opts,
|
|
200
|
-
?week: unit_opts,
|
|
201
|
-
?day: unit_opts,
|
|
202
|
-
?offset: offset_opts,
|
|
203
|
-
?disabled: bool
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
type keyset_opts = paginator_opts & {
|
|
207
|
-
?keyset: Hash[untyped, untyped],
|
|
208
|
-
?tuple_comparison: bool,
|
|
209
|
-
?pre_serialize: Proc
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
type search_opts = {
|
|
213
|
-
?search_method: Symbol
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
##### Helper Options #####
|
|
217
|
-
|
|
218
|
-
### data_hash ###
|
|
219
|
-
type pagy_data_key = :url_template | :first_url | :previous_url | :current_url
|
|
220
|
-
| :page_url | :next_url | :last_url | :count | :page
|
|
221
|
-
| :limit | :last | :in | :from | :to | :previous
|
|
222
|
-
| :next | :options | Symbol
|
|
223
|
-
|
|
224
|
-
# The return structure with optional keys (marked with ?)
|
|
225
|
-
type pagy_data_hash = {
|
|
226
|
-
?url_template: String,
|
|
227
|
-
?first_url: String,
|
|
228
|
-
?previous_url: String,
|
|
229
|
-
?current_url: String,
|
|
230
|
-
?page_url: String,
|
|
231
|
-
?next_url: String,
|
|
232
|
-
?last_url: String,
|
|
233
|
-
?count: Integer,
|
|
234
|
-
?page: Integer,
|
|
235
|
-
?limit: Integer,
|
|
236
|
-
?last: Integer,
|
|
237
|
-
?in: Integer,
|
|
238
|
-
?from: Integer,
|
|
239
|
-
?to: Integer,
|
|
240
|
-
?previous: Integer,
|
|
241
|
-
?next: Integer,
|
|
242
|
-
?options: options
|
|
243
|
-
} & Hash[Symbol, untyped] # Intersection allows for 'send' method results
|
|
244
|
-
|
|
245
|
-
type data_opts = url_opts & {
|
|
246
|
-
?data_keys: Array[pagy_data_key]
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
type headers_opts = url_opts & {
|
|
250
|
-
?headers_map: Hash[Symbol, String]
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
##### NumericUI Options #####
|
|
254
|
-
type anchor_tags_opts = url_opts & {
|
|
255
|
-
?text: String,
|
|
256
|
-
?aria_label: String
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
type nav_opts = url_opts & {
|
|
260
|
-
?id: String,
|
|
261
|
-
?aria_label: String,
|
|
262
|
-
?item_name: String,
|
|
263
|
-
?style: :pagy | :bootstrap | :bulma,
|
|
264
|
-
?anchor_string: String
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
type series_nav_opts = nav_opts & {
|
|
268
|
-
?slots: Integer,
|
|
269
|
-
?compact: bool,
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
type series_nav_js_opts = series_nav_opts & {
|
|
273
|
-
?steps: Hash[Integer, Integer]
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
type options = url_opts & paginator_opts & offset_opts & countish_opts & countless_opts &
|
|
277
|
-
unit_opts & keyset_opts & search_opts &
|
|
278
|
-
anchor_tags_opts & nav_opts & data_opts & headers_opts & nav_opts & series_nav_opts & series_nav_js_opts
|
|
279
|
-
|
|
280
|
-
##### REQUEST #####
|
|
281
|
-
|
|
282
|
-
interface _RackRequest
|
|
283
|
-
def base_url: () -> String
|
|
284
|
-
def path: () -> String
|
|
285
|
-
def GET: () -> Hash[String, untyped]
|
|
286
|
-
def POST: () -> Hash[String, untyped]
|
|
287
|
-
def cookies: () -> Hash[String, String]
|
|
288
|
-
end
|
|
289
|
-
|
|
290
|
-
type request_hash = {
|
|
291
|
-
base_url: String,
|
|
292
|
-
path: String,
|
|
293
|
-
params: Hash[String, untyped],
|
|
294
|
-
?cookie: String
|
|
295
|
-
}
|
|
296
|
-
end
|
|
297
|
-
|
|
298
|
-
module ActiveRecord
|
|
299
|
-
class Base[T]
|
|
300
|
-
end
|
|
301
|
-
class Relation[T]
|
|
302
|
-
end
|
|
303
|
-
end
|
|
304
|
-
|
|
305
|
-
module ActiveSupport
|
|
306
|
-
class TimeWithZone
|
|
307
|
-
end
|
|
308
|
-
end
|
|
309
|
-
|
|
310
|
-
module Sequel
|
|
311
|
-
class Dataset[T]
|
|
312
|
-
end
|
|
313
|
-
class Model[T]
|
|
314
|
-
end
|
|
315
|
-
end
|