1
0
mirror of https://github.com/morris/vanilla-todo.git synced 2025-08-20 12:51:43 +02:00

add some jsdoc for element autocomplete

This commit is contained in:
Morris Brodersen
2023-11-23 20:10:10 +01:00
parent 51c43ef35c
commit 89f6a0f390
17 changed files with 81 additions and 0 deletions

View File

@@ -1,3 +1,6 @@
/**
* @param {HTMLElement} el
*/
export function AppCollapsible(el) {
const state = {
show: true,

View File

@@ -17,6 +17,9 @@ const datesRow = `
</tr>
`;
/**
* @param {HTMLElement} el
*/
export function AppDatePicker(el) {
const now = new Date();
const state = {

View File

@@ -1,3 +1,11 @@
/**
* @param {HTMLElement} el
* @param {{
* dropSelector: string;
* dragThreshold?: number;
* dropRange?: number;
* }} options
*/
export function AppDraggable(el, options) {
const dragThreshold = options.dragThreshold ?? 5;
const dropRange = options.dropRange ?? 50;

View File

@@ -1,3 +1,11 @@
/**
* @param {HTMLElement} el
* @param {{
* initialDelay?: number;
* removeTimeout: number;
* selector: string;
* }} options
*/
export function AppFlip(el, options) {
let enabled = options.initialDelay === 0;
let first;

View File

@@ -1,3 +1,6 @@
/**
* @param {HTMLElement} el
*/
export function AppFps(el) {
const sampleSize = 20;
let times = [];

View File

@@ -2,6 +2,9 @@ export const BASE_URL = 'https://unpkg.com/@primer/octicons@19.8.0/build/svg/';
const cache = {};
/**
* @param {HTMLElement} el
*/
export function AppIcon(el) {
if (el.children.length > 0) return;

View File

@@ -1,3 +1,9 @@
/**
* @param {HTMLElement} el
* @param {{
* direction?: 'horizontal' | 'vertical';
* }} options
*/
export function AppSortable(el, options) {
let placeholder;
let placeholderSource;

View File

@@ -7,6 +7,9 @@ import { TodoFrameDays } from './TodoFrameDays.js';
import { TodoStore } from './TodoStore.js';
import { formatDateId } from './util.js';
/**
* @param {HTMLElement} el
*/
export function TodoApp(el) {
const state = {
items: [],

View File

@@ -2,6 +2,9 @@ import { AppDraggable } from './AppDraggable.js';
import { AppIcon } from './AppIcon.js';
import { TodoList } from './TodoList.js';
/**
* @param {HTMLElement} el
*/
export function TodoCustomList(el) {
const state = {
list: null,

View File

@@ -1,6 +1,9 @@
import { TodoList } from './TodoList.js';
import { formatDate, formatDayOfWeek } from './util.js';
/**
* @param {HTMLElement} el
*/
export function TodoDay(el) {
const state = {
dateId: el.dataset.key,

View File

@@ -2,6 +2,9 @@ import { AppIcon } from './AppIcon.js';
import { AppSortable } from './AppSortable.js';
import { TodoCustomList } from './TodoCustomList.js';
/**
* @param {HTMLElement} el
*/
export function TodoFrameCustom(el) {
const state = {
customLists: [],

View File

@@ -3,6 +3,9 @@ import { AppIcon } from './AppIcon.js';
import { TodoDay } from './TodoDay.js';
import { formatDateId } from './util.js';
/**
* @param {HTMLElement} el
*/
export function TodoFrameDays(el) {
const RANGE = 14;
const state = {

View File

@@ -1,6 +1,9 @@
import { AppDraggable } from './AppDraggable.js';
import { AppIcon } from './AppIcon.js';
/**
* @param {HTMLElement} el
*/
export function TodoItem(el) {
const state = {
item: null,

View File

@@ -1,5 +1,8 @@
import { AppIcon } from './AppIcon.js';
/**
* @param {HTMLElement} el
*/
export function TodoItemInput(el) {
let saveOnBlur = true;

View File

@@ -2,6 +2,9 @@ import { AppSortable } from './AppSortable.js';
import { TodoItem } from './TodoItem.js';
import { TodoItemInput } from './TodoItemInput.js';
/**
* @param {HTMLElement} el
*/
export function TodoList(el) {
const state = {
items: [],

View File

@@ -1,5 +1,8 @@
import { formatDateId, uuid } from './util.js';
/**
* @param {HTMLElement} el
*/
export function TodoStore(el) {
const state = {
items: [],

View File

@@ -7,6 +7,10 @@ export function uuid() {
});
}
/**
* @param {Date} date
* @returns {string}
*/
export function formatDateId(date) {
const y = date.getFullYear();
const m = date.getMonth() + 1;
@@ -18,6 +22,10 @@ export function formatDateId(date) {
return `${ys}-${ms}-${ds}`;
}
/**
* @param {Date} date
* @returns {string}
*/
export function formatDate(date) {
const m = formatMonth(date);
const d = formatDayOfMonth(date);
@@ -26,6 +34,10 @@ export function formatDate(date) {
return `${m} ${d} ${y}`;
}
/**
* @param {Date} date
* @returns {string}
*/
export function formatDayOfMonth(date) {
const d = date.getDate();
const t = d % 10;
@@ -51,6 +63,10 @@ export const DAY_NAMES = [
'Saturday',
];
/**
* @param {Date} date
* @returns {string}
*/
export function formatDayOfWeek(date) {
return DAY_NAMES[date.getDay()];
}
@@ -70,6 +86,10 @@ export const MONTH_NAMES = [
'December',
];
/**
* @param {Date} date
* @returns {string}
*/
export function formatMonth(date) {
return MONTH_NAMES[date.getMonth()];
}