pagy 5.8.1 → 5.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ee42bed221d693df78831673e1e0a33c8c0b76ceb826dc1fa022d12a44abfbc
4
- data.tar.gz: 5e463d023be1d4fe1613f76b62c3ff3c8cd64da78ac4cc29e51f753c3af0158c
3
+ metadata.gz: ce99a8aef217f835c9063fb4c31bf673671acabd7ae4abc95e32d83d58285702
4
+ data.tar.gz: dc949a684d9624041a46bdc66bf71ff99b4f437d1ff95cb1f4b2b816e7a6ae40
5
5
  SHA512:
6
- metadata.gz: aff49444a6679426a05027e0199913df1da99a636df662a65315852bf2e459d054312635af733a1700fb7408b4e80b9418ff6cf5b33b9308d6bcd86a228c099e
7
- data.tar.gz: db463d5e40da9fbe04b79bc26414f0542b20e824018d17dfdcaac767d41f1d6f748b08035abfaf0336d8468073d2e49f8cc4982c0d5b3f184087eb6fb072f568
6
+ metadata.gz: 9798dae0a11c47078a1c8dbb972a8c1cdc5859616f7d321de17c3150d06e54515b8a3e81d1df112a54cbcdae6fcec572897a46dec6d33a8199d03e561f1395c7
7
+ data.tar.gz: e09224376c5150f8a0f27d1fb7cdd956ef7e81f1cf73d5e923192c106cf43b28d4da64802cbae93b364890018d1e12f45428565cdf152e481a5b48d378772a74
data/lib/config/pagy.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Pagy initializer file (5.8.1)
3
+ # Pagy initializer file (5.9.0)
4
4
  # Customize only what you really need and notice that the core Pagy works also without any of the following lines.
5
5
  # Should you just cherry pick part of this file, please maintain the require-order of the extras
6
6
 
@@ -55,7 +55,6 @@
55
55
  #
56
56
  # Pagy::Calendar::Week::DEFAULT[:order] = :asc # Time direction of pagination
57
57
  # Pagy::Calendar::Week::DEFAULT[:format] = '%Y-%W' # strftime format
58
- # Pagy::Calendar::Week::DEFAULT[:offset] = 0 # Day offset from Sunday (0: Sunday; 1: Monday;... 6: Saturday)
59
58
  #
60
59
  # Pagy::Calendar::Day::DEFAULT[:order] = :asc # Time direction of pagination
61
60
  # Pagy::Calendar::Day::DEFAULT[:format] = '%Y-%m-%d' # strftime format
@@ -1,34 +1,9 @@
1
1
  "use strict";
