@getflip/swirl-components 0.40.1 → 0.41.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.
@@ -36,6 +36,58 @@
36
36
  }
37
37
  }
38
38
 
39
+ .pagination__page-size-selection {
40
+ display: flex;
41
+ padding-right: var(--s-space-24);
42
+ flex-shrink: 0;
43
+ align-items: center;
44
+ color: var(--s-interactive-primary-default);
45
+ white-space: nowrap;
46
+ gap: var(--s-space-8);
47
+ }
48
+
49
+ .pagination__page-size-select-container {
50
+ position: relative;
51
+ }
52
+
53
+ .pagination__page-size-select {
54
+ padding-right: calc(1rem + var(--s-space-4));
55
+ border: none;
56
+ color: var(--s-interactive-primary-default);
57
+ background-color: transparent;
58
+ font: inherit;
59
+ font-weight: var(--s-font-weight-medium);
60
+ line-height: var(--s-line-height-base);
61
+ cursor: pointer;
62
+ -webkit-appearance: none;
63
+ -moz-appearance: none;
64
+ appearance: none;
65
+ }
66
+
67
+ .pagination__page-size-select:focus:not(:focus-visible) {
68
+ outline: none;
69
+ }
70
+
71
+ .pagination__page-size-select:focus-visible {
72
+ outline-color: var(--s-focus-default);
73
+ }
74
+
75
+ @media (min-width: 992px) and (max-width: 1439px) and (hover: hover),(min-width: 1440px) {
76
+
77
+ .pagination__page-size-select {
78
+ font-size: var(--s-font-size-sm);
79
+ line-height: var(--s-line-height-sm)
80
+ }
81
+ }
82
+
83
+ .pagination__page-size-select-icon {
84
+ position: absolute;
85
+ top: 50%;
86
+ right: 0;
87
+ transform: translateY(-50%);
88
+ pointer-events: none;
89
+ }
90
+
39
91
  .pagination__page-label {
40
92
  padding-right: var(--s-space-8);
41
93
  padding-left: var(--s-space-8);
@@ -35,6 +35,13 @@ export class SwirlPagination {
35
35
  }
36
36
  this.setPage.emit(page);
37
37
  };
38
+ this.onPageSizeSelect = (event) => {
39
+ const pageSize = +event.target.value;
40
+ if (this.pageSize === pageSize) {
41
+ return;
42
+ }
43
+ this.setPageSize.emit(pageSize);
44
+ };
38
45
  this.firstPageButtonLabel = "First page";
39
46
  this.lastPageButtonLabel = "Last page";
40
47
  this.label = undefined;
@@ -43,7 +50,11 @@ export class SwirlPagination {
43
50
  this.pageLabel = "out of";
44
51
  this.pages = undefined;
45
52
  this.pageSelectLabel = "Select a page";
53
+ this.pageSize = 10;
54
+ this.pageSizeOptions = [10, 25, 50];
55
+ this.pageSizeSelectLabel = "Items per page:";
46
56
  this.prevButtonLabel = "Previous page";
57
+ this.showPageSizeSelect = undefined;
47
58
  this.variant = "default";
48
59
  }
