@getflip/swirl-components 0.67.0 → 0.68.1
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-avatar.cjs.entry.js +1 -1
- package/dist/cjs/swirl-card.cjs.entry.js +1 -1
- package/dist/cjs/swirl-components.cjs.js +1 -1
- package/dist/cjs/swirl-modal.cjs.entry.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-avatar/swirl-avatar.css +1 -1
- package/dist/collection/components/swirl-card/swirl-card.css +3 -0
- package/dist/collection/components/swirl-modal/swirl-modal.css +9 -0
- 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 +61 -3
- 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-avatar.js +1 -1
- package/dist/components/swirl-card.js +1 -1
- package/dist/components/swirl-modal.js +1 -1
- 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-avatar.entry.js +1 -1
- package/dist/esm/swirl-card.entry.js +1 -1
- package/dist/esm/swirl-components.js +1 -1
- package/dist/esm/swirl-modal.entry.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-192d2465.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/p-8d01c725.entry.js +10 -0
- package/dist/swirl-components/p-b0131a2e.entry.js +1 -0
- package/dist/swirl-components/p-fbc7f835.entry.js +1 -0
- package/dist/swirl-components/swirl-components.css +1 -1
- 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-49a2e41e.entry.js +0 -10
- package/dist/swirl-components/p-66abd436.entry.js +0 -1
- package/dist/swirl-components/p-78c61caf.entry.js +0 -1
- 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
|
@@ -7,13 +7,12 @@ import { d as defineCustomElement$4 } from './swirl-inline-error2.js';
|
|
|
7
7
|
import { d as defineCustomElement$3 } from './swirl-spinner2.js';
|
|
8
8
|
import { d as defineCustomElement$2 } from './swirl-visually-hidden2.js';
|
|
9
9
|
|
|
10
|
-
const swirlResourceListFileItemCss = "
|
|
10
|
+
const swirlResourceListFileItemCss = ".sc-swirl-resource-list-file-item-h{display:block;width:100%}.sc-swirl-resource-list-file-item-h *.sc-swirl-resource-list-file-item{box-sizing:border-box}.resource-list-file-item.sc-swirl-resource-list-file-item{position:relative;display:flex;width:100%;padding:var(--s-space-12) var(--s-space-16);align-items:center;background-color:var(--s-background-default);line-height:var(--s-line-height-base);gap:var(--s-space-12)}.resource-list-file-item.sc-swirl-resource-list-file-item:focus{outline:none}.resource-list-file-item.sc-swirl-resource-list-file-item:focus-visible{background-color:var(--s-background-hovered)}@media (min-width: 992px) and (max-width: 1439px) and (hover: hover),(min-width: 1440px){.resource-list-file-item.sc-swirl-resource-list-file-item{padding:var(--s-space-12);font-size:var(--s-font-size-sm);line-height:var(--s-line-height-sm)}}.resource-list-file-item--has-control.sc-swirl-resource-list-file-item .resource-list-file-item__label-container.sc-swirl-resource-list-file-item{padding-right:calc(var(--s-space-12) + 2.5rem)}.resource-list-file-item__icon.sc-swirl-resource-list-file-item{color:var(--s-icon-highlight)}.resource-list-file-item__label-container.sc-swirl-resource-list-file-item{position:relative;display:flex;min-width:0;min-height:2.875rem;flex-grow:1;justify-content:center;flex-direction:column}.resource-list-file-item__label-container.sc-swirl-resource-list-file-item:after{position:absolute;right:0;bottom:calc(-1 * var(--s-space-12));left:0;height:0.0625rem;background-color:var(--s-border-default);content:\"\"}.resource-list-file-item__label.sc-swirl-resource-list-file-item{overflow:hidden;font-weight:var(--s-font-weight-medium);white-space:nowrap;text-overflow:ellipsis}.resource-list-file-item__description.sc-swirl-resource-list-file-item{overflow:hidden;margin-top:var(--s-space-2);color:var(--s-text-subdued);font-size:var(--s-font-size-sm);line-height:var(--s-line-height-sm);white-space:nowrap;text-overflow:ellipsis}.resource-list-file-item__error-message.sc-swirl-resource-list-file-item{margin-top:var(--s-space-2)}.resource-list-file-item__remove-button.sc-swirl-resource-list-file-item{position:absolute;top:50%;right:var(--s-space-16);display:inline-flex;transform:translateY(-50%)}.resource-list-file-item__spinner.sc-swirl-resource-list-file-item{position:absolute;top:50%;right:var(--s-space-24);display:inline-flex;transform:translateY(-50%)}";
|
|
11
11
|
|
|
12
12
|
const SwirlResourceListFileItem$1 = /*@__PURE__*/ proxyCustomElement(class SwirlResourceListFileItem extends HTMLElement {
|
|
13
13
|
constructor() {
|
|
14
14
|
super();
|
|
15
15
|
this.__registerHost();
|
|
16
|
-
this.__attachShadow();
|
|
17
16
|
this.remove = createEvent(this, "remove", 7);
|
|
18
17
|
this.desktopMediaQuery = getDesktopMediaQuery();
|
|
19
18
|
this.desktopMediaQueryHandler = (event) => {
|
|
@@ -53,7 +52,7 @@ const SwirlResourceListFileItem$1 = /*@__PURE__*/ proxyCustomElement(class Swirl
|
|
|
53
52
|
return (h(Host, { role: "row" }, h("div", { class: className, part: "resource-list-file-item", role: "gridcell" }, h("span", { class: "resource-list-file-item__icon", innerHTML: this.icon, ref: (el) => (this.iconEl = el) }), h("span", { class: "resource-list-file-item__label-container" }, h("span", { class: "resource-list-file-item__label", id: "label" }, this.label), showDescription && (h("span", { class: "resource-list-file-item__description" }, this.description)), showError && (h("span", { "aria-live": "polite", class: "resource-list-file-item__error-message" }, h("swirl-inline-error", { message: this.errorMessage, size: "s" })))), showSpinner && (h("span", { class: "resource-list-file-item__spinner" }, h("swirl-spinner", { size: "s" }))), showRemoveButton && (h("span", { class: "resource-list-file-item__remove-button" }, h("swirl-button", { hideLabel: true, icon: "<swirl-icon-close></swirl-icon-close>", label: this.removeButtonLabel, onClick: this.remove.emit }))))));
|
|
54
53
|
}
|
|
55
54
|
static get style() { return swirlResourceListFileItemCss; }
|
|
56
|
-
}, [
|
|
55
|
+
}, [2, "swirl-resource-list-file-item", {
|
|
57
56
|
"description": [1],
|
|
58
57
|
"errorMessage": [1, "error-message"],
|
|
59
58
|
"icon": [1],
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
2
2
|
import { c as classnames } from './index2.js';
|
|
3
|
-
import {
|
|
4
|
-
import { d as defineCustomElement$
|
|
3
|
+
import { g as getDesktopMediaQuery } from './utils.js';
|
|
4
|
+
import { d as defineCustomElement$3 } from './swirl-button2.js';
|
|
5
|
+
import { d as defineCustomElement$2 } from './swirl-icon-check-strong2.js';
|
|
6
|
+
import { d as defineCustomElement$1 } from './swirl-icon-drag-handle2.js';
|
|
5
7
|
|
|
6
|
-
const swirlResourceListItemCss = ":
|
|
8
|
+
const swirlResourceListItemCss = ".sc-swirl-resource-list-item-h{position:relative;display:block;width:100%}.sc-swirl-resource-list-item-h *.sc-swirl-resource-list-item{box-sizing:border-box}.resource-list-item.sc-swirl-resource-list-item{position:relative;width:100%}.resource-list-item.sc-swirl-resource-list-item:hover{--swirl-ghost-button-background-default:var(--s-background-hovered)}.resource-list-item--checked.sc-swirl-resource-list-item .resource-list-item__checkbox.sc-swirl-resource-list-item{border-color:var(--s-icon-highlight);color:var(--s-text-on-status);background-color:var(--s-icon-highlight)}.resource-list-item--has-menu.sc-swirl-resource-list-item .resource-list-item__label-container.sc-swirl-resource-list-item{padding-right:calc(var(--s-space-16) + 2.5rem + var(--s-space-12))}@media (min-width: 768px){.resource-list-item--selectable.sc-swirl-resource-list-item .resource-list-item__content.sc-swirl-resource-list-item{padding-left:calc(var(--s-space-16) + 1.5rem + var(--s-space-12))}}.resource-list-item--selectable.sc-swirl-resource-list-item .resource-list-item__label-container.sc-swirl-resource-list-item{padding-right:calc(var(--s-space-16) + 1.5rem + var(--s-space-12))}@media (min-width: 768px){.resource-list-item--selectable.sc-swirl-resource-list-item .resource-list-item__label-container.sc-swirl-resource-list-item{padding-right:var(--s-space-16)}}.resource-list-item--hide-divider.sc-swirl-resource-list-item .resource-list-item__label-container.sc-swirl-resource-list-item:after{display:none}.resource-list-item--label-weight-medium.sc-swirl-resource-list-item{font-weight:var(--s-font-weight-medium)}.resource-list-item--draggable.sc-swirl-resource-list-item .resource-list-item__content.sc-swirl-resource-list-item{padding-left:calc(var(--s-space-16) * 2 + 1.5rem)}@media (min-width: 992px) and (max-width: 1439px) and (hover: hover),(min-width: 1440px){.resource-list-item--draggable.sc-swirl-resource-list-item .resource-list-item__content.sc-swirl-resource-list-item{padding-left:calc(var(--s-space-16) * 2 + 1rem)}}.resource-list-item--dragging.sc-swirl-resource-list-item{z-index:1;border-radius:var(--s-border-radius-s);background-color:var(--s-surface-overlay-pressed);box-shadow:0 0.0625rem 0.125rem rgba(25, 26, 28, 0.08),\n 0 0.25rem 2rem rgba(25, 26, 28, 0.16)}.resource-list-item--dragging.sc-swirl-resource-list-item:hover:not(.resource-list-item--disabled){background-color:var(--s-surface-overlay-pressed)}.resource-list-item__content.sc-swirl-resource-list-item{--swirl-avatar-group-border-color:var(--s-background-default);--swirl-badge-border-color:var(--s-background-default);display:flex;width:100%;margin:0;padding-top:var(--s-space-12);padding-right:0;padding-bottom:var(--s-space-12);padding-left:var(--s-space-16);align-items:center;border:none;color:var(--s-text-default);background-color:var(--swirl-resource-list-item-background-default);font:inherit;line-height:var(--s-line-height-base);text-align:left;text-decoration:none;cursor:pointer;gap:var(--s-space-12)}.resource-list-item__content.sc-swirl-resource-list-item:hover:not(:disabled){background-color:var(--swirl-resource-list-item-background-hovered)}.resource-list-item__content.sc-swirl-resource-list-item:hover:not(:disabled) .resource-list-item__media.sc-swirl-resource-list-item{--swirl-avatar-background-color:var(--s-surface-raised-hovered);--swirl-avatar-group-border-color:var(--s-background-hovered);--swirl-badge-border-color:var(--s-background-hovered)}.resource-list-item__content.sc-swirl-resource-list-item:active:not(:disabled){background-color:var(--swirl-resource-list-item-background-pressed)}.resource-list-item__content.sc-swirl-resource-list-item:active:not(:disabled) .resource-list-item__media.sc-swirl-resource-list-item{--swirl-avatar-group-border-color:var(--s-background-pressed);--swirl-badge-border-color:var(--s-background-pressed)}.resource-list-item__content.sc-swirl-resource-list-item:focus{outline:none}.resource-list-item__content.sc-swirl-resource-list-item:focus-visible{background-color:var(--s-background-hovered)}.resource-list-item__content.sc-swirl-resource-list-item:focus-visible .resource-list-item__media.sc-swirl-resource-list-item{--swirl-avatar-group-border-color:var(--s-background-hovered);--swirl-badge-border-color:var(--s-background-hovered)}.resource-list-item__content.sc-swirl-resource-list-item:disabled{color:var(--s-text-disabled);background-color:var(--s-background-default);cursor:default}.resource-list-item__content.sc-swirl-resource-list-item:disabled .resource-list-item__description.sc-swirl-resource-list-item{color:var(--s-text-disabled)}@media (min-width: 992px) and (max-width: 1439px) and (hover: hover),(min-width: 1440px){.resource-list-item__content.sc-swirl-resource-list-item{padding:var(--s-space-12);font-size:var(--s-font-size-sm);line-height:var(--s-line-height-sm)}}.resource-list-item__media.sc-swirl-resource-list-item{display:inline-flex}.resource-list-item__label-container.sc-swirl-resource-list-item{position:relative;display:flex;min-width:0;min-height:2.875rem;padding-right:var(--s-space-16);flex-grow:1;justify-content:center;flex-direction:column}.resource-list-item__label-container.sc-swirl-resource-list-item:after{position:absolute;right:0;bottom:calc(-1 * var(--s-space-12));left:0;height:0.0625rem;background-color:var(--s-border-default);content:\"\"}.resource-list-item__label.sc-swirl-resource-list-item{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.resource-list-item__label.sc-swirl-resource-list-item b.sc-swirl-resource-list-item,.resource-list-item__label.sc-swirl-resource-list-item strong.sc-swirl-resource-list-item{font-weight:var(--s-font-weight-semibold)}.resource-list-item__description.sc-swirl-resource-list-item{overflow:hidden;margin-top:var(--s-space-2);color:var(--s-text-subdued);font-size:var(--s-font-size-sm);line-height:var(--s-line-height-sm);white-space:nowrap;text-overflow:ellipsis}.resource-list-item__menu-trigger.sc-swirl-resource-list-item{position:absolute;top:50%;right:var(--s-space-16);transform:translateY(-50%)}.resource-list-item__checkbox.sc-swirl-resource-list-item{position:absolute;top:50%;right:var(--s-space-16);display:flex;width:1.25rem;height:1.25rem;justify-content:center;align-items:center;border:0.125rem solid var(--s-icon-default);border-radius:var(--s-border-radius-s);transform:translateY(-50%);pointer-events:none}@media (min-width: 768px){.resource-list-item__checkbox.sc-swirl-resource-list-item{right:auto;left:var(--s-space-16)}}.resource-list-item__checkbox-icon.sc-swirl-resource-list-item{display:inline-flex;width:1.0625rem;height:1.0625rem}.resource-list-item__checkbox-icon.sc-swirl-resource-list-item>*.sc-swirl-resource-list-item::part(icon){width:1.0625rem;height:1.0625rem}.resource-list-item__meta.sc-swirl-resource-list-item{position:absolute;top:calc(var(--s-space-12) + var(--s-space-4));right:var(--s-space-16);color:var(--s-text-subdued);font-size:var(--s-font-size-sm)}.resource-list-item__drag-handle.sc-swirl-resource-list-item{position:absolute;z-index:1;top:50%;left:var(--s-space-4);display:inline-flex;margin:0;padding:0;padding:var(--s-space-8);flex-shrink:0;border:none;color:var(--s-icon-default);background-color:transparent;cursor:grab;transform:translateY(-50%)}.resource-list-item__drag-handle.sc-swirl-resource-list-item:active{cursor:grabbing}.resource-list-item__drag-handle.sc-swirl-resource-list-item:focus:not(:focus-visible){outline:none}.resource-list-item__drag-handle.sc-swirl-resource-list-item:focus-visible{outline-color:var(--s-focus-default)}";
|
|
7
9
|
|
|
8
10
|
const SwirlResourceListItem = /*@__PURE__*/ proxyCustomElement(class SwirlResourceListItem extends HTMLElement {
|
|
9
11
|
constructor() {
|
|
10
12
|
super();
|
|
11
13
|
this.__registerHost();
|
|
12
|
-
this.
|
|
14
|
+
this.toggleDrag = createEvent(this, "toggleDrag", 7);
|
|
13
15
|
this.valueChange = createEvent(this, "valueChange", 7);
|
|
16
|
+
this.desktopMediaQuery = getDesktopMediaQuery();
|
|
17
|
+
this.desktopMediaQueryHandler = (event) => {
|
|
18
|
+
this.forceIconProps(event.matches);
|
|
19
|
+
this.updateIconSize(event.matches);
|
|
20
|
+
};
|
|
14
21
|
this.onClick = () => {
|
|
15
22
|
if (!this.selectable) {
|
|
16
23
|
return;
|
|
@@ -23,9 +30,19 @@ const SwirlResourceListItem = /*@__PURE__*/ proxyCustomElement(class SwirlResour
|
|
|
23
30
|
event.stopPropagation();
|
|
24
31
|
}
|
|
25
32
|
};
|
|
33
|
+
this.onDragHandleKeyDown = (event) => {
|
|
34
|
+
if (event.code === "Space" || event.code === "Enter") {
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
this.toggleDrag.emit(this.el);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
this.allowDrag = undefined;
|
|
26
40
|
this.checked = false;
|
|
27
41
|
this.description = undefined;
|
|
28
42
|
this.disabled = undefined;
|
|
43
|
+
this.dragging = undefined;
|
|
44
|
+
this.dragHandleDescription = "Press spacebar to toggle grab";
|
|
45
|
+
this.dragHandleLabel = "Move item";
|
|
29
46
|
this.hideDivider = undefined;
|
|
30
47
|
this.href = undefined;
|
|
31
48
|
this.label = undefined;
|
|
@@ -36,10 +53,28 @@ const SwirlResourceListItem = /*@__PURE__*/ proxyCustomElement(class SwirlResour
|
|
|
36
53
|
this.selectable = undefined;
|
|
37
54
|
this.value = undefined;
|
|
38
55
|
this.hasMedia = false;
|
|
56
|
+
this.iconSize = 24;
|
|
39
57
|
}
|
|
40
58
|
async componentWillLoad() {
|
|
41
59
|
this.updateMediaState();
|
|
42
60
|
}
|
|
61
|
+
componentDidLoad() {
|
|
62
|
+
this.forceIconProps(this.desktopMediaQuery.matches);
|
|
63
|
+
this.updateIconSize(this.desktopMediaQuery.matches);
|
|
64
|
+
this.desktopMediaQuery.onchange = this.desktopMediaQueryHandler;
|
|
65
|
+
}
|
|
66
|
+
disconnectedCallback() {
|
|
67
|
+
var _a, _b;
|
|
68
|
+
(_b = (_a = this.desktopMediaQuery).removeEventListener) === null || _b === void 0 ? void 0 : _b.call(_a, "change", this.desktopMediaQueryHandler);
|
|
69
|
+
}
|
|
70
|
+
forceIconProps(smallIcon) {
|
|
71
|
+
var _a;
|
|
72
|
+
const icon = (_a = this.iconEl) === null || _a === void 0 ? void 0 : _a.children[0];
|
|
73
|
+
icon === null || icon === void 0 ? void 0 : icon.setAttribute("size", smallIcon ? "20" : "24");
|
|
74
|
+
}
|
|
75
|
+
updateIconSize(smallIcon) {
|
|
76
|
+
this.iconSize = smallIcon ? 20 : 24;
|
|
77
|
+
}
|
|
43
78
|
updateMediaState() {
|
|
44
79
|
const mediaContainer = this.el.querySelector('[slot="media"]');
|
|
45
80
|
const hasMedia = Boolean(mediaContainer);
|
|
@@ -57,18 +92,24 @@ const SwirlResourceListItem = /*@__PURE__*/ proxyCustomElement(class SwirlResour
|
|
|
57
92
|
const role = this.selectable ? "checkbox" : undefined;
|
|
58
93
|
const className = classnames("resource-list-item", `resource-list-item--label-weight-${this.labelWeight}`, {
|
|
59
94
|
"resource-list-item--checked": this.checked,
|
|
95
|
+
"resource-list-item--draggable": this.allowDrag,
|
|
96
|
+
"resource-list-item--dragging": this.dragging,
|
|
60
97
|
"resource-list-item--has-menu": hasMenu,
|
|
61
98
|
"resource-list-item--hide-divider": this.hideDivider,
|
|
62
99
|
"resource-list-item--selectable": this.selectable,
|
|
63
100
|
});
|
|
64
|
-
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 })))));
|
|
101
|
+
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 })))));
|
|
65
102
|
}
|
|
66
103
|
get el() { return this; }
|
|
67
104
|
static get style() { return swirlResourceListItemCss; }
|
|
68
|
-
}, [
|
|
105
|
+
}, [6, "swirl-resource-list-item", {
|
|
106
|
+
"allowDrag": [4, "allow-drag"],
|
|
69
107
|
"checked": [1028],
|
|
70
108
|
"description": [1],
|
|
71
109
|
"disabled": [4],
|
|
110
|
+
"dragging": [4],
|
|
111
|
+
"dragHandleDescription": [1, "drag-handle-description"],
|
|
112
|
+
"dragHandleLabel": [1, "drag-handle-label"],
|
|
72
113
|
"hideDivider": [4, "hide-divider"],
|
|
73
114
|
"href": [1],
|
|
74
115
|
"label": [1],
|
|
@@ -78,13 +119,14 @@ const SwirlResourceListItem = /*@__PURE__*/ proxyCustomElement(class SwirlResour
|
|
|
78
119
|
"meta": [1],
|
|
79
120
|
"selectable": [4],
|
|
80
121
|
"value": [1],
|
|
81
|
-
"hasMedia": [32]
|
|
122
|
+
"hasMedia": [32],
|
|
123
|
+
"iconSize": [32]
|
|
82
124
|
}]);
|
|
83
125
|
function defineCustomElement() {
|
|
84
126
|
if (typeof customElements === "undefined") {
|
|
85
127
|
return;
|
|
86
128
|
}
|
|
87
|
-
const components = ["swirl-resource-list-item", "swirl-button", "swirl-icon-check-strong"];
|
|
129
|
+
const components = ["swirl-resource-list-item", "swirl-button", "swirl-icon-check-strong", "swirl-icon-drag-handle"];
|
|
88
130
|
components.forEach(tagName => { switch (tagName) {
|
|
89
131
|
case "swirl-resource-list-item":
|
|
90
132
|
if (!customElements.get(tagName)) {
|
|
@@ -93,10 +135,15 @@ function defineCustomElement() {
|
|
|
93
135
|
break;
|
|
94
136
|
case "swirl-button":
|
|
95
137
|
if (!customElements.get(tagName)) {
|
|
96
|
-
defineCustomElement$
|
|
138
|
+
defineCustomElement$3();
|
|
97
139
|
}
|
|
98
140
|
break;
|
|
99
141
|
case "swirl-icon-check-strong":
|
|
142
|
+
if (!customElements.get(tagName)) {
|
|
143
|
+
defineCustomElement$2();
|
|
144
|
+
}
|
|
145
|
+
break;
|
|
146
|
+
case "swirl-icon-drag-handle":
|
|
100
147
|
if (!customElements.get(tagName)) {
|
|
101
148
|
defineCustomElement$1();
|
|
102
149
|
}
|
|
@@ -1,23 +1,70 @@
|
|
|
1
|
-
import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
|
|
2
|
-
import {
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
2
|
+
import { S as Sortable } from './sortable.esm.js';
|
|
3
|
+
import { d as defineCustomElement$2 } from './swirl-stack2.js';
|
|
4
|
+
import { d as defineCustomElement$1 } from './swirl-visually-hidden2.js';
|
|
3
5
|
|
|
4
|
-
const swirlResourceListCss = "
|
|
6
|
+
const swirlResourceListCss = ".sc-swirl-resource-list-h{display:block;width:100%}.sc-swirl-resource-list-h *.sc-swirl-resource-list{box-sizing:border-box}";
|
|
5
7
|
|
|
6
8
|
const SwirlResourceList = /*@__PURE__*/ proxyCustomElement(class SwirlResourceList extends HTMLElement {
|
|
7
9
|
constructor() {
|
|
8
10
|
super();
|
|
9
11
|
this.__registerHost();
|
|
10
|
-
this.
|
|
12
|
+
this.itemDrop = createEvent(this, "itemDrop", 7);
|
|
11
13
|
this.focusedIndex = 0;
|
|
14
|
+
this.toggleDrag = (event) => {
|
|
15
|
+
const item = event.detail;
|
|
16
|
+
if (Boolean(this.dragging)) {
|
|
17
|
+
this.stopDrag(item);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
this.startDrag(item);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
this.startDrag = (item) => {
|
|
24
|
+
this.dragging = item;
|
|
25
|
+
this.draggingStartIndex = this.getItemIndex(this.dragging);
|
|
26
|
+
item.setAttribute("dragging", "true");
|
|
27
|
+
const index = this.getItemIndex(this.dragging);
|
|
28
|
+
this.focusItemAtIndex(index);
|
|
29
|
+
this.assistiveText = this.assistiveTextItemGrabbed;
|
|
30
|
+
};
|
|
31
|
+
this.stopDrag = (item) => {
|
|
32
|
+
const newIndex = this.getItemIndex(this.dragging);
|
|
33
|
+
this.dragging = undefined;
|
|
34
|
+
item.removeAttribute("dragging");
|
|
35
|
+
this.assistiveText = `${this.assistiveTextItemMoved} ${newIndex + 1}`;
|
|
36
|
+
this.itemDrop.emit({ item, oldIndex: this.draggingStartIndex, newIndex });
|
|
37
|
+
this.draggingStartIndex = undefined;
|
|
38
|
+
};
|
|
12
39
|
this.onKeyDown = (event) => {
|
|
13
40
|
if (event.key === "ArrowDown") {
|
|
14
41
|
event.preventDefault();
|
|
15
|
-
|
|
42
|
+
if (!Boolean(this.dragging)) {
|
|
43
|
+
this.focusItemAtIndex((this.focusedIndex + 1) % this.items.length);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
this.moveDraggedItemDown();
|
|
47
|
+
}
|
|
16
48
|
}
|
|
17
49
|
else if (event.key === "ArrowUp") {
|
|
18
50
|
event.preventDefault();
|
|
19
|
-
|
|
20
|
-
|
|
51
|
+
if (!Boolean(this.dragging)) {
|
|
52
|
+
const prevIndex = this.focusedIndex === 0
|
|
53
|
+
? this.items.length - 1
|
|
54
|
+
: this.focusedIndex - 1;
|
|
55
|
+
this.focusItemAtIndex(prevIndex);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
this.moveDraggedItemUp();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else if (event.key === "Space" || event.key === "Enter") {
|
|
62
|
+
const target = event.composedPath()[0];
|
|
63
|
+
if (Boolean(this.dragging) &&
|
|
64
|
+
!(target === null || target === void 0 ? void 0 : target.classList.contains("resource-list-item__drag-handle"))) {
|
|
65
|
+
event.preventDefault();
|
|
66
|
+
this.stopDrag(this.dragging);
|
|
67
|
+
}
|
|
21
68
|
}
|
|
22
69
|
else if (event.key === "Home") {
|
|
23
70
|
event.preventDefault();
|
|
@@ -31,28 +78,79 @@ const SwirlResourceList = /*@__PURE__*/ proxyCustomElement(class SwirlResourceLi
|
|
|
31
78
|
this.onSlotChange = () => {
|
|
32
79
|
this.collectItems();
|
|
33
80
|
};
|
|
81
|
+
this.allowDrag = undefined;
|
|
82
|
+
this.assistiveTextItemGrabbed = "Item grabbed. Use arrow keys to move item up or down. Use spacebar to save position.";
|
|
83
|
+
this.assistiveTextItemMoving = "Current position:";
|
|
84
|
+
this.assistiveTextItemMoved = "Item moved. New position:";
|
|
34
85
|
this.label = undefined;
|
|
86
|
+
this.assistiveText = undefined;
|
|
35
87
|
}
|
|
36
88
|
componentDidLoad() {
|
|
37
89
|
this.collectItems();
|
|
90
|
+
this.setItemAllowDragState();
|
|
91
|
+
this.setupDragDrop();
|
|
92
|
+
}
|
|
93
|
+
disconnectedCallback() {
|
|
94
|
+
var _a;
|
|
95
|
+
(_a = this.sortable) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
96
|
+
}
|
|
97
|
+
watchAllowDrag() {
|
|
98
|
+
this.setItemAllowDragState();
|
|
99
|
+
this.setupDragDrop();
|
|
38
100
|
}
|
|
39
101
|
collectItems() {
|
|
40
102
|
this.items = Array.from(this.el.querySelectorAll("swirl-resource-list-item, swirl-resource-list-file-item")).filter((el) => el.isConnected);
|
|
41
103
|
this.removeItemsFromTabOrder();
|
|
42
104
|
this.enableItemFocus(this.items[this.focusedIndex]);
|
|
43
105
|
}
|
|
106
|
+
getItemIndex(item) {
|
|
107
|
+
return this.items.map((i) => i).findIndex((i) => i === item);
|
|
108
|
+
}
|
|
44
109
|
removeItemsFromTabOrder() {
|
|
45
110
|
this.items.forEach((item) => {
|
|
46
|
-
var _a
|
|
47
|
-
return (
|
|
111
|
+
var _a;
|
|
112
|
+
return (_a = item === null || item === void 0 ? void 0 : item.querySelector(".resource-list-item__content, .resource-list-file-item")) === null || _a === void 0 ? void 0 : _a.setAttribute("tabIndex", "-1");
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
setItemAllowDragState() {
|
|
116
|
+
if (this.allowDrag) {
|
|
117
|
+
this.items.forEach((item) => {
|
|
118
|
+
item.setAttribute("allow-drag", "true");
|
|
119
|
+
item.addEventListener("toggleDrag", this.toggleDrag);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
this.items.forEach((item) => {
|
|
124
|
+
item.removeAttribute("allow-drag");
|
|
125
|
+
item.removeEventListener("toggleDrag", this.toggleDrag);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
setupDragDrop() {
|
|
130
|
+
if (Boolean(this.sortable)) {
|
|
131
|
+
this.sortable.destroy();
|
|
132
|
+
}
|
|
133
|
+
if (!this.allowDrag) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
this.sortable = Sortable.create(this.gridEl, {
|
|
137
|
+
animation: 150,
|
|
138
|
+
draggable: "swirl-resource-list-item",
|
|
139
|
+
handle: ".resource-list-item__drag-handle",
|
|
140
|
+
onEnd: (event) => {
|
|
141
|
+
this.itemDrop.emit({
|
|
142
|
+
item: event.item,
|
|
143
|
+
oldIndex: event.oldIndex,
|
|
144
|
+
newIndex: event.newIndex,
|
|
145
|
+
});
|
|
146
|
+
},
|
|
48
147
|
});
|
|
49
148
|
}
|
|
50
149
|
enableItemFocus(item, focus) {
|
|
51
|
-
var _a;
|
|
52
150
|
if (!Boolean(item)) {
|
|
53
151
|
return;
|
|
54
152
|
}
|
|
55
|
-
const interactiveElement =
|
|
153
|
+
const interactiveElement = item.querySelector(".resource-list-item__content, .resource-list-file-item");
|
|
56
154
|
if (!Boolean(interactiveElement)) {
|
|
57
155
|
return;
|
|
58
156
|
}
|
|
@@ -70,19 +168,47 @@ const SwirlResourceList = /*@__PURE__*/ proxyCustomElement(class SwirlResourceLi
|
|
|
70
168
|
this.enableItemFocus(item, true);
|
|
71
169
|
this.focusedIndex = index;
|
|
72
170
|
}
|
|
171
|
+
moveDraggedItemDown() {
|
|
172
|
+
const nextSibling = this.dragging.nextElementSibling;
|
|
173
|
+
if (!Boolean(nextSibling)) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
nextSibling.after(this.dragging);
|
|
177
|
+
this.collectItems();
|
|
178
|
+
this.focusItemAtIndex(this.getItemIndex(this.dragging));
|
|
179
|
+
this.assistiveText = `${this.assistiveTextItemMoving} ${this.getItemIndex(this.dragging) + 1}`;
|
|
180
|
+
}
|
|
181
|
+
moveDraggedItemUp() {
|
|
182
|
+
const prevSibling = this.dragging.previousElementSibling;
|
|
183
|
+
if (!Boolean(prevSibling)) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
prevSibling.before(this.dragging);
|
|
187
|
+
this.collectItems();
|
|
188
|
+
this.focusItemAtIndex(this.getItemIndex(this.dragging));
|
|
189
|
+
this.assistiveText = `${this.assistiveTextItemMoving} ${this.getItemIndex(this.dragging) + 1}`;
|
|
190
|
+
}
|
|
73
191
|
render() {
|
|
74
|
-
return (h(Host, { onKeyDown: this.onKeyDown }, h("swirl-stack", { "aria-label": this.label, role: "grid" }, h("slot", { onSlotchange: this.onSlotChange }))));
|
|
192
|
+
return (h(Host, { onKeyDown: this.onKeyDown }, h("swirl-visually-hidden", { role: "alert" }, this.assistiveText), h("swirl-stack", { "aria-label": this.label, class: "resource-list", ref: (el) => (this.gridEl = el), role: "grid" }, h("slot", { onSlotchange: this.onSlotChange }))));
|
|
75
193
|
}
|
|
76
194
|
get el() { return this; }
|
|
195
|
+
static get watchers() { return {
|
|
196
|
+
"allowDrag": ["watchAllowDrag"]
|
|
197
|
+
}; }
|
|
77
198
|
static get style() { return swirlResourceListCss; }
|
|
78
|
-
}, [
|
|
79
|
-
"
|
|
199
|
+
}, [6, "swirl-resource-list", {
|
|
200
|
+
"allowDrag": [4, "allow-drag"],
|
|
201
|
+
"assistiveTextItemGrabbed": [1, "assistive-text-item-grabbed"],
|
|
202
|
+
"assistiveTextItemMoving": [1, "assistive-text-item-moving"],
|
|
203
|
+
"assistiveTextItemMoved": [1, "assistive-text-item-moved"],
|
|
204
|
+
"label": [1],
|
|
205
|
+
"assistiveText": [32]
|
|
80
206
|
}]);
|
|
81
207
|
function defineCustomElement() {
|
|
82
208
|
if (typeof customElements === "undefined") {
|
|
83
209
|
return;
|
|
84
210
|
}
|
|
85
|
-
const components = ["swirl-resource-list", "swirl-stack"];
|
|
211
|
+
const components = ["swirl-resource-list", "swirl-stack", "swirl-visually-hidden"];
|
|
86
212
|
components.forEach(tagName => { switch (tagName) {
|
|
87
213
|
case "swirl-resource-list":
|
|
88
214
|
if (!customElements.get(tagName)) {
|
|
@@ -90,6 +216,11 @@ function defineCustomElement() {
|
|
|
90
216
|
}
|
|
91
217
|
break;
|
|
92
218
|
case "swirl-stack":
|
|
219
|
+
if (!customElements.get(tagName)) {
|
|
220
|
+
defineCustomElement$2();
|
|
221
|
+
}
|
|
222
|
+
break;
|
|
223
|
+
case "swirl-visually-hidden":
|
|
93
224
|
if (!customElements.get(tagName)) {
|
|
94
225
|
defineCustomElement$1();
|
|
95
226
|
}
|