@getflip/swirl-components 0.50.2 → 0.51.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/components.json +10 -1
- package/dist/cjs/swirl-pagination.cjs.entry.js +24 -8
- package/dist/cjs/swirl-search.cjs.entry.js +5 -1
- package/dist/cjs/swirl-toast.cjs.entry.js +2 -2
- package/dist/collection/assets/pdfjs/pdf.worker.min.js +1 -1
- package/dist/collection/components/swirl-pagination/swirl-pagination.css +7 -14
- package/dist/collection/components/swirl-pagination/swirl-pagination.js +23 -7
- package/dist/collection/components/swirl-search/swirl-search.js +19 -1
- package/dist/collection/components/swirl-search/swirl-search.stories.js +3 -0
- package/dist/collection/components/swirl-toast/swirl-toast.css +4 -0
- package/dist/collection/components/swirl-toast/swirl-toast.js +1 -1
- package/dist/components/assets/pdfjs/pdf.worker.min.js +1 -1
- package/dist/components/swirl-pagination.js +24 -8
- package/dist/components/swirl-search.js +5 -1
- package/dist/components/swirl-toast2.js +2 -2
- package/dist/esm/swirl-pagination.entry.js +24 -8
- package/dist/esm/swirl-search.entry.js +5 -1
- package/dist/esm/swirl-toast.entry.js +2 -2
- package/dist/swirl-components/p-41e9050c.entry.js +1 -0
- package/dist/swirl-components/p-77daca19.entry.js +1 -0
- package/dist/swirl-components/p-ae7a2dde.entry.js +1 -0
- package/dist/swirl-components/swirl-components.esm.js +1 -1
- package/dist/types/components/swirl-pagination/swirl-pagination.d.ts +4 -1
- package/dist/types/components/swirl-search/swirl-search.d.ts +2 -0
- package/dist/types/components.d.ts +1 -0
- package/dist/types/utils.d.ts +1 -1
- package/package.json +1 -1
- package/dist/swirl-components/p-da7879cd.entry.js +0 -1
- package/dist/swirl-components/p-dbe4ee1a.entry.js +0 -1
- package/dist/swirl-components/p-f50fcc4d.entry.js +0 -1
|
@@ -100,40 +100,33 @@
|
|
|
100
100
|
gap: var(--s-space-8);
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
.pagination__page-
|
|
104
|
-
position: relative;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
.pagination__page-select {
|
|
103
|
+
.pagination__page-input {
|
|
108
104
|
display: inline-flex;
|
|
105
|
+
width: 3rem;
|
|
109
106
|
padding-top: var(--s-space-8);
|
|
110
|
-
padding-right: var(--s-space-
|
|
107
|
+
padding-right: var(--s-space-8);
|
|
111
108
|
padding-bottom: var(--s-space-8);
|
|
112
|
-
padding-left: var(--s-space-
|
|
109
|
+
padding-left: var(--s-space-8);
|
|
113
110
|
border: none;
|
|
114
111
|
border-radius: var(--s-border-radius-sm);
|
|
115
112
|
background-color: transparent;
|
|
116
113
|
font: inherit;
|
|
117
114
|
line-height: var(--s-line-height-base);
|
|
118
115
|
text-align: center;
|
|
119
|
-
cursor: pointer;
|
|
120
116
|
box-shadow: inset 0 0 0 var(--s-border-width-default) var(--s-border-strong);
|
|
121
|
-
-webkit-appearance: none;
|
|
122
|
-
-moz-appearance: none;
|
|
123
|
-
appearance: none;
|
|
124
117
|
}
|
|
125
118
|
|
|
126
|
-
.pagination__page-
|
|
119
|
+
.pagination__page-input:focus:not(:focus-visible) {
|
|
127
120
|
outline: none;
|
|
128
121
|
}
|
|
129
122
|
|
|
130
|
-
.pagination__page-
|
|
123
|
+
.pagination__page-input:focus-visible {
|
|
131
124
|
outline-color: var(--s-focus-default);
|
|
132
125
|
}
|
|
133
126
|
|
|
134
127
|
@media (min-width: 992px) and (max-width: 1439px) and (hover: hover),(min-width: 1440px) {
|
|
135
128
|
|
|
136
|
-
.pagination__page-
|
|
129
|
+
.pagination__page-input {
|
|
137
130
|
font-size: var(--s-font-size-sm);
|
|
138
131
|
line-height: var(--s-line-height-sm)
|
|
139
132
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { h, Host } from "@stencil/core";
|
|
2
2
|
import classnames from "classnames";
|
|
3
|
+
import { debounce } from "../../utils";
|
|
3
4
|
export class SwirlPagination {
|
|
4
5
|
constructor() {
|
|
6
|
+
this.onFocusPageInput = (event) => {
|
|
7
|
+
event.target.select();
|
|
8
|
+
};
|
|
5
9
|
this.onFirstPageButtonClick = () => {
|
|
6
10
|
if (this.page === 1) {
|
|
7
11
|
return;
|
|
@@ -28,13 +32,28 @@ export class SwirlPagination {
|
|
|
28
32
|
}
|
|
29
33
|
this.setPage.emit(nextPage);
|
|
30
34
|
};
|
|
31
|
-
this.
|
|
32
|
-
|
|
35
|
+
this.onPageInput = () => {
|
|
36
|
+
let page = +this.pageInput.value;
|
|
37
|
+
if (isNaN(page)) {
|
|
38
|
+
page = this.page;
|
|
39
|
+
this.pageInput.value = String(page);
|
|
40
|
+
}
|
|
41
|
+
else if (page > this.pages) {
|
|
42
|
+
page = this.pages;
|
|
43
|
+
this.pageInput.value = String(page);
|
|
44
|
+
}
|
|
45
|
+
else if (page < 1) {
|
|
46
|
+
page = 1;
|
|
47
|
+
this.pageInput.value = String(page);
|
|
48
|
+
}
|
|
33
49
|
if (this.page === page) {
|
|
34
50
|
return;
|
|
35
51
|
}
|
|
36
|
-
this.
|
|
52
|
+
this.onPageUpdate(page);
|
|
37
53
|
};
|
|
54
|
+
this.onPageUpdate = debounce((page) => {
|
|
55
|
+
this.setPage.emit(page);
|
|
56
|
+
}, 500);
|
|
38
57
|
this.onPageSizeSelect = (event) => {
|
|
39
58
|
const pageSize = +event.target.value;
|
|
40
59
|
if (this.pageSize === pageSize) {
|
|
@@ -62,10 +81,7 @@ export class SwirlPagination {
|
|
|
62
81
|
const showDropDown = this.variant === "advanced";
|
|
63
82
|
const ariaPageLabel = `${this.page} ${this.pageLabel} ${this.pages}`;
|
|
64
83
|
const className = classnames("pagination", `pagination--variant-${this.variant}`);
|
|
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("
|
|
66
|
-
.fill(undefined)
|
|
67
|
-
.map((_, index) => index + 1)
|
|
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 }))))));
|
|
84
|
+
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("input", { "aria-label": this.pageSelectLabel, class: "pagination__page-input", onFocus: this.onFocusPageInput, onInput: this.onPageInput, ref: (el) => (this.pageInput = el), type: "text", value: this.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 }))))));
|
|
69
85
|
}
|
|
70
86
|
static get is() { return "swirl-pagination"; }
|
|
71
87
|
static get encapsulation() { return "shadow"; }
|
|
@@ -21,6 +21,9 @@ export class SwirlSearch {
|
|
|
21
21
|
this.onFocus = (event) => {
|
|
22
22
|
this.inputFocus.emit(event);
|
|
23
23
|
};
|
|
24
|
+
this.onInput = (event) => {
|
|
25
|
+
this.inputInput.emit(event.target.value);
|
|
26
|
+
};
|
|
24
27
|
this.autoFocus = undefined;
|
|
25
28
|
this.clearButtonLabel = "Clear search term";
|
|
26
29
|
this.disabled = undefined;
|
|
@@ -57,7 +60,7 @@ export class SwirlSearch {
|
|
|
57
60
|
const className = classnames("search", `search--variant-${this.variant}`, {
|
|
58
61
|
"search--disabled": this.disabled,
|
|
59
62
|
});
|
|
60
|
-
return (h(Host, null, h("span", { class: className, ref: (el) => (this.iconEl = el) }, h("swirl-icon-search", { class: "search__icon" }), h("input", { "aria-disabled": this.disabled ? "true" : undefined, "aria-label": this.label, autoComplete: "off", autoFocus: this.autoFocus, class: "search__input", disabled: this.disabled, id: this.inputId, inputMode: "search", name: this.inputName, onBlur: this.onBlur, onChange: this.onChange, onFocus: this.onFocus, placeholder: this.placeholder, ref: (el) => (this.input = el), type: "search", value: this.value }), !this.disabled && (h("button", { "aria-label": this.clearButtonLabel, class: "search__clear-button", onClick: this.clear, type: "button" }, h("swirl-icon-cancel", null))))));
|
|
63
|
+
return (h(Host, null, h("span", { class: className, ref: (el) => (this.iconEl = el) }, h("swirl-icon-search", { class: "search__icon" }), h("input", { "aria-disabled": this.disabled ? "true" : undefined, "aria-label": this.label, autoComplete: "off", autoFocus: this.autoFocus, class: "search__input", disabled: this.disabled, id: this.inputId, inputMode: "search", name: this.inputName, onBlur: this.onBlur, onChange: this.onChange, onFocus: this.onFocus, onInput: this.onInput, placeholder: this.placeholder, ref: (el) => (this.input = el), type: "search", value: this.value }), !this.disabled && (h("button", { "aria-label": this.clearButtonLabel, class: "search__clear-button", onClick: this.clear, type: "button" }, h("swirl-icon-cancel", null))))));
|
|
61
64
|
}
|
|
62
65
|
static get is() { return "swirl-search"; }
|
|
63
66
|
static get encapsulation() { return "scoped"; }
|
|
@@ -275,6 +278,21 @@ export class SwirlSearch {
|
|
|
275
278
|
}
|
|
276
279
|
}
|
|
277
280
|
}
|
|
281
|
+
}, {
|
|
282
|
+
"method": "inputInput",
|
|
283
|
+
"name": "inputInput",
|
|
284
|
+
"bubbles": true,
|
|
285
|
+
"cancelable": true,
|
|
286
|
+
"composed": true,
|
|
287
|
+
"docs": {
|
|
288
|
+
"tags": [],
|
|
289
|
+
"text": ""
|
|
290
|
+
},
|
|
291
|
+
"complexType": {
|
|
292
|
+
"original": "string",
|
|
293
|
+
"resolved": "string",
|
|
294
|
+
"references": {}
|
|
295
|
+
}
|
|
278
296
|
}, {
|
|
279
297
|
"method": "valueChange",
|
|
280
298
|
"name": "valueChange",
|
|
@@ -11,6 +11,9 @@ export default {
|
|
|
11
11
|
};
|
|
12
12
|
const Template = (args) => {
|
|
13
13
|
const element = generateStoryElement("swirl-search", args);
|
|
14
|
+
element.addEventListener("inputInput", (event) => {
|
|
15
|
+
console.log(event);
|
|
16
|
+
});
|
|
14
17
|
return element;
|
|
15
18
|
};
|
|
16
19
|
export const SwirlSearch = Template.bind({});
|
|
@@ -56,7 +56,7 @@ export class SwirlToast {
|
|
|
56
56
|
}
|
|
57
57
|
render() {
|
|
58
58
|
const className = classnames("toast", `toast--intent-${this.intent}`);
|
|
59
|
-
return (h(Host, null, h("div", { class: className }, this.icon && (h("span", { class: "toast__icon", innerHTML: this.icon, part: "toast__icon", ref: (el) => (this.iconEl = el) })), h("span", { class: "toast__content", part: "toast__content" }
|
|
59
|
+
return (h(Host, null, h("div", { class: className }, this.icon && (h("span", { class: "toast__icon", innerHTML: this.icon, part: "toast__icon", ref: (el) => (this.iconEl = el) })), h("span", { class: "toast__content", innerHTML: this.content, part: "toast__content" }), h("button", { "aria-label": this.dismissLabel || this.accessibleDismissLabel, class: "toast__dismiss-button", onClick: this.onDismiss, type: "button" }, this.dismissLabel, !Boolean(this.dismissLabel) && (h("swirl-icon-close", { ref: (el) => (this.dismissIconEl = el) }))))));
|
|
60
60
|
}
|
|
61
61
|
static get is() { return "swirl-toast"; }
|
|
62
62
|
static get encapsulation() { return "shadow"; }
|