@fluid-topics/ft-reorderable-list 1.2.48 → 1.2.50

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.
@@ -5,6 +5,7 @@ export declare class FtdsReorderableList extends FtLitElement implements FtdsReo
5
5
  static styles: import("lit").CSSResult;
6
6
  editable: boolean;
7
7
  removable: boolean;
8
+ emptyListMessage: string;
8
9
  items: FtdsReorderableListItem[];
9
10
  list?: HTMLElement;
10
11
  draggableItems?: HTMLElement[];
@@ -15,11 +15,13 @@ import { FtTypography, FtTypographyVariants } 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";
18
+ import { RemoveItemEvent, EditItemEvent, OrderChangeEvent } from "./event";
18
19
  class FtdsReorderableList extends FtLitElement {
19
20
  constructor() {
20
21
  super(...arguments);
21
22
  this.editable = false;
22
23
  this.removable = false;
24
+ this.emptyListMessage = "";
23
25
  this.items = [];
24
26
  this.draggingItem = undefined;
25
27
  }
@@ -31,7 +33,7 @@ class FtdsReorderableList extends FtLitElement {
31
33
  @dragstart="${this.onDragStart}"
32
34
  @dragover="${this.onDragOver}"
33
35
  @dragend="${this.onDragEnd}">
34
- ${repeat(this.items, (item) => live(item.id), (item) => {
36
+ ${this.items.length > 0 ? repeat(this.items, (item) => live(item.id), (item) => {
35
37
  return html `
36
38
  <li role="option"
37
39
  draggable="true"
@@ -49,16 +51,21 @@ class FtdsReorderableList extends FtLitElement {
49
51
  ${this.editable ? html `
50
52
  <ftds-button icon=${FtIcons.ADMIN}
51
53
  family="${DesignSystemFamily.brand}"
52
- size="${DesignSystemSize.large}"></ftds-button>
54
+ size="${DesignSystemSize.large}"
55
+ @click="${() => this.dispatchEvent(new EditItemEvent(item.id))}"
56
+ ></ftds-button>
53
57
  ` : nothing}
54
58
  ${this.removable ? html `
55
59
  <ftds-button icon=${FtIcons.TRASH}
56
60
  family="${DesignSystemFamily.brand}"
57
- size="${DesignSystemSize.large}"></ftds-button>
61
+ size="${DesignSystemSize.large}"
62
+ @click="${() => this.dispatchEvent(new RemoveItemEvent(item.id))}"
63
+ ></ftds-button>
58
64
  ` : nothing}
59
65
  </div>
60
66
  </li>`;
61
- })}
67
+ }) : html `
68
+ <ft-typography variant="${FtTypographyVariants.body2semibold}">${this.emptyListMessage}</ft-typography>`}
62
69
  </ol>
63
70
  <slot part="actions"></slot>
64
71
  </div>
@@ -131,6 +138,7 @@ class FtdsReorderableList extends FtLitElement {
131
138
  this.moveItemDown(itemIndex);
132
139
  }
133
140
  await this.keepFocusOnItem(itemId);
141
+ this.dispatchEvent(new OrderChangeEvent());
134
142
  }
135
143
  else {
136
144
  if (up) {
@@ -166,7 +174,7 @@ class FtdsReorderableList extends FtLitElement {
166
174
  return reorderedItems;
167
175
  }
168
176
  onDragStart(event) {
169
- event.dataTransfer.effectAllowed = 'move';
177
+ event.dataTransfer.effectAllowed = "move";
170
178
  this.draggingItem = event.target;
171
179
  this.draggingItem.classList.add("dragging");
172
180
  }
@@ -190,6 +198,7 @@ class FtdsReorderableList extends FtLitElement {
190
198
  (_a = this.draggableItems) === null || _a === void 0 ? void 0 : _a.forEach(item => item.classList.remove("over"));
191
199
  this.draggingItem.remove();
192
200
  this.draggingItem = undefined;
201
+ this.dispatchEvent(new OrderChangeEvent());
193
202
  }
194
203
  syncReferenceList() {
195
204
  let newOrder = [...this.dragGrips].map((e) => e.dataset.itemId);
@@ -239,6 +248,9 @@ __decorate([
239
248
  __decorate([
240
249
  property({ type: Boolean })
241
250
  ], FtdsReorderableList.prototype, "removable", void 0);
251
+ __decorate([
252
+ property()
253
+ ], FtdsReorderableList.prototype, "emptyListMessage", void 0);
242
254
  __decorate([
243
255
  property()
244
256
  ], FtdsReorderableList.prototype, "items", void 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-reorderable-list",
3
- "version": "1.2.48",
3
+ "version": "1.2.50",
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": "0.1.92",
23
- "@fluid-topics/ft-wc-utils": "1.2.48",
23
+ "@fluid-topics/ft-wc-utils": "1.2.50",
24
24
  "lit": "3.1.0"
25
25
  },
26
26
  "devDependencies": {
27
- "@fluid-topics/ft-wc-test-utils": "1.2.48"
27
+ "@fluid-topics/ft-wc-test-utils": "1.2.50"
28
28
  },
29
- "gitHead": "c2298efffb5e12489201c4c46c6b9cd2911adf58"
29
+ "gitHead": "2cc419b6e01ae50f6ecba171e7b700507a6a85a0"
30
30
  }