@fluid-topics/ft-reorderable-list 1.3.45 → 1.3.46
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/build/ft-reorderable-list.light.js +279 -261
- package/build/ft-reorderable-list.min.js +316 -298
- package/build/ftds-reorderable-list.js +30 -30
- package/package.json +4 -4
|
@@ -11,7 +11,7 @@ import { repeat } from "lit/directives/repeat.js";
|
|
|
11
11
|
import { live } from "lit/directives/live.js";
|
|
12
12
|
import { DesignSystemFamily, DesignSystemSize, FtLitElement } from "@fluid-topics/ft-wc-utils";
|
|
13
13
|
import { styles } from "./ftds-reorderable-list.styles";
|
|
14
|
-
import {
|
|
14
|
+
import { FtdsTypography, FtdsTypographyVariants } from "@fluid-topics/ft-typography";
|
|
15
15
|
import { FtdsButton } from "@fluid-topics/ft-button";
|
|
16
16
|
import { FtIcon, FtIcons } from "@fluid-topics/ft-icon";
|
|
17
17
|
import { FtdsNotice } from "@fluid-topics/ft-notice";
|
|
@@ -30,9 +30,9 @@ class FtdsReorderableList extends FtLitElement {
|
|
|
30
30
|
<div class="ftds-reorderable-list--container">
|
|
31
31
|
<ol role="listbox"
|
|
32
32
|
aria-activedescendant=""
|
|
33
|
-
@dragstart
|
|
34
|
-
@dragover
|
|
35
|
-
@dragend
|
|
33
|
+
@dragstart=${this.onDragStart}
|
|
34
|
+
@dragover=${this.onDragOver}
|
|
35
|
+
@dragend=${this.onDragEnd}>
|
|
36
36
|
${this.items.length > 0 ? repeat(this.items, (item) => live(item.id), (item) => {
|
|
37
37
|
return html `
|
|
38
38
|
<li role="option"
|
|
@@ -49,23 +49,23 @@ class FtdsReorderableList extends FtLitElement {
|
|
|
49
49
|
</div>
|
|
50
50
|
<div class="ftds-reorderable-list-item--right">
|
|
51
51
|
${this.editable ? html `
|
|
52
|
-
<ftds-button icon
|
|
52
|
+
<ftds-button icon="${FtIcons.ADMIN}"
|
|
53
53
|
family="${DesignSystemFamily.brand}"
|
|
54
54
|
size="${DesignSystemSize.large}"
|
|
55
|
-
@click
|
|
55
|
+
@click=${() => this.dispatchEvent(new EditItemEvent(item.id))}
|
|
56
56
|
></ftds-button>
|
|
57
57
|
` : nothing}
|
|
58
58
|
${this.removable ? html `
|
|
59
|
-
<ftds-button icon
|
|
59
|
+
<ftds-button icon="${FtIcons.TRASH}"
|
|
60
60
|
family="${DesignSystemFamily.brand}"
|
|
61
61
|
size="${DesignSystemSize.large}"
|
|
62
|
-
@click
|
|
62
|
+
@click=${() => this.dispatchEvent(new RemoveItemEvent(item.id))}
|
|
63
63
|
></ftds-button>
|
|
64
64
|
` : nothing}
|
|
65
65
|
</div>
|
|
66
66
|
</li>`;
|
|
67
67
|
}) : html `
|
|
68
|
-
<
|
|
68
|
+
<ftds-typography variant="${FtdsTypographyVariants.body2semibold}">${this.emptyListMessage}</ftds-typography>`}
|
|
69
69
|
</ol>
|
|
70
70
|
<slot part="actions"></slot>
|
|
71
71
|
</div>
|
|
@@ -79,27 +79,27 @@ class FtdsReorderableList extends FtLitElement {
|
|
|
79
79
|
size="${DesignSystemSize.medium}"
|
|
80
80
|
data-item-id="${item.id}"
|
|
81
81
|
tabindex="1"
|
|
82
|
-
@keydown
|
|
83
|
-
@focus
|
|
82
|
+
@keydown=${this.onDragButtonKeyDown}
|
|
83
|
+
@focus=${(event) => {
|
|
84
84
|
var _a;
|
|
85
|
-
|
|
85
|
+
const selected = this.getSelectedOption(event);
|
|
86
86
|
selected.setAttribute("aria-selected", "true");
|
|
87
87
|
(_a = this.list) === null || _a === void 0 ? void 0 : _a.setAttribute("aria-activedescendant", `option-${item.id}`);
|
|
88
|
-
}}
|
|
89
|
-
@focusout
|
|
88
|
+
}}
|
|
89
|
+
@focusout=${(event) => {
|
|
90
90
|
var _a;
|
|
91
|
-
|
|
91
|
+
const selected = this.getSelectedOption(event);
|
|
92
92
|
selected.setAttribute("aria-selected", "false");
|
|
93
93
|
(_a = this.list) === null || _a === void 0 ? void 0 : _a.setAttribute("aria-activedescendant", "");
|
|
94
|
-
}}
|
|
95
|
-
@click
|
|
94
|
+
}}
|
|
95
|
+
@click=${(e) => {
|
|
96
96
|
e.target.focus();
|
|
97
|
-
}}
|
|
97
|
+
}}
|
|
98
98
|
|
|
99
99
|
></ft-icon>
|
|
100
|
-
<
|
|
100
|
+
<ftds-typography variant="${FtdsTypographyVariants.body2semibold}">
|
|
101
101
|
${item.label}
|
|
102
|
-
</
|
|
102
|
+
</ftds-typography>
|
|
103
103
|
`;
|
|
104
104
|
}
|
|
105
105
|
renderItemLeftActions(item) {
|
|
@@ -112,7 +112,7 @@ class FtdsReorderableList extends FtLitElement {
|
|
|
112
112
|
family="${DesignSystemFamily.neutral}"
|
|
113
113
|
size="${DesignSystemSize.large}"
|
|
114
114
|
label="${ifDefined(action.label)}"
|
|
115
|
-
@click
|
|
115
|
+
@click=${action.run}>
|
|
116
116
|
${ifDefined(action.text)}
|
|
117
117
|
</ftds-button>
|
|
118
118
|
`)}
|
|
@@ -152,7 +152,7 @@ class FtdsReorderableList extends FtLitElement {
|
|
|
152
152
|
}
|
|
153
153
|
async keepFocusOnItem(itemId) {
|
|
154
154
|
await this.updateComplete;
|
|
155
|
-
|
|
155
|
+
const gripButton = this.shadowRoot.querySelector(`ft-icon[data-item-id="${itemId}"]`);
|
|
156
156
|
gripButton.classList.add("dragging");
|
|
157
157
|
gripButton.focus();
|
|
158
158
|
}
|
|
@@ -183,7 +183,7 @@ class FtdsReorderableList extends FtLitElement {
|
|
|
183
183
|
event.preventDefault();
|
|
184
184
|
const draggingOverItem = this.getDragAfterElement(this.list, event.clientY);
|
|
185
185
|
this.draggingItem.style.cursor = "grabbing";
|
|
186
|
-
(_a = this.draggableItems) === null || _a === void 0 ? void 0 : _a.forEach(item => item.classList.remove("over"));
|
|
186
|
+
(_a = this.draggableItems) === null || _a === void 0 ? void 0 : _a.forEach((item) => item.classList.remove("over"));
|
|
187
187
|
if (draggingOverItem) {
|
|
188
188
|
this.list.insertBefore(this.draggingItem, draggingOverItem);
|
|
189
189
|
}
|
|
@@ -195,14 +195,14 @@ class FtdsReorderableList extends FtLitElement {
|
|
|
195
195
|
var _a;
|
|
196
196
|
this.syncReferenceList();
|
|
197
197
|
event.target.classList.remove("dragging");
|
|
198
|
-
(_a = this.draggableItems) === null || _a === void 0 ? void 0 : _a.forEach(item => item.classList.remove("over"));
|
|
198
|
+
(_a = this.draggableItems) === null || _a === void 0 ? void 0 : _a.forEach((item) => item.classList.remove("over"));
|
|
199
199
|
this.draggingItem.remove();
|
|
200
200
|
this.draggingItem = undefined;
|
|
201
201
|
this.dispatchEvent(new OrderChangeEvent());
|
|
202
202
|
}
|
|
203
203
|
syncReferenceList() {
|
|
204
|
-
|
|
205
|
-
this.items = newOrder.map(id => this.items.find(item => item.id === id));
|
|
204
|
+
const newOrder = [...this.dragGrips].map((e) => e.dataset.itemId);
|
|
205
|
+
this.items = newOrder.map((id) => this.items.find((item) => item.id === id));
|
|
206
206
|
}
|
|
207
207
|
getDragAfterElement(container, y) {
|
|
208
208
|
const draggableElements = [...this.notDraggedItems];
|
|
@@ -219,24 +219,24 @@ class FtdsReorderableList extends FtLitElement {
|
|
|
219
219
|
}
|
|
220
220
|
moveFocusToPreviousItem(itemIndex) {
|
|
221
221
|
if (itemIndex > 0) {
|
|
222
|
-
|
|
222
|
+
const buttonToFocus = this.dragGrips[itemIndex - 1];
|
|
223
223
|
buttonToFocus === null || buttonToFocus === void 0 ? void 0 : buttonToFocus.focus();
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
moveFocusToNextItem(itemIndex) {
|
|
227
227
|
if (itemIndex < this.items.length - 1) {
|
|
228
|
-
|
|
228
|
+
const buttonToFocus = this.dragGrips[itemIndex + 1];
|
|
229
229
|
buttonToFocus === null || buttonToFocus === void 0 ? void 0 : buttonToFocus.focus();
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
getSelectedOption(event) {
|
|
233
|
-
|
|
233
|
+
const target = event.target;
|
|
234
234
|
const itemId = target.dataset.itemId;
|
|
235
235
|
return [...this.draggableItems].find((e) => e.id === itemId);
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
238
|
FtdsReorderableList.elementDefinitions = {
|
|
239
|
-
"
|
|
239
|
+
"ftds-typography": FtdsTypography,
|
|
240
240
|
"ftds-button": FtdsButton,
|
|
241
241
|
"ft-icon": FtIcon,
|
|
242
242
|
"ftds-notice": FtdsNotice,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-reorderable-list",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.46",
|
|
4
4
|
"description": "An reorderable list component",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Lit"
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@fluid-topics/design-system-variables": "2.53.1",
|
|
23
|
-
"@fluid-topics/ft-wc-utils": "1.3.
|
|
23
|
+
"@fluid-topics/ft-wc-utils": "1.3.46",
|
|
24
24
|
"lit": "3.1.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@fluid-topics/ft-wc-test-utils": "1.3.
|
|
27
|
+
"@fluid-topics/ft-wc-test-utils": "1.3.46"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "d6cf25d6ed0dead8c7aff4f94a493c35d12f1392"
|
|
30
30
|
}
|