1
0
mirror of https://github.com/morris/vanilla-todo.git synced 2025-08-29 16:49:49 +02:00

update deps

This commit is contained in:
Morris Brodersen
2023-11-13 20:03:04 +01:00
parent 9d1c3b7b8f
commit 5518d5ec37
37 changed files with 802 additions and 2945 deletions

View File

@@ -6,7 +6,7 @@ export function AppCollapsible(el) {
el.addEventListener('collapse', (e) => update({ show: !e.detail }));
el.querySelector('.bar > .toggle').addEventListener('click', () =>
update({ show: !state.show })
update({ show: !state.show }),
);
update();
@@ -16,7 +16,7 @@ export function AppCollapsible(el) {
el.querySelector('.bar > .toggle > .app-icon').classList.toggle(
'-r180',
state.show
state.show,
);
el.querySelectorAll('.body').forEach((el) => {

View File

@@ -60,7 +60,7 @@ export function AppDatePicker(el) {
el.querySelectorAll('.app-icon').forEach(AppIcon);
el.addEventListener('toggleDatePicker', (e) =>
update({ show: e.detail ?? !state.show })
update({ show: e.detail ?? !state.show }),
);
el.addEventListener('setMonth', (e) => update(e.detail));
@@ -78,10 +78,10 @@ export function AppDatePicker(el) {
detail: new Date(
e.target.dataset.year,
e.target.dataset.month - 1,
e.target.dataset.day
e.target.dataset.day,
),
bubbles: true,
})
}),
);
});
@@ -95,7 +95,7 @@ export function AppDatePicker(el) {
: {
year: state.year - 1,
month: 12,
}
},
);
}
@@ -109,7 +109,7 @@ export function AppDatePicker(el) {
: {
year: state.year + 1,
month: 1,
}
},
);
}
@@ -122,7 +122,7 @@ export function AppDatePicker(el) {
const first = new Date(state.year, state.month - 1, 1);
el.querySelector('.month').innerHTML = `${formatMonth(
first
first,
)} ${first.getFullYear()}`;
let current = new Date(first);
@@ -147,7 +147,7 @@ export function AppDatePicker(el) {
'-highlight',
current.getFullYear() === now.getFullYear() &&
current.getMonth() === now.getMonth() &&
current.getDate() === now.getDate()
current.getDate() === now.getDate(),
);
current.setDate(current.getDate() + 1);

View File

@@ -26,7 +26,7 @@ export function AppDraggable(el, options) {
e.stopImmediatePropagation();
}
},
true
true,
);
function start(e) {
@@ -122,7 +122,7 @@ export function AppDraggable(el, options) {
new CustomEvent('draggableStart', {
detail: buildDetail(),
bubbles: true,
})
}),
);
}
@@ -131,7 +131,7 @@ export function AppDraggable(el, options) {
new CustomEvent('draggableDrag', {
detail: buildDetail(),
bubbles: true,
})
}),
);
}
@@ -148,7 +148,7 @@ export function AppDraggable(el, options) {
new CustomEvent('draggableLeave', {
detail: buildDetail(),
bubbles: true,
})
}),
);
}
@@ -158,7 +158,7 @@ export function AppDraggable(el, options) {
new CustomEvent('draggableEnter', {
detail: buildDetail(),
bubbles: true,
})
}),
);
}
@@ -178,7 +178,7 @@ export function AppDraggable(el, options) {
new CustomEvent('draggableOver', {
detail: buildDetail(),
bubbles: true,
})
}),
);
}
@@ -192,14 +192,14 @@ export function AppDraggable(el, options) {
new CustomEvent('draggableDrop', {
detail: buildDetail(),
bubbles: true,
})
}),
);
} else {
image.dispatchEvent(
new CustomEvent('draggableCancel', {
detail: buildDetail(),
bubbles: true,
})
}),
);
}
}
@@ -297,7 +297,7 @@ export function AppDraggable(el, options) {
const distanceSquared = pointDistanceToRectSquared(
clientX,
clientY,
rect
rect,
);
if (distanceSquared > dropRangeSquared) return;

View File

@@ -25,7 +25,7 @@ export function AppFps(el) {
const fps = (sampleSize / sum) * 1000;
el.innerText = `${fps.toFixed(0)} fps (${min.toFixed(0)} ms - ${max.toFixed(
0
0,
)} ms)`;
times = [];

View File

@@ -5,11 +5,11 @@ export function AppSortable(el, options) {
let currentIndex = -1;
el.addEventListener('draggableStart', (e) =>
e.detail.image.addEventListener('draggableCancel', cleanUp)
e.detail.image.addEventListener('draggableCancel', cleanUp),
);
el.addEventListener('draggableOver', (e) =>
maybeDispatchUpdate(calculateIndex(e.detail.image), e)
maybeDispatchUpdate(calculateIndex(e.detail.image), e),
);
el.addEventListener('draggableLeave', (e) => maybeDispatchUpdate(-1, e));
@@ -19,8 +19,8 @@ export function AppSortable(el, options) {
new CustomEvent('sortableDrop', {
detail: buildDetail(e),
bubbles: true,
})
)
}),
),
);
el.addEventListener('sortableUpdate', (e) => {
@@ -47,7 +47,7 @@ export function AppSortable(el, options) {
new CustomEvent('sortableUpdate', {
detail: buildDetail(originalEvent),
bubbles: true,
})
}),
);
}
}