49
60
  render() {
@@ -51,7 +62,7 @@ export class SwirlPagination {
51
62
  const showDropDown = this.variant === "advanced";
52
63
  const ariaPageLabel = `${this.page} ${this.pageLabel} ${this.pages}`;
53
64
  const className = classnames("pagination", `pagination--variant-${this.variant}`);
54
- return (h(Host, null, h("nav", { "aria-label": this.label, class: className }, h("ul", { class: "pagination__list", part: "pagination__list" }, h("li", { class: "pagination__list-item" }, h("swirl-button", { class: "pagination__first-page-button", disabled: this.page <= 1, hideLabel: true, icon: "<swirl-icon-double-arrow-left></swirl-icon-double-arrow-left>", intent: "primary", label: this.firstPageButtonLabel, onClick: this.onFirstPageButtonClick })), h("li", { class: "pagination__list-item" }, h("swirl-button", { class: "pagination__prev-button", disabled: this.page <= 1, hideLabel: true, icon: "<swirl-icon-chevron-left></swirl-icon-chevron-left>", intent: "primary", label: this.prevButtonLabel, onClick: this.onPrevButtonClick })), showPageLabel ? (h("li", { class: "pagination__list-item pagination__page-label" }, h("span", null, showDropDown ? (h("span", { "aria-current": "page", class: "pagination__advanced-label" }, h("span", { class: "pagination__page-select-container" }, h("select", { "aria-label": this.pageSelectLabel, class: "pagination__page-select", onChange: this.onSelect }, new Array(this.pages)
65
+ return (h(Host, null, h("nav", { "aria-label": this.label, class: className }, h("ul", { class: "pagination__list", part: "pagination__list" }, this.showPageSizeSelect && (h("li", { class: "pagination__list-item" }, h("label", { class: "pagination__page-size-selection" }, h("swirl-text", null, this.pageSizeSelectLabel), h("swirl-stack", { align: "center", class: "pagination__page-size-select-container", orientation: "horizontal" }, h("select", { class: "pagination__page-size-select", onChange: this.onPageSizeSelect }, this.pageSizeOptions.map((pageSizeOption) => (h("option", { key: pageSizeOption, selected: pageSizeOption === this.pageSize, value: pageSizeOption }, pageSizeOption)))), h("swirl-icon-expand-more", { "aria-hidden": "true", class: "pagination__page-size-select-icon", size: 16 }))))), h("li", { class: "pagination__list-item" }, h("swirl-button", { class: "pagination__first-page-button", disabled: this.page <= 1, hideLabel: true, icon: "<swirl-icon-double-arrow-left></swirl-icon-double-arrow-left>", intent: "primary", label: this.firstPageButtonLabel, onClick: this.onFirstPageButtonClick })), h("li", { class: "pagination__list-item" }, h("swirl-button", { class: "pagination__prev-button", disabled: this.page <= 1, hideLabel: true, icon: "<swirl-icon-chevron-left></swirl-icon-chevron-left>", intent: "primary", label: this.prevButtonLabel, onClick: this.onPrevButtonClick })), showPageLabel ? (h("li", { class: "pagination__list-item pagination__page-label" }, h("span", null, showDropDown ? (h("span", { "aria-current": "page", class: "pagination__advanced-label" }, h("span", { class: "pagination__page-select-container" }, h("select", { "aria-label": this.pageSelectLabel, class: "pagination__page-select", onChange: this.onSelect }, new Array(this.pages)
55
66
  .fill(undefined)
56
67
  .map((_, index) => index + 1)
57
68
  .map((page) => (h("option", { selected: this.page === page, value: String(page) }, page))))), h("span", { "aria-hidden": "true" }, this.pageLabel, " ", this.pages))) : (h("span", { "aria-current": "page" }, ariaPageLabel))))) : (h("li", { class: "pagination__list-item" }, h("swirl-visually-hidden", null, h("span", { "aria-current": "page" }, ariaPageLabel)))), h("li", { class: "pagination__list-item" }, h("swirl-button", { class: "pagination__next-button", disabled: this.page >= this.pages, hideLabel: true, icon: "<swirl-icon-chevron-right></swirl-icon-chevron-right>", iconPosition: "end", intent: "primary", label: this.nextButtonLabel, onClick: this.onNextButtonClick })), h("li", { class: "pagination__list-item" }, h("swirl-button", { class: "pagination__last-page-button", disabled: this.page >= this.pages, hideLabel: true, icon: "<swirl-icon-double-arrow-right></swirl-icon-double-arrow-right>", intent: "primary", label: this.lastPageButtonLabel, onClick: this.onLastPageButtonClick }))))));
@@ -211,6 +222,58 @@ export class SwirlPagination {
211
222
  "reflect": false,
212
223
  "defaultValue": "\"Select a page\""
213
224
  },
225
+ "pageSize": {
226
+ "type": "number",
227
+ "mutable": false,
228
+ "complexType": {
229
+ "original": "number",
230
+ "resolved": "number",
231
+ "references": {}
232
+ },
233
+ "required": false,
234
+ "optional": true,
235
+ "docs": {
236
+ "tags": [],
237
+ "text": ""
238
+ },
239
+ "attribute": "page-size",
240
+ "reflect": false,
241
+ "defaultValue": "10"
242
+ },
243
+ "pageSizeOptions": {
244
+ "type": "unknown",
245
+ "mutable": false,
246
+ "complexType": {
247
+ "original": "number[]",
248
+ "resolved": "number[]",
249
+ "references": {}
250
+ },
251
+ "required": false,
252
+ "optional": true,
253
+ "docs": {
254
+ "tags": [],
255
+ "text": ""
256
+ },
257
+ "defaultValue": "[10, 25, 50]"
258
+ },
259
+ "pageSizeSelectLabel": {
260
+ "type": "string",
261
+ "mutable": false,
262
+ "complexType": {
263
+ "original": "string",
264
+ "resolved": "string",
265
+ "references": {}
266
+ },
267
+ "required": false,
268
+ "optional": true,
269
+ "docs": {
270
+ "tags": [],
271
+ "text": ""
272
+ },
273
+ "attribute": "page-size-select-label",
274
+ "reflect": false,
275
+ "defaultValue": "\"Items per page:\""
276
+ },
214
277
  "prevButtonLabel": {
215
278
  "type": "string",
216
279
  "mutable": false,
@@ -229,6 +292,23 @@ export class SwirlPagination {
229
292
  "reflect": false,
230
293
  "defaultValue": "\"Previous page\""
231
294
  },
295
+ "showPageSizeSelect": {
296
+ "type": "boolean",
297
+ "mutable": false,
298
+ "complexType": {
299
+ "original": "boolean",
300
+ "resolved": "boolean",
301
+ "references": {}
302
+ },
303
+ "required": false,
304
+ "optional": true,
305
+ "docs": {
306
+ "tags": [],
307
+ "text": ""
308
+ },
309
+ "attribute": "show-page-size-select",
310
+ "reflect": false
311
+ },
232
312
  "variant": {
233
313
  "type": "string",
234
314
  "mutable": false,
@@ -270,6 +350,21 @@ export class SwirlPagination {
270
350
  "resolved": "number",
271
351
  "references": {}
272
352
  }
353
+ }, {
354
+ "method": "setPageSize",
355
+ "name": "setPageSize",
356
+ "bubbles": true,
357
+ "cancelable": true,
358
+ "composed": true,
359
+ "docs": {
360
+ "tags": [],
361
+ "text": ""
362
+ },
363
+ "complexType": {
364
+ "original": "number",
365
+ "resolved": "number",
366
+ "references": {}
367
+ }
273
368
  }];
274
369
  }
275
370
  }