wj-elements 0.7.7 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animations.js +28 -51
- package/dist/animations.js.map +1 -1
- package/dist/base-path.js +19 -31
- package/dist/base-path.js.map +1 -1
- package/dist/custom-elements.json +11504 -11499
- package/dist/dark.css +1 -302
- package/dist/date.js +16 -36
- package/dist/date.js.map +1 -1
- package/dist/element-utils.js +20 -81
- package/dist/element-utils.js.map +1 -1
- package/dist/event.js +49 -165
- package/dist/event.js.map +1 -1
- package/dist/form-associated-element-BjeJn7j8.js +101 -0
- package/dist/{form-associated-element-DEQ4y-jn.js.map → form-associated-element-BjeJn7j8.js.map} +1 -1
- package/dist/icon-DmsqtDpL.js +102 -0
- package/dist/{icon-CReYMzAK.js.map → icon-DmsqtDpL.js.map} +1 -1
- package/dist/light.css +1 -731
- package/dist/localize.js +36 -111
- package/dist/localize.js.map +1 -1
- package/dist/packages/wje-accordion-item/accordion-item.element.d.ts +3 -2
- package/dist/permissions.js +14 -41
- package/dist/permissions.js.map +1 -1
- package/dist/popup.element-CbkhthPP.js +806 -0
- package/dist/{popup.element-CwXvVFK7.js.map → popup.element-CbkhthPP.js.map} +1 -1
- package/dist/router-links-CNsJ-elb.js +105 -0
- package/dist/{router-links-wjqCnncc.js.map → router-links-CNsJ-elb.js.map} +1 -1
- package/dist/skeleton.css +1 -197
- package/dist/styles.css +1 -866
- package/dist/universal-service.js +48 -109
- package/dist/universal-service.js.map +1 -1
- package/dist/utils.js +11 -18
- package/dist/utils.js.map +1 -1
- package/dist/web-types.json +760 -760
- package/dist/wje-accordion-item.js +33 -106
- package/dist/wje-accordion-item.js.map +1 -1
- package/dist/wje-accordion.js +19 -84
- package/dist/wje-accordion.js.map +1 -1
- package/dist/wje-animation.js +37 -4258
- package/dist/wje-animation.js.map +1 -1
- package/dist/wje-aside.js +9 -34
- package/dist/wje-aside.js.map +1 -1
- package/dist/wje-avatar.js +36 -126
- package/dist/wje-avatar.js.map +1 -1
- package/dist/wje-badge.js +10 -52
- package/dist/wje-badge.js.map +1 -1
- package/dist/wje-breadcrumb.js +205 -672
- package/dist/wje-breadcrumb.js.map +1 -1
- package/dist/wje-breadcrumbs.js +177 -633
- package/dist/wje-breadcrumbs.js.map +1 -1
- package/dist/wje-button-group.js +48 -153
- package/dist/wje-button-group.js.map +1 -1
- package/dist/wje-button.js +92 -413
- package/dist/wje-button.js.map +1 -1
- package/dist/wje-card-content.js +7 -30
- package/dist/wje-card-content.js.map +1 -1
- package/dist/wje-card-controls.js +7 -30
- package/dist/wje-card-controls.js.map +1 -1
- package/dist/wje-card-header.js +7 -30
- package/dist/wje-card-header.js.map +1 -1
- package/dist/wje-card-subtitle.js +7 -34
- package/dist/wje-card-subtitle.js.map +1 -1
- package/dist/wje-card-title.js +7 -34
- package/dist/wje-card-title.js.map +1 -1
- package/dist/wje-card.js +15 -71
- package/dist/wje-card.js.map +1 -1
- package/dist/wje-carousel-item.js +12 -56
- package/dist/wje-carousel-item.js.map +1 -1
- package/dist/wje-carousel.js +154 -509
- package/dist/wje-carousel.js.map +1 -1
- package/dist/wje-checkbox.js +50 -227
- package/dist/wje-checkbox.js.map +1 -1
- package/dist/wje-chip.js +43 -160
- package/dist/wje-chip.js.map +1 -1
- package/dist/wje-col.js +7 -20
- package/dist/wje-col.js.map +1 -1
- package/dist/wje-color-picker.js +445 -1464
- package/dist/wje-color-picker.js.map +1 -1
- package/dist/wje-container.js +9 -35
- package/dist/wje-container.js.map +1 -1
- package/dist/wje-copy-button.js +64 -204
- package/dist/wje-copy-button.js.map +1 -1
- package/dist/wje-dialog.js +85 -553
- package/dist/wje-dialog.js.map +1 -1
- package/dist/wje-divider.js +7 -34
- package/dist/wje-divider.js.map +1 -1
- package/dist/wje-dropdown.js +78 -305
- package/dist/wje-dropdown.js.map +1 -1
- package/dist/wje-element.js +191 -700
- package/dist/wje-element.js.map +1 -1
- package/dist/wje-file-upload-item.js +51 -156
- package/dist/wje-file-upload-item.js.map +1 -1
- package/dist/wje-file-upload.js +181 -619
- package/dist/wje-file-upload.js.map +1 -1
- package/dist/wje-footer.js +7 -31
- package/dist/wje-footer.js.map +1 -1
- package/dist/wje-form.js +7 -32
- package/dist/wje-form.js.map +1 -1
- package/dist/wje-format-digital.js +26 -118
- package/dist/wje-format-digital.js.map +1 -1
- package/dist/wje-grid.js +7 -33
- package/dist/wje-grid.js.map +1 -1
- package/dist/wje-header.js +9 -35
- package/dist/wje-header.js.map +1 -1
- package/dist/wje-icon-library.js +12 -18
- package/dist/wje-icon-library.js.map +1 -1
- package/dist/wje-icon-picker.js +65 -320
- package/dist/wje-icon-picker.js.map +1 -1
- package/dist/wje-icon.js +1 -1
- package/dist/wje-img-comparer.js +37 -114
- package/dist/wje-img-comparer.js.map +1 -1
- package/dist/wje-img.js +50 -198
- package/dist/wje-img.js.map +1 -1
- package/dist/wje-infinite-scroll.js +94 -346
- package/dist/wje-infinite-scroll.js.map +1 -1
- package/dist/wje-input-file.js +23 -84
- package/dist/wje-input-file.js.map +1 -1
- package/dist/wje-input.js +78 -392
- package/dist/wje-input.js.map +1 -1
- package/dist/wje-item.js +11 -64
- package/dist/wje-item.js.map +1 -1
- package/dist/wje-kanban.js +124 -401
- package/dist/wje-kanban.js.map +1 -1
- package/dist/wje-label.js +9 -32
- package/dist/wje-label.js.map +1 -1
- package/dist/wje-level-indicator.js +38 -157
- package/dist/wje-level-indicator.js.map +1 -1
- package/dist/wje-list.js +10 -40
- package/dist/wje-list.js.map +1 -1
- package/dist/wje-main.js +7 -31
- package/dist/wje-main.js.map +1 -1
- package/dist/wje-masonry.js +66 -211
- package/dist/wje-masonry.js.map +1 -1
- package/dist/wje-master.js +45 -161
- package/dist/wje-master.js.map +1 -1
- package/dist/wje-menu-button.js +10 -38
- package/dist/wje-menu-button.js.map +1 -1
- package/dist/wje-menu-item.js +127 -577
- package/dist/wje-menu-item.js.map +1 -1
- package/dist/wje-menu-label.js +9 -35
- package/dist/wje-menu-label.js.map +1 -1
- package/dist/wje-menu.js +14 -49
- package/dist/wje-menu.js.map +1 -1
- package/dist/wje-option.js +48 -279
- package/dist/wje-option.js.map +1 -1
- package/dist/wje-options.js +130 -384
- package/dist/wje-options.js.map +1 -1
- package/dist/wje-orgchart-group.js +16 -52
- package/dist/wje-orgchart-group.js.map +1 -1
- package/dist/wje-orgchart-item.js +24 -93
- package/dist/wje-orgchart-item.js.map +1 -1
- package/dist/wje-orgchart.js +18 -68
- package/dist/wje-orgchart.js.map +1 -1
- package/dist/wje-pagination.js +113 -397
- package/dist/wje-pagination.js.map +1 -1
- package/dist/wje-popup.js +3 -3
- package/dist/wje-popup.js.map +1 -1
- package/dist/wje-progress-bar.js +53 -205
- package/dist/wje-progress-bar.js.map +1 -1
- package/dist/wje-qr-code.js +398 -2980
- package/dist/wje-qr-code.js.map +1 -1
- package/dist/wje-radio-group.js +52 -190
- package/dist/wje-radio-group.js.map +1 -1
- package/dist/wje-radio.js +24 -118
- package/dist/wje-radio.js.map +1 -1
- package/dist/wje-rate.js +62 -266
- package/dist/wje-rate.js.map +1 -1
- package/dist/wje-relative-time.js +24 -99
- package/dist/wje-relative-time.js.map +1 -1
- package/dist/wje-reorder-dropzone.js +9 -31
- package/dist/wje-reorder-dropzone.js.map +1 -1
- package/dist/wje-reorder-handle.js +67 -204
- package/dist/wje-reorder-handle.js.map +1 -1
- package/dist/wje-reorder-item.js +14 -44
- package/dist/wje-reorder-item.js.map +1 -1
- package/dist/wje-reorder.js +61 -246
- package/dist/wje-reorder.js.map +1 -1
- package/dist/wje-route.js +6 -24
- package/dist/wje-route.js.map +1 -1
- package/dist/wje-router-link.js +11 -39
- package/dist/wje-router-link.js.map +1 -1
- package/dist/wje-router-outlet.js +76 -172
- package/dist/wje-router-outlet.js.map +1 -1
- package/dist/wje-routerx.js +537 -1331
- package/dist/wje-routerx.js.map +1 -1
- package/dist/wje-row.js +9 -31
- package/dist/wje-row.js.map +1 -1
- package/dist/wje-select.js +326 -1152
- package/dist/wje-select.js.map +1 -1
- package/dist/wje-slider.js +44 -225
- package/dist/wje-slider.js.map +1 -1
- package/dist/wje-sliding-container.js +295 -1319
- package/dist/wje-sliding-container.js.map +1 -1
- package/dist/wje-split-view.js +35 -121
- package/dist/wje-split-view.js.map +1 -1
- package/dist/wje-status.js +14 -45
- package/dist/wje-status.js.map +1 -1
- package/dist/wje-step.js +9 -32
- package/dist/wje-step.js.map +1 -1
- package/dist/wje-stepper.js +109 -357
- package/dist/wje-stepper.js.map +1 -1
- package/dist/wje-store.js +67 -360
- package/dist/wje-store.js.map +1 -1
- package/dist/wje-tab-group.js +85 -314
- package/dist/wje-tab-group.js.map +1 -1
- package/dist/wje-tab-panel.js +7 -28
- package/dist/wje-tab-panel.js.map +1 -1
- package/dist/wje-tab.js +21 -198
- package/dist/wje-tab.js.map +1 -1
- package/dist/wje-textarea.js +64 -264
- package/dist/wje-textarea.js.map +1 -1
- package/dist/wje-thumbnail.js +10 -51
- package/dist/wje-thumbnail.js.map +1 -1
- package/dist/wje-toast.js +127 -632
- package/dist/wje-toast.js.map +1 -1
- package/dist/wje-toggle.js +52 -177
- package/dist/wje-toggle.js.map +1 -1
- package/dist/wje-toolbar-action.js +128 -456
- package/dist/wje-toolbar-action.js.map +1 -1
- package/dist/wje-toolbar.js +75 -270
- package/dist/wje-toolbar.js.map +1 -1
- package/dist/wje-tooltip.js +50 -161
- package/dist/wje-tooltip.js.map +1 -1
- package/dist/wje-tree-item.js +70 -301
- package/dist/wje-tree-item.js.map +1 -1
- package/dist/wje-tree.js +145 -489
- package/dist/wje-tree.js.map +1 -1
- package/dist/wje-visually-hidden.js +7 -34
- package/dist/wje-visually-hidden.js.map +1 -1
- package/package.json +3 -2
- package/dist/form-associated-element-DEQ4y-jn.js +0 -245
- package/dist/icon-CReYMzAK.js +0 -245
- package/dist/popup.element-CwXvVFK7.js +0 -2133
- package/dist/router-links-wjqCnncc.js +0 -156
package/dist/wje-orgchart.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-orgchart.js","sources":["../packages/wje-orgchart/orgchart.element.js","../packages/wje-orgchart/orgchart.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary Orgchart is a custom web component that extends WJElement.\n * @documentation https://elements.webjet.sk/components/Orgchart\n * @status stable\n * @augments WJElement\n * @attribute {boolean} flat - Removes the incoming connector spacing for nested charts that should visually continue on the same level.\n * @csspart - Styles the element.\n * @csspart native - Styles the native element.\n * @tag wje-orgchart\n * @example\n */\nexport default class Orgchart extends WJElement {\n /**\n * Creates an instance of Orgchart.\n * @class\n */\n constructor() {\n super();\n }\n\n /**\n * Sets whether the chart should omit its incoming connector spacing.\n * @param {boolean} value True when the chart should render without top connector spacing.\n */\n set flat(value) {\n this.toggleAttribute('flat', Boolean(value));\n }\n\n /**\n * Gets whether the chart omits its incoming connector spacing.\n * @returns {boolean} True when the chart has the flat attribute.\n */\n get flat() {\n return this.hasAttribute('flat');\n }\n\n className = 'Orgchart';\n\n /**\n * Returns the CSS styles for the component.\n * @static\n * @returns {CSSStyleSheet}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns attributes that trigger a redraw when they change.\n * @returns {Array<string>} Attribute names that require a new template render.\n */\n static get observedAttributes() {\n return ['flat'];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n this.syncAria();\n }\n\n /**\n * Draws the component for the org chart.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-orgchart');\n\n let slot = document.createElement('slot');\n\n native.appendChild(slot);\n\n fragment.appendChild(native);\n\n this.native = native;\n this.defaultSlot = slot;\n\n return fragment;\n }\n\n /**\n * Syncs flat chart state to direct slotted children.\n */\n afterDraw() {\n this.defaultSlot.addEventListener('slotchange', this.syncFlatChildren);\n this.syncFlatChildren();\n }\n\n /**\n * Marks direct children that are rendered inside a flat chart.\n */\n syncFlatChildren = () => {\n let children = new Set(this.defaultSlot?.assignedElements({ flatten: true }) || []);\n\n this.flatChildren?.forEach((child) => {\n if (!children.has(child)) child.classList.remove('flat-child');\n });\n\n children.forEach((child) => child.classList.toggle('flat-child', this.flat));\n this.flatChildren = children;\n };\n\n /**\n * Sync ARIA attributes on host.\n */\n syncAria() {\n if (!this.hasAttribute('role')) {\n this.setAriaState({ role: 'tree' });\n }\n }\n}\n","import Orgchart from './orgchart.element.js';\n\nexport default Orgchart;\n\nOrgchart.define('wje-orgchart', Orgchart);\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wje-orgchart.js","sources":["../packages/wje-orgchart/orgchart.element.js","../packages/wje-orgchart/orgchart.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary Orgchart is a custom web component that extends WJElement.\n * @documentation https://elements.webjet.sk/components/Orgchart\n * @status stable\n * @augments WJElement\n * @attribute {boolean} flat - Removes the incoming connector spacing for nested charts that should visually continue on the same level.\n * @csspart - Styles the element.\n * @csspart native - Styles the native element.\n * @tag wje-orgchart\n * @example\n */\nexport default class Orgchart extends WJElement {\n /**\n * Creates an instance of Orgchart.\n * @class\n */\n constructor() {\n super();\n }\n\n /**\n * Sets whether the chart should omit its incoming connector spacing.\n * @param {boolean} value True when the chart should render without top connector spacing.\n */\n set flat(value) {\n this.toggleAttribute('flat', Boolean(value));\n }\n\n /**\n * Gets whether the chart omits its incoming connector spacing.\n * @returns {boolean} True when the chart has the flat attribute.\n */\n get flat() {\n return this.hasAttribute('flat');\n }\n\n className = 'Orgchart';\n\n /**\n * Returns the CSS styles for the component.\n * @static\n * @returns {CSSStyleSheet}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns attributes that trigger a redraw when they change.\n * @returns {Array<string>} Attribute names that require a new template render.\n */\n static get observedAttributes() {\n return ['flat'];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n this.syncAria();\n }\n\n /**\n * Draws the component for the org chart.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-orgchart');\n\n let slot = document.createElement('slot');\n\n native.appendChild(slot);\n\n fragment.appendChild(native);\n\n this.native = native;\n this.defaultSlot = slot;\n\n return fragment;\n }\n\n /**\n * Syncs flat chart state to direct slotted children.\n */\n afterDraw() {\n this.defaultSlot.addEventListener('slotchange', this.syncFlatChildren);\n this.syncFlatChildren();\n }\n\n /**\n * Marks direct children that are rendered inside a flat chart.\n */\n syncFlatChildren = () => {\n let children = new Set(this.defaultSlot?.assignedElements({ flatten: true }) || []);\n\n this.flatChildren?.forEach((child) => {\n if (!children.has(child)) child.classList.remove('flat-child');\n });\n\n children.forEach((child) => child.classList.toggle('flat-child', this.flat));\n this.flatChildren = children;\n };\n\n /**\n * Sync ARIA attributes on host.\n */\n syncAria() {\n if (!this.hasAttribute('role')) {\n this.setAriaState({ role: 'tree' });\n }\n }\n}\n","import Orgchart from './orgchart.element.js';\n\nexport default Orgchart;\n\nOrgchart.define('wje-orgchart', Orgchart);\n"],"names":["Orgchart","WJElement","constructor","super","className","syncFlatChildren","children","Set","this","defaultSlot","assignedElements","flatten","flatChildren","forEach","child","has","classList","remove","toggle","flat","value","toggleAttribute","Boolean","hasAttribute","setupAttributes","isShadowRoot","syncAria","draw","fragment","document","createDocumentFragment","native","createElement","setAttribute","add","slot","appendChild","afterDraw","addEventListener","setAriaState","role","define"],"mappings":";;;;AAce,MAAMA,UAAiBC,EAAAA;AAAAA,EAKlC,cAAAC;AACIC,UAAAA;AAmBJC,qCAAY;AA6DZC,4CAAmB,MAAA;;AACf,UAAIC,KAAW,IAAIC,MAAIC,UAAKC,gBAALD,mBAAkBE,iBAAiB,EAAEC,SAAAA,KAAS,OAAW;AAEhFH,iBAAKI,iBAALJ,mBAAmBK,QAASC,CAAAA,OAAAA;AACnBR,QAAAA,GAASS,IAAID,EAAAA,KAAQA,GAAME,UAAUC,OAAO,YAAA;AAAA,MAAA,IAGrDX,GAASO,QAASC,CAAAA,OAAUA,GAAME,UAAUE,OAAO,cAAcV,KAAKW,IAAAA,CAAAA,GACtEX,KAAKI,eAAeN;AAAAA,IAAAA;AAAAA,EAvFxB;AAAA,EAMA,IAAA,KAASc,IAAAA;AACLZ,SAAKa,gBAAgB,QAAQC,QAAQF,EAAAA,CAAAA;AAAAA,EACzC;AAAA,EAMA,IAAA,OAAID;AACA,WAAOX,KAAKe,aAAa;EAC7B;AAAA,EASA,WAAA;AACI;EACJ;AAAA,EAMA,WAAA;AACI,WAAO,CAAC,MAAA;AAAA,EACZ;AAAA,EAKA,kBAAAC;AACIhB,SAAKiB,eAAe,QACpBjB,KAAKkB,SAAAA;AAAAA,EACT;AAAA,EAMA,OAAAC;AACI,QAAIC,KAAWC,SAASC,0BAEpBC,KAASF,SAASG,cAAc,KAAA;AACpCD,IAAAA,GAAOE,aAAa,QAAQ,QAAA,GAC5BF,GAAOf,UAAUkB,IAAI,iBAAA;AAErB,QAAIC,IAAON,SAASG,cAAc,MAAA;AASlC,WAPAD,GAAOK,YAAYD,CAAAA,GAEnBP,GAASQ,YAAYL,EAAAA,GAErBvB,KAAKuB,SAASA,IACdvB,KAAKC,cAAc0B,GAEZP;AAAAA,EACX;AAAA,EAKA,YAAAS;AACI7B,SAAKC,YAAY6B,iBAAiB,cAAc9B,KAAKH,gBAAAA,GACrDG,KAAKH,iBAAAA;AAAAA,EACT;AAAA,EAmBA,WAAAqB;AACSlB,SAAKe,aAAa,MAAA,KACnBf,KAAK+B,aAAa,EAAEC,MAAM,OAAA,CAAA;AAAA,EAElC;AAAA;AClHJxC,EAASyC,OAAO,gBAAgBzC,CAAAA;"}
|
package/dist/wje-pagination.js
CHANGED
|
@@ -1,459 +1,175 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { Localizer } from "./localize.js";
|
|
5
|
-
import
|
|
6
|
-
import { I as
|
|
7
|
-
import
|
|
8
|
-
import { event } from "./event.js";
|
|
9
|
-
|
|
10
|
-
const totalPages = Math.ceil(totalItems / pageSize);
|
|
11
|
-
if (currentPage < 1) {
|
|
12
|
-
currentPage = 1;
|
|
13
|
-
} else if (currentPage > totalPages) {
|
|
14
|
-
currentPage = totalPages;
|
|
15
|
-
}
|
|
16
|
-
let startPage;
|
|
17
|
-
let endPage;
|
|
18
|
-
const pagesNearEnd = maxPages + 1;
|
|
19
|
-
const boundary = pagesNearEnd + 3;
|
|
20
|
-
if (totalPages > boundary) {
|
|
21
|
-
if (currentPage < pagesNearEnd) {
|
|
22
|
-
startPage = 1;
|
|
23
|
-
endPage = Math.min(pagesNearEnd + 1, totalPages);
|
|
24
|
-
} else if (currentPage >= totalPages - pagesNearEnd) {
|
|
25
|
-
startPage = Math.max(totalPages - pagesNearEnd, 1);
|
|
26
|
-
endPage = totalPages;
|
|
27
|
-
} else {
|
|
28
|
-
const halfPages = Math.floor(maxPages / 2);
|
|
29
|
-
startPage = currentPage - halfPages + 1;
|
|
30
|
-
endPage = maxPages % 2 === 1 ? currentPage + halfPages + 1 : currentPage + halfPages - 1;
|
|
31
|
-
}
|
|
32
|
-
} else {
|
|
33
|
-
startPage = 1;
|
|
34
|
-
endPage = totalPages;
|
|
35
|
-
}
|
|
36
|
-
const startIndex = (currentPage - 1) * pageSize;
|
|
37
|
-
const endIndex = Math.min(startIndex + pageSize - 1, totalItems - 1);
|
|
38
|
-
const pages = Array.from({ length: endPage - startPage + 1 }, (_, i) => startPage + i);
|
|
39
|
-
return {
|
|
40
|
-
boundary,
|
|
41
|
-
currentPage,
|
|
42
|
-
endIndex,
|
|
43
|
-
endPage,
|
|
44
|
-
totalPages,
|
|
45
|
-
pages,
|
|
46
|
-
pageSize,
|
|
47
|
-
startIndex,
|
|
48
|
-
startPage,
|
|
49
|
-
totalItems
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
const styles = ":host {\n --wje-pagination-gap: 1rem;\n --wje-pagination-summary-gap: 1rem;\n --wje-pagination-page-size-gap: var(--wje-spacing-small, 0.5rem);\n --wje-pagination-mobile-gap: var(--wje-spacing-x-large, 2rem);\n --wje-pagination-page-size-width: 68px;\n --wje-pagination-page-button-width: 32px;\n --wje-pagination-page-button-gap: 0.5rem;\n\n display: block;\n container: wje-pagination / inline-size;\n\n .native-pagination {\n display: flex;\n align-items: center;\n gap: var(--wje-pagination-gap);\n\n .summary,\n .page-size {\n display: flex;\n align-items: center;\n }\n\n .summary {\n gap: var(--wje-pagination-summary-gap);\n }\n\n .page-size {\n gap: var(--wje-pagination-page-size-gap);\n }\n\n .page-size-label {\n display: none;\n white-space: nowrap;\n }\n\n wje-select {\n width: var(--wje-pagination-page-size-width);\n margin-block: 0;\n wje-option {\n &::part(native) {\n padding-inline: var(--wje-spacing-x-small);\n }\n &[selected]{\n background: var(--wje-option-highlighted);\n }\n }\n wje-option::part(check) {\n display: none;\n }\n }\n\n .info {\n font-size: var(--wje-font-size-small);\n }\n\n .pages {\n display: flex;\n align-items: center;\n gap: var(--wje-pagination-page-button-gap);\n\n .dots {\n display: flex;\n justify-content: center;\n align-items: center;\n width: var(--wje-pagination-page-button-width);\n &::before {\n content: '...';\n }\n }\n wje-button {\n width: var(--wje-pagination-page-button-width);\n &[disabled] {\n cursor: default;\n }\n }\n }\n }\n}\n\n@container wje-pagination (max-width: 768px) {\n :host {\n .native-pagination {\n width: 100%;\n flex-direction: column;\n justify-content: center;\n gap: var(--wje-pagination-mobile-gap);\n\n .summary {\n justify-content: center;\n flex-wrap: wrap;\n }\n\n .page-size-label {\n display: inline;\n }\n\n .pages {\n width: 100%;\n max-width: 100%;\n justify-content: safe center;\n overflow-x: auto;\n }\n }\n }\n}\n";
|
|
53
|
-
class Pagination extends WJElement {
|
|
54
|
-
/**
|
|
55
|
-
* Creates an instance of Pagination.
|
|
56
|
-
*/
|
|
4
|
+
import { Localizer as t } from "./localize.js";
|
|
5
|
+
import e from "./wje-element.js";
|
|
6
|
+
import { I as i } from "./icon-DmsqtDpL.js";
|
|
7
|
+
import a from "./wje-button.js";
|
|
8
|
+
import { event as n } from "./event.js";
|
|
9
|
+
class s extends e {
|
|
57
10
|
constructor() {
|
|
58
11
|
super();
|
|
59
|
-
|
|
60
|
-
* Dependencies of the Button element.
|
|
61
|
-
* @type {object}
|
|
62
|
-
*/
|
|
63
|
-
__publicField(this, "dependencies", {
|
|
64
|
-
"wje-icon": Icon,
|
|
65
|
-
"wje-button": Button
|
|
66
|
-
});
|
|
12
|
+
__publicField(this, "dependencies", { "wje-icon": i, "wje-button": a });
|
|
67
13
|
__publicField(this, "className", "Pagination");
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
* If the clicked page number is the same as the current page, no action is performed.
|
|
71
|
-
* Otherwise, the current page is updated to the new page number, and a custom event
|
|
72
|
-
* 'wje-pagination:page-change' is dispatched with the pagination object.
|
|
73
|
-
* @param {Event} e The event triggered by the page click.
|
|
74
|
-
* @param {number} page The page number that was clicked.
|
|
75
|
-
*/
|
|
76
|
-
__publicField(this, "pageClickAction", (e, page) => {
|
|
77
|
-
if (+page === this.page || this.page > this.paginateObj.totalPages) return;
|
|
78
|
-
this.page = page;
|
|
79
|
-
event.dispatchCustomEvent(this, "wje-pagination:page-change", { page: this.page, pageSize: this.pageSize });
|
|
14
|
+
__publicField(this, "pageClickAction", (t2, e2) => {
|
|
15
|
+
+e2 === this.page || this.page > this.paginateObj.totalPages || (this.page = e2, n.dispatchCustomEvent(this, "wje-pagination:page-change", { page: this.page, pageSize: this.pageSize }));
|
|
80
16
|
});
|
|
81
|
-
this.localizer = new
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
* @param {string} value The value to set for the 'page' attribute.
|
|
87
|
-
*/
|
|
88
|
-
set page(value) {
|
|
89
|
-
this.setAttribute("page", value);
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Retrieves the current page number as a numeric value.
|
|
93
|
-
* @returns {number} The current page number. Returns 0 if the attribute 'page' is not set or is not a numeric value.
|
|
94
|
-
*/
|
|
17
|
+
this.localizer = new t(this), this._paginateObj = null;
|
|
18
|
+
}
|
|
19
|
+
set page(t2) {
|
|
20
|
+
this.setAttribute("page", t2);
|
|
21
|
+
}
|
|
95
22
|
get page() {
|
|
96
23
|
return +this.getAttribute("page") || 0;
|
|
97
24
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
* @param {number|string} value The maximum number of pages to set. Can be a number or a parsable string representing a number.
|
|
102
|
-
*/
|
|
103
|
-
set maxPages(value) {
|
|
104
|
-
this.setAttribute("max-pages", value);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Gets the maximum number of pages.
|
|
108
|
-
* This getter retrieves the value of the "max-pages" attribute from the element.
|
|
109
|
-
* If the attribute is not set or is invalid, it defaults to 3.
|
|
110
|
-
* @returns {number} The maximum number of pages as a numeric value.
|
|
111
|
-
*/
|
|
25
|
+
set maxPages(t2) {
|
|
26
|
+
this.setAttribute("max-pages", t2);
|
|
27
|
+
}
|
|
112
28
|
get maxPages() {
|
|
113
29
|
return +this.getAttribute("max-pages") || 10;
|
|
114
30
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
*/
|
|
119
|
-
set pageSize(value) {
|
|
120
|
-
this.setAttribute("page-size", value);
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Retrieves the value of the 'page-size' attribute and converts it to a number.
|
|
124
|
-
* If the attribute is not set or is invalid, returns the default value of 3.
|
|
125
|
-
* @returns {number} The numeric value of the 'page-size' attribute or the default value of 3.
|
|
126
|
-
*/
|
|
31
|
+
set pageSize(t2) {
|
|
32
|
+
this.setAttribute("page-size", t2);
|
|
33
|
+
}
|
|
127
34
|
get pageSize() {
|
|
128
35
|
return +this.getAttribute("page-size") || 3;
|
|
129
36
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
*/
|
|
134
|
-
set totalItems(value) {
|
|
135
|
-
this.setAttribute("total-items", value);
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Retrieves the total number of items represented by the 'total-items' attribute.
|
|
139
|
-
* @returns {number} The total number of items. Defaults to 0 if the attribute is not set or is invalid.
|
|
140
|
-
*/
|
|
37
|
+
set totalItems(t2) {
|
|
38
|
+
this.setAttribute("total-items", t2);
|
|
39
|
+
}
|
|
141
40
|
get totalItems() {
|
|
142
41
|
return +this.getAttribute("total-items") || 0;
|
|
143
42
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
* @param {boolean} value Determines whether to show the first button. If true, the 'show-first-button' attribute is added; if false, it is removed.
|
|
148
|
-
*/
|
|
149
|
-
set showFirstButton(value) {
|
|
150
|
-
this.removeAttribute("show-first-button");
|
|
151
|
-
if (value) {
|
|
152
|
-
this.setAttribute("show-first-button", "");
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Determines whether the 'show-first-button' attribute is present on the element.
|
|
157
|
-
* @returns {boolean} True if the 'show-first-button' attribute is set; otherwise, false.
|
|
158
|
-
*/
|
|
43
|
+
set showFirstButton(t2) {
|
|
44
|
+
this.removeAttribute("show-first-button"), t2 && this.setAttribute("show-first-button", "");
|
|
45
|
+
}
|
|
159
46
|
get showFirstButton() {
|
|
160
47
|
return this.hasAttribute("show-first-button");
|
|
161
48
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
* @param {boolean} value A boolean value indicating whether to show the "last" button.
|
|
166
|
-
* If true, the "show-last-button" attribute is added;
|
|
167
|
-
* if false, the attribute is removed.
|
|
168
|
-
*/
|
|
169
|
-
set showLastButton(value) {
|
|
170
|
-
this.removeAttribute("show-last-button");
|
|
171
|
-
if (value) {
|
|
172
|
-
this.setAttribute("show-last-button", "");
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Determines if the 'show-last-button' attribute is present on the element.
|
|
177
|
-
* @returns {boolean} True if the 'show-last-button' attribute is present, otherwise false.
|
|
178
|
-
*/
|
|
49
|
+
set showLastButton(t2) {
|
|
50
|
+
this.removeAttribute("show-last-button"), t2 && this.setAttribute("show-last-button", "");
|
|
51
|
+
}
|
|
179
52
|
get showLastButton() {
|
|
180
53
|
return this.hasAttribute("show-last-button");
|
|
181
54
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
* @param {object} value The value to set the pagination object. The pagination details are computed internally.
|
|
186
|
-
*/
|
|
187
|
-
set paginateObj(value) {
|
|
188
|
-
this._paginateObj = value;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Retrieves the pagination object used for managing paginated data.
|
|
192
|
-
* @returns {object} The pagination object containing details and functionality for paginating data.
|
|
193
|
-
*/
|
|
55
|
+
set paginateObj(t2) {
|
|
56
|
+
this._paginateObj = t2;
|
|
57
|
+
}
|
|
194
58
|
get paginateObj() {
|
|
195
59
|
return this._paginateObj;
|
|
196
60
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
* @param {boolean} value A boolean value determining whether to add or remove the 'round' attribute.
|
|
201
|
-
*/
|
|
202
|
-
set round(value) {
|
|
203
|
-
this.removeAttribute("round");
|
|
204
|
-
if (value) {
|
|
205
|
-
this.setAttribute("round", "");
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Retrieves the value of the 'round' attribute for the current element.
|
|
210
|
-
* @returns {boolean} A boolean indicating whether the 'round' attribute is present on the element.
|
|
211
|
-
*/
|
|
61
|
+
set round(t2) {
|
|
62
|
+
this.removeAttribute("round"), t2 && this.setAttribute("round", "");
|
|
63
|
+
}
|
|
212
64
|
get round() {
|
|
213
65
|
return this.hasAttribute("round");
|
|
214
66
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
*/
|
|
219
|
-
set showInfo(value) {
|
|
220
|
-
this.removeAttribute("show-info");
|
|
221
|
-
if (value) {
|
|
222
|
-
this.setAttribute("show-info", "");
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Retrieves the value of the 'show-info' attribute.
|
|
227
|
-
* Checks if the 'show-info' attribute is present on the element.
|
|
228
|
-
* @returns {boolean} True if the 'show-info' attribute is present, otherwise false.
|
|
229
|
-
*/
|
|
67
|
+
set showInfo(t2) {
|
|
68
|
+
this.removeAttribute("show-info"), t2 && this.setAttribute("show-info", "");
|
|
69
|
+
}
|
|
230
70
|
get showInfo() {
|
|
231
71
|
return this.hasAttribute("show-info");
|
|
232
72
|
}
|
|
233
|
-
set showPageSizeOptions(
|
|
234
|
-
|
|
235
|
-
this.setAttribute("show-page-size-options", value);
|
|
73
|
+
set showPageSizeOptions(t2) {
|
|
74
|
+
t2 && this.setAttribute("show-page-size-options", t2);
|
|
236
75
|
}
|
|
237
76
|
get showPageSizeOptions() {
|
|
238
77
|
return this.hasAttribute("show-page-size-options");
|
|
239
78
|
}
|
|
240
|
-
set pageSizeOptions(
|
|
241
|
-
|
|
242
|
-
this.setAttribute("page-size-options", value);
|
|
79
|
+
set pageSizeOptions(t2) {
|
|
80
|
+
t2 && this.setAttribute("page-size-options", t2);
|
|
243
81
|
}
|
|
244
|
-
/**
|
|
245
|
-
* Retrieves the list of available page size options.
|
|
246
|
-
* This method is used to fetch the values representing the different page size options
|
|
247
|
-
* that can be provided or configured in a paginated component or system.
|
|
248
|
-
* @returns {Array<number>} An array of numbers representing the selectable page size options.
|
|
249
|
-
*/
|
|
250
82
|
get pageSizeOptions() {
|
|
251
|
-
let
|
|
252
|
-
|
|
253
|
-
return options.split(",").map((o) => +o).filter((o) => !isNaN(o));
|
|
83
|
+
let t2 = this.getAttribute("page-size-options");
|
|
84
|
+
return t2 ? t2.split(",").map((t3) => +t3).filter((t3) => !isNaN(t3)) : [6, 10, 50, 100, 500];
|
|
254
85
|
}
|
|
255
|
-
set hideEmpty(
|
|
256
|
-
|
|
257
|
-
this.setAttribute("hide-empty", value);
|
|
86
|
+
set hideEmpty(t2) {
|
|
87
|
+
t2 && this.setAttribute("hide-empty", t2);
|
|
258
88
|
}
|
|
259
89
|
get hideEmpty() {
|
|
260
90
|
return this.hasAttribute("hide-empty");
|
|
261
91
|
}
|
|
262
|
-
/**
|
|
263
|
-
* Returns the CSS styles for the component.
|
|
264
|
-
* @static
|
|
265
|
-
* @returns {CSSStyleSheet}
|
|
266
|
-
*/
|
|
267
92
|
static get cssStyleSheet() {
|
|
268
|
-
return
|
|
93
|
+
return ':host{--wje-pagination-gap: 1rem;--wje-pagination-summary-gap: 1rem;--wje-pagination-page-size-gap: var(--wje-spacing-small, .5rem);--wje-pagination-mobile-gap: var(--wje-spacing-x-large, 2rem);--wje-pagination-page-size-width: 68px;--wje-pagination-page-button-width: 32px;--wje-pagination-page-button-gap: .5rem;display:block;container:wje-pagination / inline-size}:host .native-pagination{display:flex;align-items:center;gap:var(--wje-pagination-gap)}:host .native-pagination .summary,:host .native-pagination .page-size{display:flex;align-items:center}:host .native-pagination .summary{gap:var(--wje-pagination-summary-gap)}:host .native-pagination .page-size{gap:var(--wje-pagination-page-size-gap)}:host .native-pagination .page-size-label{display:none;white-space:nowrap}:host .native-pagination wje-select{width:var(--wje-pagination-page-size-width);margin-block:0}:host .native-pagination wje-select wje-option::part(native){padding-inline:var(--wje-spacing-x-small)}:host .native-pagination wje-select wje-option[selected]{background:var(--wje-option-highlighted)}:host .native-pagination wje-select wje-option::part(check){display:none}:host .native-pagination .info{font-size:var(--wje-font-size-small)}:host .native-pagination .pages{display:flex;align-items:center;gap:var(--wje-pagination-page-button-gap)}:host .native-pagination .pages .dots{display:flex;justify-content:center;align-items:center;width:var(--wje-pagination-page-button-width)}:host .native-pagination .pages .dots:before{content:"..."}:host .native-pagination .pages wje-button{width:var(--wje-pagination-page-button-width)}:host .native-pagination .pages wje-button[disabled]{cursor:default}@container wje-pagination (max-width: 768px){:host .native-pagination{width:100%;flex-direction:column;justify-content:center;gap:var(--wje-pagination-mobile-gap)}:host .native-pagination .summary{justify-content:center;flex-wrap:wrap}:host .native-pagination .page-size-label{display:inline}:host .native-pagination .pages{width:100%;max-width:100%;justify-content:safe center;overflow-x:auto}}';
|
|
269
94
|
}
|
|
270
|
-
/**
|
|
271
|
-
* Getter for the observedAttributes attribute of the input element.
|
|
272
|
-
* @returns {Array} The attributes to observe for changes.
|
|
273
|
-
*/
|
|
274
95
|
static get observedAttributes() {
|
|
275
96
|
return ["page", "total-items", "page-size"];
|
|
276
97
|
}
|
|
277
|
-
/**
|
|
278
|
-
* Sets up the attributes for the component.
|
|
279
|
-
*/
|
|
280
98
|
setupAttributes() {
|
|
281
|
-
this.isShadowRoot = "open";
|
|
282
|
-
this.setAriaState({
|
|
283
|
-
role: "navigation"
|
|
284
|
-
});
|
|
99
|
+
this.isShadowRoot = "open", this.setAriaState({ role: "navigation" });
|
|
285
100
|
}
|
|
286
101
|
async beforeDraw() {
|
|
287
|
-
this.classList.remove("empty");
|
|
288
|
-
this.
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
102
|
+
if (this.classList.remove("empty"), this.removeAttribute("hidden"), !this.totalItems || 0 === this.totalItems) return this.classList.add("empty"), void (this.hideEmpty && this.setAttribute("hidden", ""));
|
|
103
|
+
this.paginateObj = await (function(t2, e2 = 1, i2 = 10, a2 = 5) {
|
|
104
|
+
const n2 = Math.ceil(t2 / i2);
|
|
105
|
+
let s2, o;
|
|
106
|
+
e2 < 1 ? e2 = 1 : e2 > n2 && (e2 = n2);
|
|
107
|
+
const r = a2 + 1, p = r + 3;
|
|
108
|
+
if (n2 > p) if (e2 < r) s2 = 1, o = Math.min(r + 1, n2);
|
|
109
|
+
else if (e2 >= n2 - r) s2 = Math.max(n2 - r, 1), o = n2;
|
|
110
|
+
else {
|
|
111
|
+
const t3 = Math.floor(a2 / 2);
|
|
112
|
+
s2 = e2 - t3 + 1, o = a2 % 2 == 1 ? e2 + t3 + 1 : e2 + t3 - 1;
|
|
113
|
+
}
|
|
114
|
+
else s2 = 1, o = n2;
|
|
115
|
+
const l = (e2 - 1) * i2;
|
|
116
|
+
return { boundary: p, currentPage: e2, endIndex: Math.min(l + i2 - 1, t2 - 1), endPage: o, totalPages: n2, pages: Array.from({ length: o - s2 + 1 }, (t3, e3) => s2 + e3), pageSize: i2, startIndex: l, startPage: s2, totalItems: t2 };
|
|
117
|
+
})(this.totalItems, this.page + 1, this.pageSize, this.maxPages) || {};
|
|
118
|
+
}
|
|
301
119
|
draw() {
|
|
302
|
-
let
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
native.classList.add("native-pagination");
|
|
306
|
-
native.append(this.htmlPagination());
|
|
307
|
-
fragment.append(native);
|
|
308
|
-
return fragment;
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* Creates a pagination control for navigating between pages of content.
|
|
312
|
-
* This method generates and returns a document fragment containing pagination controls, including buttons for navigating to the first, previous, next, and last pages, as well as optional informational text about the current set of displayed items and total number of items.
|
|
313
|
-
* @returns {DocumentFragment} A document fragment containing the pagination controls.
|
|
314
|
-
*/
|
|
120
|
+
let t2 = document.createDocumentFragment(), e2 = document.createElement("div");
|
|
121
|
+
return e2.setAttribute("part", "native"), e2.classList.add("native-pagination"), e2.append(this.htmlPagination()), t2.append(e2), t2;
|
|
122
|
+
}
|
|
315
123
|
htmlPagination() {
|
|
316
124
|
var _a, _b, _c, _d;
|
|
317
|
-
let
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
let
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
pageSizeLabel.classList.add("page-size-label");
|
|
327
|
-
pageSizeLabel.textContent = this.localizer.translate("wj.pagination.itemsPerPage");
|
|
328
|
-
let select = document.createElement("wje-select");
|
|
329
|
-
select.setAttribute("part", "page-size-select");
|
|
330
|
-
select.setAttribute("size", "small");
|
|
331
|
-
select.setAttribute("variant", "standard");
|
|
332
|
-
select.setAttribute("value", this.pageSize);
|
|
333
|
-
select.setAttribute("aria-label", pageSizeLabel.textContent);
|
|
334
|
-
select.addEventListener("wje-select:change", (e) => {
|
|
335
|
-
if (+e.detail.context.value[0] !== this.pageSize) {
|
|
336
|
-
this.pageSize = +e.detail.context.value[0];
|
|
337
|
-
this.page = 0;
|
|
338
|
-
event.dispatchCustomEvent(this, "wje-pagination:page-change", { page: this.page, pageSize: this.pageSize });
|
|
339
|
-
}
|
|
340
|
-
});
|
|
341
|
-
let options = this.pageSizeOptions.map((o) => {
|
|
342
|
-
let option = document.createElement("wje-option");
|
|
343
|
-
option.value = o;
|
|
344
|
-
option.textContent = o;
|
|
345
|
-
return option;
|
|
346
|
-
});
|
|
347
|
-
let info = document.createElement("div");
|
|
348
|
-
info.setAttribute("part", "info");
|
|
349
|
-
info.classList.add("info");
|
|
350
|
-
info.innerHTML = `${((_a = this.paginateObj) == null ? void 0 : _a.startIndex) + 1} - ${((_b = this.paginateObj) == null ? void 0 : _b.endIndex) + 1} ${this.localizer.translate("wj.pagination.of")} ${this.totalItems}`;
|
|
351
|
-
let pagination = document.createElement("div");
|
|
352
|
-
pagination.setAttribute("part", "pages");
|
|
353
|
-
pagination.classList.add("pages");
|
|
354
|
-
const button = document.createElement("wje-button");
|
|
355
|
-
button.setAttribute("part", "page-button");
|
|
356
|
-
button.setAttribute("fill", "link");
|
|
357
|
-
if (this.round) button.setAttribute("round", "");
|
|
358
|
-
let firstButton = button.cloneNode(true);
|
|
359
|
-
firstButton.setAttribute("part", "page-button first-button");
|
|
360
|
-
firstButton.title = this.localizer.translate("wj.pagination.first");
|
|
361
|
-
firstButton.setAttribute("label", firstButton.title);
|
|
362
|
-
firstButton.innerHTML = `<wje-icon name="chevron-left-pipe" slot="icon-only"></wje-icon>`;
|
|
363
|
-
firstButton.addEventListener("click", (e) => this.pageClickAction(e, 0));
|
|
364
|
-
const prevButton = button.cloneNode(true);
|
|
365
|
-
prevButton.setAttribute("part", "page-button previous-button");
|
|
366
|
-
prevButton.title = this.localizer.translate("wj.pagination.prev");
|
|
367
|
-
prevButton.setAttribute("label", prevButton.title);
|
|
368
|
-
prevButton.innerHTML = `<wje-icon name="chevron-left" slot="icon-only"></wje-icon>`;
|
|
369
|
-
if (this.page === 0) prevButton.disabled = true;
|
|
370
|
-
prevButton.addEventListener("click", (e) => this.pageClickAction(e, this.page - 1));
|
|
371
|
-
const nextButton = button.cloneNode(true);
|
|
372
|
-
nextButton.setAttribute("part", "page-button next-button");
|
|
373
|
-
nextButton.title = this.localizer.translate("wj.pagination.next");
|
|
374
|
-
nextButton.setAttribute("label", nextButton.title);
|
|
375
|
-
nextButton.innerHTML = `<wje-icon name="chevron-right" slot="icon-only"></wje-icon>`;
|
|
376
|
-
if (this.page + 1 >= ((_c = this.paginateObj) == null ? void 0 : _c.totalPages)) nextButton.disabled = true;
|
|
377
|
-
nextButton.addEventListener("click", (e) => this.pageClickAction(e, this.page + 1));
|
|
378
|
-
let lastButton = button.cloneNode(true);
|
|
379
|
-
lastButton.setAttribute("part", "page-button last-button");
|
|
380
|
-
lastButton.title = this.localizer.translate("wj.pagination.last");
|
|
381
|
-
lastButton.setAttribute("label", lastButton.title);
|
|
382
|
-
lastButton.innerHTML = `<wje-icon name="chevron-right-pipe" slot="icon-only"></wje-icon>`;
|
|
383
|
-
lastButton.disabled = ((_d = this.paginateObj) == null ? void 0 : _d.endIndex) + 1 >= this.totalItems;
|
|
384
|
-
lastButton.addEventListener(
|
|
385
|
-
"click",
|
|
386
|
-
(e) => {
|
|
387
|
-
var _a2;
|
|
388
|
-
return this.pageClickAction(e, ((_a2 = this.paginateObj) == null ? void 0 : _a2.totalPages) - 1);
|
|
389
|
-
}
|
|
390
|
-
);
|
|
391
|
-
select.append(...options);
|
|
392
|
-
if (this.showFirstButton) pagination.appendChild(firstButton);
|
|
393
|
-
pagination.appendChild(prevButton);
|
|
394
|
-
pagination.appendChild(this.htmlStackButtons(this.paginateObj));
|
|
395
|
-
pagination.appendChild(nextButton);
|
|
396
|
-
if (this.showLastButton) pagination.appendChild(lastButton);
|
|
397
|
-
if (this.showPageSizeOptions) {
|
|
398
|
-
pageSize.append(pageSizeLabel, select);
|
|
399
|
-
summary.append(pageSize);
|
|
400
|
-
}
|
|
401
|
-
if (this.showInfo) summary.append(info);
|
|
402
|
-
if (summary.childElementCount) fragment.append(summary);
|
|
403
|
-
fragment.appendChild(pagination);
|
|
404
|
-
return fragment;
|
|
405
|
-
}
|
|
406
|
-
/**
|
|
407
|
-
* Creates and returns a DocumentFragment containing a series of buttons for pagination purposes,
|
|
408
|
-
* based on the provided pagination object.
|
|
409
|
-
* @param {object} paginateObj An object containing pagination details.
|
|
410
|
-
* @param {number} paginateObj.currentPage The current active page index (1-based).
|
|
411
|
-
* @param {Array<number>} paginateObj.pages An array of page numbers to display in the pagination.
|
|
412
|
-
* @param {number} paginateObj.totalPages Total number of pages available for pagination.
|
|
413
|
-
* @returns {DocumentFragment} A DocumentFragment containing the buttons and additional pagination elements.
|
|
414
|
-
*/
|
|
415
|
-
htmlStackButtons(paginateObj) {
|
|
416
|
-
let fragment = document.createDocumentFragment();
|
|
417
|
-
const button = document.createElement("wje-button");
|
|
418
|
-
button.setAttribute("part", "page-button page-number");
|
|
419
|
-
button.setAttribute("fill", "link");
|
|
420
|
-
if (this.round) button.setAttribute("round", "");
|
|
421
|
-
let dots = document.createElement("span");
|
|
422
|
-
dots.setAttribute("part", "dots");
|
|
423
|
-
dots.classList.add("dots");
|
|
424
|
-
dots.setAttribute("aria-hidden", "true");
|
|
425
|
-
const first = button.cloneNode(true);
|
|
426
|
-
first.textContent = "1";
|
|
427
|
-
first.addEventListener("click", (e) => this.pageClickAction(e, 0));
|
|
428
|
-
const last = button.cloneNode(true);
|
|
429
|
-
last.textContent = paginateObj == null ? void 0 : paginateObj.totalPages;
|
|
430
|
-
last.addEventListener("click", (e) => this.pageClickAction(e, (paginateObj == null ? void 0 : paginateObj.totalPages) - 1));
|
|
431
|
-
if ((paginateObj == null ? void 0 : paginateObj.currentPage) >= this.maxPages + 1 && (paginateObj == null ? void 0 : paginateObj.boundary) < (paginateObj == null ? void 0 : paginateObj.totalPages)) {
|
|
432
|
-
fragment.appendChild(first);
|
|
433
|
-
fragment.appendChild(dots);
|
|
434
|
-
}
|
|
435
|
-
paginateObj == null ? void 0 : paginateObj.pages.forEach((page) => {
|
|
436
|
-
let newButton = button.cloneNode(true);
|
|
437
|
-
newButton.textContent = page;
|
|
438
|
-
if (page - 1 === this.page) {
|
|
439
|
-
newButton.removeAttribute("fill");
|
|
440
|
-
newButton.setAttribute("aria-current", "page");
|
|
441
|
-
newButton.setAttribute("part", "page-button page-number current-page");
|
|
442
|
-
} else {
|
|
443
|
-
newButton.addEventListener("click", (e) => this.pageClickAction(e, page - 1));
|
|
444
|
-
}
|
|
445
|
-
fragment.appendChild(newButton);
|
|
125
|
+
let t2 = document.createDocumentFragment(), e2 = document.createElement("div");
|
|
126
|
+
e2.setAttribute("part", "summary"), e2.classList.add("summary");
|
|
127
|
+
let i2 = document.createElement("div");
|
|
128
|
+
i2.setAttribute("part", "page-size"), i2.classList.add("page-size");
|
|
129
|
+
let a2 = document.createElement("span");
|
|
130
|
+
a2.setAttribute("part", "page-size-label"), a2.classList.add("page-size-label"), a2.textContent = this.localizer.translate("wj.pagination.itemsPerPage");
|
|
131
|
+
let s2 = document.createElement("wje-select");
|
|
132
|
+
s2.setAttribute("part", "page-size-select"), s2.setAttribute("size", "small"), s2.setAttribute("variant", "standard"), s2.setAttribute("value", this.pageSize), s2.setAttribute("aria-label", a2.textContent), s2.addEventListener("wje-select:change", (t3) => {
|
|
133
|
+
+t3.detail.context.value[0] !== this.pageSize && (this.pageSize = +t3.detail.context.value[0], this.page = 0, n.dispatchCustomEvent(this, "wje-pagination:page-change", { page: this.page, pageSize: this.pageSize }));
|
|
446
134
|
});
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
}
|
|
451
|
-
|
|
135
|
+
let o = this.pageSizeOptions.map((t3) => {
|
|
136
|
+
let e3 = document.createElement("wje-option");
|
|
137
|
+
return e3.value = t3, e3.textContent = t3, e3;
|
|
138
|
+
}), r = document.createElement("div");
|
|
139
|
+
r.setAttribute("part", "info"), r.classList.add("info"), r.innerHTML = `${((_a = this.paginateObj) == null ? void 0 : _a.startIndex) + 1} - ${((_b = this.paginateObj) == null ? void 0 : _b.endIndex) + 1} ${this.localizer.translate("wj.pagination.of")} ${this.totalItems}`;
|
|
140
|
+
let p = document.createElement("div");
|
|
141
|
+
p.setAttribute("part", "pages"), p.classList.add("pages");
|
|
142
|
+
const l = document.createElement("wje-button");
|
|
143
|
+
l.setAttribute("part", "page-button"), l.setAttribute("fill", "link"), this.round && l.setAttribute("round", "");
|
|
144
|
+
let g = l.cloneNode(true);
|
|
145
|
+
g.setAttribute("part", "page-button first-button"), g.title = this.localizer.translate("wj.pagination.first"), g.setAttribute("label", g.title), g.innerHTML = '<wje-icon name="chevron-left-pipe" slot="icon-only"></wje-icon>', g.addEventListener("click", (t3) => this.pageClickAction(t3, 0));
|
|
146
|
+
const h = l.cloneNode(true);
|
|
147
|
+
h.setAttribute("part", "page-button previous-button"), h.title = this.localizer.translate("wj.pagination.prev"), h.setAttribute("label", h.title), h.innerHTML = '<wje-icon name="chevron-left" slot="icon-only"></wje-icon>', 0 === this.page && (h.disabled = true), h.addEventListener("click", (t3) => this.pageClickAction(t3, this.page - 1));
|
|
148
|
+
const u = l.cloneNode(true);
|
|
149
|
+
u.setAttribute("part", "page-button next-button"), u.title = this.localizer.translate("wj.pagination.next"), u.setAttribute("label", u.title), u.innerHTML = '<wje-icon name="chevron-right" slot="icon-only"></wje-icon>', this.page + 1 >= ((_c = this.paginateObj) == null ? void 0 : _c.totalPages) && (u.disabled = true), u.addEventListener("click", (t3) => this.pageClickAction(t3, this.page + 1));
|
|
150
|
+
let c = l.cloneNode(true);
|
|
151
|
+
return c.setAttribute("part", "page-button last-button"), c.title = this.localizer.translate("wj.pagination.last"), c.setAttribute("label", c.title), c.innerHTML = '<wje-icon name="chevron-right-pipe" slot="icon-only"></wje-icon>', c.disabled = ((_d = this.paginateObj) == null ? void 0 : _d.endIndex) + 1 >= this.totalItems, c.addEventListener("click", (t3) => {
|
|
152
|
+
var _a2;
|
|
153
|
+
return this.pageClickAction(t3, ((_a2 = this.paginateObj) == null ? void 0 : _a2.totalPages) - 1);
|
|
154
|
+
}), s2.append(...o), this.showFirstButton && p.appendChild(g), p.appendChild(h), p.appendChild(this.htmlStackButtons(this.paginateObj)), p.appendChild(u), this.showLastButton && p.appendChild(c), this.showPageSizeOptions && (i2.append(a2, s2), e2.append(i2)), this.showInfo && e2.append(r), e2.childElementCount && t2.append(e2), t2.appendChild(p), t2;
|
|
155
|
+
}
|
|
156
|
+
htmlStackButtons(t2) {
|
|
157
|
+
let e2 = document.createDocumentFragment();
|
|
158
|
+
const i2 = document.createElement("wje-button");
|
|
159
|
+
i2.setAttribute("part", "page-button page-number"), i2.setAttribute("fill", "link"), this.round && i2.setAttribute("round", "");
|
|
160
|
+
let a2 = document.createElement("span");
|
|
161
|
+
a2.setAttribute("part", "dots"), a2.classList.add("dots"), a2.setAttribute("aria-hidden", "true");
|
|
162
|
+
const n2 = i2.cloneNode(true);
|
|
163
|
+
n2.textContent = "1", n2.addEventListener("click", (t3) => this.pageClickAction(t3, 0));
|
|
164
|
+
const s2 = i2.cloneNode(true);
|
|
165
|
+
return s2.textContent = t2 == null ? void 0 : t2.totalPages, s2.addEventListener("click", (e3) => this.pageClickAction(e3, (t2 == null ? void 0 : t2.totalPages) - 1)), (t2 == null ? void 0 : t2.currentPage) >= this.maxPages + 1 && (t2 == null ? void 0 : t2.boundary) < (t2 == null ? void 0 : t2.totalPages) && (e2.appendChild(n2), e2.appendChild(a2)), t2 == null ? void 0 : t2.pages.forEach((t3) => {
|
|
166
|
+
let a3 = i2.cloneNode(true);
|
|
167
|
+
a3.textContent = t3, t3 - 1 === this.page ? (a3.removeAttribute("fill"), a3.setAttribute("aria-current", "page"), a3.setAttribute("part", "page-button page-number current-page")) : a3.addEventListener("click", (e3) => this.pageClickAction(e3, t3 - 1)), e2.appendChild(a3);
|
|
168
|
+
}), ((t2 == null ? void 0 : t2.pages.length) === this.maxPages || (t2 == null ? void 0 : t2.currentPage) < this.maxPages + 1) && t2.boundary < (t2 == null ? void 0 : t2.totalPages) && (e2.appendChild(a2.cloneNode(true)), e2.appendChild(s2)), e2;
|
|
452
169
|
}
|
|
453
170
|
}
|
|
454
|
-
|
|
455
|
-
Pagination.define("wje-pagination", Pagination);
|
|
171
|
+
s.define("wje-pagination", s), s.define("wje-pagination", s);
|
|
456
172
|
export {
|
|
457
|
-
|
|
173
|
+
s as default
|
|
458
174
|
};
|
|
459
175
|
//# sourceMappingURL=wje-pagination.js.map
|