@getflip/swirl-components 0.67.0 → 0.68.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 +175 -9
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/sortable.esm-73cf219b.js +3023 -0
- package/dist/cjs/swirl-app-layout_7.cjs.entry.js +168 -11
- package/dist/cjs/swirl-components.cjs.js +1 -1
- package/dist/cjs/swirl-option-list.cjs.entry.js +8 -3027
- package/dist/cjs/swirl-resource-list-file-item.cjs.entry.js +1 -1
- package/dist/collection/components/swirl-resource-list/swirl-resource-list.js +231 -10
- package/dist/collection/components/swirl-resource-list/swirl-resource-list.spec.js +52 -9
- package/dist/collection/components/swirl-resource-list/swirl-resource-list.stories.js +3 -31
- package/dist/collection/components/swirl-resource-list-file-item/swirl-resource-list-file-item.js +1 -1
- package/dist/collection/components/swirl-resource-list-file-item/swirl-resource-list-file-item.spec.js +16 -18
- package/dist/collection/components/swirl-resource-list-item/swirl-resource-list-item.css +53 -0
- package/dist/collection/components/swirl-resource-list-item/swirl-resource-list-item.js +129 -3
- package/dist/collection/components/swirl-resource-list-item/swirl-resource-list-item.spec.js +31 -20
- package/dist/components/sortable.esm.js +3021 -0
- package/dist/components/swirl-option-list2.js +1 -3020
- package/dist/components/swirl-resource-list-file-item.js +2 -3
- package/dist/components/swirl-resource-list-item2.js +56 -9
- package/dist/components/swirl-resource-list2.js +146 -15
- package/dist/esm/loader.js +1 -1
- package/dist/esm/sortable.esm-8c3d5856.js +3021 -0
- package/dist/esm/swirl-app-layout_7.entry.js +169 -12
- package/dist/esm/swirl-components.js +1 -1
- package/dist/esm/swirl-option-list.entry.js +1 -3020
- package/dist/esm/swirl-resource-list-file-item.entry.js +1 -1
- package/dist/swirl-components/p-1486d7ea.js +7 -0
- package/dist/swirl-components/p-61e97cc5.entry.js +1 -0
- package/dist/swirl-components/p-687f534e.entry.js +1 -0
- package/dist/swirl-components/p-8c62e1d4.entry.js +1 -0
- package/dist/swirl-components/swirl-components.esm.js +1 -1
- package/dist/types/components/swirl-resource-list/swirl-resource-list.d.ts +25 -0
- package/dist/types/components/swirl-resource-list-item/swirl-resource-list-item.d.ts +15 -1
- package/dist/types/components.d.ts +26 -0
- package/package.json +1 -1
- package/vscode-data.json +32 -0
- package/dist/swirl-components/p-85052283.entry.js +0 -1
- package/dist/swirl-components/p-bbf0621a.entry.js +0 -1
- package/dist/swirl-components/p-be12400c.entry.js +0 -7
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { h, Host, } from "@stencil/core";
|
|
2
2
|
import classnames from "classnames";
|
|
3
|
+
import { getDesktopMediaQuery } from "../../utils";
|
|
3
4
|
/**
|
|
4
5
|
* @slot media - Media displayed inside the item (e.g. swirl-avatar)
|
|
5
6
|
*/
|
|
6
7
|
export class SwirlResourceListItem {
|
|
7
8
|
constructor() {
|
|
9
|
+
this.desktopMediaQuery = getDesktopMediaQuery();
|
|
10
|
+
this.desktopMediaQueryHandler = (event) => {
|
|
11
|
+
this.forceIconProps(event.matches);
|
|
12
|
+
this.updateIconSize(event.matches);
|
|
13
|
+
};
|
|
8
14
|
this.onClick = () => {
|
|
9
15
|
if (!this.selectable) {
|
|
10
16
|
return;
|
|
@@ -17,9 +23,19 @@ export class SwirlResourceListItem {
|
|
|
17
23
|
event.stopPropagation();
|
|
18
24
|
}
|
|
19
25
|
};
|
|
26
|
+
this.onDragHandleKeyDown = (event) => {
|
|
27
|
+
if (event.code === "Space" || event.code === "Enter") {
|
|
28
|
+
event.preventDefault();
|
|
29
|
+
this.toggleDrag.emit(this.el);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
this.allowDrag = undefined;
|
|
20
33
|
this.checked = false;
|
|
21
34
|
this.description = undefined;
|
|
22
35
|
this.disabled = undefined;
|
|
36
|
+
this.dragging = undefined;
|
|
37
|
+
this.dragHandleDescription = "Press spacebar to toggle grab";
|
|
38
|
+
this.dragHandleLabel = "Move item";
|
|
23
39
|
this.hideDivider = undefined;
|
|
24
40
|
this.href = undefined;
|
|
25
41
|
this.label = undefined;
|
|
@@ -30,10 +46,28 @@ export class SwirlResourceListItem {
|
|
|
30
46
|
this.selectable = undefined;
|
|
31
47
|
this.value = undefined;
|
|
32
48
|
this.hasMedia = false;
|
|
49
|
+
this.iconSize = 24;
|
|
33
50
|
}
|
|
34
51
|
async componentWillLoad() {
|
|
35
52
|
this.updateMediaState();
|
|
36
53
|
}
|
|
54
|
+
componentDidLoad() {
|
|
55
|
+
this.forceIconProps(this.desktopMediaQuery.matches);
|
|
56
|
+
this.updateIconSize(this.desktopMediaQuery.matches);
|
|
57
|
+
this.desktopMediaQuery.onchange = this.desktopMediaQueryHandler;
|
|
58
|
+
}
|
|
59
|
+
disconnectedCallback() {
|
|
60
|
+
var _a, _b;
|
|
61
|
+
(_b = (_a = this.desktopMediaQuery).removeEventListener) === null || _b === void 0 ? void 0 : _b.call(_a, "change", this.desktopMediaQueryHandler);
|
|
62
|
+
}
|
|
63
|
+
forceIconProps(smallIcon) {
|
|
64
|
+
var _a;
|
|
65
|
+
const icon = (_a = this.iconEl) === null || _a === void 0 ? void 0 : _a.children[0];
|
|
66
|
+
icon === null || icon === void 0 ? void 0 : icon.setAttribute("size", smallIcon ? "20" : "24");
|
|
67
|
+
}
|
|
68
|
+
updateIconSize(smallIcon) {
|
|
69
|
+
this.iconSize = smallIcon ? 20 : 24;
|
|
70
|
+
}
|
|
37
71
|
updateMediaState() {
|
|
38
72
|
const mediaContainer = this.el.querySelector('[slot="media"]');
|
|
39
73
|
const hasMedia = Boolean(mediaContainer);
|
|
@@ -51,14 +85,16 @@ export class SwirlResourceListItem {
|
|
|
51
85
|
const role = this.selectable ? "checkbox" : undefined;
|
|
52
86
|
const className = classnames("resource-list-item", `resource-list-item--label-weight-${this.labelWeight}`, {
|
|
53
87
|
"resource-list-item--checked": this.checked,
|
|
88
|
+
"resource-list-item--draggable": this.allowDrag,
|
|
89
|
+
"resource-list-item--dragging": this.dragging,
|
|
54
90
|
"resource-list-item--has-menu": hasMenu,
|
|
55
91
|
"resource-list-item--hide-divider": this.hideDivider,
|
|
56
92
|
"resource-list-item--selectable": this.selectable,
|
|
57
93
|
});
|
|
58
|
-
return (h(Host, { role: "row" }, h("div", { class: className, role: "gridcell" }, h(Tag, { "aria-checked": ariaChecked, "aria-disabled": disabled ? "true" : undefined, "aria-labelledby": "label", class: "resource-list-item__content", href: this.href, disabled: disabled, onClick: this.onClick, part: "resource-list-item__content", role: role, tabIndex: 0 }, this.hasMedia && (h("span", { class: "resource-list-item__media" }, h("slot", { name: "media" }))), h("span", { class: "resource-list-item__label-container" }, h("span", { class: "resource-list-item__label", id: "label", innerHTML: this.label }), this.description && (h("span", { class: "resource-list-item__description" }, this.description)))), 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))))), showMeta && (h("span", { class: "resource-list-item__meta" }, this.meta)), showMenu && (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>", id: this.menuTriggerId, intent: "primary", label: this.menuTriggerLabel, onClick: this.onMenuTriggerClick })))));
|
|
94
|
+
return (h(Host, { role: "row" }, h("div", { class: className, role: "gridcell" }, h(Tag, { "aria-checked": ariaChecked, "aria-disabled": disabled ? "true" : undefined, "aria-labelledby": "label", class: "resource-list-item__content", href: this.href, disabled: disabled, onClick: this.onClick, part: "resource-list-item__content", role: role, tabIndex: 0 }, this.hasMedia && (h("span", { class: "resource-list-item__media" }, h("slot", { name: "media" }))), h("span", { class: "resource-list-item__label-container" }, h("span", { class: "resource-list-item__label", id: "label", innerHTML: this.label }), this.description && (h("span", { class: "resource-list-item__description" }, this.description)))), 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))))), showMeta && (h("span", { class: "resource-list-item__meta" }, this.meta)), showMenu && (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>", id: this.menuTriggerId, 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 })))));
|
|
59
95
|
}
|
|
60
96
|
static get is() { return "swirl-resource-list-item"; }
|
|
61
|
-
static get encapsulation() { return "
|
|
97
|
+
static get encapsulation() { return "scoped"; }
|
|
62
98
|
static get originalStyleUrls() {
|
|
63
99
|
return {
|
|
64
100
|
"$": ["swirl-resource-list-item.css"]
|
|
@@ -71,6 +107,23 @@ export class SwirlResourceListItem {
|
|
|
71
107
|
}
|
|
72
108
|
static get properties() {
|
|
73
109
|
return {
|
|
110
|
+
"allowDrag": {
|
|
111
|
+
"type": "boolean",
|
|
112
|
+
"mutable": false,
|
|
113
|
+
"complexType": {
|
|
114
|
+
"original": "boolean",
|
|
115
|
+
"resolved": "boolean",
|
|
116
|
+
"references": {}
|
|
117
|
+
},
|
|
118
|
+
"required": false,
|
|
119
|
+
"optional": true,
|
|
120
|
+
"docs": {
|
|
121
|
+
"tags": [],
|
|
122
|
+
"text": ""
|
|
123
|
+
},
|
|
124
|
+
"attribute": "allow-drag",
|
|
125
|
+
"reflect": false
|
|
126
|
+
},
|
|
74
127
|
"checked": {
|
|
75
128
|
"type": "boolean",
|
|
76
129
|
"mutable": true,
|
|
@@ -123,6 +176,59 @@ export class SwirlResourceListItem {
|
|
|
123
176
|
"attribute": "disabled",
|
|
124
177
|
"reflect": false
|
|
125
178
|
},
|
|
179
|
+
"dragging": {
|
|
180
|
+
"type": "boolean",
|
|
181
|
+
"mutable": false,
|
|
182
|
+
"complexType": {
|
|
183
|
+
"original": "boolean",
|
|
184
|
+
"resolved": "boolean",
|
|
185
|
+
"references": {}
|
|
186
|
+
},
|
|
187
|
+
"required": false,
|
|
188
|
+
"optional": true,
|
|
189
|
+
"docs": {
|
|
190
|
+
"tags": [],
|
|
191
|
+
"text": ""
|
|
192
|
+
},
|
|
193
|
+
"attribute": "dragging",
|
|
194
|
+
"reflect": false
|
|
195
|
+
},
|
|
196
|
+
"dragHandleDescription": {
|
|
197
|
+
"type": "string",
|
|
198
|
+
"mutable": false,
|
|
199
|
+
"complexType": {
|
|
200
|
+
"original": "string",
|
|
201
|
+
"resolved": "string",
|
|
202
|
+
"references": {}
|
|
203
|
+
},
|
|
204
|
+
"required": false,
|
|
205
|
+
"optional": true,
|
|
206
|
+
"docs": {
|
|
207
|
+
"tags": [],
|
|
208
|
+
"text": ""
|
|
209
|
+
},
|
|
210
|
+
"attribute": "drag-handle-description",
|
|
211
|
+
"reflect": false,
|
|
212
|
+
"defaultValue": "\"Press spacebar to toggle grab\""
|
|
213
|
+
},
|
|
214
|
+
"dragHandleLabel": {
|
|
215
|
+
"type": "string",
|
|
216
|
+
"mutable": false,
|
|
217
|
+
"complexType": {
|
|
218
|
+
"original": "string",
|
|
219
|
+
"resolved": "string",
|
|
220
|
+
"references": {}
|
|
221
|
+
},
|
|
222
|
+
"required": false,
|
|
223
|
+
"optional": true,
|
|
224
|
+
"docs": {
|
|
225
|
+
"tags": [],
|
|
226
|
+
"text": ""
|
|
227
|
+
},
|
|
228
|
+
"attribute": "drag-handle-label",
|
|
229
|
+
"reflect": false,
|
|
230
|
+
"defaultValue": "\"Move item\""
|
|
231
|
+
},
|
|
126
232
|
"hideDivider": {
|
|
127
233
|
"type": "boolean",
|
|
128
234
|
"mutable": false,
|
|
@@ -287,11 +393,31 @@ export class SwirlResourceListItem {
|
|
|
287
393
|
}
|
|
288
394
|
static get states() {
|
|
289
395
|
return {
|
|
290
|
-
"hasMedia": {}
|
|
396
|
+
"hasMedia": {},
|
|
397
|
+
"iconSize": {}
|
|
291
398
|
};
|
|
292
399
|
}
|
|
293
400
|
static get events() {
|
|
294
401
|
return [{
|
|
402
|
+
"method": "toggleDrag",
|
|
403
|
+
"name": "toggleDrag",
|
|
404
|
+
"bubbles": true,
|
|
405
|
+
"cancelable": true,
|
|
406
|
+
"composed": true,
|
|
407
|
+
"docs": {
|
|
408
|
+
"tags": [],
|
|
409
|
+
"text": ""
|
|
410
|
+
},
|
|
411
|
+
"complexType": {
|
|
412
|
+
"original": "HTMLSwirlResourceListItemElement",
|
|
413
|
+
"resolved": "HTMLSwirlResourceListItemElement",
|
|
414
|
+
"references": {
|
|
415
|
+
"HTMLSwirlResourceListItemElement": {
|
|
416
|
+
"location": "global"
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}, {
|
|
295
421
|
"method": "valueChange",
|
|
296
422
|
"name": "valueChange",
|
|
297
423
|
"bubbles": true,
|
package/dist/collection/components/swirl-resource-list-item/swirl-resource-list-item.spec.js
CHANGED
|
@@ -15,24 +15,21 @@ describe("swirl-resource-list-item", () => {
|
|
|
15
15
|
});
|
|
16
16
|
expect(page.root).toEqualHtml(`
|
|
17
17
|
<swirl-resource-list-item description="Description" label="Label" role="row">
|
|
18
|
-
<
|
|
19
|
-
<
|
|
20
|
-
<
|
|
21
|
-
<
|
|
22
|
-
|
|
18
|
+
<div class="resource-list-item resource-list-item--label-weight-medium" role="gridcell">
|
|
19
|
+
<button aria-labelledby="label" class="resource-list-item__content" part="resource-list-item__content" tabindex="0">
|
|
20
|
+
<span class="resource-list-item__media">
|
|
21
|
+
<swirl-avatar label="John Doe" src="https://picsum.photos/id/433/144/144" slot="media"></swirl-avatar>
|
|
22
|
+
</span>
|
|
23
|
+
<span class="resource-list-item__label-container">
|
|
24
|
+
<span class="resource-list-item__label" id="label">
|
|
25
|
+
Label
|
|
23
26
|
</span>
|
|
24
|
-
<span class="resource-list-
|
|
25
|
-
|
|
26
|
-
Label
|
|
27
|
-
</span>
|
|
28
|
-
<span class="resource-list-item__description">
|
|
29
|
-
Description
|
|
30
|
-
</span>
|
|
27
|
+
<span class="resource-list-item__description">
|
|
28
|
+
Description
|
|
31
29
|
</span>
|
|
32
|
-
</
|
|
33
|
-
</
|
|
34
|
-
</
|
|
35
|
-
<swirl-avatar label="John Doe" src="https://picsum.photos/id/433/144/144" slot="media"></swirl-avatar>
|
|
30
|
+
</span>
|
|
31
|
+
</button>
|
|
32
|
+
</div>
|
|
36
33
|
</swirl-resource-list-item>
|
|
37
34
|
`);
|
|
38
35
|
});
|
|
@@ -43,7 +40,7 @@ describe("swirl-resource-list-item", () => {
|
|
|
43
40
|
<swirl-resource-list-item href="#" label="Label"></swirl-resource-list-item>
|
|
44
41
|
`,
|
|
45
42
|
});
|
|
46
|
-
const element = page.root.
|
|
43
|
+
const element = page.root.querySelector(".resource-list-item__content");
|
|
47
44
|
expect(element.tagName).toBe("A");
|
|
48
45
|
expect(element.getAttribute("href")).toBe("#");
|
|
49
46
|
});
|
|
@@ -56,7 +53,7 @@ describe("swirl-resource-list-item", () => {
|
|
|
56
53
|
});
|
|
57
54
|
const spy = jest.fn();
|
|
58
55
|
page.root.addEventListener("valueChange", spy);
|
|
59
|
-
const element = page.root.
|
|
56
|
+
const element = page.root.querySelector(".resource-list-item__content");
|
|
60
57
|
expect(element.getAttribute("role")).toBe("checkbox");
|
|
61
58
|
expect(element.getAttribute("aria-checked")).toBe("false");
|
|
62
59
|
element.click();
|
|
@@ -75,7 +72,7 @@ describe("swirl-resource-list-item", () => {
|
|
|
75
72
|
<swirl-resource-list-item label="Label" meta="Meta"></swirl-resource-list-item>
|
|
76
73
|
`,
|
|
77
74
|
});
|
|
78
|
-
expect(page.root.
|
|
75
|
+
expect(page.root.querySelector(".resource-list-item__meta")).not.toBeNull();
|
|
79
76
|
});
|
|
80
77
|
it("renders a menu trigger", async () => {
|
|
81
78
|
const page = await newSpecPage({
|
|
@@ -84,6 +81,20 @@ describe("swirl-resource-list-item", () => {
|
|
|
84
81
|
<swirl-resource-list-item label="Label" menu-trigger-id="trigger"></swirl-resource-list-item>
|
|
85
82
|
`,
|
|
86
83
|
});
|
|
87
|
-
expect(page.root.
|
|
84
|
+
expect(page.root.querySelector(".resource-list-item__menu-trigger")).not.toBeNull();
|
|
85
|
+
});
|
|
86
|
+
it("can be draggable", async () => {
|
|
87
|
+
const page = await newSpecPage({
|
|
88
|
+
components: [SwirlResourceListItem],
|
|
89
|
+
html: `<swirl-resource-list-item allow-drag="true" label="Resource List Item"></swirl-resource-list-item>`,
|
|
90
|
+
});
|
|
91
|
+
const spy = jest.fn();
|
|
92
|
+
const dragHandle = page.root.querySelector(".resource-list-item__drag-handle");
|
|
93
|
+
page.root.addEventListener("toggleDrag", spy);
|
|
94
|
+
dragHandle.dispatchEvent(new KeyboardEvent("keydown", { code: "Space" }));
|
|
95
|
+
expect(page.root
|
|
96
|
+
.querySelector(".resource-list-item__drag-handle")
|
|
97
|
+
.getAttribute("aria-label")).toBe('Move item "Resource List Item"');
|
|
98
|
+
expect(spy).toHaveBeenCalled();
|
|
88
99
|
});
|
|
89
100
|
});
|