View File

@@ -109,11 +109,11 @@ export function TodoApp(el) {
Object.assign(state, next);
el.querySelectorAll('.todo-frame').forEach((el) =>
el.dispatchEvent(new CustomEvent('todoData', { detail: state }))
el.dispatchEvent(new CustomEvent('todoData', { detail: state })),
);
el.querySelectorAll('.app-collapsible').forEach((el) =>
el.dispatchEvent(new CustomEvent('collapse'))
el.dispatchEvent(new CustomEvent('collapse')),
);
}

View File

@@ -68,7 +68,7 @@ export function TodoCustomList(el) {
if (state.list.items.length > 0) {
if (
!confirm(
'Deleting this list will delete its items as well. Are you sure?'
'Deleting this list will delete its items as well. Are you sure?',
)
) {
return;
@@ -79,7 +79,7 @@ export function TodoCustomList(el) {
new CustomEvent('deleteTodoList', {
detail: state.list,
bubbles: true,
})
}),
);
});
@@ -116,7 +116,7 @@ export function TodoCustomList(el) {
new CustomEvent('saveTodoList', {
detail: { list: state.list, title: inputEl.value.trim() },
bubbles: true,
})
}),
);
update({ editing: false });
}
@@ -132,12 +132,11 @@ export function TodoCustomList(el) {
titleEl.innerText = state.list.title || '...';
el.querySelector('.todo-list').dispatchEvent(
new CustomEvent('todoItems', { detail: state.list.items })
new CustomEvent('todoItems', { detail: state.list.items }),
);
el.querySelector(
'.todo-list > .todo-item-input'
).dataset.key = `todo-item-input${state.list.id}`;
el.querySelector('.todo-list > .todo-item-input').dataset.key =
`todo-item-input${state.list.id}`;
el.classList.toggle('-editing', state.editing);

View File

@@ -43,7 +43,7 @@ export function TodoDay(el) {
el.querySelector('.header > .dayofweek').innerText = formatDayOfWeek(date);
el.querySelector('.header > .date').innerText = formatDate(date);
el.querySelector('.todo-list').dispatchEvent(
new CustomEvent('todoItems', { detail: state.items })
new CustomEvent('todoItems', { detail: state.items }),
);
}
}

View File

@@ -29,19 +29,19 @@ export function TodoFrameCustom(el) {
el.querySelector('.back').addEventListener('click', () =>
el.dispatchEvent(
new CustomEvent('seekCustomTodoLists', { detail: -1, bubbles: true })
)
new CustomEvent('seekCustomTodoLists', { detail: -1, bubbles: true }),
),
);
el.querySelector('.forward').addEventListener('click', () =>
el.dispatchEvent(
new CustomEvent('seekCustomTodoLists', { detail: 1, bubbles: true })
)
new CustomEvent('seekCustomTodoLists', { detail: 1, bubbles: true }),
),
);
el.querySelector('.add').addEventListener('click', () => {
el.dispatchEvent(
new CustomEvent('addTodoList', { detail: {}, bubbles: true })
new CustomEvent('addTodoList', { detail: {}, bubbles: true }),
);
// TODO seek if not at end
});
@@ -56,7 +56,7 @@ export function TodoFrameCustom(el) {
index: e.detail.index,
},
bubbles: true,
})
}),
);
});

View File

