pagy 5.6.6 → 5.6.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 39e1594de6e9b2ca3919cf666e3b7735c96656447d78c39ce0a4aaf85a737487
4
- data.tar.gz: ec8e032be1fe73b5890c1fc42c05d81c397015b468120a8cd97dcdd2bf88fcfa
3
+ metadata.gz: 760d2f510c1c4c30364ab9074eb54f70ed3c70008b4d133200f0aad4b4568b31
4
+ data.tar.gz: 61ac693d82c769a7e1ba5ef797b360423de7e9298b7e29745bbbf31af251f15d
5
5
  SHA512:
6
- metadata.gz: 3df6ce4c03f578555b88c34691be3c667c1aaf2d4712382ebb1ddf905ad5f2f545987ce61270aa0a57705f1cfbe592ffbc649afb5c1137e8f69552388750e198
7
- data.tar.gz: c40c023541aaf714d0bfaa0fbaa4034edcb81d2d8b627a05f4e696d9eaa165f5f1aff7596497c9b4ccb9bf19773b65bb1aa79c7ba19765f3c993eab9e260e864
6
+ metadata.gz: 4f72984782585cb4b49cb6e0e136941069df5a49e430db2307502bcdf381980ba79347e16d23f556a7be9f8473bfa4e641352179fbc1fe9c467f47782ab9fdb4
7
+ data.tar.gz: b380f3900fc1727f6cac60d54d6918bfd1962cb758f89e5c4db10bcf719cfd5a0bec6e706661aed30f4cbdfdba021028f45cf3dfef2a851d61b8bd3aa21b5ccc
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2017-2021 Domizio Demichelis
3
+ Copyright (c) 2017-2022 Domizio Demichelis
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/lib/config/pagy.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Pagy initializer file (5.6.6)
3
+ # Pagy initializer file (5.6.10)
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
 
