pagy 8.6.0 → 9.0.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.
- checksums.yaml +4 -4
- data/apps/calendar.ru +5 -5
- data/apps/demo.ru +8 -9
- data/apps/keyset_ar.ru +236 -0
- data/apps/keyset_s.ru +238 -0
- data/apps/rails.ru +7 -9
- data/apps/repro.ru +5 -6
- data/apps/tmp/calendar.sqlite3 +0 -0
- data/apps/tmp/calendar.sqlite3-shm +0 -0
- data/apps/tmp/calendar.sqlite3-wal +0 -0
- data/apps/tmp/local_secret.txt +1 -1
- data/apps/tmp/pagy-keyset-ar.sqlite3 +0 -0
- data/apps/tmp/{pagy-rails.sqlite3 → pagy-keyset-ar.sqlite3-shm} +0 -0
- data/apps/tmp/pagy-keyset-ar.sqlite3-wal +0 -0
- data/apps/tmp/pagy-keyset-s.sqlite3 +0 -0
- data/bin/pagy +4 -2
- data/config/pagy.rb +34 -31
- data/javascripts/pagy-module.js +1 -1
- data/javascripts/pagy.js +2 -2
- data/javascripts/pagy.min.js +2 -2
- data/javascripts/pagy.min.js.map +3 -3
- data/javascripts/pagy.mjs +2 -2
- data/lib/pagy/b64.rb +33 -0
- data/lib/pagy/backend.rb +21 -17
- data/lib/pagy/calendar/day.rb +1 -1
- data/lib/pagy/calendar/month.rb +1 -1
- data/lib/pagy/calendar/quarter.rb +1 -1
- data/lib/pagy/calendar/unit.rb +7 -10
- data/lib/pagy/calendar/week.rb +1 -1
- data/lib/pagy/calendar/year.rb +1 -1
- data/lib/pagy/calendar.rb +5 -5
- data/lib/pagy/countless.rb +11 -15
- data/lib/pagy/extras/arel.rb +8 -10
- data/lib/pagy/extras/array.rb +4 -6
- data/lib/pagy/extras/bootstrap.rb +5 -5
- data/lib/pagy/extras/bulma.rb +10 -7
- data/lib/pagy/extras/calendar.rb +4 -5
- data/lib/pagy/extras/countless.rb +15 -13
- data/lib/pagy/extras/elasticsearch_rails.rb +15 -15
- data/lib/pagy/extras/gearbox.rb +26 -26
- data/lib/pagy/extras/headers.rb +25 -24
- data/lib/pagy/extras/js_tools.rb +8 -8
- data/lib/pagy/extras/jsonapi.rb +26 -16
- data/lib/pagy/extras/keyset.rb +36 -0
- data/lib/pagy/extras/limit.rb +63 -0
- data/lib/pagy/extras/meilisearch.rb +11 -11
- data/lib/pagy/extras/metadata.rb +2 -2
- data/lib/pagy/extras/overflow.rb +6 -6
- data/lib/pagy/extras/pagy.rb +16 -16
- data/lib/pagy/extras/searchkick.rb +11 -11
- data/lib/pagy/extras/size.rb +2 -2
- data/lib/pagy/extras/standalone.rb +6 -6
- data/lib/pagy/extras/trim.rb +2 -2
- data/lib/pagy/frontend.rb +32 -33
- data/lib/pagy/i18n.rb +1 -1
- data/lib/pagy/keyset/active_record.rb +38 -0
- data/lib/pagy/keyset/sequel.rb +51 -0
- data/lib/pagy/keyset.rb +98 -0
- data/lib/pagy/shared_methods.rb +27 -0
- data/lib/pagy/url_helpers.rb +4 -4
- data/lib/pagy.rb +54 -68
- data/locales/ar.yml +2 -1
- data/locales/be.yml +1 -1
- data/locales/bg.yml +1 -1
- data/locales/bs.yml +1 -1
- data/locales/ca.yml +1 -1
- data/locales/ckb.yml +1 -1
- data/locales/cs.yml +1 -1
- data/locales/da.yml +1 -1
- data/locales/de.yml +1 -1
- data/locales/en.yml +1 -1
- data/locales/es.yml +1 -1
- data/locales/fr.yml +1 -1
- data/locales/hr.yml +1 -1
- data/locales/id.yml +1 -1
- data/locales/it.yml +1 -1
- data/locales/ja.yml +1 -1
- data/locales/km.yml +1 -1
- data/locales/ko.yml +1 -1
- data/locales/nb.yml +1 -1
- data/locales/nl.yml +1 -1
- data/locales/nn.yml +1 -1
- data/locales/pl.yml +1 -1
- data/locales/pt-BR.yml +1 -1
- data/locales/pt.yml +1 -1
- data/locales/ru.yml +1 -1
- data/locales/sr.yml +1 -1
- data/locales/sv-SE.yml +1 -1
- data/locales/sv.yml +1 -1
- data/locales/sw.yml +1 -1
- data/locales/ta.yml +1 -1
- data/locales/tr.yml +1 -1
- data/locales/uk.yml +1 -1
- data/locales/vi.yml +1 -1
- data/locales/zh-CN.yml +1 -1
- data/locales/zh-HK.yml +1 -1
- data/locales/zh-TW.yml +1 -1
- metadata +16 -16
- data/lib/pagy/extras/foundation.rb +0 -95
- data/lib/pagy/extras/items.rb +0 -64
- data/lib/pagy/extras/materialize.rb +0 -100
- data/lib/pagy/extras/semantic.rb +0 -94
- data/lib/pagy/extras/uikit.rb +0 -98
data/lib/pagy/extras/items.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
# See the Pagy documentation: https://ddnexus.github.io/pagy/docs/extras/items
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require_relative 'js_tools'
|
5
|
-
|
6
|
-
class Pagy # :nodoc:
|
7
|
-
DEFAULT[:items_param] = :items
|
8
|
-
DEFAULT[:max_items] = 100
|
9
|
-
DEFAULT[:items_extra] = true # extra enabled by default
|
10
|
-
|
11
|
-
# Allow the client to request a custom number of items per page with an optional selector UI
|
12
|
-
module ItemsExtra
|
13
|
-
# Additions for the Backend module
|
14
|
-
module BackendAddOn
|
15
|
-
private
|
16
|
-
|
17
|
-
# Set the items variable considering the params and other pagy variables
|
18
|
-
def pagy_set_items_from_params(vars)
|
19
|
-
return if vars[:items] # :items explicitly set
|
20
|
-
return unless vars.key?(:items_extra) ? vars[:items_extra] : DEFAULT[:items_extra] # :items_extra is false
|
21
|
-
return unless (items_count = pagy_get_items_size(vars)) # no items from request params
|
22
|
-
|
23
|
-
vars[:items] = [items_count.to_i, vars.key?(:max_items) ? vars[:max_items] : DEFAULT[:max_items]].compact.min
|
24
|
-
end
|
25
|
-
|
26
|
-
# Get the items count from the params
|
27
|
-
# Overridable by the jsonapi extra
|
28
|
-
def pagy_get_items_size(vars)
|
29
|
-
params[vars[:items_param] || DEFAULT[:items_param]]
|
30
|
-
end
|
31
|
-
end
|
32
|
-
Backend.prepend ItemsExtra::BackendAddOn
|
33
|
-
|
34
|
-
# Additions for the Frontend module
|
35
|
-
module FrontendAddOn
|
36
|
-
ITEMS_TOKEN = '__pagy_items__'
|
37
|
-
|
38
|
-
# Return the items selector HTML. For example "Show [20] items per page"
|
39
|
-
def pagy_items_selector_js(pagy, id: nil, item_name: nil)
|
40
|
-
return '' unless pagy.vars[:items_extra]
|
41
|
-
|
42
|
-
id = %( id="#{id}") if id
|
43
|
-
vars = pagy.vars
|
44
|
-
items = vars[:items]
|
45
|
-
vars[:items] = ITEMS_TOKEN
|
46
|
-
url_token = pagy_url_for(pagy, PAGE_TOKEN)
|
47
|
-
vars[:items] = items # restore the items
|
48
|
-
|
49
|
-
items_input = %(<input name="items" type="number" min="1" max="#{vars[:max_items]}" value="#{
|
50
|
-
items}" style="padding: 0; text-align: center; width: #{items.to_s.length + 1}rem;">#{JSTools::A_TAG})
|
51
|
-
|
52
|
-
%(<span#{id} class="pagy items-selector-js" #{
|
53
|
-
pagy_data(pagy, :selector, pagy.from, url_token)
|
54
|
-
}><label>#{
|
55
|
-
pagy_t('pagy.items_selector_js',
|
56
|
-
item_name: item_name || pagy_t('pagy.item_name', count: items),
|
57
|
-
items_input:,
|
58
|
-
count: items)
|
59
|
-
}</label></span>)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
Frontend.prepend ItemsExtra::FrontendAddOn
|
63
|
-
end
|
64
|
-
end
|
@@ -1,100 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
warn '[PAGY WARNING] The materialize extra has been discontinued and it will be removed in v9 ' \
|
4
|
-
'(https://github.com/ddnexus/pagy/discussions/672#discussioncomment-9212328)'
|
5
|
-
|
6
|
-
require_relative 'js_tools'
|
7
|
-
|
8
|
-
class Pagy # :nodoc:
|
9
|
-
# Frontend modules are specially optimized for performance.
|
10
|
-
# The resulting code may not look very elegant, but produces the best benchmarks
|
11
|
-
module MaterializeExtra
|
12
|
-
# Pagination for materialize: it returns the html with the series of links to the pages
|
13
|
-
def pagy_materialize_nav(pagy, id: nil, aria_label: nil, **vars)
|
14
|
-
id = %( id="#{id}") if id
|
15
|
-
a = pagy_anchor(pagy)
|
16
|
-
|
17
|
-
html = +%(<div#{id} class="pagy-materialize nav pagination" role="navigation" #{
|
18
|
-
nav_aria_label(pagy, aria_label:)}><ul class="pagination">#{
|
19
|
-
materialize_prev_html(pagy, a)})
|
20
|
-
pagy.series(**vars).each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
|
21
|
-
html << case item
|
22
|
-
when Integer
|
23
|
-
%(<li class="waves-effect">#{a.(item)}</li>)
|
24
|
-
when String
|
25
|
-
%(<li class="active"><a role="link" aria-current="page" aria-disabled="true">#{pagy.label_for(item)}</a></li>)
|
26
|
-
when :gap
|
27
|
-
%(<li class="gap disabled"><a role="link" aria-disabled="true">#{pagy_t 'pagy.gap'}</a></li>)
|
28
|
-
else
|
29
|
-
raise InternalError, "expected item types in series to be Integer, String or :gap; got #{item.inspect}"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
html << %(#{materialize_next_html(pagy, a)}</ul></div>)
|
33
|
-
end
|
34
|
-
|
35
|
-
# Javascript pagination for materialize: it returns a nav with a data-pagy attribute used by the pagy.js file
|
36
|
-
def pagy_materialize_nav_js(pagy, id: nil, aria_label: nil, **vars)
|
37
|
-
sequels = pagy.sequels(**vars)
|
38
|
-
id = %( id="#{id}") if id
|
39
|
-
a = pagy_anchor(pagy)
|
40
|
-
|
41
|
-
tokens = { 'before' => %(<ul class="pagination">#{materialize_prev_html pagy, a}),
|
42
|
-
'a' => %(<li class="waves-effect">#{a.(PAGE_TOKEN, LABEL_TOKEN)}</li>),
|
43
|
-
'current' => %(<li class="active"><a role="link" aria-current="page" aria-disabled="true">#{
|
44
|
-
LABEL_TOKEN}</a></li>),
|
45
|
-
'gap' => %(<li class="gap disabled"><a role="link" aria-disabled="true">#{pagy_t 'pagy.gap'}</a></li>),
|
46
|
-
'after' => %(#{materialize_next_html pagy, a}</ul>) }
|
47
|
-
|
48
|
-
%(<div#{id} class="#{'pagy-rjs ' if sequels.size > 1}pagy-materialize nav-js" role="navigation" #{
|
49
|
-
nav_aria_label(pagy, aria_label:)} #{
|
50
|
-
pagy_data(pagy, :nav, tokens, sequels, pagy.label_sequels(sequels))
|
51
|
-
}></div>)
|
52
|
-
end
|
53
|
-
|
54
|
-
# Javascript combo pagination for materialize: it returns a nav with a data-pagy attribute used by the pagy.js file
|
55
|
-
def pagy_materialize_combo_nav_js(pagy, id: nil, aria_label: nil)
|
56
|
-
id = %( id="#{id}") if id
|
57
|
-
a = pagy_anchor(pagy)
|
58
|
-
pages = pagy.pages
|
59
|
-
|
60
|
-
page_input = %(<input name="page" type="number" min="1" max="#{pages}" value="#{pagy.page}" aria-current="page" ) <<
|
61
|
-
%(style="text-align: center; width: #{pages.to_s.length + 1}rem; height: 1.5rem; font-size: 1.2rem; ) <<
|
62
|
-
%(border: none; border-radius: 2px; color: white; background-color: #ee6e73;" class="browser-default"> ) <<
|
63
|
-
JSTools::A_TAG
|
64
|
-
|
65
|
-
%(<ul#{id} class="pagy-materialize combo-nav-js pagination" role="navigation" style="padding-right: 0;" #{
|
66
|
-
nav_aria_label(pagy, aria_label:)} #{
|
67
|
-
pagy_data(pagy, :combo, pagy_url_for(pagy, PAGE_TOKEN))
|
68
|
-
}>#{
|
69
|
-
materialize_prev_html(pagy, a)
|
70
|
-
}<li style="vertical-align: -webkit-baseline-middle;"><label style="font-size: 1.2rem;">#{
|
71
|
-
pagy_t('pagy.combo_nav_js', page_input:, pages:)
|
72
|
-
}</label></li>#{
|
73
|
-
materialize_next_html(pagy, a)
|
74
|
-
}</ul>)
|
75
|
-
end
|
76
|
-
|
77
|
-
private
|
78
|
-
|
79
|
-
def materialize_prev_html(pagy, a)
|
80
|
-
if (p_prev = pagy.prev)
|
81
|
-
%(<li class="waves-effect prev">#{
|
82
|
-
a.(p_prev, '<i class="material-icons">chevron_left</i>', aria_label: pagy_t('pagy.aria_label.prev'))}</li>)
|
83
|
-
else
|
84
|
-
%(<li class="prev disabled"><a role="link" aria-disabled="true" aria-label="#{
|
85
|
-
pagy_t('pagy.aria_label.prev')}"><i class="material-icons">chevron_left</i></a></li>)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def materialize_next_html(pagy, a)
|
90
|
-
if (p_next = pagy.next)
|
91
|
-
%(<li class="waves-effect next">#{
|
92
|
-
a.(p_next, '<i class="material-icons">chevron_right</i>', aria_label: pagy_t('pagy.aria_label.next'))}</li>)
|
93
|
-
else
|
94
|
-
%(<li class="next disabled"#><a role="link" aria-disabled="true" aria-label="#{
|
95
|
-
pagy_t('pagy.aria_label.next')}><i class="material-icons">chevron_right</i></a></li>)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
Frontend.prepend MaterializeExtra
|
100
|
-
end
|
data/lib/pagy/extras/semantic.rb
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
warn '[PAGY WARNING] The semantic extra has been discontinued and it will be removed in v9 ' \
|
4
|
-
'(https://github.com/ddnexus/pagy/discussions/672#discussioncomment-9212328)'
|
5
|
-
|
6
|
-
require_relative 'js_tools'
|
7
|
-
|
8
|
-
class Pagy # :nodoc:
|
9
|
-
# Frontend modules are specially optimized for performance.
|
10
|
-
# The resulting code may not look very elegant, but produces the best benchmarks
|
11
|
-
module SemanticExtra
|
12
|
-
# Pagination for semantic: it returns the html with the series of links to the pages
|
13
|
-
def pagy_semantic_nav(pagy, id: nil, aria_label: nil, **vars)
|
14
|
-
id = %( id="#{id}") if id
|
15
|
-
a = pagy_anchor(pagy)
|
16
|
-
|
17
|
-
html = %(<div#{id} role="navigation" class="pagy-semantic nav ui pagination menu" #{
|
18
|
-
nav_aria_label(pagy, aria_label:)}>#{semantic_prev_html(pagy, a)})
|
19
|
-
pagy.series(**vars).each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
|
20
|
-
html << case item
|
21
|
-
when Integer
|
22
|
-
a.(item, pagy.label_for(item), classes: 'item')
|
23
|
-
when String
|
24
|
-
%(<a role="link" class="item active" aria-current="page" aria-disabled="true">#{pagy.label_for(item)}</a>)
|
25
|
-
when :gap
|
26
|
-
%(<div class="disabled item">#{pagy_t 'pagy.gap'}</div>)
|
27
|
-
else
|
28
|
-
raise InternalError, "expected item types in series to be Integer, String or :gap; got #{item.inspect}"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
html << %(#{semantic_next_html(pagy, a)}</div>)
|
32
|
-
end
|
33
|
-
|
34
|
-
# Javascript pagination for semantic: it returns a nav with a data-pagy attribute used by the pagy.js file
|
35
|
-
def pagy_semantic_nav_js(pagy, id: nil, aria_label: nil, **vars)
|
36
|
-
sequels = pagy.sequels(**vars)
|
37
|
-
id = %( id="#{id}") if id
|
38
|
-
a = pagy_anchor(pagy)
|
39
|
-
tokens = { 'before' => semantic_prev_html(pagy, a),
|
40
|
-
'a' => a.(PAGE_TOKEN, LABEL_TOKEN, classes: 'item'),
|
41
|
-
'current' => %(<a role="link" class="item active" aria-current="page" aria-disabled="true">#{LABEL_TOKEN}</a>),
|
42
|
-
'gap' => %(<div class="disabled item">#{pagy_t('pagy.gap')}</div>),
|
43
|
-
'after' => semantic_next_html(pagy, a) }
|
44
|
-
|
45
|
-
%(<div#{id} class="#{'pagy-rjs ' if sequels.size > 1}pagy-semantic nav-js ui pagination menu" role="navigation" #{
|
46
|
-
nav_aria_label(pagy, aria_label:)} #{
|
47
|
-
pagy_data(pagy, :nav, tokens, sequels, pagy.label_sequels(sequels))
|
48
|
-
}></div>)
|
49
|
-
end
|
50
|
-
|
51
|
-
# Combo pagination for semantic: it returns a nav with a data-pagy attribute used by the pagy.js file
|
52
|
-
def pagy_semantic_combo_nav_js(pagy, id: nil, aria_label: nil)
|
53
|
-
id = %( id="#{id}") if id
|
54
|
-
a = pagy_anchor(pagy)
|
55
|
-
pages = pagy.pages
|
56
|
-
|
57
|
-
page_input = %(<input name="page" type="number" min="1" max="#{pages}" value="#{pagy.page}" aria-current="page") <<
|
58
|
-
%(style="text-align: center; width: #{pages.to_s.length + 1}rem; padding: 0; margin: 0 0.3rem">) <<
|
59
|
-
JSTools::A_TAG
|
60
|
-
|
61
|
-
%(<div#{id} class="pagy-semantic combo-nav-js ui compact menu" role="navigation" #{
|
62
|
-
nav_aria_label(pagy, aria_label:)} #{
|
63
|
-
pagy_data(pagy, :combo, pagy_url_for(pagy, PAGE_TOKEN))
|
64
|
-
}>#{
|
65
|
-
semantic_prev_html(pagy, a)
|
66
|
-
}<div class="item"><label>#{
|
67
|
-
pagy_t('pagy.combo_nav_js', page_input:, pages:)
|
68
|
-
}</label></div> #{
|
69
|
-
semantic_next_html(pagy, a)
|
70
|
-
}</div>)
|
71
|
-
end
|
72
|
-
|
73
|
-
private
|
74
|
-
|
75
|
-
def semantic_prev_html(pagy, a)
|
76
|
-
if (p_prev = pagy.prev)
|
77
|
-
a.(p_prev, pagy_t('pagy.prev'), classes: 'item', aria_label: pagy_t('pagy.aria_label.prev'))
|
78
|
-
else
|
79
|
-
%(<div class="item disabled" role="a" aria-disabled="true" aria-label="#{
|
80
|
-
pagy_t('pagy.aria_label.prev')}">#{pagy_t('pagy.prev')}</div>)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def semantic_next_html(pagy, a)
|
85
|
-
if (p_next = pagy.next)
|
86
|
-
a.(p_next, pagy_t('pagy.next'), classes: 'item', aria_label: pagy_t('pagy.aria_label.next'))
|
87
|
-
else
|
88
|
-
%(<div class="item disabled" role="link" aria-disabled="true" aria=label="#{
|
89
|
-
pagy_t('pagy.aria_label.prev')}">#{pagy_t('pagy.next')}</div>)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
Frontend.prepend SemanticExtra
|
94
|
-
end
|
data/lib/pagy/extras/uikit.rb
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
warn '[PAGY WARNING] The uikit extra has been discontinued and it will be removed in v9 ' \
|
4
|
-
'(https://github.com/ddnexus/pagy/discussions/672#discussioncomment-9212328)'
|
5
|
-
|
6
|
-
require_relative 'js_tools'
|
7
|
-
|
8
|
-
class Pagy # :nodoc:
|
9
|
-
# Frontend modules are specially optimized for performance.
|
10
|
-
# The resulting code may not look very elegant, but produces the best benchmarks
|
11
|
-
module UikitExtra
|
12
|
-
# Pagination for uikit: it returns the html with the series of links to the pages
|
13
|
-
def pagy_uikit_nav(pagy, id: nil, aria_label: nil, **vars)
|
14
|
-
id = %( id="#{id}") if id
|
15
|
-
a = pagy_anchor(pagy)
|
16
|
-
|
17
|
-
html = %(<ul#{id} class="pagy-uikit nav uk-pagination uk-flex-center" role="navigation" #{
|
18
|
-
nav_aria_label(pagy, aria_label:)}>#{
|
19
|
-
uikit_prev_html(pagy, a)})
|
20
|
-
pagy.series(**vars).each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
|
21
|
-
html << case item
|
22
|
-
when Integer
|
23
|
-
%(<li>#{a.(item)}</li>)
|
24
|
-
when String
|
25
|
-
%(<li class="uk-active"><span role="link" aria-current="page" aria-disabled="true">#{
|
26
|
-
pagy.label_for(item)}</span></li>)
|
27
|
-
when :gap
|
28
|
-
%(<li class="uk-disabled"><span>#{pagy_t 'pagy.gap'}</span></li>)
|
29
|
-
else
|
30
|
-
raise InternalError, "expected item types in series to be Integer, String or :gap; got #{item.inspect}"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
html << %(#{uikit_next_html(pagy, a)}</ul>)
|
34
|
-
end
|
35
|
-
|
36
|
-
# Javascript pagination for uikit: it returns a nav with a data-pagy attribute used by the pagy.js file
|
37
|
-
def pagy_uikit_nav_js(pagy, id: nil, aria_label: nil, **vars)
|
38
|
-
sequels = pagy.sequels(**vars)
|
39
|
-
id = %( id="#{id}") if id
|
40
|
-
a = pagy_anchor(pagy)
|
41
|
-
tokens = { 'before' => uikit_prev_html(pagy, a),
|
42
|
-
'a' => %(<li>#{a.(PAGE_TOKEN, LABEL_TOKEN)}</li>),
|
43
|
-
'current' => %(<li class="uk-active"><span role="link" aria-current="page" aria-disabled="true">#{
|
44
|
-
LABEL_TOKEN}</span></li>),
|
45
|
-
'gap' => %(<li class="uk-disabled"><span>#{pagy_t 'pagy.gap'}</span></li>),
|
46
|
-
'after' => uikit_next_html(pagy, a) }
|
47
|
-
|
48
|
-
%(<ul#{id} class="#{'pagy-rjs ' if sequels.size > 1}pagy-uikit nav-js uk-pagination uk-flex-center" role="navigation" #{
|
49
|
-
nav_aria_label(pagy, aria_label:)} #{
|
50
|
-
pagy_data(pagy, :nav, tokens, sequels, pagy.label_sequels(sequels))
|
51
|
-
}></ul>)
|
52
|
-
end
|
53
|
-
|
54
|
-
# Javascript combo pagination for uikit: it returns a nav with a data-pagy attribute used by the pagy.js file
|
55
|
-
def pagy_uikit_combo_nav_js(pagy, id: nil, aria_label: nil)
|
56
|
-
id = %( id="#{id}") if id
|
57
|
-
a = pagy_anchor(pagy)
|
58
|
-
pages = pagy.pages
|
59
|
-
|
60
|
-
page_input = %(<input name="page" type="number" min="1" max="#{pages}" value="#{pagy.page}" aria-current="page" ) <<
|
61
|
-
%(style="text-align: center; width: #{pages.to_s.length + 1}rem;">#{JSTools::A_TAG})
|
62
|
-
|
63
|
-
%(<ul#{id} class="pagy-uikit combo-nav-js uk-button-group uk-pagination uk-flex-center" role="navigation" #{
|
64
|
-
nav_aria_label(pagy, aria_label:)} #{
|
65
|
-
pagy_data(pagy, :combo, pagy_url_for(pagy, PAGE_TOKEN))
|
66
|
-
}>#{
|
67
|
-
uikit_prev_html(pagy, a)
|
68
|
-
}<li><label>#{
|
69
|
-
pagy_t('pagy.combo_nav_js', page_input:, pages:)
|
70
|
-
}</label></li>#{
|
71
|
-
uikit_next_html(pagy, a)
|
72
|
-
}</ul>)
|
73
|
-
end
|
74
|
-
|
75
|
-
private
|
76
|
-
|
77
|
-
def uikit_prev_html(pagy, a)
|
78
|
-
span = %(<span uk-pagination-previous></span>)
|
79
|
-
if (p_prev = pagy.prev)
|
80
|
-
%(<li>#{a.(p_prev, span, aria_label: pagy_t('pagy.aria_label.prev'))}</li>)
|
81
|
-
else
|
82
|
-
%(<li class="uk-disabled"><a role="link" aria-disabled="true" aria-label="#{
|
83
|
-
pagy_t('pagy.aria_label.prev')}">#{span}</a></li>)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def uikit_next_html(pagy, a)
|
88
|
-
span = %(<span uk-pagination-next></span>)
|
89
|
-
if (p_next = pagy.next)
|
90
|
-
%(<li>#{a.(p_next, span, aria_label: pagy_t('pagy.aria_label.prev'))}</li>)
|
91
|
-
else
|
92
|
-
%(<li class="uk-disabled"><a role="link" aria-disabled="true" aria-label="#{
|
93
|
-
pagy_t('pagy.aria_label.next')}">#{span}</a></li>)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
Frontend.include UikitExtra
|
98
|
-
end
|