@getflip/swirl-components 0.133.0 → 0.134.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 +17 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/swirl-app-layout_6.cjs.entry.js +4 -1
- package/dist/cjs/swirl-components.cjs.js +1 -1
- package/dist/cjs/swirl-icon-arrow-left_4.cjs.entry.js +5 -2
- package/dist/collection/assets/pdfjs/pdf.worker.min.js +1 -1
- package/dist/collection/components/swirl-resource-list-item/swirl-resource-list-item.js +4 -1
- package/dist/collection/components/swirl-resource-list-item/swirl-resource-list-item.spec.js +5 -3
- package/dist/collection/components/swirl-thumbnail/swirl-thumbnail.css +33 -9
- package/dist/collection/components/swirl-thumbnail/swirl-thumbnail.js +21 -1
- package/dist/collection/components/swirl-thumbnail/swirl-thumbnail.spec.js +17 -2
- package/dist/components/assets/pdfjs/pdf.worker.min.js +1 -1
- package/dist/components/swirl-resource-list-item2.js +4 -1
- package/dist/components/swirl-thumbnail2.js +6 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/swirl-app-layout_6.entry.js +4 -1
- package/dist/esm/swirl-components.js +1 -1
- package/dist/esm/swirl-icon-arrow-left_4.entry.js +5 -2
- package/dist/swirl-components/{p-8e6ec2e7.entry.js → p-538e75c0.entry.js} +1 -1
- package/dist/swirl-components/{p-66c27209.entry.js → p-8d65d86c.entry.js} +1 -1
- package/dist/swirl-components/swirl-components.esm.js +1 -1
- package/dist/types/components/swirl-resource-list-item/swirl-resource-list-item.d.ts +1 -0
- package/dist/types/components/swirl-thumbnail/swirl-thumbnail.d.ts +1 -0
- package/dist/types/components.d.ts +2 -0
- package/package.json +1 -1
- package/vscode-data.json +4 -0
|
@@ -39,6 +39,9 @@ export class SwirlResourceListItem {
|
|
|
39
39
|
this.toggleDrag.emit(this.el);
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
+
this.onControlClick = (event) => {
|
|
43
|
+
event.stopPropagation();
|
|
44
|
+
};
|
|
42
45
|
this.active = undefined;
|
|
43
46
|
this.allowDrag = undefined;
|
|
44
47
|
this.checked = false;
|
|
@@ -146,7 +149,7 @@ export class SwirlResourceListItem {
|
|
|
146
149
|
"resource-list-item--wrap-description": this.descriptionWrap,
|
|
147
150
|
"resource-list-item--wrap-label": this.labelWrap,
|
|
148
151
|
});
|
|
149
|
-
return (h(Host, { role: "row" }, h("div", { class: className, role: "gridcell" }, h(Tag, { "aria-checked": ariaChecked, "aria-disabled": disabled ? "true" : undefined, "aria-labelledby": this.id, class: "resource-list-item__content", href: href, disabled: disabled, onClick: this.onClick, onBlur: this.onBlur, onFocus: this.onFocus, part: "resource-list-item__content", role: role, tabIndex: 0, type: Tag === "button" ? "button" : undefined }, this.hasMedia && (h("span", { class: "resource-list-item__media" }, h("slot", { name: "media" }))), h("span", { class: "resource-list-item__label-container", style: labelContainerStyles }, h("span", { class: "resource-list-item__label", id: this.id, innerHTML: this.label }), this.description && (h("span", { class: "resource-list-item__description", innerHTML: this.description }))), showMeta && (h("span", { class: "resource-list-item__meta" }, h("span", { class: "resource-list-item__meta-text" }, this.meta), h("span", { class: "resource-list-item__badges" }, h("slot", { name: "badges" }))))), this.selectable && (h("span", { "aria-hidden": "true", class: "resource-list-item__checkbox" }, h("span", { class: "resource-list-item__checkbox-icon" }, this.checked && (h("swirl-icon-check-strong", null))))), h("span", { class: "resource-list-item__control", ref: (el) => (this.controlContainer = el) }, h("slot", { name: "control" })), showMenu && (h("swirl-popover-trigger", { popover: this.menuTriggerId }, h("swirl-button", { "aria-disabled": disabled ? "true" : undefined, class: "resource-list-item__menu-trigger", disabled: disabled, hideLabel: true, icon: "<swirl-icon-more-horizontal></swirl-icon-more-horizontal>", intent: "primary", label: this.menuTriggerLabel, onClick: this.onMenuTriggerClick })))), this.allowDrag && (h("button", { "aria-describedby": this.dragHandleDescription, "aria-label": `${this.dragHandleLabel} "${this.label}"`, class: "resource-list-item__drag-handle", onKeyDown: this.onDragHandleKeyDown, type: "button" }, h("swirl-icon-drag-handle", { size: this.iconSize })))));
|
|
152
|
+
return (h(Host, { role: "row" }, h("div", { class: className, role: "gridcell" }, h(Tag, { "aria-checked": ariaChecked, "aria-disabled": disabled ? "true" : undefined, "aria-labelledby": this.id, class: "resource-list-item__content", href: href, disabled: disabled, onClick: this.onClick, onBlur: this.onBlur, onFocus: this.onFocus, part: "resource-list-item__content", role: role, tabIndex: 0, type: Tag === "button" ? "button" : undefined }, this.hasMedia && (h("span", { class: "resource-list-item__media" }, h("slot", { name: "media" }))), h("span", { class: "resource-list-item__label-container", style: labelContainerStyles }, h("span", { class: "resource-list-item__label", id: this.id, innerHTML: this.label }), this.description && (h("span", { class: "resource-list-item__description", innerHTML: this.description }))), showMeta && (h("span", { class: "resource-list-item__meta" }, h("span", { class: "resource-list-item__meta-text" }, this.meta), h("span", { class: "resource-list-item__badges" }, h("slot", { name: "badges" }))))), this.selectable && (h("span", { "aria-hidden": "true", class: "resource-list-item__checkbox" }, h("span", { class: "resource-list-item__checkbox-icon" }, this.checked && (h("swirl-icon-check-strong", null))))), h("span", { class: "resource-list-item__control", onClick: this.onControlClick, ref: (el) => (this.controlContainer = el) }, h("slot", { name: "control" })), showMenu && (h("swirl-popover-trigger", { popover: this.menuTriggerId }, h("swirl-button", { "aria-disabled": disabled ? "true" : undefined, class: "resource-list-item__menu-trigger", disabled: disabled, hideLabel: true, icon: "<swirl-icon-more-horizontal></swirl-icon-more-horizontal>", intent: "primary", label: this.menuTriggerLabel, onClick: this.onMenuTriggerClick })))), this.allowDrag && (h("button", { "aria-describedby": this.dragHandleDescription, "aria-label": `${this.dragHandleLabel} "${this.label}"`, class: "resource-list-item__drag-handle", onKeyDown: this.onDragHandleKeyDown, type: "button" }, h("swirl-icon-drag-handle", { size: this.iconSize })))));
|
|
150
153
|
}
|
|
151
154
|
static get is() { return "swirl-resource-list-item"; }
|
|
152
155
|
static get encapsulation() { return "scoped"; }
|
package/dist/collection/components/swirl-resource-list-item/swirl-resource-list-item.spec.js
CHANGED
|
@@ -76,14 +76,16 @@ describe("swirl-resource-list-item", () => {
|
|
|
76
76
|
});
|
|
77
77
|
expect(page.root.querySelector(".resource-list-item__meta")).not.toBeNull();
|
|
78
78
|
});
|
|
79
|
-
it("renders a
|
|
79
|
+
it("renders a control", async () => {
|
|
80
80
|
const page = await newSpecPage({
|
|
81
81
|
components: [SwirlResourceListItem],
|
|
82
82
|
html: `
|
|
83
|
-
<swirl-resource-list-item label="Label"
|
|
83
|
+
<swirl-resource-list-item label="Label">
|
|
84
|
+
<swirl-button label="Label" slot="control"></swirl-button>
|
|
85
|
+
</swirl-resource-list-item>
|
|
84
86
|
`,
|
|
85
87
|
});
|
|
86
|
-
expect(page.root.querySelector(".resource-list-
|
|
88
|
+
expect(page.root.querySelector(".resource-list-item__control").children.length).toBe(1);
|
|
87
89
|
});
|
|
88
90
|
it("can be draggable", async () => {
|
|
89
91
|
const page = await newSpecPage({
|
|
@@ -12,13 +12,8 @@
|
|
|
12
12
|
overflow: hidden;
|
|
13
13
|
padding: 0.0625rem;
|
|
14
14
|
border-radius: var(--s-border-radius-s);
|
|
15
|
-
box-shadow: inset 0 0 0 0.03125rem rgba(0, 0, 0, 0.1);
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
.thumbnail .thumbnail__image {
|
|
19
|
-
width: 100%;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
17
|
.thumbnail--size-s {
|
|
23
18
|
--swirl-thumbnail-size: 2.5rem;
|
|
24
19
|
}
|
|
@@ -62,11 +57,40 @@
|
|
|
62
57
|
bottom: var(--s-space-8);
|
|
63
58
|
}
|
|
64
59
|
|
|
60
|
+
.thumbnail--interactive .thumbnail__image-wrapper {
|
|
61
|
+
position: relative;
|
|
62
|
+
padding: 0;
|
|
63
|
+
border: none;
|
|
64
|
+
background-color: transparent;
|
|
65
|
+
cursor: pointer;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.thumbnail--interactive .thumbnail__image-wrapper:hover:after {
|
|
69
|
+
position: absolute;
|
|
70
|
+
background-color: rgba(0, 0, 0, 0.06);
|
|
71
|
+
content: "";
|
|
72
|
+
inset: 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.thumbnail--interactive .thumbnail__image-wrapper:active:after {
|
|
76
|
+
position: absolute;
|
|
77
|
+
background-color: rgba(0, 0, 0, 0.13);
|
|
78
|
+
content: "";
|
|
79
|
+
inset: 0;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.thumbnail__image-wrapper {
|
|
83
|
+
width: 100%;
|
|
84
|
+
height: 100%;
|
|
85
|
+
border-radius: var(--s-border-radius-s);
|
|
86
|
+
box-shadow: inset 0 0 0 0.03125rem rgba(0, 0, 0, 0.1);
|
|
87
|
+
}
|
|
88
|
+
|
|
65
89
|
.thumbnail__image {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
90
|
+
width: 100%;
|
|
91
|
+
height: 100%;
|
|
92
|
+
-o-object-fit: cover;
|
|
93
|
+
object-fit: cover;
|
|
70
94
|
}
|
|
71
95
|
|
|
72
96
|
.thumbnail__progress-indicator {
|
|
@@ -4,6 +4,7 @@ export class SwirlThumbnail {
|
|
|
4
4
|
constructor() {
|
|
5
5
|
this.alt = undefined;
|
|
6
6
|
this.format = "landscape";
|
|
7
|
+
this.interactive = undefined;
|
|
7
8
|
this.progress = undefined;
|
|
8
9
|
this.progressLabel = "Loading progress";
|
|
9
10
|
this.removeButtonLabel = "Remove";
|
|
@@ -15,10 +16,12 @@ export class SwirlThumbnail {
|
|
|
15
16
|
render() {
|
|
16
17
|
const showRemoveButton = this.showRemoveButton && this.size === "xl" && this.format === "square";
|
|
17
18
|
const showTimestamp = Boolean(this.timestamp) && this.size === "xl" && this.format === "square";
|
|
19
|
+
const ImageWrapper = this.interactive ? "button" : "span";
|
|
18
20
|
const className = classnames("thumbnail", `thumbnail--format-${this.format}`, `thumbnail--size-${this.size}`, {
|
|
21
|
+
"thumbnail--interactive": this.interactive,
|
|
19
22
|
"thumbnail--has-progress": this.progress !== undefined,
|
|
20
23
|
});
|
|
21
|
-
return (h(Host, null, h("span", { class: className, role: "group" }, h("img", { alt: this.alt, class: "thumbnail__image", loading: "lazy", src: this.src }), this.progress !== undefined && (h("span", { class: "thumbnail__progress-indicator" }, h("swirl-progress-indicator", { label: this.progressLabel, value: this.progress }))), showRemoveButton && (h("span", { class: "thumbnail__remove-button" }, h("swirl-button", { hideLabel: true, icon: "<swirl-icon-close></swirl-icon-close>", label: this.removeButtonLabel, onClick: this.remove.emit, pill: true, variant: "on-image" }))), showTimestamp && (h("span", { class: "thumbnail__timestamp" }, this.timestamp)))));
|
|
24
|
+
return (h(Host, null, h("span", { class: className, role: "group" }, h(ImageWrapper, { class: "thumbnail__image-wrapper", type: this.interactive ? "button" : undefined }, h("img", { alt: this.alt, class: "thumbnail__image", loading: "lazy", src: this.src })), this.progress !== undefined && (h("span", { class: "thumbnail__progress-indicator" }, h("swirl-progress-indicator", { label: this.progressLabel, value: this.progress }))), showRemoveButton && (h("span", { class: "thumbnail__remove-button" }, h("swirl-button", { hideLabel: true, icon: "<swirl-icon-close></swirl-icon-close>", label: this.removeButtonLabel, onClick: this.remove.emit, pill: true, variant: "on-image" }))), showTimestamp && (h("span", { class: "thumbnail__timestamp" }, this.timestamp)))));
|
|
22
25
|
}
|
|
23
26
|
static get is() { return "swirl-thumbnail"; }
|
|
24
27
|
static get encapsulation() { return "shadow"; }
|
|
@@ -74,6 +77,23 @@ export class SwirlThumbnail {
|
|
|
74
77
|
"reflect": false,
|
|
75
78
|
"defaultValue": "\"landscape\""
|
|
76
79
|
},
|
|
80
|
+
"interactive": {
|
|
81
|
+
"type": "boolean",
|
|
82
|
+
"mutable": false,
|
|
83
|
+
"complexType": {
|
|
84
|
+
"original": "boolean",
|
|
85
|
+
"resolved": "boolean",
|
|
86
|
+
"references": {}
|
|
87
|
+
},
|
|
88
|
+
"required": false,
|
|
89
|
+
"optional": true,
|
|
90
|
+
"docs": {
|
|
91
|
+
"tags": [],
|
|
92
|
+
"text": ""
|
|
93
|
+
},
|
|
94
|
+
"attribute": "interactive",
|
|
95
|
+
"reflect": false
|
|
96
|
+
},
|
|
77
97
|
"progress": {
|
|
78
98
|
"type": "number",
|
|
79
99
|
"mutable": false,
|
|
@@ -10,7 +10,9 @@ describe("swirl-thumbnail", () => {
|
|
|
10
10
|
<swirl-thumbnail alt="Brief description of the image." format="portrait" size="l" src="https://picsum.photos/id/433/400/400">
|
|
11
11
|
<mock:shadow-root>
|
|
12
12
|
<span class="thumbnail thumbnail--format-portrait thumbnail--size-l" role="group">
|
|
13
|
-
<
|
|
13
|
+
<span class="thumbnail__image-wrapper">
|
|
14
|
+
<img alt="Brief description of the image." class="thumbnail__image" loading="lazy" src="https://picsum.photos/id/433/400/400">
|
|
15
|
+
</span>
|
|
14
16
|
</span>
|
|
15
17
|
</mock:shadow-root>
|
|
16
18
|
</swirl-thumbnail>
|
|
@@ -25,7 +27,9 @@ describe("swirl-thumbnail", () => {
|
|
|
25
27
|
<swirl-thumbnail alt="Brief description of the image." format="square" show-remove-button="" size="xl" src="https://picsum.photos/id/433/400/400" timestamp="12:12">
|
|
26
28
|
<mock:shadow-root>
|
|
27
29
|
<span class="thumbnail thumbnail--format-square thumbnail--size-xl" role="group">
|
|
28
|
-
<
|
|
30
|
+
<span class="thumbnail__image-wrapper">
|
|
31
|
+
<img alt="Brief description of the image." class="thumbnail__image" loading="lazy" src="https://picsum.photos/id/433/400/400">
|
|
32
|
+
</span>
|
|
29
33
|
<span class="thumbnail__remove-button">
|
|
30
34
|
<swirl-button hidelabel="" icon="<swirl-icon-close></swirl-icon-close>" label="Remove" pill="" variant="on-image"></swirl-button>
|
|
31
35
|
</span>
|
|
@@ -37,4 +41,15 @@ describe("swirl-thumbnail", () => {
|
|
|
37
41
|
</swirl-thumbnail>
|
|
38
42
|
`);
|
|
39
43
|
});
|
|
44
|
+
it("can be interactive", async () => {
|
|
45
|
+
const page = await newSpecPage({
|
|
46
|
+
components: [SwirlThumbnail],
|
|
47
|
+
html: `<swirl-thumbnail alt="Brief description of the image." interactive src="https://picsum.photos/id/433/400/400"></swirl-thumbnail>`,
|
|
48
|
+
});
|
|
49
|
+
expect(page.root.shadowRoot
|
|
50
|
+
.querySelector(".thumbnail")
|
|
51
|
+
.classList.contains("thumbnail--interactive")).toBeTruthy();
|
|
52
|
+
const expectedButton = page.root.shadowRoot.querySelector(".thumbnail__image-wrapper");
|
|
53
|
+
expect(expectedButton.tagName).toBe("BUTTON");
|
|
54
|
+
});
|
|
40
55
|
});
|