Skip to content

Commit

Permalink
Update List.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettmflynn committed Apr 17, 2024
1 parent d44dc15 commit 1a8d8d7
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/renderer/src/stories/List.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export class List extends LitElement {
overflow: auto;
}
#empty {
margin: 1rem;
margin-left: -40px;
Expand Down Expand Up @@ -148,10 +147,11 @@ export class List extends LitElement {
#previousItems = []
#items: ListItemType[] = []

set items(value: ListItemType[]) {
set items(value: ListItemType[] | any[]) {

const oldList = this.#previousItems
this.#items = value.map(item => this.transform ? this.transform(item) ?? item : item)
const uniform = value.map(item => item && typeof item === 'object' ? item : { value: item })
this.#items = uniform.map(item => this.transform ? this.transform(item) ?? item : item)
this.#previousItems = this.#items.map(item => ({...item})) // Clone items
const oldObject = this.object
this.#updateObject()
Expand Down Expand Up @@ -325,16 +325,17 @@ export class List extends LitElement {
this.object[i] = value;
}

if (typeof content === 'string') {
if (content instanceof HTMLElement) li.append(editableElement = content)
else if (isObjectContent) {} // Skip other object contents

// Always attempt render of other items
else {
const valueEl = document.createElement("span");
if (!key) editableElement = valueEl
valueEl.innerText = content;
div.appendChild(valueEl);
}

// Skip object contents
else if (content instanceof HTMLElement) li.append(editableElement = content)



if (div.innerText) li.title = div.innerText
Expand Down

0 comments on commit 1a8d8d7

Please sign in to comment.