2
- const Pagy = {
3
- version: "5.8.1",
4
- // Scan for elements with a "data-pagy" attribute and call their init functions with the decoded args
5
- init(arg) {
6
- const target = arg instanceof Element ? arg : document;
7
- const elements = target.querySelectorAll("[data-pagy]");
8
- for (const el of elements) {
9
- try {
10
- const uint8array = Uint8Array.from(atob(el.getAttribute("data-pagy")), c => c.charCodeAt(0));
11
- const [keyword, ...args] = JSON.parse(new TextDecoder().decode(uint8array)); // base64-utf8 JSON -> Array
12
- if (keyword === "nav") {
13
- Pagy.initNav(el, args);
14
- }
15
- else if (keyword === "combo") {
16
- Pagy.initCombo(el, args);
17
- }
18
- else if (keyword === "selector") {
19
- Pagy.initSelector(el, args);
20
- }
21
- else {
22
- console.warn("Skipped Pagy.init() for: %o\nUnknown keyword '%s'", el, keyword);
23
- }
24
- }
25
- catch (err) {
26
- console.warn("Skipped Pagy.init() for: %o\n%s", el, err);
27
- }
28
- }
29
- },
2
+ const Pagy = (() => {
3
+ // The observer instance for responsive navs
4
+ const rjsObserver = new ResizeObserver(entries => entries.forEach(e => e.target.querySelectorAll(".pagy-rjs").forEach(el => el.pagyRender())));
30
5
  // Init the *_nav_js helpers
31
- initNav(el, [tags, sequels, labelSequels, trimParam]) {
6
+ const initNav = (el, [tags, sequels, labelSequels, trimParam]) => {
32
7
  const container = el.parentElement ?? el;
33
8
  const widths = Object.keys(sequels).map(w => parseInt(w)).sort((a, b) => b - a);
34
9
  let lastWidth = -1;
@@ -45,7 +20,7 @@ const Pagy = {
45
20
  const item = series[i];
46
21
  const label = labels[i];
47
22
  if (typeof trimParam === "string" && item === 1) {
48
- html += Pagy.trim(fillIn(tags.link, item.toString(), label), trimParam);
23
+ html += trim(fillIn(tags.link, item.toString(), label), trimParam);
49
24
  }
50
25
  else if (typeof item === "number") {
51
26
  html += fillIn(tags.link, item.toString(), label);
@@ -63,27 +38,21 @@ const Pagy = {
63
38
  lastWidth = width;
64
39
  })();
65
40
  if (el.classList.contains("pagy-rjs")) {
66
- Pagy.rjsObserver.observe(container);
41
+ rjsObserver.observe(container);
67
42
  }
68
- },
69
- // The observer instance for responsive navs
70
- rjsObserver: new ResizeObserver(entries => {
71
- entries.forEach(e => e.target.querySelectorAll(".pagy-rjs").forEach(el => el.pagyRender()));
72
- }),
43
+ };
73
44
  // Init the *_combo_nav_js helpers
74
- initCombo(el, [link, trimParam]) {
75
- Pagy.initInput(el, inputValue => [inputValue, link.replace(/__pagy_page__/, inputValue)], trimParam);
76
- },
45
+ const initCombo = (el, [link, trimParam]) => initInput(el, inputValue => [inputValue, link.replace(/__pagy_page__/, inputValue)], trimParam);
77
46
  // Init the items_selector_js helper
78
- initSelector(el, [from, link, trimParam]) {
79
- Pagy.initInput(el, inputValue => {
47
+ const initSelector = (el, [from, link, trimParam]) => {
48
+ initInput(el, inputValue => {
80
49
  const page = Math.max(Math.ceil(from / parseInt(inputValue)), 1).toString();
81
50
  const html = link.replace(/__pagy_page__/, page).replace(/__pagy_items__/, inputValue);
82
51
  return [page, html];
83
52
  }, trimParam);
84
- },
53
+ };
85
54
  // Init the input element
86
- initInput(el, getVars, trimParam) {
55
+ const initInput = (el, getVars, trimParam) => {
87
56
  const input = el.querySelector("input");
88
57
  const initial = input.value;
89
58
  const action = function () {
@@ -98,7 +67,7 @@ const Pagy = {
98
67
  }
99
68
  let [page, html] = getVars(input.value); // eslint-disable-line prefer-const
100
69
  if (typeof trimParam === "string" && page === "1") {
101
- html = Pagy.trim(html, trimParam);
70
+ html = trim(html, trimParam);
102
71
  }
103
72
  el.insertAdjacentHTML("afterbegin", html);
104
73
  el.querySelector("a").click();
@@ -108,8 +77,38 @@ const Pagy = {
108
77
  input.addEventListener("keypress", e => { if (e.key === "Enter") {
109
78
  action();
110
79
  } }); // trigger action
111
- },
80
+ };
112
81
  // Trim the ${page-param}=1 params in links
113
- trim: (link, param) => link.replace(new RegExp(`[?&]${param}=1\\b(?!&)|\\b${param}=1&`), "")
114
- };
115
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGFneS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInBhZ3kudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQWNBLE1BQU0sSUFBSSxHQUFHO0lBQ1QsT0FBTyxFQUFFLE9BQU87SUFFaEIscUdBQXFHO0lBQ3JHLElBQUksQ0FBQyxHQUFrQjtRQUNuQixNQUFNLE1BQU0sR0FBSyxHQUFHLFlBQVksT0FBTyxDQUFDLENBQUMsQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLFFBQVEsQ0FBQztRQUN6RCxNQUFNLFFBQVEsR0FBRyxNQUFNLENBQUMsZ0JBQWdCLENBQUMsYUFBYSxDQUFDLENBQUM7UUFDeEQsS0FBSyxNQUFNLEVBQUUsSUFBSSxRQUFRLEVBQUU7WUFDdkIsSUFBSTtnQkFDQSxNQUFNLFVBQVUsR0FBVyxVQUFVLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxFQUFFLENBQUMsWUFBWSxDQUFDLFdBQVcsQ0FBVyxDQUFDLEVBQUUsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxDQUFDLENBQUMsVUFBVSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7Z0JBQy9HLE1BQU0sQ0FBQyxPQUFPLEVBQUUsR0FBRyxJQUFJLENBQUMsR0FBRyxJQUFJLENBQUMsS0FBSyxDQUFDLElBQUksV0FBVyxFQUFFLENBQUMsTUFBTSxDQUFDLFVBQVUsQ0FBQyxDQUFDLENBQUMsQ0FBQyw0QkFBNEI7Z0JBQ3pHLElBQUksT0FBTyxLQUFLLEtBQUssRUFBRTtvQkFDbkIsSUFBSSxDQUFDLE9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XCIsIGVsLCBlcnIpIH1cbiAgICAgICAgfVxuICAgIH0sXG5cbiAgICAvLyBJbml0IHRoZSAqX25hdl9qcyBoZWxwZXJzXG4gICAgaW5pdE5hdihlbDpOYXZFbGVtZW50LCBbdGFncywgc2VxdWVscywgbGFiZWxTZXF1ZWxzLCB0cmltUGFyYW1dOk5hdkFyZ3MpIHtcbiAgICAgICAgY29uc3QgY29udGFpbmVyID0gZWwucGFyZW50RWxlbWVudCA/PyBlbDtcbiAgICAgICAgY29uc3Qgd2lkdGhzICAgID0gT2JqZWN0LmtleXMoc2VxdWVscykubWFwKHcgPT4gcGFyc2VJbnQodykpLnNvcnQoKGEsIGIpID0+IGIgLSBhKTtcbiAgICAgICAgbGV0IGxhc3RXaWR0aCAgID0gLTE7XG4gICAgICAgIGNvbnN0IGZpbGxJbiAgICA9IChsaW5rOnN0cmluZywgcGFnZTpzdHJpbmcsIGxhYmVsOnN0cmluZyk6c3RyaW5nID0+XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaW5rLnJlcGxhY2UoL19fcGFneV9wYWdlX18vZywgcGFnZSkucmVwbGFjZSgvX19wYWd5X2xhYmVsX18vZywgbGFiZWwpO1xuICAgICAgICAoZWwucGFneVJlbmRlciA9IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgY29uc3Qgd2lkdGggPSB3aWR0aHMuZmluZCh3ID0+IHcgPCBjb250YWluZXIuY2xpZW50V2lkdGgpIHx8IDA7XG4gICAgICAgICAgICBpZiAod2lkdGggPT09IGxhc3RXaWR0aCkgeyByZXR1cm4gfSAvLyBubyBjaGFuZ2U6IGFib3J0XG4gICAgICAgICAgICBsZXQgaHRtbCAgICAgPSB0YWdzLmJlZm9yZTtcbiAgICAgICAgICAgIGNvbnN0IHNlcmllcyA9IHNlcXVlbHNbd2lkdGgudG9TdHJpbmcoKV07XG4gICAgICAgICAgICBjb25zdCBsYWJlbHMgPSBsYWJlbFNlcXVlbHM/Llt3aWR0aC50b1N0cmluZygpXSA/PyBzZXJpZXMubWFwKGwgPT4gbC50b1N0cmluZygpKTtcbiAgICAgICAgICAgIGZvciAoY29uc3QgaSBpbiBzZXJpZXMpIHtcbiAgICAgICAgICAgICAgICBjb25zdCBpdGVtICA9IHNlcmllc1tpXTtcbiAgICAgICAgICAgICAgICBjb25zdCBsYWJlbCA9IGxhYmVsc1tpXTtcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHRyaW1QYXJhbSA9PT0gXCJzdHJpbmdcIiAmJiBpdGVtID09PSAxKSB7XG4gICAgICAgICAgICAgICAgICAgIGh0bWwgKz0gUGFneS50cmltKGZpbGxJbih0YWdzLmxpbmssIGl0ZW0udG9TdHJpbmcoKSwgbGFiZWwpLCB0cmltUGFyYW0pO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIGl0ZW0gPT09IFwibnVtYmVyXCIpIHtcbiAgICAgICAgICAgICAgICAgICAgaHRtbCArPSBmaWxsSW4odGFncy5saW5rLCBpdGVtLnRvU3RyaW5nKCksIGxhYmVsKTtcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGl0ZW0gPT09IFwiZ2FwXCIpIHtcbiAgICAgICAgICAgICAgICAgICAgaHRtbCArPSB0YWdzLmdhcDtcbiAgICAgICAgICAgICAgICB9IGVsc2UgeyAvLyBhY3RpdmUgcGFnZVxuICAgICAgICAgICAgICAgICAgICBodG1sICs9IGZpbGxJbih0YWdzLmFjdGl2ZSwgaXRlbSwgbGFiZWwpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGh0bWwgKz0gdGFncy5hZnRlcjsgICAvLyBlc2xpbnQtZGlzYWJsZS1saW5lIGFsaWduLWFzc2lnbm1lbnRzL2FsaWduLWFzc2lnbm1lbnRzXG4gICAgICAgICAgICBlbC5pbm5lckhUTUwgPSBcIlwiO1xuICAgICAgICAgICAgZWwuaW5zZXJ0QWRqYWNlbnRIVE1MKFwiYWZ0ZXJiZ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iKVxufTtcbiJdfQ==
82
+ const trim = (link, param) => link.replace(new RegExp(`[?&]${param}=1\\b(?!&)|\\b${param}=1&`), "");
83
+ // Public interface
84
+ return {
85
+ version: "5.9.0",
86
+ // Scan for elements with a "data-pagy" attribute and call their init functions with the decoded args
87
+ init(arg) {
88
+ const target = arg instanceof Element ? arg : document;
89
+ const elements = target.querySelectorAll("[data-pagy]");
90
+ for (const el of elements) {
91
+ try {
92
+ const uint8array = Uint8Array.from(atob(el.getAttribute("data-pagy")), c => c.charCodeAt(0));
93
+ const [keyword, ...args] = JSON.parse((new TextDecoder()).decode(uint8array)); // base64-utf8 -> JSON -> Array
94
+ if (keyword === "nav") {
95
+ initNav(el, args);
96
+ }
97
+ else if (keyword === "combo") {
98
+ initCombo(el, args);
99
+ }
100
+ else if (keyword === "selector") {
101
+ initSelector(el, args);
102
+ }
103
+ else {
104
+ console.warn("Skipped Pagy.init() for: %o\nUnknown keyword '%s'", el, keyword);
105
+ }
106
+ }
107
+ catch (err) {
108
+ console.warn("Skipped Pagy.init() for: %o\n%s", el, err);
109
+ }
110
+ }
111
+ }
112
+ };
113
+ })();
114
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGFneS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInBhZ3kudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQWNBLE1BQU0sSUFBSSxHQUFHLENBQUMsR0FBRyxFQUFFO0lBQ2YsNENBQTRDO0lBQzVDLE1BQU0sV0FBVyxHQUFHLElBQUksY0FBYyxDQUFDLE9BQU8sQ0FBQyxFQUFFLENBQzdDLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxDQUFDLENBQUMsTUFBTSxDQUFDLGdCQUFnQixDQUFhLFdBQVcsQ0FBQyxDQUFDLE9BQU8sQ0FBQyxFQUFFLENBQUMsRUFBRSxDQUFDLEVBQUUsQ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L19fcGFneV9sYWJlbF9fL2csIGxhYmVsKTtcbiAgICAgICAgKGVsLnBhZ3lSZW5kZXIgPSBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gd2lkdGhzLmZpbmQodyA9PiB3IDwgY29udGFpbmVyLmNsaWVudFdpZHRoKSB8fCAwO1xuICAgICAgICAgICAgaWYgKHdpZHRoID09PSBsYXN0V2lkdGgpIHsgcmV0dXJuIH0gLy8gbm8gY2hhbmdlOiBhYm9ydFxuICAgICAgICAgICAgbGV0IGh0bWwgICAgID0gdGFncy5iZWZvcmU7XG4gICAgICAgICAgICBjb25zdCBzZXJpZXMgPSBzZXF1ZWxzW3dpZHRoLnRvU3RyaW5nKCldO1xuICAgICAgICAgICAgY29uc3QgbGFiZWxzID0gbGFiZWxTZXF1ZWxzPy5bd2lkdGgudG9TdHJpbmcoKV0gPz8gc2VyaWVzLm1hcChsID0+IGwudG9TdHJpbmcoKSk7XG4gICAgICAgICAgICBmb3IgKGNvbnN0IGkgaW4gc2VyaWVzKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgaXRlbSAgPSBzZXJpZXNbaV07XG4gICAgICAgICAgICAgICAgY29uc3QgbGFiZWwgPSBsYWJlbHNbaV07XG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiB0cmltUGFyYW0gPT09IFwic3RyaW5nXCIgJiYgaXRlbSA9PT0gMSkge1xuICAgICAgICAgICAgICAgICAgICBodG1sICs9IHRyaW0oZmlsbEluKHRhZ3MubGluaywgaXRlbS50b1N0cmluZygpLCBsYWJlbCksIHRyaW1QYXJhbSk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgaXRlbSA9PT0gXCJudW1iZXJcIikge1xuICAgICAgICAgICAgICAgICAgICBodG1sICs9IGZpbGxJbih0YWdzLmxpbmssIGl0ZW0udG9TdHJpbmcoKSwgbGFiZWwpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaXRlbSA9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LT4gSlNPTiAtPiBBcnJheVxuICAgICAgICAgICAgICAgICAgICBpZiAoa2V5d29yZCA9PT0gXCJuYXZcIikge1xuICAgICAgICAgICAgICAgICAgICAgICAgaW5pdE5hdihlbCBhcyBOYXZFbGVtZW50LCBhcmdzIGFzIE5hdkFyZ3MpO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGtleXdvcmQgPT09IFwiY29tYm9cIikge1xuICAgICAgICAgICAgICAgICAgICAgICAgaW5pdENvbWJvKGVsLCBhcmdzIGFzIENvbWJvQXJncyk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoa2V5d29yZCA9PT0gXCJzZWxlY3RvclwiKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpbml0U2VsZWN0b3IoZWwsIGFyZ3MgYXMgU2VsZWN0b3JBcmdzKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUud2FybihcIlNraXBwZWQgUGFneS5pbml0KCkgZm9yOiAlb1xcblVua25vd24ga2V5d29yZCAnJXMnXCIsIGVsLCBrZXl3b3JkKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycikgeyBjb25zb2xlLndhcm4oXCJTa2lwcGVkIFBhZ3kuaW5pdCgpIGZvcjogJW9cXG4lc1wiLCBlbCwgZXJyKSB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xufSkoKTtcbiJdfQ==
@@ -1,30 +1,5 @@
1
- declare type NavArgs = readonly [Tags, Sequels, null | LabelSequels, string?];
2
- declare type ComboArgs = readonly [string, string?];
3
- declare type SelectorArgs = readonly [number, string, string?];
4
- interface Tags {
5
- readonly before: string;
6
- readonly link: string;
7
- readonly active: string;
8
- readonly gap: string;
9
- readonly after: string;
10
- }
11
- interface Sequels {
12
- readonly [width: string]: (string | number | "gap")[];
13
- }
14
- interface LabelSequels {
15
- readonly [width: string]: string[];
16
- }
17
- interface NavElement extends Element {
18
- pagyRender(): void;
19
- }
20
1
  declare const Pagy: {
21
2
  version: string;
22
3
  init(arg?: Element | never): void;
23
- initNav(el: NavElement, [tags, sequels, labelSequels, trimParam]: NavArgs): void;
24
- rjsObserver: ResizeObserver;
25
- initCombo(el: Element, [link, trimParam]: ComboArgs): void;
26
- initSelector(el: Element, [from, link, trimParam]: SelectorArgs): void;
27
- initInput(el: Element, getVars: (v: string) => [string, string], trimParam?: string): void;
28
- trim: (link: string, param: string) => string;
29
4
  };
30
5
  export default Pagy;
@@ -1,33 +1,8 @@
1
- const Pagy = {
2
- version: "5.8.1",
3
- // Scan for elements with a "data-pagy" attribute and call their init functions with the decoded args
4
- init(arg) {
5
- const target = arg instanceof Element ? arg : document;
6
- const elements = target.querySelectorAll("[data-pagy]");
7
- for (const el of elements) {
8
- try {
9
- const uint8array = Uint8Array.from(atob(el.getAttribute("data-pagy")), c => c.charCodeAt(0));
10
- const [keyword, ...args] = JSON.parse(new TextDecoder().decode(uint8array)); // base64-utf8 JSON -> Array
11
- if (keyword === "nav") {
12
- Pagy.initNav(el, args);
13
- }
14
- else if (keyword === "combo") {
15
- Pagy.initCombo(el, args);
16
- }
17
- else if (keyword === "selector") {
18
- Pagy.initSelector(el, args);
19
- }
20
- else {
21
- console.warn("Skipped Pagy.init() for: %o\nUnknown keyword '%s'", el, keyword);
22
- }
23
- }
24
- catch (err) {
25
- console.warn("Skipped Pagy.init() for: %o\n%s", el, err);
26
- }
27
- }
28
- },
1
+ const Pagy = (() => {
2
+ // The observer instance for responsive navs
3
+ const rjsObserver = new ResizeObserver(entries => entries.forEach(e => e.target.querySelectorAll(".pagy-rjs").forEach(el => el.pagyRender())));
29
4
  // Init the *_nav_js helpers
30
- initNav(el, [tags, sequels, labelSequels, trimParam]) {
5
+ const initNav = (el, [tags, sequels, labelSequels, trimParam]) => {
31
6
  const container = el.parentElement ?? el;
32
7
  const widths = Object.keys(sequels).map(w => parseInt(w)).sort((a, b) => b - a);
33
8
  let lastWidth = -1;
@@ -44,7 +19,7 @@ const Pagy = {
44
19
  const item = series[i];
45
20
  const label = labels[i];
46
21
  if (typeof trimParam === "string" && item === 1) {
47
- html += Pagy.trim(fillIn(tags.link, item.toString(), label), trimParam);
22
+ html += trim(fillIn(tags.link, item.toString(), label), trimParam);
48
23
  }
49
24
  else if (typeof item === "number") {
50
25
  html += fillIn(tags.link, item.toString(), label);
@@ -62,27 +37,21 @@ const Pagy = {
62
37
  lastWidth = width;
63
38
  })();
64
39
  if (el.classList.contains("pagy-rjs")) {
65
- Pagy.rjsObserver.observe(container);
40
+ rjsObserver.observe(container);
66
41
  }
67
- },
68
- // The observer instance for responsive navs
69
- rjsObserver: new ResizeObserver(entries => {
70
- entries.forEach(e => e.target.querySelectorAll(".pagy-rjs").forEach(el => el.pagyRender()));
71
- }),
42
+ };
72
43
  // Init the *_combo_nav_js helpers
73
- initCombo(el, [link, trimParam]) {
74
- Pagy.initInput(el, inputValue => [inputValue, link.replace(/__pagy_page__/, inputValue)], trimParam);
75
- },
44
+ const initCombo = (el, [link, trimParam]) => initInput(el, inputValue => [inputValue, link.replace(/__pagy_page__/, inputValue)], trimParam);
76
45
  // Init the items_selector_js helper
77
- initSelector(el, [from, link, trimParam]) {
78
- Pagy.initInput(el, inputValue => {
46
+ const initSelector = (el, [from, link, trimParam]) => {
47
+ initInput(el, inputValue => {
79
48
  const page = Math.max(Math.ceil(from / parseInt(inputValue)), 1).toString();
80
49
  const html = link.replace(/__pagy_page__/, page).replace(/__pagy_items__/, inputValue);
81
50
  return [page, html];
82
51
  }, trimParam);
83
- },
52
+ };
84
53
  // Init the input element
85
- initInput(el, getVars, trimParam) {
54
+ const initInput = (el, getVars, trimParam) => {
86
55
  const input = el.querySelector("input");
87
56
  const initial = input.value;
88
57
  const action = function () {
@@ -97,7 +66,7 @@ const Pagy = {
97
66
  }
98
67
  let [page, html] = getVars(input.value); // eslint-disable-line prefer-const
99
68
  if (typeof trimParam === "string" && page === "1") {
100
- html = Pagy.trim(html, trimParam);
69
+ html = trim(html, trimParam);
101
70
  }
102
71
  el.insertAdjacentHTML("afterbegin", html);
103
72
  el.querySelector("a").click();
@@ -107,8 +76,38 @@ const Pagy = {
107
76
  input.addEventListener("keypress", e => { if (e.key === "Enter") {
108
77
  action();
109
78
  } }); // trigger action
110
- },
79
+ };
111
80
  // Trim the ${page-param}=1 params in links
112
- trim: (link, param) => link.replace(new RegExp(`[?&]${param}=1\\b(?!&)|\\b${param}=1&`), "")
113
- };
81
+ const trim = (link, param) => link.replace(new RegExp(`[?&]${param}=1\\b(?!&)|\\b${param}=1&`), "");
82
+ // Public interface
83
+ return {
84
+ version: "5.9.0",
85
+ // Scan for elements with a "data-pagy" attribute and call their init functions with the decoded args
86
+ init(arg) {
87
+ const target = arg instanceof Element ? arg : document;
88
+ const elements = target.querySelectorAll("[data-pagy]");
89
+ for (const el of elements) {
90
+ try {
91
+ const uint8array = Uint8Array.from(atob(el.getAttribute("data-pagy")), c => c.charCodeAt(0));
92
+ const [keyword, ...args] = JSON.parse((new TextDecoder()).decode(uint8array)); // base64-utf8 -> JSON -> Array
93
+ if (keyword === "nav") {
94
+ initNav(el, args);
95
+ }
96
+ else if (keyword === "combo") {
97
+ initCombo(el, args);
98
+ }
99
+ else if (keyword === "selector") {
100
+ initSelector(el, args);
101
+ }
102
+ else {
103
+ console.warn("Skipped Pagy.init() for: %o\nUnknown keyword '%s'", el, keyword);
104
+ }
105
+ }
106
+ catch (err) {
107
+ console.warn("Skipped Pagy.init() for: %o\n%s", el, err);
108
+ }
109
+ }
110
+ }
111
+ };
112
+ })();
114
113
  export default Pagy;
@@ -1 +1 @@
1
- !function(){function n(n){if(Array.isArray(n))return n}function t(n){if(Symbol.iterator in Object(n)||"[object Arguments]"===Object.prototype.toString.call(n))return Array.from(n)}function e(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function r(r,i){return n(r)||t(r)||e()}var i={version:"5.8.1",init:function(r){var a,o=(r instanceof Element?r:document).querySelectorAll("[data-pagy]"),c=!0,u=!1,l=void 0;try{for(var f,p=o[Symbol.iterator]();!(c=(f=p.next()).done);c=!0){var s=f.value;try{var v=Uint8Array.from(atob(s.getAttribute("data-pagy")),(function(n){return n.charCodeAt(0)})),y=n(a=JSON.parse((new TextDecoder).decode(v)))||t(a)||e(),g=y[0],d=y.slice(1);"nav"===g?i.initNav(s,d):"combo"===g?i.initCombo(s,d):"selector"===g?i.initSelector(s,d):console.warn("Skipped Pagy.init() for: %o\nUnknown keyword '%s'",s,g)}catch(n){console.warn("Skipped Pagy.init() for: %o\n%s",s,n)}}}catch(n){u=!0,l=n}finally{try{c||null==p.return||p.return()}finally{if(u)throw l}}},initNav:function(n,t){var e,a=r(t),o=a[0],c=a[1],u=a[2],l=a[3],f=null!==(e=n.parentElement)&&void 0!==e?e:n,p=Object.keys(c).map((function(n){return parseInt(n)})).sort((function(n,t){return t-n})),s=-1,v=function(n,t,e){return n.replace(/__pagy_page__/g,t).replace(/__pagy_label__/g,e)};(n.pagyRender=function(){var t=p.find((function(n){return n<f.clientWidth}))||0;if(t!==s){var e,r=o.before,a=c[t.toString()],y=null!==(e=null==u?void 0:u[t.toString()])&&void 0!==e?e:a.map((function(n){return n.toString()}));for(var g in a){var d=a[g],_=y[g];r+="string"==typeof l&&1===d?i.trim(v(o.link,d.toString(),_),l):"number"==typeof d?v(o.link,d.toString(),_):"gap"===d?o.gap:v(o.active,d,_)}r+=o.after,n.innerHTML="",n.insertAdjacentHTML("afterbegin",r),s=t}})(),n.classList.contains("pagy-rjs")&&i.rjsObserver.observe(f)},rjsObserver:new ResizeObserver((function(n){n.forEach((function(n){return n.target.querySelectorAll(".pagy-rjs").forEach((function(n){return n.pagyRender()}))}))})),initCombo:function(n,t){var e=r(t),a=e[0],o=e[1];i.initInput(n,(function(n){return[n,a.replace(/__pagy_page__/,n)]}),o)},initSelector:function(n,t){var e=r(t),a=e[0],o=e[1],c=e[2];i.initInput(n,(function(n){var t=Math.max(Math.ceil(a/parseInt(n)),1).toString();return[t,o.replace(/__pagy_page__/,t).replace(/__pagy_items__/,n)]}),c)},initInput:function(n,t,e){var a=n.querySelector("input"),o=a.value,c=function(){if(a.value!==o){var c=r([a.min,a.value,a.max].map((function(n){return parseInt(n)||0}))),u=c[0],l=c[1],f=c[2];if(l<u||l>f)return a.value=o,void a.select();var p=r(t(a.value)),s=p[0],v=p[1];"string"==typeof e&&"1"===s&&(v=i.trim(v,e)),n.insertAdjacentHTML("afterbegin",v),n.querySelector("a").click()}};["change","focus"].forEach((function(n){return a.addEventListener(n,a.select)})),a.addEventListener("focusout",c),a.addEventListener("keypress",(function(n){"Enter"===n.key&&c()}))},trim:function(n,t){return n.replace(new RegExp("[?&]".concat(t,"=1\\b(?!&)|\\b").concat(t,"=1&")),"")}},a=i;window.Pagy=a}();
1
+ !function(){function n(n){if(Array.isArray(n))return n}function e(n){if(Symbol.iterator in Object(n)||"[object Arguments]"===Object.prototype.toString.call(n))return Array.from(n)}function t(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function r(r,a){return n(r)||e(r)||t()}var a,o,i,c,u,f,l=(a=new ResizeObserver((function(n){return n.forEach((function(n){return n.target.querySelectorAll(".pagy-rjs").forEach((function(n){return n.pagyRender()}))}))})),o=function(n,e){var t,o=r(e),i=o[0],c=o[1],u=o[2],l=o[3],p=null!==(t=n.parentElement)&&void 0!==t?t:n,s=Object.keys(c).map((function(n){return parseInt(n)})).sort((function(n,e){return e-n})),y=-1,g=function(n,e,t){return n.replace(/__pagy_page__/g,e).replace(/__pagy_label__/g,t)};(n.pagyRender=function(){var e=s.find((function(n){return n<p.clientWidth}))||0;if(e!==y){var t,r=i.before,a=c[e.toString()],o=null!==(t=null==u?void 0:u[e.toString()])&&void 0!==t?t:a.map((function(n){return n.toString()}));for(var v in a){var d=a[v],_=o[v];r+="string"==typeof l&&1===d?f(g(i.link,d.toString(),_),l):"number"==typeof d?g(i.link,d.toString(),_):"gap"===d?i.gap:g(i.active,d,_)}r+=i.after,n.innerHTML="",n.insertAdjacentHTML("afterbegin",r),y=e}})(),n.classList.contains("pagy-rjs")&&a.observe(p)},i=function(n,e){var t=r(e),a=t[0],o=t[1];return u(n,(function(n){return[n,a.replace(/__pagy_page__/,n)]}),o)},c=function(n,e){var t=r(e),a=t[0],o=t[1],i=t[2];u(n,(function(n){var e=Math.max(Math.ceil(a/parseInt(n)),1).toString();return[e,o.replace(/__pagy_page__/,e).replace(/__pagy_items__/,n)]}),i)},u=function(n,e,t){var a=n.querySelector("input"),o=a.value,i=function(){if(a.value!==o){var i=r([a.min,a.value,a.max].map((function(n){return parseInt(n)||0}))),c=i[0],u=i[1],l=i[2];if(u<c||u>l)return a.value=o,void a.select();var p=r(e(a.value)),s=p[0],y=p[1];"string"==typeof t&&"1"===s&&(y=f(y,t)),n.insertAdjacentHTML("afterbegin",y),n.querySelector("a").click()}};["change","focus"].forEach((function(n){return a.addEventListener(n,a.select)})),a.addEventListener("focusout",i),a.addEventListener("keypress",(function(n){"Enter"===n.key&&i()}))},f=function(n,e){return n.replace(new RegExp("[?&]".concat(e,"=1\\b(?!&)|\\b").concat(e,"=1&")),"")},{version:"5.9.0",init:function(r){var a,u=(r instanceof Element?r:document).querySelectorAll("[data-pagy]"),f=!0,l=!1,p=void 0;try{for(var s,y=u[Symbol.iterator]();!(f=(s=y.next()).done);f=!0){var g=s.value;try{var v=Uint8Array.from(atob(g.getAttribute("data-pagy")),(function(n){return n.charCodeAt(0)})),d=n(a=JSON.parse((new TextDecoder).decode(v)))||e(a)||t(),_=d[0],b=d.slice(1);"nav"===_?o(g,b):"combo"===_?i(g,b):"selector"===_?c(g,b):console.warn("Skipped Pagy.init() for: %o\nUnknown keyword '%s'",g,_)}catch(n){console.warn("Skipped Pagy.init() for: %o\n%s",g,n)}}}catch(n){l=!0,p=n}finally{try{f||null==y.return||y.return()}finally{if(l)throw p}}}});window.Pagy=l}();
@@ -13,16 +13,16 @@ class Pagy # :nodoc:
13
13
  # Setup the calendar variables
14
14
  def setup_unit_vars
15
15
  super
16
- @initial = new_time(@starting.year, @starting.month, @starting.day)
17
- @final = new_time(@ending.year, @ending.month, @ending.day) + DAY
18
- @pages = @last = (@final - @initial).to_i / DAY
16
+ @initial = @starting.beginning_of_day
17
+ @final = @ending.tomorrow.beginning_of_day
18
+ @pages = @last = (@with_zone ? (@final.time - @initial.time) : (@final - @initial)).to_i / 1.day
19
19
  @from = starting_time_for(@page)
20
- @to = @from + DAY
20
+ @to = @from.tomorrow
21
21
  end
22
22
 
23
23
  # Starting time for the page
24
24
  def starting_time_for(page)
25
- @initial + (offset_units_for(page) * DAY)
25
+ @initial + offset_units_for(page).days
26
26
  end
27
27
  end
28
28
  end
@@ -1,16 +1,36 @@
1
1
  # See Pagy::Countless API documentation: https://ddnexus.github.io/pagy/api/calendar
2
2
  # frozen_string_literal: true
3
3
 
4
- require_relative 'month_mixin'
5
-
6
4
  class Pagy # :nodoc:
7
5
  class Calendar # :nodoc:
8
6
  # Calendar month subclass
9
7
  class Month < Calendar
10
- DEFAULT = { order: :asc, # rubocop:disable Style/MutableConstant
8
+ DEFAULT = { order: :asc, # rubocop:disable Style/MutableConstant
11
9
  format: '%Y-%m' }
12
- MONTHS = 1 # number of months in the unit
13
- include MonthMixin
10
+
11
+ protected
12
+
13
+ # Setup the calendar variables
14
+ def setup_unit_vars
15
+ super
16
+ @initial = @starting.beginning_of_month
17
+ @final = @ending.next_month.beginning_of_month
18
+ @pages = @last = (months_in(@final) - months_in(@initial))
19
+ @from = starting_time_for(@page)
20
+ @to = @from.next_month
21
+ end
22
+
23
+ # Starting time for the page
24
+ def starting_time_for(page)
25
+ @initial + offset_units_for(page).months
26
+ end
27
+
28
+ private
29
+
30
+ # Number of months in time
31
+ def months_in(time)
32
+ (time.year * 12) + time.month
33
+ end
14
34
  end
15
35
  end
16
36
  end
@@ -1,23 +1,43 @@
1
1
  # See Pagy::Countless API documentation: https://ddnexus.github.io/pagy/api/calendar
2
2
  # frozen_string_literal: true
3
3
 
4
- require_relative 'month_mixin'
5
-
6
4
  class Pagy # :nodoc:
7
5
  class Calendar # :nodoc:
8
6
  # Calendar quarter subclass
9
7
  class Quarter < Calendar
10
8
  DEFAULT = { order: :asc, # rubocop:disable Style/MutableConstant
11
9
  format: '%Y-Q%q' } # '%q' token
12
- MONTHS = 3 # number of months of the unit
13
- include MonthMixin
14
10
 
15
11
  # The label for any page, with the substitution of the '%q' token
16
12
  def label_for(page, opts = {})
17
13
  starting_time = starting_time_for(page.to_i) # page could be a string
18
- opts[:format] = (opts[:format] || @vars[:format]).gsub('%q') { (starting_time.month / 4) + 1 }
14
+ opts[:format] = (opts[:format] || @vars[:format]).gsub('%q') { (starting_time.month / 3.0).ceil }
19
15
  localize(starting_time, opts)
20
16
  end
17
+
18
+ protected
19
+
20
+ # Setup the calendar variables
21
+ def setup_unit_vars
22
+ super
23
+ @initial = @starting.beginning_of_quarter
24
+ @final = @ending.next_quarter.beginning_of_quarter
25
+ @pages = @last = (months_in(@final) - months_in(@initial)) / 3
26
+ @from = starting_time_for(@page)
27
+ @to = @from.next_quarter
28
+ end
29
+
30
+ # Starting time for the page
31
+ def starting_time_for(page)
32
+ @initial + (offset_units_for(page) * 3).months
33
+ end
34
+
35
+ private
36
+
37
+ # Number of months in time
38
+ def months_in(time)
39
+ (time.year * 12) + time.month
40
+ end
21
41
  end
22
42
  end
23
43
  end
@@ -5,34 +5,29 @@ class Pagy # :nodoc:
5
5
  class Calendar # :nodoc:
6
6
  # Calendar week subclass
7
7
  class Week < Calendar
8
- DEFAULT = { order: :asc, # rubocop:disable Style/MutableConstant
9
- format: '%Y-%W',
10
- offset: 0 }
8
+ DEFAULT = { order: :asc, # rubocop:disable Style/MutableConstant
9
+ format: '%Y-%W' }
11
10
 
12
11
  protected
13
12
 
14
13
  # Setup the calendar variables
15
14
  def setup_unit_vars
16
- setup_vars(offset: 0)
17
15
  super
18
- @initial = unit_starting_time_for(@starting)
19
- @final = unit_starting_time_for(@ending) + WEEK
20
- @pages = @last = (@final - @initial).to_i / WEEK
16
+ if @vars[:offset] # remove in pagy 6
17
+ Warning.warn '[PAGY WARNING] The week :offset variable has been deprecated and will be ignored from pagy 6. ' \
18
+ "Set the Date.beginning_of_week variable to be one of #{::Date::DAYS_INTO_WEEK.keys.inspect} instead."
19
+ Date.beginning_of_week = ::Date::DAYS_INTO_WEEK.keys[@vars[:offset]]
20
+ end
21
+ @initial = @starting.beginning_of_week
22
+ @final = @ending.next_week.beginning_of_week
23
+ @pages = @last = (@with_zone ? (@final.time - @initial.time) : (@final - @initial)).to_i / 1.week
21
24
  @from = starting_time_for(@page)
22
- @to = @from + WEEK
25
+ @to = @from.next_week
23
26
  end
24
27
 
25
28
  # Starting time for the page
26
29
  def starting_time_for(page)
27
- @initial + (offset_units_for(page) * WEEK)
28
- end
29
-
30
- private
31
-
32
- # Unit starting time for time
33
- def unit_starting_time_for(time)
34
- starting_time = time - (((time.wday - @offset) * DAY) % WEEK)
35
- new_time(starting_time.year, starting_time.month, starting_time.day)
30
+ @initial + offset_units_for(page).weeks
36
31
  end
37
32
  end
38
33
  end
@@ -13,16 +13,16 @@ class Pagy # :nodoc:
13
13
  # Setup the calendar variables
14
14
  def setup_unit_vars
15
15
  super
16
- @initial = new_time(@starting.year)
17
- @final = new_time(@ending.year + 1)
16
+ @initial = @starting.beginning_of_year
17
+ @final = @ending.next_year.beginning_of_year
18
18
  @pages = @last = @final.year - @initial.year
19
19
  @from = starting_time_for(@page)
20
- @to = new_time(@from.year + 1)
20
+ @to = @from.next_year
21
21
  end
22
22
 
23
23
  # Starting time for the page
24
24
  def starting_time_for(page)
25
- new_time(@initial.year + offset_units_for(page))
25
+ @initial.years_since(offset_units_for(page))
26
26
  end
27
27
  end
28
28
  end
data/lib/pagy/calendar.rb CHANGED
@@ -1,6 +1,12 @@
1
1
  # See Pagy::Countless API documentation: https://ddnexus.github.io/pagy/api/calendar
2
2
  # frozen_string_literal: true
3
3
 
4
+ require 'active_support'
5
+ require 'active_support/core_ext/time'
6
+ require 'active_support/core_ext/date_and_time/calculations'
7
+ require 'active_support/core_ext/numeric/time'
8
+ require 'active_support/core_ext/integer/time'
9
+
4
10
  require 'pagy'
5
11
 
6
12
  class Pagy # :nodoc:
@@ -8,8 +14,6 @@ class Pagy # :nodoc:
8
14
  class Calendar < Pagy
9
15
  # List of units in desc order of duration. It can be used for custom units.
10
16
  UNITS = %i[year quarter month week day] # rubocop:disable Style/MutableConstant
11
- DAY = 60 * 60 * 24 # One day in seconds
12
- WEEK = DAY * 7 # One week in seconds
13
17
 
14
18
  attr_reader :order
15
19
 
@@ -49,8 +53,9 @@ class Pagy # :nodoc:
49
53
 
50
54
  @starting, @ending = @vars[:period]
51
55
  raise VariableError.new(self, :period, 'to be a an Array of min and max local Time instances', @vars[:period]) \
52
- unless @starting.is_a?(Time) && @ending.is_a?(Time) && !@starting.utc? && !@ending.utc? && @starting <= @ending \
53
- && (@utc_offset = @starting.utc_offset) == @ending.utc_offset
56
+ unless @starting.is_a?(Time) && @ending.is_a?(Time) && !@starting.utc? && !@ending.utc? && @starting <= @ending
57
+
58
+ @with_zone = @starting.is_a?(ActiveSupport::TimeWithZone) # remove in 6.0 and reu]place Time in the line above
54
59
  end
55
60
 
56
61
  # Apply the strftime format to the time (overridden by the i18n extra when localization is required)
@@ -64,11 +69,6 @@ class Pagy # :nodoc:
64
69
  @order == :asc ? page - 1 : @pages - page
65
70
  end
66
71
 
67
- # Create a new local time at the beginning of the day
68
- def new_time(year, month = 1, day = 1)
69
- Time.new(year, month, day, 0, 0, 0, @utc_offset)
70
- end
71
-
72
72
  # Period of the active page (used internally for nested units)
73
73
  def active_period
74
74
  [[@starting, @from].max, [@to - 1, @ending].min] # -1 sec: include only last unit day
@@ -11,8 +11,8 @@ class Pagy
11
11
  normalize_vars(vars)
12
12
  setup_vars(page: 1, outset: 0)
13
13
  setup_items_var
14
+ setup_offset_var
14
15
  setup_params_var
15
- @offset = (@items * (@page - 1)) + @outset
16
16
  end
17
17
 
18
18
  # Finalize the instance variables based on the fetched size
@@ -19,7 +19,7 @@ class Pagy # :nodoc:
19
19
  @items = gearbox_items[@page - 1] || gearbox_items.last
20
20
  end
21
21
 
22
- # Setup @pages and @last based on the :gearbox_items variable
22
+ # Setup @pages and @last based on the :gearbox_items variable (not used by Pagy::Countless)
23
23
  def setup_pages_var
24
24
  return super if !@vars[:gearbox_extra] || @vars[:items_extra]
25
25
 
@@ -37,6 +37,18 @@ class Pagy # :nodoc:
37
37
  [pages, 1].max
38
38
  end)
39
39
  end
40
+
41
+ # Setup @offset based on the :gearbox_items variable
42
+ def setup_offset_var
43
+ return super if !@vars[:gearbox_extra] || @vars[:items_extra]
44
+
45
+ gearbox_items = @vars[:gearbox_items]
46
+ @offset = if @page <= gearbox_items.count
47
+ gearbox_items[0, @page - 1].sum
48
+ else
49
+ gearbox_items.sum + (gearbox_items.last * (@page - gearbox_items.count - 1))
50
+ end + @outset
51
+ end
40
52
  end
41
53
  prepend GearboxExtra
42
54
  end
data/lib/pagy.rb CHANGED
@@ -5,7 +5,7 @@ require 'pathname'
5
5
 
6
6
  # Core class
7
7
  class Pagy
8
- VERSION = '5.8.1'
8
+ VERSION = '5.9.0'
9
9
 
10
10
  # Root pathname to get the path of Pagy files like templates or dictionaries
11
11
  def self.root
@@ -32,10 +32,10 @@ class Pagy
32
32
  setup_vars(count: 0, page: 1, outset: 0)
33
33
  setup_items_var
34
34
  setup_pages_var
35
+ setup_offset_var
35
36
  setup_params_var
36
37
  raise OverflowError.new(self, :page, "in 1..#{@last}", @page) if @page > @last
37
38
 
38
- @offset = (@items * (@page - 1)) + @outset
39
39
  @from = [@offset - @outset + 1, @count].min
40
40
  @to = [@offset - @outset + @items, @count].min
41
41
  @in = [@to - @from + 1, @count].min
@@ -96,17 +96,22 @@ class Pagy
96
96
  end
97
97
  end
98
98
 
99
- # Setup and validate the items (overridden by the gearbox extra)
99
+ # Setup @items (overridden by the gearbox extra)
100
100
  def setup_items_var
101
101
  setup_vars(items: 1)
102
102
  end
103
103
 
104
- # Setup and validates the pages (overridden by the gearbox extra)
104
+ # Setup @pages and @last (overridden by the gearbox extra)
105
105
  def setup_pages_var
106
106
  @pages = @last = [(@count.to_f / @items).ceil, 1].max
107
107
  end
108
108
 
109
- # Setup and validates the params
109
+ # Setup @offset based on the :gearbox_items variable
110
+ def setup_offset_var
111
+ @offset = (@items * (@page - 1)) + @outset # may be already set from gear_box
112
+ end
113
+
114
+ # Setup and validate @params
110
115
  def setup_params_var
111
116
  raise VariableError.new(self, :params, 'must be a Hash or a Proc', @params) \
112
117
  unless (@params = @vars[:params]).is_a?(Hash) || @params.is_a?(Proc)
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagy
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.8.1
4
+ version: 5.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Domizio Demichelis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-17 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2022-01-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  description: Agnostic pagination in plain ruby. It does it all. Better.
14
28
  email:
15
29
  - dd.nexus@gmail.com
@@ -60,7 +74,6 @@ files:
60
74
  - lib/pagy/calendar.rb
61
75
  - lib/pagy/calendar/day.rb
62
76
  - lib/pagy/calendar/month.rb
63
- - lib/pagy/calendar/month_mixin.rb
64
77
  - lib/pagy/calendar/quarter.rb
65
78
  - lib/pagy/calendar/week.rb
66
79
  - lib/pagy/calendar/year.rb
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Pagy
4
- class Calendar
5
- # Mixin for month based unit periods
6
- # It is used for month and quarter, but you could use it to implement less common unit of 6, 4, 2 months
7
- # (see the https://ddnexus.github.io/pagy/api/calendar#custom-units sections for details).
8
- # The including class must set the MONTHS duration for the unit and the usual DEFAULT.
9
- module MonthMixin
10
- protected
11
-
12
- # Setup the calendar variables
13
- def setup_unit_vars
14
- super
15
- @months = self.class::MONTHS # number of months in the unit
16
- @initial = unit_starting_time_for(@starting)
17
- @final = add_months_to(unit_starting_time_for(@ending), @months)
18
- @pages = @last = (months_in(@final) - months_in(@initial)) / @months
19
- @from = starting_time_for(@page)
20
- @to = add_months_to(@from, @months)
21
- end
22
-
23
- # Starting time for the page
24
- def starting_time_for(page)
25
- add_months_to(@initial, offset_units_for(page) * @months)
26
- end
27
-
28
- private
29
-
30
- # Unit starting time for time
31
- def unit_starting_time_for(time)
32
- # remove 1 month for 0-11 calculations and add it back for 1-12 conversion
33
- starting_month = (@months * ((time.month - 1) / @months)) + 1
34
- new_time(time.year, starting_month)
35
- end
36
-
37
- # Number of months in time
38
- def months_in(time)
39
- (time.year * 12) + time.month
40
- end
41
-
42
- # Add months to time
43
- def add_months_to(time, months)
44
- months += months_in(time) - 1 # remove 1 month for 0-11 calculations
45
- new_time(months / 12, (months % 12) + 1) # add 1 month back for 1-12 conversion
46
- end
47
- end
48
- end
49
- end