@@ -1,136 +1,3 @@
1
- // See the Pagy documentation: https://ddnexus.github.io/pagy/extras#javascript
1
+ "use strict";function _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_unsupportedIterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a))return _arrayLikeToArray(a)}function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function e(a){throw a},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function e(a){h=!0,f=a},f:function f(){try{g||null==c["return"]||c["return"]()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}var Pagy={version:"5.6.10",init:function init(a){var b,c=a instanceof HTMLElement?a:document,d=c.querySelectorAll("[data-pagy-json]"),e=_createForOfIteratorHelper(d);try{for(e.s();!(b=e.n()).done;){var f=b.value,g=f.getAttribute("data-pagy-json");try{var h=JSON.parse(g),i=h.shift();"nav"===i?Pagy.nav.apply(Pagy,[f].concat(_toConsumableArray(h))):"combo_nav"===i?Pagy.comboNav.apply(Pagy,[f].concat(_toConsumableArray(h))):"items_selector"===i&&Pagy.itemsSelector.apply(Pagy,[f].concat(_toConsumableArray(h)))}catch(a){console.warn("Pagy.init() skipped element: %o\n%s",f,a)}}}catch(a){e.e(a)}finally{e.f()}},nav:function nav(a,b,c,d,e){var f={};if(null===d)for(var k in c)f[k]=c[k].map(function(a){return a.toString()});else f=d;var g,h=Object.getOwnPropertyNames(c).map(function(a){return parseInt(a)}).sort(function(c,a){return a-c}),j=function(a,b,c){return a.replace(/__pagy_page__/g,b).replace(/__pagy_label__/g,c)};if(a.pagyRender=function(){var d=h.find(function(b){return null!==a.parentElement&&a.parentElement.clientWidth>b})||0;if(d!==g){var k=b.before,l=c[d.toString()],m=f[d.toString()];for(var p in l){var n=l[p],o=m[p];if("string"==typeof e&&1===n){var i=j(b.link,n.toString(),o);k+=Pagy.trim(i,e)}else k+="number"==typeof n?j(b.link,n.toString(),o):"gap"===n?b.gap:j(b.active,n,o)}k+=b.after,a.innerHTML="",a.insertAdjacentHTML("afterbegin",k),g=d}},a.pagyRender(),"undefined"!=typeof window){var l=0;window.addEventListener("resize",function(){clearTimeout(l),l=window.setTimeout(Pagy.renderNavs,100)},!0)}},renderNavs:function renderNavs(){var a=document.getElementsByClassName("pagy-njs");Array.from(a).forEach(function(a){return a.pagyRender()})},comboNav:function comboNav(a,b,c,d){var e=a.getElementsByTagName("input")[0];Pagy.addInputBehavior(e,function(){if(b!==e.value){var f=c.replace(/__pagy_page__/,e.value);"string"==typeof d&&"1"===e.value&&(f=Pagy.trim(f,d)),a.insertAdjacentHTML("afterbegin",f),a.getElementsByTagName("a")[0].click()}})},itemsSelector:function itemsSelector(a,b,c,d){var e=a.getElementsByTagName("input")[0],f=e.value;Pagy.addInputBehavior(e,function(){var g=Math.max,h=Math.ceil,i=e.value;if("0"!==i&&""!==i&&f!==i){var j=g(h(b/parseInt(i)),1).toString(),k=c.replace(/__pagy_page__/,j).replace(/__pagy_items__/,i);"string"==typeof d&&"1"===j&&(k=Pagy.trim(k,d)),a.insertAdjacentHTML("afterbegin",k),a.getElementsByTagName("a")[0].click()}})},addInputBehavior:function addInputBehavior(a,b){a.addEventListener("click",a.select),a.addEventListener("focusout",b),a.addEventListener("keypress",function(a){"Enter"===a.key&&b()})},trim:function trim(a,b){return a.replace(new RegExp("[?&]".concat(b,"=1\\b(?!&)|\\b").concat(b,"=1&")),"")}};
2
2
 
3
- // This code should be OK also with very old browsers
4
-
5
- // Container for the whole pagy stuff
6
- function Pagy(){}
7
-
8
- Pagy.version = '5.6.6'
9
-
10
- // Used by the waitForMe function
11
- Pagy.delay = 100
12
-
13
- // Scan the target for data-pagy-json elements and apply their functions
14
- Pagy.init =
15
- function(arg) {
16
- var target = arg instanceof Event || arg === undefined ? document : arg,
17
- elements = target.querySelectorAll('[data-pagy-json]')
18
- for (var i = 0, len = elements.length; i < len; i++) {
19
- var args = JSON.parse(elements[i].getAttribute('data-pagy-json')),
20
- fname = args.shift()
21
- args.unshift(elements[i])
22
- Pagy[fname].apply(null, args)
23
- }
24
- }
25
-
26
- // Power the pagy*_nav_js helpers
27
- Pagy.nav =
28
- function(pagyEl, tags, sequels, label_sequels, trimParam ) {
29
- label_sequels = (label_sequels === null) ? sequels : label_sequels
30
- var widths = [], lastWidth,
31
- fill = function(string, item, label) { return string.replace(/__pagy_page__/g, item)
32
- .replace(/__pagy_label__/g, label) }
33
- for (var width in sequels) {
34
- if (sequels.hasOwnProperty(width)) { widths.push(parseInt(width, 10)) }
35
- }
36
- widths.sort(function(a, b) { return b - a })
37
-
38
- pagyEl.render =
39
- function() {
40
- var width, i, len
41
- for (i = 0, len = widths.length; i < len; i++) {
42
- if (this.parentElement.clientWidth > widths[i]) { width = widths[i]; break }
43
- }
44
- if (width !== lastWidth) {
45
- var html = tags.before,
46
- series = sequels[width],
47
- labels = label_sequels[width]
48
- for (i = 0, len = series.length; i < len; i++) {
49
- var item = series[i],
50
- label = labels[i]
51
- if (typeof(trimParam) === 'string' && item === 1) { html += Pagy.trim(fill(tags.link, item, label), trimParam) }
52
- else if (typeof(item) === 'number') { html += fill(tags.link, item, label) }
53
- else if (item === 'gap') { html += tags.gap }
54
- else if (typeof(item) === 'string') { html += fill(tags.active, item, label) }
55
- }
56
- html += tags.after
57
- this.innerHTML = ''
58
- this.insertAdjacentHTML('afterbegin', html)
59
- lastWidth = width
60
- }
61
- }.bind(pagyEl)
62
- pagyEl.render()
63
- }
64
-
65
- // Power the pagy*_combo_nav_js helpers
66
- Pagy.combo_nav =
67
- function(pagyEl, page, link, trimParam) {
68
- var input = pagyEl.getElementsByTagName('input')[0],
69
- toPage =
70
- function() {
71
- if (page !== input.value) {
72
- var html = link.replace(/__pagy_page__/, input.value)
73
- if (typeof (trimParam) === 'string' && input.value === '1') { html = Pagy.trim(html, trimParam) }
74
- pagyEl.insertAdjacentHTML('afterbegin', html)
75
- pagyEl.getElementsByTagName('a')[0].click()
76
- }
77
- }
78
- Pagy.addInputEventListeners(input, toPage)
79
- }
80
-
81
- // Power the pagy_items_selector_js helper
82
- Pagy.items_selector =
83
- function(pagyEl, from, link, param) {
84
- var input = pagyEl.getElementsByTagName('input')[0],
85
- current = input.value,
86
- toPage =
87
- function() {
88
- var items = input.value
89
- if (items === 0 || items === '') { return }
90
- if (current !== items) {
91
- var page = Math.max(Math.ceil(from / items), 1),
92
- html = link.replace(/__pagy_page__/, page).replace(/__pagy_items__/, items)
93
- if (typeof (param) === 'string' && page === 1) { html = Pagy.trim(html, param) }
94
- pagyEl.insertAdjacentHTML('afterbegin', html)
95
- pagyEl.getElementsByTagName('a')[0].click()
96
- }
97
- }
98
- Pagy.addInputEventListeners(input, toPage)
99
- }
100
-
101
- // Utility for input fields
102
- Pagy.addInputEventListeners =
103
- function(input, toPage) {
104
- // select the content on click: easier for typing a number
105
- input.addEventListener('click', function() { this.select() })
106
- // toPage when the input looses focus
107
- input.addEventListener('focusout', toPage)
108
- // … and when pressing enter inside the input
109
- input.addEventListener('keyup', function(e) { if (e.which === 13) {toPage()} }.bind(this))
110
- }
111
-
112
- // Power the trim extra for js helpers
113
- Pagy.trim =
114
- function(html, param) {
115
- var re = new RegExp('[?&]' + param + '=1\\b(?!&)|\\b' + param + '=1&')
116
- return html.replace(re, '')
117
- }
118
-
119
- // Render all *nav_js helpers
120
- Pagy.renderNavs =
121
- function() {
122
- var navs = document.getElementsByClassName('pagy-njs') // 'pagy-njs' is common to all *nav_js helpers
123
- for (var i = 0, len = navs.length; i < len; i++) { navs[i].render() }
124
- }
125
-
126
- // Throttle to avoid to fire multiple time the renderNavs on resize
127
- Pagy.waitForMe =
128
- function() {
129
- if (typeof(Pagy.tid) === 'number') { clearTimeout(Pagy.tid) }
130
- Pagy.tid = setTimeout(Pagy.renderNavs, Pagy.delay)
131
- }
132
-
133
- // If there is a window object then add the event listener on resize
134
- if (typeof window !== 'undefined') {
135
- window.addEventListener('resize', Pagy.waitForMe, true)
136
- }
3
+ //# sourceMappingURL=pagy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/pagy.ts"],"names":[],"mappings":"mrDAkCA,GAAM,CAAA,IAAI,CAAG,CACT,OAAO,CAAE,QADA,CAIT,IAJS,eAIJ,CAJI,CAI6B,OAC5B,CAAM,CAAG,CAAG,WAAY,CAAA,WAAf,CAA6B,CAA7B,CAAmC,QADhB,CAE5B,CAAQ,CAAG,CAAM,CAAC,gBAAP,CAAwB,kBAAxB,CAFiB,8BAGZ,CAHY,MAGlC,2BAAgC,IAArB,CAAA,CAAqB,SACtB,CAAI,CAAG,CAAO,CAAC,YAAR,CAAqB,gBAArB,CADe,CAE5B,GAAI,IACM,CAAA,CAAI,C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AI,CAAgB,OAAV,GAAA,CAAC,CAAC,GAAR,EAA2B,CAAQ,EAAM,CAAjF,CACH,CArIQ,CAuIT,IAAI,CAAE,cAAC,CAAD,CAAc,CAAd,QACI,CAAA,CAAI,CAAC,OAAL,CAAa,GAAI,CAAA,MAAJ,eAAkB,CAAlB,0BAAwC,CAAxC,QAAb,CAAkE,EAAlE,CADJ,CAvIG,CAAb","file":"pagy.js","sourcesContent":["// This file is the source that generates pagy.js, polyfilled with the `@babel/preset-env` `\"useBuiltIns\": \"entry\"`.\n// You can generate a custom targeted javascript file for the browsers you need by changing that settings in package.json,\n// then compile it with `npm run compile -w src`.\n\n// Args types from data-pagy-json\ntype NavArgs = [NavTags, NavSequels, null|NavLabelSequels, string]\ntype ComboNavArgs = [string, string, string]\ntype ItemsSelectorArgs = [number, string, string]\n\n// Tags from the data-pagy-json of *nav_js helpers\ninterface NavTags {\n readonly before:string;\n readonly link:string;\n readonly active:string;\n readonly gap:string;\n readonly after:string;\n}\n\n// Tags from the data-pagy-json of *nav_js helpers\ninterface NavSequels {\n readonly [width:string]:(string|number|\"gap\")[];\n}\n\n// Tags from the data-pagy-json of *nav_js helpers\ninterface NavLabelSequels {\n [width:string]:string[];\n}\n\n// Add pagyRender to Element\ninterface Element {\n pagyRender():void;\n}\n\n// The Pagy object\nconst Pagy = {\n version: \"5.6.10\",\n\n // Scan for \"data-pagy-json\" elements, parse their JSON content and apply their functions\n init(arg?:HTMLElement|Document|Event) {\n const target = arg instanceof HTMLElement ? arg : document;\n const elements = target.querySelectorAll(\"[data-pagy-json]\");\n for (const element of elements) {\n const json = element.getAttribute(\"data-pagy-json\") as string;\n try {\n const args = JSON.parse(json);\n const fname = args.shift() as \"nav\"|\"combo_nav\"|\"items_selector\";\n if (fname === \"nav\") {\n Pagy.nav(element, ...args as NavArgs);\n } else if (fname === \"combo_nav\") {\n Pagy.comboNav(element, ...args as ComboNavArgs);\n } else if (fname === \"items_selector\") {\n Pagy.itemsSelector(element, ...args as ItemsSelectorArgs);\n }\n } catch (err) {\n console.warn(\"Pagy.init() skipped element: %o\\n%s\", element, err);\n }\n }\n },\n\n // Power the *_nav_js helpers\n nav(pagyEl:Element, tags:NavTags, sequels:NavSequels, optLabelSequels:null|NavLabelSequels, trimParam?:string) {\n let labelSequels = {} as NavLabelSequels;\n // Handle null labelSequels\n if (optLabelSequels === null) {\n for (const width in sequels) {\n labelSequels[width] = sequels[width].map(item => item.toString());\n }\n } else {\n labelSequels = optLabelSequels;\n }\n // Set and sort the widths as number[]\n const widths = Object.getOwnPropertyNames(sequels)\n .map(w => parseInt(w))\n .sort((a, b) => b - a);\n let lastWidth:number;\n const fillIn = (string:string, item:string, label:string):string =>\n string.replace(/__pagy_page__/g, item)\n .replace(/__pagy_label__/g, label);\n\n pagyEl.pagyRender = function () {\n // Find the width that fits in parent\n const width = widths.find(w => pagyEl.parentElement !== null && pagyEl.parentElement.clientWidth > w) || 0;\n // Only if the width changed\n if (width !== lastWidth) {\n let html = tags.before;\n const series = sequels[width.toString()];\n const labels = labelSequels[width.toString()];\n for (const i in series) {\n const item = series[i];\n const label = labels[i];\n if (typeof trimParam === \"string\" && item === 1) {\n const link = fillIn(tags.link, item.toString(), label);\n html += Pagy.trim(link, trimParam);\n } else if (typeof item === \"number\") {\n html += fillIn(tags.link, item.toString(), label);\n } else if (item === \"gap\") {\n html += tags.gap;\n } else { // active page\n html += fillIn(tags.active, item, label);\n }\n }\n html += tags.after;\n pagyEl.innerHTML = \"\";\n pagyEl.insertAdjacentHTML(\"afterbegin\", html);\n lastWidth = width;\n }\n };\n pagyEl.pagyRender();\n // If there is a window object then add a single throttled \"resize\" event listener\n if (typeof window !== \"undefined\") {\n let tid = 0;\n window.addEventListener(\"resize\", () => {\n clearTimeout(tid);\n tid = window.setTimeout(Pagy.renderNavs, 100);\n }, true);\n }\n },\n\n // Render all *nav_js helpers (i.e. all the elements of class \"pagy-njs\")\n renderNavs() {\n const navs = document.getElementsByClassName(\"pagy-njs\");\n Array.from(navs).forEach(nav => nav.pagyRender());\n },\n\n // Power the *_combo_nav_js helpers\n comboNav(pagyEl:Element, page:string, link:string, trimParam?:string) {\n const input = pagyEl.getElementsByTagName(\"input\")[0];\n Pagy.addInputBehavior(input, () => {\n if (page !== input.value) {\n let html = link.replace(/__pagy_page__/, input.value);\n if (typeof trimParam === \"string\" && input.value === \"1\") {\n html = Pagy.trim(html, trimParam);\n }\n pagyEl.insertAdjacentHTML(\"afterbegin\", html);\n pagyEl.getElementsByTagName(\"a\")[0].click();\n }\n });\n },\n\n // Power the pagy_items_selector_js helper\n itemsSelector(pagyEl:Element, from:number, link:string, trimParam?:string) {\n const input = pagyEl.getElementsByTagName(\"input\")[0];\n const current = input.value;\n Pagy.addInputBehavior(input, () => {\n const items = input.value;\n if (items === \"0\" || items === \"\") { return }\n if (current !== items) {\n const page = Math.max(Math.ceil(from / parseInt(items)), 1).toString();\n let html = link.replace(/__pagy_page__/, page)\n .replace(/__pagy_items__/, items);\n if (typeof trimParam === \"string\" && page === \"1\") {\n html = Pagy.trim(html, trimParam);\n }\n pagyEl.insertAdjacentHTML(\"afterbegin\", html);\n pagyEl.getElementsByTagName(\"a\")[0].click();\n }\n });\n },\n\n // Add behavior to input fields\n addInputBehavior(input:HTMLInputElement, goToPage:() => void) {\n // select the content on click: easier for direct typing\n input.addEventListener(\"click\", input.select);\n // goToPage when the input loses focus\n input.addEventListener(\"focusout\", goToPage);\n // goToPage when pressing enter while the input has focus\n input.addEventListener(\"keypress\", e => { if (e.key === \"Enter\") { goToPage() } });\n },\n\n trim: (link:string, param:string):string =>\n link.replace(new RegExp(`[?&]${param}=1\\\\b(?!&)|\\\\b${param}=1&`), \"\")\n};\n"]}
data/lib/pagy.rb CHANGED
@@ -5,7 +5,7 @@ require 'pathname'
5
5
 
6
6
  # Core class
7
7
  class Pagy
8
- VERSION = '5.6.6'
8
+ VERSION = '5.6.10'
9
9
 
10
10
  # Root pathname to get the path of Pagy files like templates or dictionaries
11
11
  def self.root
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagy
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.6.6
4
+ version: 5.6.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Domizio Demichelis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-09 00:00:00.000000000 Z
11
+ date: 2022-01-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Agnostic pagination in plain ruby. It does it all. Better.
14
14
  email:
@@ -20,6 +20,7 @@ files:
20
20
  - LICENSE.txt
21
21
  - lib/config/pagy.rb
22
22
  - lib/javascripts/pagy.js
23
+ - lib/javascripts/pagy.js.map
23
24
  - lib/locales/ar.yml
24
25
  - lib/locales/bg.yml
25
26
  - lib/locales/bs.yml
@@ -111,6 +112,11 @@ licenses:
111
112
  - MIT
112
113
  metadata:
113
114
  rubygems_mfa_required: 'true'
115
+ homepage_uri: https://github.com/ddnexus/pagy
116
+ documentation_uri: https://ddnexus.github.io/pagy
117
+ bug_tracker_uri: https://github.com/ddnexus/pagy/issues
118
+ changelog_uri: https://github.com/ddnexus/pagy/blob/master/CHANGELOG.md
119
+ live_support: https://gitter.im/ruby-pagy/Lobby
114
120
  post_install_message:
115
121
  rdoc_options: []
116
122
  require_paths: