pagy 8.6.3 → 9.3.4
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/LICENSE.txt +1 -1
- data/apps/calendar.ru +119 -127
- data/apps/demo.ru +274 -260
- data/apps/index.rb +7 -0
- data/apps/keyset_ar.ru +227 -0
- data/apps/keyset_s.ru +219 -0
- data/apps/rails.ru +25 -20
- data/apps/repro.ru +108 -103
- data/bin/pagy +18 -20
- data/config/pagy.rb +19 -15
- 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 +20 -20
- data/lib/pagy/calendar/day.rb +2 -2
- data/lib/pagy/calendar/month.rb +2 -2
- data/lib/pagy/calendar/quarter.rb +2 -2
- data/lib/pagy/calendar/unit.rb +7 -10
- data/lib/pagy/calendar/week.rb +2 -2
- data/lib/pagy/calendar/year.rb +2 -2
- data/lib/pagy/calendar.rb +15 -13
- data/lib/pagy/countless.rb +10 -14
- data/lib/pagy/extras/arel.rb +3 -11
- data/lib/pagy/extras/array.rb +5 -10
- data/lib/pagy/extras/bootstrap.rb +5 -5
- data/lib/pagy/extras/bulma.rb +10 -7
- data/lib/pagy/extras/calendar.rb +13 -17
- data/lib/pagy/extras/countless.rb +8 -13
- data/lib/pagy/extras/elasticsearch_rails.rb +16 -25
- data/lib/pagy/extras/gearbox.rb +18 -18
- data/lib/pagy/extras/headers.rb +25 -24
- data/lib/pagy/extras/i18n.rb +1 -1
- data/lib/pagy/extras/js_tools.rb +6 -6
- data/lib/pagy/extras/jsonapi.rb +30 -21
- data/lib/pagy/extras/keyset.rb +30 -0
- data/lib/pagy/extras/limit.rb +63 -0
- data/lib/pagy/extras/meilisearch.rb +9 -17
- data/lib/pagy/extras/metadata.rb +3 -3
- data/lib/pagy/extras/overflow.rb +9 -9
- data/lib/pagy/extras/pagy.rb +16 -16
- data/lib/pagy/extras/searchkick.rb +9 -17
- data/lib/pagy/extras/size.rb +1 -1
- data/lib/pagy/extras/standalone.rb +6 -6
- data/lib/pagy/extras/trim.rb +3 -3
- data/lib/pagy/frontend.rb +32 -33
- data/lib/pagy/i18n.rb +3 -2
- data/lib/pagy/keyset/active_record.rb +38 -0
- data/lib/pagy/keyset/sequel.rb +51 -0
- data/lib/pagy/keyset.rb +118 -0
- data/lib/pagy/shared_methods.rb +26 -0
- data/lib/pagy/url_helpers.rb +5 -5
- data/lib/pagy.rb +53 -67
- data/locales/ar.yml +1 -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/dz.yml +17 -0
- 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 +3 -1
- data/locales/ta.yml +3 -1
- data/locales/tr.yml +1 -1
- data/locales/uk.yml +1 -1
- data/locales/vi.yml +1 -1
- data/locales/zh-CN.yml +7 -9
- data/locales/zh-HK.yml +7 -9
- data/locales/zh-TW.yml +7 -9
- metadata +14 -27
- 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 +0 -1
- data/apps/tmp/pagy-keyset.sqlite3 +0 -0
- data/apps/tmp/pagy-keyset.sqlite3-shm +0 -0
- data/apps/tmp/pagy-keyset.sqlite3-wal +0 -0
- data/javascripts/pagy-module.js +0 -100
- data/javascripts/pagy.js +0 -4
- 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/locales/sw.yml
CHANGED
@@ -3,6 +3,8 @@ sw:
|
|
3
3
|
pagy:
|
4
4
|
# please add a comment in the https://github.com/ddnexus/pagy/issues/603
|
5
5
|
# posting the translation of the following "Page"/"Pages" with the plurals for this locale
|
6
|
+
# Please change the final test in 18n_loacles_test.rb to remove the sw.yml exclusion
|
7
|
+
# after you make these changes.
|
6
8
|
aria_label:
|
7
9
|
nav: "Pages"
|
8
10
|
# one: ""
|
@@ -20,4 +22,4 @@ sw:
|
|
20
22
|
single_page: "Inaonyesha %{item_name} %{count}"
|
21
23
|
multiple_pages: "Inaonyesha %{item_name} %{from}-%{to} ya %{count} kwa jumla"
|
22
24
|
combo_nav_js: "Kurasa %{page_input} ya %{pages}"
|
23
|
-
|
25
|
+
limit_selector_js: "Onyesha %{limit_input} %{item_name} kwa kila ukurasa"
|
data/locales/ta.yml
CHANGED
@@ -4,6 +4,8 @@ ta:
|
|
4
4
|
aria_label:
|
5
5
|
# please add a comment in the https://github.com/ddnexus/pagy/issues/604
|
6
6
|
# posting the translation of the following "Page"/"Pages" with the plurals for this locale
|
7
|
+
# Please change the final test in 18n_loacles_test.rb to remove the ta.yml exclusion
|
8
|
+
# after you make these changes.
|
7
9
|
nav: "Pages"
|
8
10
|
# one: ""
|
9
11
|
# other: ""
|
@@ -20,4 +22,4 @@ ta:
|
|
20
22
|
single_page: "%{count} %{item_name} காட்டப்படுகின்றது"
|
21
23
|
multiple_pages: "மொத்தம் %{count} %{item_name}, காட்டப்படுபவை %{from}-%{to}"
|
22
24
|
combo_nav_js: "%{pages}-இல் %{page_input}-வது பக்கம்"
|
23
|
-
|
25
|
+
limit_selector_js: "ஒரு பக்கத்திற்கு %{limit_input} %{item_name} காட்டு"
|
data/locales/tr.yml
CHANGED
@@ -16,4 +16,4 @@ tr:
|
|
16
16
|
single_page: "Toplam %{count} %{item_name} gösteriliyor"
|
17
17
|
multiple_pages: "%{count} %{item_name} içerisinden %{from}-%{to} kadarı gösteriliyor"
|
18
18
|
combo_nav_js: "Sayfa %{page_input} / %{pages}"
|
19
|
-
|
19
|
+
limit_selector_js: "Sayfada %{limit_input} %{item_name} göster"
|
data/locales/uk.yml
CHANGED
@@ -22,4 +22,4 @@ uk:
|
|
22
22
|
single_page: "%{count} %{item_name}"
|
23
23
|
multiple_pages: "Загалом %{count} %{item_name}, показані з %{from} по %{to}"
|
24
24
|
combo_nav_js: "Сторінка %{page_input} з %{pages}"
|
25
|
-
|
25
|
+
limit_selector_js: "Показати %{limit_input} %{item_name} на сторінці"
|
data/locales/vi.yml
CHANGED
@@ -14,4 +14,4 @@ vi:
|
|
14
14
|
single_page: "%{count} %{item_name}"
|
15
15
|
multiple_pages: "Đang hiển thị %{from}-%{to} trong tổng số %{count} %{item_name}"
|
16
16
|
combo_nav_js: "Trang %{page_input} trên %{pages}"
|
17
|
-
|
17
|
+
limit_selector_js: "Hiển thị %{limit_input} %{item_name} mỗi trang"
|
data/locales/zh-CN.yml
CHANGED
@@ -2,18 +2,16 @@
|
|
2
2
|
zh-CN:
|
3
3
|
pagy:
|
4
4
|
aria_label:
|
5
|
-
|
6
|
-
# posting the translation of the following "Page"/"Pages" with the plurals for this locale
|
7
|
-
nav: "Pages"
|
5
|
+
nav: "页"
|
8
6
|
prev: "上一页"
|
9
7
|
next: "下一页"
|
10
8
|
prev: "<"
|
11
9
|
next: ">"
|
12
10
|
gap: "…"
|
13
|
-
item_name: ""
|
11
|
+
item_name: "项"
|
14
12
|
info:
|
15
|
-
no_items: "
|
16
|
-
single_page: "
|
17
|
-
multiple_pages: "共 %{count}
|
18
|
-
combo_nav_js: "第 %{page_input}
|
19
|
-
|
13
|
+
no_items: "未找到任何 %{item_name}"
|
14
|
+
single_page: "显示 %{count} 项 %{item_name}"
|
15
|
+
multiple_pages: "共 %{count} 项 %{item_name},显示第 %{from}-%{to} 项"
|
16
|
+
combo_nav_js: "第 %{page_input} 页,共 %{pages} 页"
|
17
|
+
limit_selector_js: "每页显示 %{limit_input} 项 %{item_name}"
|
data/locales/zh-HK.yml
CHANGED
@@ -2,18 +2,16 @@
|
|
2
2
|
zh-HK:
|
3
3
|
pagy:
|
4
4
|
aria_label:
|
5
|
-
|
6
|
-
# posting the translation of the following "Page"/"Pages" with the plurals for this locale
|
7
|
-
nav: "Pages"
|
5
|
+
nav: "頁"
|
8
6
|
prev: "上一頁"
|
9
7
|
next: "下一頁"
|
10
8
|
prev: "<"
|
11
9
|
next: ">"
|
12
10
|
gap: "…"
|
13
|
-
item_name: ""
|
11
|
+
item_name: "項"
|
14
12
|
info:
|
15
|
-
no_items: "
|
16
|
-
single_page: "顯示 %{count} %{item_name}"
|
17
|
-
multiple_pages: "
|
18
|
-
combo_nav_js: "第 %{page_input}
|
19
|
-
|
13
|
+
no_items: "搵唔到任何 %{item_name}"
|
14
|
+
single_page: "顯示 %{count} 項 %{item_name}"
|
15
|
+
multiple_pages: "總共 %{count} 項 %{item_name},顯示第 %{from} 至 %{to} 項"
|
16
|
+
combo_nav_js: "第 %{page_input} 頁,共 %{pages} 頁"
|
17
|
+
limit_selector_js: "每頁顯示 %{limit_input} 項 %{item_name}"
|
data/locales/zh-TW.yml
CHANGED
@@ -2,18 +2,16 @@
|
|
2
2
|
zh-TW:
|
3
3
|
pagy:
|
4
4
|
aria_label:
|
5
|
-
|
6
|
-
# posting the translation of the following "Page"/"Pages" with the plurals for this locale
|
7
|
-
nav: "Pages"
|
5
|
+
nav: "頁"
|
8
6
|
prev: "上一頁"
|
9
7
|
next: "下一頁"
|
10
8
|
prev: "<"
|
11
9
|
next: ">"
|
12
10
|
gap: "…"
|
13
|
-
item_name: ""
|
11
|
+
item_name: "項"
|
14
12
|
info:
|
15
|
-
no_items: "
|
16
|
-
single_page: "顯示 %{count}
|
17
|
-
multiple_pages: "共 %{count}
|
18
|
-
combo_nav_js: "第 %{page_input}
|
19
|
-
|
13
|
+
no_items: "未找到任何 %{item_name}"
|
14
|
+
single_page: "顯示 %{count} 項 %{item_name}"
|
15
|
+
multiple_pages: "共 %{count} 項 %{item_name},顯示第 %{from} 至 %{to} 項"
|
16
|
+
combo_nav_js: "第 %{page_input} 頁,共 %{pages} 頁"
|
17
|
+
limit_selector_js: "每頁顯示 %{limit_input} 項 %{item_name}"
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pagy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 9.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Domizio Demichelis
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-03-10 00:00:00.000000000 Z
|
12
11
|
dependencies: []
|
13
12
|
description: Agnostic pagination in plain ruby. It does it all. Better.
|
14
13
|
email:
|
@@ -21,25 +20,20 @@ files:
|
|
21
20
|
- LICENSE.txt
|
22
21
|
- apps/calendar.ru
|
23
22
|
- apps/demo.ru
|
23
|
+
- apps/index.rb
|
24
|
+
- apps/keyset_ar.ru
|
25
|
+
- apps/keyset_s.ru
|
24
26
|
- apps/rails.ru
|
25
27
|
- apps/repro.ru
|
26
|
-
- apps/tmp/calendar.sqlite3
|
27
|
-
- apps/tmp/calendar.sqlite3-shm
|
28
|
-
- apps/tmp/calendar.sqlite3-wal
|
29
|
-
- apps/tmp/local_secret.txt
|
30
|
-
- apps/tmp/pagy-keyset.sqlite3
|
31
|
-
- apps/tmp/pagy-keyset.sqlite3-shm
|
32
|
-
- apps/tmp/pagy-keyset.sqlite3-wal
|
33
28
|
- bin/pagy
|
34
29
|
- config/pagy.rb
|
35
|
-
- javascripts/pagy-module.js
|
36
30
|
- javascripts/pagy.d.ts
|
37
|
-
- javascripts/pagy.js
|
38
31
|
- javascripts/pagy.min.js
|
39
32
|
- javascripts/pagy.min.js.map
|
40
33
|
- javascripts/pagy.mjs
|
41
34
|
- lib/optimist.rb
|
42
35
|
- lib/pagy.rb
|
36
|
+
- lib/pagy/b64.rb
|
43
37
|
- lib/pagy/backend.rb
|
44
38
|
- lib/pagy/calendar.rb
|
45
39
|
- lib/pagy/calendar/day.rb
|
@@ -58,26 +52,27 @@ files:
|
|
58
52
|
- lib/pagy/extras/calendar.rb
|
59
53
|
- lib/pagy/extras/countless.rb
|
60
54
|
- lib/pagy/extras/elasticsearch_rails.rb
|
61
|
-
- lib/pagy/extras/foundation.rb
|
62
55
|
- lib/pagy/extras/gearbox.rb
|
63
56
|
- lib/pagy/extras/headers.rb
|
64
57
|
- lib/pagy/extras/i18n.rb
|
65
|
-
- lib/pagy/extras/items.rb
|
66
58
|
- lib/pagy/extras/js_tools.rb
|
67
59
|
- lib/pagy/extras/jsonapi.rb
|
68
|
-
- lib/pagy/extras/
|
60
|
+
- lib/pagy/extras/keyset.rb
|
61
|
+
- lib/pagy/extras/limit.rb
|
69
62
|
- lib/pagy/extras/meilisearch.rb
|
70
63
|
- lib/pagy/extras/metadata.rb
|
71
64
|
- lib/pagy/extras/overflow.rb
|
72
65
|
- lib/pagy/extras/pagy.rb
|
73
66
|
- lib/pagy/extras/searchkick.rb
|
74
|
-
- lib/pagy/extras/semantic.rb
|
75
67
|
- lib/pagy/extras/size.rb
|
76
68
|
- lib/pagy/extras/standalone.rb
|
77
69
|
- lib/pagy/extras/trim.rb
|
78
|
-
- lib/pagy/extras/uikit.rb
|
79
70
|
- lib/pagy/frontend.rb
|
80
71
|
- lib/pagy/i18n.rb
|
72
|
+
- lib/pagy/keyset.rb
|
73
|
+
- lib/pagy/keyset/active_record.rb
|
74
|
+
- lib/pagy/keyset/sequel.rb
|
75
|
+
- lib/pagy/shared_methods.rb
|
81
76
|
- lib/pagy/url_helpers.rb
|
82
77
|
- locales/ar.yml
|
83
78
|
- locales/be.yml
|
@@ -88,6 +83,7 @@ files:
|
|
88
83
|
- locales/cs.yml
|
89
84
|
- locales/da.yml
|
90
85
|
- locales/de.yml
|
86
|
+
- locales/dz.yml
|
91
87
|
- locales/en.yml
|
92
88
|
- locales/es.yml
|
93
89
|
- locales/fr.yml
|
@@ -128,14 +124,6 @@ metadata:
|
|
128
124
|
bug_tracker_uri: https://github.com/ddnexus/pagy/issues
|
129
125
|
changelog_uri: https://github.com/ddnexus/pagy/blob/master/CHANGELOG.md
|
130
126
|
support: https://github.com/ddnexus/pagy/discussions/categories/q-a
|
131
|
-
post_install_message: |
|
132
|
-
*********************** PAGY WARNING! ***********************
|
133
|
-
The foundation, materialize, semantic and uikit CSS extras
|
134
|
-
have been discontinued and will be removed in v9
|
135
|
-
https://github.com/ddnexus/pagy/discussions/672
|
136
|
-
The javascript files have been deprecated/renamed
|
137
|
-
https://ddnexus.github.io/pagy/changelog/#deprecations
|
138
|
-
*************************************************************
|
139
127
|
rdoc_options: []
|
140
128
|
require_paths:
|
141
129
|
- lib
|
@@ -150,8 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
138
|
- !ruby/object:Gem::Version
|
151
139
|
version: '0'
|
152
140
|
requirements: []
|
153
|
-
rubygems_version: 3.
|
154
|
-
signing_key:
|
141
|
+
rubygems_version: 3.6.2
|
155
142
|
specification_version: 4
|
156
143
|
summary: The best pagination ruby gem
|
157
144
|
test_files: []
|
data/apps/tmp/calendar.sqlite3
DELETED
Binary file
|
Binary file
|
File without changes
|
data/apps/tmp/local_secret.txt
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
4c57eebd7544c7f0acc9943ab614ab3da71d2461f5581ed8d41e9b8aa1bf23bff831f82e934eed96c608da0feac2c3dd21383c269d896cf01fcd6fa81aca2462
|
Binary file
|
Binary file
|
Binary file
|
data/javascripts/pagy-module.js
DELETED
@@ -1,100 +0,0 @@
|
|
1
|
-
const Pagy = (() => {
|
2
|
-
const rjsObserver = new ResizeObserver((entries) => entries.forEach((e) => e.target.querySelectorAll(".pagy-rjs").forEach((el) => el.pagyRender())));
|
3
|
-
const initNav = (el, [tokens, sequels, labelSequels, trimParam]) => {
|
4
|
-
const container = el.parentElement ?? el;
|
5
|
-
const widths = Object.keys(sequels).map((w) => parseInt(w)).sort((a, b) => b - a);
|
6
|
-
let lastWidth = -1;
|
7
|
-
const fillIn = (a, page, label) => a.replace(/__pagy_page__/g, page).replace(/__pagy_label__/g, label);
|
8
|
-
(el.pagyRender = function() {
|
9
|
-
const width = widths.find((w) => w < container.clientWidth) || 0;
|
10
|
-
if (width === lastWidth) {
|
11
|
-
return;
|
12
|
-
}
|
13
|
-
let html = tokens.before;
|
14
|
-
const series = sequels[width.toString()];
|
15
|
-
const labels = labelSequels?.[width.toString()] ?? series.map((l) => l.toString());
|
16
|
-
series.forEach((item, i) => {
|
17
|
-
const label = labels[i];
|
18
|
-
let filled;
|
19
|
-
if (typeof item === "number") {
|
20
|
-
filled = fillIn(tokens.a, item.toString(), label);
|
21
|
-
} else if (item === "gap") {
|
22
|
-
filled = tokens.gap;
|
23
|
-
} else {
|
24
|
-
filled = fillIn(tokens.current, item, label);
|
25
|
-
}
|
26
|
-
html += typeof trimParam === "string" && item == 1 ? trim(filled, trimParam) : filled;
|
27
|
-
});
|
28
|
-
html += tokens.after;
|
29
|
-
el.innerHTML = "";
|
30
|
-
el.insertAdjacentHTML("afterbegin", html);
|
31
|
-
lastWidth = width;
|
32
|
-
})();
|
33
|
-
if (el.classList.contains("pagy-rjs")) {
|
34
|
-
rjsObserver.observe(container);
|
35
|
-
}
|
36
|
-
};
|
37
|
-
const initCombo = (el, [url_token, trimParam]) => initInput(el, (inputValue) => [inputValue, url_token.replace(/__pagy_page__/, inputValue)], trimParam);
|
38
|
-
const initSelector = (el, [from, url_token, trimParam]) => {
|
39
|
-
initInput(el, (inputValue) => {
|
40
|
-
const page = Math.max(Math.ceil(from / parseInt(inputValue)), 1).toString();
|
41
|
-
const url = url_token.replace(/__pagy_page__/, page).replace(/__pagy_items__/, inputValue);
|
42
|
-
return [page, url];
|
43
|
-
}, trimParam);
|
44
|
-
};
|
45
|
-
const initInput = (el, getVars, trimParam) => {
|
46
|
-
const input = el.querySelector("input");
|
47
|
-
const link = el.querySelector("a");
|
48
|
-
const initial = input.value;
|
49
|
-
const action = function() {
|
50
|
-
if (input.value === initial) {
|
51
|
-
return;
|
52
|
-
}
|
53
|
-
const [min, val, max] = [input.min, input.value, input.max].map((n) => parseInt(n) || 0);
|
54
|
-
if (val < min || val > max) {
|
55
|
-
input.value = initial;
|
56
|
-
input.select();
|
57
|
-
return;
|
58
|
-
}
|
59
|
-
let [page, url] = getVars(input.value);
|
60
|
-
if (typeof trimParam === "string" && page === "1") {
|
61
|
-
url = trim(url, trimParam);
|
62
|
-
}
|
63
|
-
link.href = url;
|
64
|
-
link.click();
|
65
|
-
};
|
66
|
-
["change", "focus"].forEach((e) => input.addEventListener(e, () => input.select()));
|
67
|
-
input.addEventListener("focusout", action);
|
68
|
-
input.addEventListener("keypress", (e) => {
|
69
|
-
if (e.key === "Enter") {
|
70
|
-
action();
|
71
|
-
}
|
72
|
-
});
|
73
|
-
};
|
74
|
-
const trim = (a, param) => a.replace(new RegExp(`[?&]${param}=1\\b(?!&)|\\b${param}=1&`), "");
|
75
|
-
return {
|
76
|
-
version: "8.6.3",
|
77
|
-
init(arg) {
|
78
|
-
const target = arg instanceof Element ? arg : document;
|
79
|
-
const elements = target.querySelectorAll("[data-pagy]");
|
80
|
-
for (const el of elements) {
|
81
|
-
try {
|
82
|
-
const uint8array = Uint8Array.from(atob(el.getAttribute("data-pagy")), (c) => c.charCodeAt(0));
|
83
|
-
const [keyword, ...args] = JSON.parse(new TextDecoder().decode(uint8array));
|
84
|
-
if (keyword === "nav") {
|
85
|
-
initNav(el, args);
|
86
|
-
} else if (keyword === "combo") {
|
87
|
-
initCombo(el, args);
|
88
|
-
} else if (keyword === "selector") {
|
89
|
-
initSelector(el, args);
|
90
|
-
} else {
|
91
|
-
console.warn("Skipped Pagy.init() for: %o\nUnknown keyword '%s'", el, keyword);
|
92
|
-
}
|
93
|
-
} catch (err) {
|
94
|
-
console.warn("Skipped Pagy.init() for: %o\n%s", el, err);
|
95
|
-
}
|
96
|
-
}
|
97
|
-
}
|
98
|
-
};
|
99
|
-
})();
|
100
|
-
export default Pagy;
|
data/javascripts/pagy.js
DELETED
@@ -1,4 +0,0 @@
|
|
1
|
-
window.Pagy=(()=>{const j=new ResizeObserver((B)=>B.forEach((D)=>D.target.querySelectorAll(".pagy-rjs").forEach((E)=>E.pagyRender()))),x=(B,[D,E,z,G])=>{const F=B.parentElement??B,K=Object.keys(E).map((H)=>parseInt(H)).sort((H,M)=>M-H);let L=-1;const T=(H,M,R)=>H.replace(/__pagy_page__/g,M).replace(/__pagy_label__/g,R);if((B.pagyRender=function(){const H=K.find((Q)=>Q<F.clientWidth)||0;if(H===L)return;let M=D.before;const R=E[H.toString()],X=z?.[H.toString()]??R.map((Q)=>Q.toString());R.forEach((Q,J)=>{const $=X[J];let U;if(typeof Q==="number")U=T(D.a,Q.toString(),$);else if(Q==="gap")U=D.gap;else U=T(D.current,Q,$);M+=typeof G==="string"&&Q==1?Z(U,G):U}),M+=D.after,B.innerHTML="",B.insertAdjacentHTML("afterbegin",M),L=H})(),B.classList.contains("pagy-rjs"))j.observe(F)},A=(B,[D,E])=>Y(B,(z)=>[z,D.replace(/__pagy_page__/,z)],E),C=(B,[D,E,z])=>{Y(B,(G)=>{const F=Math.max(Math.ceil(D/parseInt(G)),1).toString(),K=E.replace(/__pagy_page__/,F).replace(/__pagy_items__/,G);return[F,K]},z)},Y=(B,D,E)=>{const z=B.querySelector("input"),G=B.querySelector("a"),F=z.value,K=function(){if(z.value===F)return;const[L,T,H]=[z.min,z.value,z.max].map((X)=>parseInt(X)||0);if(T<L||T>H){z.value=F,z.select();return}let[M,R]=D(z.value);if(typeof E==="string"&&M==="1")R=Z(R,E);G.href=R,G.click()};["change","focus"].forEach((L)=>z.addEventListener(L,()=>z.select())),z.addEventListener("focusout",K),z.addEventListener("keypress",(L)=>{if(L.key==="Enter")K()})},Z=(B,D)=>B.replace(new RegExp(`[?&]${D}=1\\b(?!&)|\\b${D}=1&`),"");return{version:"8.6.3",init(B){const E=(B instanceof Element?B:document).querySelectorAll("[data-pagy]");for(let z of E)try{const G=Uint8Array.from(atob(z.getAttribute("data-pagy")),(L)=>L.charCodeAt(0)),[F,...K]=JSON.parse((new TextDecoder()).decode(G));if(F==="nav")x(z,K);else if(F==="combo")A(z,K);else if(F==="selector")C(z,K);else console.warn("Skipped Pagy.init() for: %o\nUnknown keyword '%s'",z,F)}catch(G){console.warn("Skipped Pagy.init() for: %o\n%s",z,G)}}}})();
|
2
|
-
|
3
|
-
//# debugId=B9DC02765C7A5B6764756E2164756E21
|
4
|
-
//# sourceMappingURL=pagy.min.js.map
|
@@ -1,95 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
warn '[PAGY WARNING] The foundation 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 FoundationExtra
|
12
|
-
# Pagination for Foundation: it returns the html with the series of links to the pages
|
13
|
-
def pagy_foundation_nav(pagy, id: nil, aria_label: nil, **vars)
|
14
|
-
id = %( id="#{id}") if id
|
15
|
-
a = pagy_anchor(pagy)
|
16
|
-
|
17
|
-
html = +%(<nav#{id} class="pagy-foundation-nav" #{
|
18
|
-
nav_aria_label(pagy, aria_label:)}><ul class="pagination"> #{
|
19
|
-
foundation_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="current" role="link" aria-current="page" aria-disabled="true">#{pagy.label_for(item)}</li>)
|
26
|
-
when :gap
|
27
|
-
%(<li class="ellipsis gap"></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 << %(#{foundation_next_html(pagy, a)}</ul></nav>)
|
33
|
-
end
|
34
|
-
|
35
|
-
# Javascript pagination for foundation: it returns a nav with a data-pagy attribute used by the pagy.js file
|
36
|
-
def pagy_foundation_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
|
-
tokens = { 'before' => %(<ul class="pagination">#{foundation_prev_html pagy, a}),
|
41
|
-
'a' => %(<li>#{a.(PAGE_TOKEN, LABEL_TOKEN)}</li>),
|
42
|
-
'current' => %(<li class="current" role="link" aria-current="page" aria-disabled="true">#{LABEL_TOKEN}</li>),
|
43
|
-
'gap' => %(<li class="ellipsis gap"></li>),
|
44
|
-
'after' => %(#{foundation_next_html pagy, a}</ul>) }
|
45
|
-
|
46
|
-
%(<nav#{id} class="#{'pagy-rjs ' if sequels.size > 1}pagy-foundation-nav-js" #{
|
47
|
-
nav_aria_label(pagy, aria_label:)} #{
|
48
|
-
pagy_data(pagy, :nav, tokens, sequels, pagy.label_sequels(sequels))
|
49
|
-
}></nav>)
|
50
|
-
end
|
51
|
-
|
52
|
-
# Javascript combo pagination for Foundation: it returns a nav with a data-pagy attribute used by the pagy.js file
|
53
|
-
def pagy_foundation_combo_nav_js(pagy, id: nil, aria_label: nil)
|
54
|
-
id = %( id="#{id}") if id
|
55
|
-
a = pagy_anchor(pagy)
|
56
|
-
pages = pagy.pages
|
57
|
-
|
58
|
-
page_input = %(<input name="page" type="number" min="1" max="#{pages}" value="#{pagy.page}" aria-current="page" ) <<
|
59
|
-
%(style="text-align: center; width: #{pages.to_s.length + 1}rem; ) <<
|
60
|
-
%(height: 1.5rem; padding: .5rem; margin: 0 .4rem; font-size: .875rem;" class="current">#{JSTools::A_TAG})
|
61
|
-
|
62
|
-
%(<nav#{id} class="pagy-foundation-combo-nav-js" #{
|
63
|
-
nav_aria_label(pagy, aria_label:)} #{
|
64
|
-
pagy_data(pagy, :combo, pagy_url_for(pagy, PAGE_TOKEN))
|
65
|
-
}><ul class="pagination">#{
|
66
|
-
foundation_prev_html(pagy, a)
|
67
|
-
}<li style="padding: 0 .3rem"><label style="display: flex; align-items: center; white-space: nowrap">#{
|
68
|
-
pagy_t('pagy.combo_nav_js', page_input:, pages:)
|
69
|
-
}</label></li>#{
|
70
|
-
foundation_next_html(pagy, a)
|
71
|
-
}</ul></nav>)
|
72
|
-
end
|
73
|
-
|
74
|
-
private
|
75
|
-
|
76
|
-
def foundation_prev_html(pagy, a)
|
77
|
-
if (p_prev = pagy.prev)
|
78
|
-
%(<li class="prev">#{a.(p_prev, pagy_t('pagy.prev'), aria_label: pagy_t('pagy.aria_label.prev'))}</li>)
|
79
|
-
else
|
80
|
-
%(<li class="prev disabled" role="link" aria-disabled="true" aria-label="#{
|
81
|
-
pagy_t('pagy.aria_label.prev')}">#{pagy_t('pagy.prev')}</li>)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def foundation_next_html(pagy, a)
|
86
|
-
if (p_next = pagy.next)
|
87
|
-
%(<li class="next">#{a.(p_next, pagy_t('pagy.next'), aria_label: pagy_t('pagy.aria_label.next'))}</li>)
|
88
|
-
else
|
89
|
-
%(<li class="next disabled" role="link" aria-disabled="true" aria-label="#{
|
90
|
-
pagy_t('pagy.aria_label.next')}">#{pagy_t('pagy.next')}</li>)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
Frontend.prepend FoundationExtra
|
95
|
-
end
|
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
|