@@ -55,35 +55,39 @@ export function TodoFrameDays(el) {
el.querySelectorAll('.app-date-picker').forEach(AppDatePicker);
el.querySelector('.backward').addEventListener('click', () =>
el.dispatchEvent(new CustomEvent('seekDays', { detail: -1, bubbles: true }))
el.dispatchEvent(
new CustomEvent('seekDays', { detail: -1, bubbles: true }),
),
);
el.querySelector('.forward').addEventListener('click', () =>
el.dispatchEvent(new CustomEvent('seekDays', { detail: 1, bubbles: true }))
el.dispatchEvent(new CustomEvent('seekDays', { detail: 1, bubbles: true })),
);
el.querySelector('.fastbackward').addEventListener('click', () =>
el.dispatchEvent(new CustomEvent('seekDays', { detail: -5, bubbles: true }))
el.dispatchEvent(
new CustomEvent('seekDays', { detail: -5, bubbles: true }),
),
);
el.querySelector('.fastforward').addEventListener('click', () =>
el.dispatchEvent(new CustomEvent('seekDays', { detail: 5, bubbles: true }))
el.dispatchEvent(new CustomEvent('seekDays', { detail: 5, bubbles: true })),
);
el.querySelector('.home').addEventListener('click', () =>
el.dispatchEvent(new CustomEvent('seekToToday', { bubbles: true }))
el.dispatchEvent(new CustomEvent('seekToToday', { bubbles: true })),
);
el.querySelector('.pickdate').addEventListener('click', () =>
el
.querySelector('.datepicker')
.dispatchEvent(new CustomEvent('toggleDatePicker'))
.dispatchEvent(new CustomEvent('toggleDatePicker')),
);
el.querySelector('.datepicker').addEventListener('pickDate', (e) =>
el.dispatchEvent(
new CustomEvent('seekToDate', { detail: e.detail, bubbles: true })
)
new CustomEvent('seekToDate', { detail: e.detail, bubbles: true }),
),
);
el.addEventListener('todoData', (e) => update(e.detail));

View File

@@ -50,7 +50,7 @@ export function TodoItem(el) {
done: !state.item.done,
},
bubbles: true,
})
}),
);
});
@@ -105,7 +105,7 @@ export function TodoItem(el) {
new CustomEvent('deleteTodoItem', {
detail: state.item,
bubbles: true,
})
}),
);
});
@@ -119,7 +119,7 @@ export function TodoItem(el) {
label,
},
bubbles: true,
})
}),
);
update({ editing: false });

View File

@@ -51,7 +51,7 @@ export function TodoItemInput(el) {
new CustomEvent('addTodoItem', {
detail: { label },
bubbles: true,
})
}),
);
}

View File

@@ -23,8 +23,8 @@ export function TodoList(el) {
index: e.detail.index,
},
bubbles: true,
})
)
}),
),
);
el.addEventListener('todoItems', (e) => update({ items: e.detail }));

View File

@@ -50,7 +50,7 @@ export function TodoStore(el) {
const movedItem = state.items.find((item) => item.id === e.detail.item.id);
const listItems = state.items.filter(
(item) => item.listId === e.detail.listId && item !== movedItem
(item) => item.listId === e.detail.listId && item !== movedItem,
);
listItems.sort((a, b) => a.index - b.index);
@@ -66,7 +66,7 @@ export function TodoStore(el) {
});
el.addEventListener('deleteTodoItem', (e) =>
dispatch({ items: state.items.filter((item) => item.id !== e.detail.id) })
dispatch({ items: state.items.filter((item) => item.id !== e.detail.id) }),
);
el.addEventListener('addTodoList', (e) => {
@@ -97,7 +97,7 @@ export function TodoStore(el) {
el.addEventListener('moveTodoList', (e) => {
const movedListIndex = state.customLists.findIndex(
(list) => list.id === e.detail.list.id
(list) => list.id === e.detail.list.id,
);
const movedList = state.customLists[movedListIndex];
@@ -115,9 +115,9 @@ export function TodoStore(el) {
el.addEventListener('deleteTodoList', (e) =>
dispatch({
customLists: state.customLists.filter(
(customList) => customList.id !== e.detail.id
(customList) => customList.id !== e.detail.id,
),
})
}),
);
el.addEventListener('seekDays', (e) => {
@@ -128,20 +128,20 @@ export function TodoStore(el) {
});
el.addEventListener('seekToToday', () =>
dispatch({ at: formatDateId(new Date()) })
dispatch({ at: formatDateId(new Date()) }),
);
el.addEventListener('seekToDate', (e) =>
dispatch({ at: formatDateId(e.detail) })
dispatch({ at: formatDateId(e.detail) }),
);
el.addEventListener('seekCustomTodoLists', (e) =>
dispatch({
customAt: Math.max(
0,
Math.min(state.customLists.length - 1, state.customAt + e.detail)
Math.min(state.customLists.length - 1, state.customAt + e.detail),
),
})
}),
);
function dispatch(next) {
@@ -152,7 +152,7 @@ export function TodoStore(el) {
new CustomEvent('todoData', {
detail: state,
bubbles: false,
})
}),
);
}

View File

@@ -33,12 +33,12 @@ export function formatDayOfMonth(date) {
return d === 11 || d === 12 || d === 13
? `${d}th`
: t === 1
? `${d}st`
: t === 2
? `${d}nd`
: t === 3
? `${d}rd`
: `${d}th`;
? `${d}st`
: t === 2
? `${d}nd`
: t === 3
? `${d}rd`
: `${d}th`;
}
export const DAY_NAMES = [