@shiodome47/planner 0.2.0 → 0.3.1
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/README.md +19 -4
- package/dist/chunks/JumpBar-43r8C8G3.js +1175 -0
- package/dist/core/logic.d.ts +29 -1
- package/dist/core/review.d.ts +20 -0
- package/dist/core/types.d.ts +21 -0
- package/dist/core.js +234 -156
- package/dist/projects.js +297 -283
- package/dist/style.css +1 -1
- package/dist/timeline.js +193 -140
- package/dist/ui/EndedHabits.d.ts +41 -0
- package/dist/ui/dnd.d.ts +4 -1
- package/package.json +1 -1
- package/dist/chunks/JumpBar-DMnykrl0.js +0 -904
package/dist/core.js
CHANGED
|
@@ -204,160 +204,169 @@ function oe(e) {
|
|
|
204
204
|
return e.period === "year" && !!x(e.yearDay) && !x(e.yearDay).day;
|
|
205
205
|
}
|
|
206
206
|
// src/core/logic.ts
|
|
207
|
-
var
|
|
207
|
+
var se = {
|
|
208
208
|
today: 0,
|
|
209
209
|
week: 1,
|
|
210
210
|
month: 2,
|
|
211
211
|
year: 3,
|
|
212
212
|
life: 4
|
|
213
213
|
};
|
|
214
|
-
function
|
|
214
|
+
function T(e, t) {
|
|
215
215
|
if (e === "today") return n(t);
|
|
216
216
|
if (e === "tomorrow") return n(u(t, 1));
|
|
217
217
|
if (e === "nextweek") return s("week", u(t, 7));
|
|
218
218
|
if (e === "week") return s("week", t);
|
|
219
219
|
if (e === "month") return s("month", t);
|
|
220
220
|
}
|
|
221
|
-
function
|
|
221
|
+
function ce(e, t) {
|
|
222
222
|
if (e === "today") return n(t);
|
|
223
223
|
if (e === "week") return s("week", t);
|
|
224
224
|
if (e === "month") return s("month", t);
|
|
225
225
|
}
|
|
226
|
-
function
|
|
226
|
+
function E(e, t) {
|
|
227
227
|
if (!(e.parentId || e.habitId) || !e.placedFor) return !1;
|
|
228
|
-
let n =
|
|
228
|
+
let n = ce(e.horizon, t);
|
|
229
229
|
return n !== void 0 && e.placedFor < n;
|
|
230
230
|
}
|
|
231
|
-
function
|
|
232
|
-
return
|
|
231
|
+
function D(e, t) {
|
|
232
|
+
return A(e) ? O(e.due, t) : !j(e) && e.horizon === "week" && !!e.placedFor && e.placedFor > s("week", t);
|
|
233
233
|
}
|
|
234
|
-
function
|
|
234
|
+
function O(e, t) {
|
|
235
235
|
let r = u(i(t), 7);
|
|
236
236
|
return e >= n(r) && e <= n(u(r, 6));
|
|
237
237
|
}
|
|
238
|
-
function
|
|
239
|
-
return
|
|
238
|
+
function k(e, t) {
|
|
239
|
+
return A(e) ? h(e.due, t) === 1 : e.horizon === "today" && !!e.placedFor && e.placedFor > n(t);
|
|
240
240
|
}
|
|
241
|
-
function
|
|
241
|
+
function A(e) {
|
|
242
242
|
return !!e.due && !e.parentId && !e.habitId;
|
|
243
243
|
}
|
|
244
|
-
function
|
|
244
|
+
function j(e) {
|
|
245
245
|
return !!e.projectId && !e.parentId;
|
|
246
246
|
}
|
|
247
|
-
function
|
|
247
|
+
function M(e, t) {
|
|
248
248
|
let r = h(e, t);
|
|
249
249
|
return r === null ? "life" : r <= 1 ? "today" : e <= n(u(i(t), 13)) ? "week" : r <= 92 ? "month" : r <= 366 ? "year" : "life";
|
|
250
250
|
}
|
|
251
|
-
function
|
|
252
|
-
return
|
|
251
|
+
function N(e, t) {
|
|
252
|
+
return A(e) ? M(e.due, t) : j(e) ? "pool" : e.horizon;
|
|
253
253
|
}
|
|
254
|
-
function
|
|
254
|
+
function le(e, t) {
|
|
255
255
|
if (!e.doneAt) return !0;
|
|
256
|
-
let n =
|
|
256
|
+
let n = N(e, t);
|
|
257
257
|
return n === "pool" || d(c[n], e.doneAt, t);
|
|
258
258
|
}
|
|
259
|
-
function
|
|
260
|
-
return !
|
|
259
|
+
function P(e, t) {
|
|
260
|
+
return !E(e, t) && le(e, t);
|
|
261
261
|
}
|
|
262
|
-
function
|
|
263
|
-
return t.find((t) => t.parentId === e.id && !
|
|
262
|
+
function F(e, t, n) {
|
|
263
|
+
return t.find((t) => t.parentId === e.id && !E(t, n));
|
|
264
264
|
}
|
|
265
|
-
function
|
|
265
|
+
function I(t) {
|
|
266
266
|
if (t === "pool") return [...e];
|
|
267
267
|
if (t === "today") return [];
|
|
268
|
-
let n =
|
|
269
|
-
return e.filter((e) =>
|
|
268
|
+
let n = se[t];
|
|
269
|
+
return e.filter((e) => se[e] < n).flatMap((e) => e === "today" ? ["today", "tomorrow"] : e === "week" ? ["week", "nextweek"] : [e]);
|
|
270
270
|
}
|
|
271
|
-
function
|
|
272
|
-
return
|
|
271
|
+
function ue(e) {
|
|
272
|
+
return I(e).filter((e) => e !== "tomorrow" && e !== "nextweek").at(-1);
|
|
273
|
+
}
|
|
274
|
+
function de(e) {
|
|
275
|
+
let n = new Set(e), r = {}, i = [];
|
|
276
|
+
for (let e of t) n.has(e) ? (i.length && (r[e] = i), i = []) : i.push(e);
|
|
277
|
+
return {
|
|
278
|
+
before: r,
|
|
279
|
+
after: n.size ? i : []
|
|
280
|
+
};
|
|
273
281
|
}
|
|
274
|
-
function
|
|
282
|
+
function L(e) {
|
|
275
283
|
let n = [];
|
|
276
|
-
for (let r of t) e.filter((e) => e.priority === r).sort(
|
|
284
|
+
for (let r of t) e.filter((e) => e.priority === r).sort(R).forEach((e, t) => n.push({
|
|
277
285
|
task: e,
|
|
278
286
|
label: `${r}${t + 1}`
|
|
279
287
|
}));
|
|
280
288
|
return n;
|
|
281
289
|
}
|
|
282
|
-
function
|
|
290
|
+
function R(e, t) {
|
|
283
291
|
return e.order - t.order || e.createdAt.localeCompare(t.createdAt);
|
|
284
292
|
}
|
|
285
|
-
function
|
|
293
|
+
function fe(t, n) {
|
|
286
294
|
let r = new Map(t.projects.map((e) => [e.id, e])), i = new Map(t.tasks.map((e) => [e.id, e])), a = new Map(t.habits.map((e) => [e.id, e])), o = (e) => {
|
|
287
295
|
let t = a.get(e);
|
|
288
296
|
return t ? _(t.period) : void 0;
|
|
289
297
|
}, s = (e, a) => {
|
|
290
|
-
let s =
|
|
298
|
+
let s = F(e, t.tasks, n), c = e.parentId ? i.get(e.parentId) : void 0;
|
|
291
299
|
return {
|
|
292
300
|
task: e,
|
|
293
|
-
horizon:
|
|
301
|
+
horizon: N(e, n),
|
|
294
302
|
label: a,
|
|
295
303
|
done: !!e.doneAt,
|
|
296
304
|
faded: !!s && !e.doneAt,
|
|
297
|
-
placedTo: s ?
|
|
298
|
-
from: c ?
|
|
305
|
+
placedTo: s ? k(s, n) ? "tomorrow" : D(s, n) ? "nextweek" : s.horizon : void 0,
|
|
306
|
+
from: c ? N(c, n) : e.habitId ? o(e.habitId) : void 0,
|
|
299
307
|
project: e.projectId ? r.get(e.projectId) : void 0
|
|
300
308
|
};
|
|
301
309
|
};
|
|
302
310
|
return e.map((e) => {
|
|
303
|
-
let i = t.tasks.filter((t) =>
|
|
304
|
-
let o = d(e.period, e.checkedAt, n), s =
|
|
311
|
+
let i = t.tasks.filter((t) => N(t, n) === e && P(t, n)), a = e === "today" ? i.filter((e) => !k(e, n)) : e === "week" ? i.filter((e) => !D(e, n)) : i, o = e === "today" ? i.filter((e) => k(e, n)) : [], c = e === "week" ? i.filter((e) => D(e, n)) : [], u = l[e], f = (e, i, a) => {
|
|
312
|
+
let o = d(e.period, e.checkedAt, n), s = Y(e, t.tasks, n);
|
|
305
313
|
return {
|
|
306
314
|
habit: e,
|
|
307
315
|
checked: o,
|
|
308
316
|
project: e.projectId ? r.get(e.projectId) : void 0,
|
|
309
317
|
faded: !!s && !o && !i,
|
|
310
|
-
placedTo: s && !i ?
|
|
318
|
+
placedTo: s && !i ? k(s, n) ? "tomorrow" : D(s, n) ? "nextweek" : s.horizon : void 0,
|
|
311
319
|
auto: i,
|
|
312
320
|
dueDay: a ?? C(e, n)
|
|
313
321
|
};
|
|
314
|
-
}, p = u ?
|
|
315
|
-
for (let
|
|
316
|
-
let
|
|
317
|
-
|
|
322
|
+
}, p = t.habits.filter((e) => !e.endedAt), m = u ? p.filter((e) => e.period === u).sort(R).map((e) => f(e, !1)) : [], h = [];
|
|
323
|
+
for (let t of p.filter((e) => e.period !== u).sort(R)) {
|
|
324
|
+
let r = w(t, e, n);
|
|
325
|
+
r && h.push(f(t, !0, r));
|
|
318
326
|
}
|
|
319
327
|
return {
|
|
320
328
|
horizon: e,
|
|
321
329
|
habitPeriod: u,
|
|
322
|
-
habits: [...
|
|
323
|
-
tasks:
|
|
324
|
-
tomorrow:
|
|
325
|
-
nextWeek:
|
|
330
|
+
habits: [...m, ...h],
|
|
331
|
+
tasks: L(a).map(({ task: e, label: t }) => s(e, t)),
|
|
332
|
+
tomorrow: L(o).map(({ task: e, label: t }) => s(e, t)),
|
|
333
|
+
nextWeek: L(c).map(({ task: e, label: t }) => s(e, t)),
|
|
334
|
+
ended: u ? G(t.habits.filter((e) => e.period === u)) : []
|
|
326
335
|
};
|
|
327
336
|
});
|
|
328
337
|
}
|
|
329
|
-
var
|
|
330
|
-
function
|
|
338
|
+
var z = (e) => e.toISOString();
|
|
339
|
+
function B(e, t, n) {
|
|
331
340
|
let r = e.filter((e) => e.horizon === t && e.priority === n);
|
|
332
341
|
return r.length === 0 ? 0 : Math.max(...r.map((e) => e.order)) + 1;
|
|
333
342
|
}
|
|
334
|
-
function
|
|
335
|
-
let r =
|
|
343
|
+
function V(e, t, n) {
|
|
344
|
+
let r = z(n);
|
|
336
345
|
return {
|
|
337
346
|
id: crypto.randomUUID(),
|
|
338
347
|
title: t.title,
|
|
339
348
|
horizon: t.horizon,
|
|
340
349
|
priority: t.priority,
|
|
341
|
-
order:
|
|
342
|
-
...t.tomorrow ? { placedFor:
|
|
343
|
-
...t.nextWeek ? { placedFor:
|
|
350
|
+
order: B(e.tasks, t.horizon, t.priority),
|
|
351
|
+
...t.tomorrow ? { placedFor: T("tomorrow", n) } : {},
|
|
352
|
+
...t.nextWeek ? { placedFor: T("nextweek", n) } : {},
|
|
344
353
|
...t.projectId ? { projectId: t.projectId } : {},
|
|
345
354
|
...t.due ? { due: t.due } : {},
|
|
346
355
|
createdAt: r,
|
|
347
356
|
updatedAt: r
|
|
348
357
|
};
|
|
349
358
|
}
|
|
350
|
-
function
|
|
351
|
-
let i =
|
|
359
|
+
function pe(e, t, n, r) {
|
|
360
|
+
let i = z(r), a = n === "tomorrow" ? "today" : n === "nextweek" ? "week" : n, o = F(t, e.tasks, r), s = o && !o.doneAt ? H(e.tasks, o.id, r).concat(o.id) : [];
|
|
352
361
|
return {
|
|
353
362
|
tasks: [{
|
|
354
363
|
id: crypto.randomUUID(),
|
|
355
364
|
title: t.title,
|
|
356
365
|
horizon: a,
|
|
357
366
|
priority: t.priority,
|
|
358
|
-
order:
|
|
367
|
+
order: B(e.tasks, a, t.priority),
|
|
359
368
|
parentId: t.id,
|
|
360
|
-
...
|
|
369
|
+
...T(n, r) ? { placedFor: T(n, r) } : {},
|
|
361
370
|
...t.projectId ? { projectId: t.projectId } : {},
|
|
362
371
|
...t.due ? { due: t.due } : {},
|
|
363
372
|
...t.note ? { note: t.note } : {},
|
|
@@ -367,28 +376,28 @@ function U(e, t, n, r) {
|
|
|
367
376
|
deleteTaskIds: s
|
|
368
377
|
};
|
|
369
378
|
}
|
|
370
|
-
function
|
|
371
|
-
return { deleteTaskIds: [t.id, ...
|
|
379
|
+
function me(e, t, n) {
|
|
380
|
+
return { deleteTaskIds: [t.id, ...H(e.tasks, t.id, n)] };
|
|
372
381
|
}
|
|
373
|
-
function
|
|
382
|
+
function he(e, t, n, r) {
|
|
374
383
|
if (t.horizon === n) return {};
|
|
375
384
|
let { placedFor: i, ...a } = t;
|
|
376
385
|
return { tasks: [{
|
|
377
386
|
...a,
|
|
378
387
|
horizon: n,
|
|
379
|
-
order:
|
|
380
|
-
updatedAt:
|
|
388
|
+
order: B(e.tasks, n, t.priority),
|
|
389
|
+
updatedAt: z(r)
|
|
381
390
|
}] };
|
|
382
391
|
}
|
|
383
|
-
function
|
|
392
|
+
function H(e, t, n) {
|
|
384
393
|
let r = [];
|
|
385
|
-
for (let i of e) i.parentId === t && !
|
|
394
|
+
for (let i of e) i.parentId === t && !E(i, n) && r.push(i.id, ...H(e, i.id, n));
|
|
386
395
|
return r;
|
|
387
396
|
}
|
|
388
|
-
function
|
|
389
|
-
let r = new Map(e.tasks.map((e) => [e.id, e])), i = /* @__PURE__ */ new Set([t.id, ...
|
|
397
|
+
function U(e, t, n) {
|
|
398
|
+
let r = new Map(e.tasks.map((e) => [e.id, e])), i = /* @__PURE__ */ new Set([t.id, ...H(e.tasks, t.id, n)]);
|
|
390
399
|
for (let e = t.parentId ? r.get(t.parentId) : void 0; e; e = e.parentId ? r.get(e.parentId) : void 0) i.add(e.id);
|
|
391
|
-
let a =
|
|
400
|
+
let a = z(n), o = !t.doneAt, s = [...i].map((e) => r.get(e)).filter((e) => !!e).map((e) => {
|
|
392
401
|
let { doneAt: t, ...n } = e;
|
|
393
402
|
return o ? {
|
|
394
403
|
...n,
|
|
@@ -401,13 +410,13 @@ function G(e, t, n) {
|
|
|
401
410
|
}), c = t.habitId ? e.habits.find((e) => e.id === t.habitId) : void 0;
|
|
402
411
|
return c && d(c.period, c.checkedAt, n) !== o ? {
|
|
403
412
|
tasks: s,
|
|
404
|
-
habits: [
|
|
413
|
+
habits: [W(c, n)]
|
|
405
414
|
} : { tasks: s };
|
|
406
415
|
}
|
|
407
|
-
function
|
|
408
|
-
let i = e.tasks.filter((e) => e.horizon === t.horizon && e.priority === t.priority &&
|
|
416
|
+
function ge(e, t, n, r) {
|
|
417
|
+
let i = e.tasks.filter((e) => e.horizon === t.horizon && e.priority === t.priority && P(e, r) && k(e, r) === k(t, r)).sort(R), a = i.findIndex((e) => e.id === t.id), o = a + n;
|
|
409
418
|
if (a < 0 || o < 0 || o >= i.length) return {};
|
|
410
|
-
let s =
|
|
419
|
+
let s = z(r), c = [...i];
|
|
411
420
|
[c[a], c[o]] = [c[o], c[a]];
|
|
412
421
|
let l = new Map(i.map((e) => [e.id, e.order]));
|
|
413
422
|
return { tasks: c.map((e, t) => ({
|
|
@@ -416,19 +425,19 @@ function pe(e, t, n, r) {
|
|
|
416
425
|
updatedAt: s
|
|
417
426
|
})).filter((e) => l.get(e.id) !== e.order) };
|
|
418
427
|
}
|
|
419
|
-
function
|
|
428
|
+
function _e(e, t, n, r) {
|
|
420
429
|
return t.priority === n ? {} : { tasks: [{
|
|
421
430
|
...t,
|
|
422
431
|
priority: n,
|
|
423
|
-
order:
|
|
424
|
-
updatedAt:
|
|
432
|
+
order: B(e.tasks, t.horizon, n),
|
|
433
|
+
updatedAt: z(r)
|
|
425
434
|
}] };
|
|
426
435
|
}
|
|
427
|
-
function
|
|
428
|
-
return { deleteTaskIds: [t.id, ...
|
|
436
|
+
function ve(e, t, n) {
|
|
437
|
+
return { deleteTaskIds: [t.id, ...H(e.tasks, t.id, n)] };
|
|
429
438
|
}
|
|
430
|
-
function
|
|
431
|
-
let r = e.habits.filter((e) => e.period === t.period), i =
|
|
439
|
+
function ye(e, t, n) {
|
|
440
|
+
let r = e.habits.filter((e) => e.period === t.period), i = z(n);
|
|
432
441
|
return {
|
|
433
442
|
id: crypto.randomUUID(),
|
|
434
443
|
title: t.title,
|
|
@@ -439,8 +448,8 @@ function ge(e, t, n) {
|
|
|
439
448
|
updatedAt: i
|
|
440
449
|
};
|
|
441
450
|
}
|
|
442
|
-
function
|
|
443
|
-
let { checkedAt: r, ...i } = e, a =
|
|
451
|
+
function W(e, t) {
|
|
452
|
+
let { checkedAt: r, ...i } = e, a = z(t), o = e.history ?? [];
|
|
444
453
|
if (d(e.period, e.checkedAt, t)) {
|
|
445
454
|
let t = n(new Date(e.checkedAt));
|
|
446
455
|
return {
|
|
@@ -449,7 +458,7 @@ function K(e, t) {
|
|
|
449
458
|
updatedAt: a
|
|
450
459
|
};
|
|
451
460
|
}
|
|
452
|
-
let s = n(t), c = o.includes(s) ? o : [...o, s].sort().slice(-
|
|
461
|
+
let s = n(t), c = o.includes(s) ? o : [...o, s].sort().slice(-800);
|
|
453
462
|
return {
|
|
454
463
|
...i,
|
|
455
464
|
checkedAt: a,
|
|
@@ -457,9 +466,40 @@ function K(e, t) {
|
|
|
457
466
|
updatedAt: a
|
|
458
467
|
};
|
|
459
468
|
}
|
|
460
|
-
var
|
|
461
|
-
function
|
|
462
|
-
|
|
469
|
+
var be = 800;
|
|
470
|
+
function G(e) {
|
|
471
|
+
return e.filter((e) => e.endedAt).sort((e, t) => t.endedAt.localeCompare(e.endedAt));
|
|
472
|
+
}
|
|
473
|
+
function xe(e, t, n, r, i) {
|
|
474
|
+
let a = z(i), { endNote: o, ...s } = t, c = r.trim(), l = {
|
|
475
|
+
...s,
|
|
476
|
+
endedAt: t.endedAt ?? a,
|
|
477
|
+
endedAs: n,
|
|
478
|
+
...c ? { endNote: c } : {},
|
|
479
|
+
updatedAt: a
|
|
480
|
+
}, u = t.endedAt ? [] : e.tasks.filter((e) => e.habitId === t.id && !e.doneAt && !E(e, i));
|
|
481
|
+
return {
|
|
482
|
+
habits: [l],
|
|
483
|
+
...u.length ? { deleteTaskIds: u.map((e) => e.id) } : {}
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
function Se(e, t, r) {
|
|
487
|
+
if (!t.endedAt) return {};
|
|
488
|
+
let i = z(r), { endedAt: a, endedAs: o, endNote: s, breaks: c, ...l } = t, u = n(new Date(a)) === n(r), d = {
|
|
489
|
+
endedAt: a,
|
|
490
|
+
endedAs: o ?? "paused",
|
|
491
|
+
...s ? { endNote: s } : {},
|
|
492
|
+
resumedAt: i
|
|
493
|
+
}, f = u ? t.breaks ?? [] : [...t.breaks ?? [], d], p = e.habits.filter((e) => e.period === t.period && !e.endedAt && e.id !== t.id), m = p.length === 0 ? 0 : Math.max(...p.map((e) => e.order)) + 1;
|
|
494
|
+
return { habits: [{
|
|
495
|
+
...l,
|
|
496
|
+
...f.length ? { breaks: f } : {},
|
|
497
|
+
order: m,
|
|
498
|
+
updatedAt: i
|
|
499
|
+
}] };
|
|
500
|
+
}
|
|
501
|
+
function Ce(e, t, n) {
|
|
502
|
+
let r = z(n), i = e.projects.filter((e) => e.parentId === t.parentId);
|
|
463
503
|
return {
|
|
464
504
|
id: crypto.randomUUID(),
|
|
465
505
|
name: t.name,
|
|
@@ -470,56 +510,56 @@ function ve(e, t, n) {
|
|
|
470
510
|
updatedAt: r
|
|
471
511
|
};
|
|
472
512
|
}
|
|
473
|
-
function
|
|
513
|
+
function K(e, t) {
|
|
474
514
|
return e.projects.filter((e) => e.parentId === t).sort((e, t) => e.order - t.order);
|
|
475
515
|
}
|
|
476
|
-
function
|
|
516
|
+
function we(e) {
|
|
477
517
|
let t = new Set(e.projects.map((e) => e.id));
|
|
478
518
|
return e.projects.filter((e) => !e.parentId || !t.has(e.parentId)).sort((e, t) => e.order - t.order);
|
|
479
519
|
}
|
|
480
|
-
function
|
|
481
|
-
let n = /* @__PURE__ */ new Set([t.id, ...
|
|
520
|
+
function Te(e, t) {
|
|
521
|
+
let n = /* @__PURE__ */ new Set([t.id, ...K(e, t.id).map((e) => e.id)]);
|
|
482
522
|
return {
|
|
483
523
|
deleteProjectIds: [...n],
|
|
484
524
|
deleteTaskIds: e.tasks.filter((e) => e.projectId && n.has(e.projectId)).map((e) => e.id),
|
|
485
525
|
deleteHabitIds: e.habits.filter((e) => e.projectId && n.has(e.projectId)).map((e) => e.id)
|
|
486
526
|
};
|
|
487
527
|
}
|
|
488
|
-
function
|
|
489
|
-
if (n === t.parentId || n === t.id || n &&
|
|
528
|
+
function Ee(e, t, n, r) {
|
|
529
|
+
if (n === t.parentId || n === t.id || n && K(e, t.id).length > 0) return {};
|
|
490
530
|
let i = e.projects.filter((e) => e.parentId === n && e.id !== t.id), { parentId: a, ...o } = t;
|
|
491
531
|
return { projects: [{
|
|
492
532
|
...o,
|
|
493
533
|
...n ? { parentId: n } : {},
|
|
494
534
|
order: i.length === 0 ? 0 : Math.max(...i.map((e) => e.order)) + 1,
|
|
495
|
-
updatedAt:
|
|
535
|
+
updatedAt: z(r)
|
|
496
536
|
}] };
|
|
497
537
|
}
|
|
498
|
-
function
|
|
538
|
+
function q(e, t = [], n = []) {
|
|
499
539
|
let r = new Set(n), i = new Map(t.map((e) => [e.id, e])), a = e.filter((e) => !r.has(e.id)).map((e) => i.get(e.id) ?? e), o = t.filter((t) => !e.some((e) => e.id === t.id) && !r.has(t.id));
|
|
500
540
|
return [...a, ...o];
|
|
501
541
|
}
|
|
502
|
-
function
|
|
542
|
+
function De(e, t) {
|
|
503
543
|
return {
|
|
504
544
|
...e,
|
|
505
|
-
tasks:
|
|
506
|
-
habits:
|
|
507
|
-
projects:
|
|
545
|
+
tasks: q(e.tasks, t.tasks, t.deleteTaskIds),
|
|
546
|
+
habits: q(e.habits, t.habits, t.deleteHabitIds),
|
|
547
|
+
projects: q(e.projects, t.projects, t.deleteProjectIds)
|
|
508
548
|
};
|
|
509
549
|
}
|
|
510
|
-
function
|
|
550
|
+
function J(e, t, n) {
|
|
511
551
|
let r = [...e], [i] = r.splice(t, 1);
|
|
512
552
|
return r.splice(n, 0, i), r;
|
|
513
553
|
}
|
|
514
|
-
function
|
|
554
|
+
function Oe(e, n, r, i, a) {
|
|
515
555
|
let o = n.indexOf(r), s = n.indexOf(i);
|
|
516
556
|
if (o < 0 || s < 0 || o === s) return {};
|
|
517
557
|
let c = new Map(e.tasks.map((e) => [e.id, e])), l = c.get(i), u = c.get(r);
|
|
518
558
|
if (!l || !u) return {};
|
|
519
|
-
let d = l.priority, f =
|
|
559
|
+
let d = l.priority, f = J(n, o, s).map((e) => c.get(e)).filter((e) => !!e).map((e) => e.id === r ? {
|
|
520
560
|
...e,
|
|
521
561
|
priority: d
|
|
522
|
-
} : e), p =
|
|
562
|
+
} : e), p = z(a), m = [];
|
|
523
563
|
for (let e of t) f.filter((t) => t.priority === e).forEach((e, t) => {
|
|
524
564
|
let n = c.get(e.id);
|
|
525
565
|
(n.order !== t || n.priority !== e.priority) && m.push({
|
|
@@ -530,11 +570,11 @@ function Se(e, n, r, i, a) {
|
|
|
530
570
|
});
|
|
531
571
|
return { tasks: m };
|
|
532
572
|
}
|
|
533
|
-
function
|
|
573
|
+
function ke(e, t, n, r, i) {
|
|
534
574
|
let a = t.indexOf(n), o = t.indexOf(r);
|
|
535
575
|
if (a < 0 || o < 0 || a === o) return {};
|
|
536
|
-
let s = new Map(e.habits.map((e) => [e.id, e])), c =
|
|
537
|
-
return { habits:
|
|
576
|
+
let s = new Map(e.habits.map((e) => [e.id, e])), c = z(i);
|
|
577
|
+
return { habits: J(t, a, o).map((e, t) => ({
|
|
538
578
|
habit: s.get(e),
|
|
539
579
|
order: t
|
|
540
580
|
})).filter((e) => !!e.habit && e.habit.order !== e.order).map(({ habit: e, order: t }) => ({
|
|
@@ -543,11 +583,11 @@ function Ce(e, t, n, r, i) {
|
|
|
543
583
|
updatedAt: c
|
|
544
584
|
})) };
|
|
545
585
|
}
|
|
546
|
-
function
|
|
586
|
+
function Ae(e, t, n, r) {
|
|
547
587
|
let i = e.projects.find((e) => e.id === t), a = [...e.projects].filter((e) => e.parentId === i?.parentId).sort((e, t) => e.order - t.order).map((e) => e.id), o = a.indexOf(t), s = a.indexOf(n);
|
|
548
588
|
if (o < 0 || s < 0 || o === s) return {};
|
|
549
|
-
let c = new Map(e.projects.map((e) => [e.id, e])), l =
|
|
550
|
-
return { projects:
|
|
589
|
+
let c = new Map(e.projects.map((e) => [e.id, e])), l = z(r);
|
|
590
|
+
return { projects: J(a, o, s).map((e, t) => ({
|
|
551
591
|
project: c.get(e),
|
|
552
592
|
order: t
|
|
553
593
|
})).filter(({ project: e, order: t }) => e.order !== t).map(({ project: e, order: t }) => ({
|
|
@@ -556,23 +596,23 @@ function we(e, t, n, r) {
|
|
|
556
596
|
updatedAt: l
|
|
557
597
|
})) };
|
|
558
598
|
}
|
|
559
|
-
function
|
|
560
|
-
return t.find((t) => t.habitId === e.id && !
|
|
599
|
+
function Y(e, t, n) {
|
|
600
|
+
return t.find((t) => t.habitId === e.id && !E(t, n));
|
|
561
601
|
}
|
|
562
|
-
function
|
|
563
|
-
return
|
|
602
|
+
function je(e) {
|
|
603
|
+
return I(_(e.period));
|
|
564
604
|
}
|
|
565
|
-
function
|
|
566
|
-
let i =
|
|
605
|
+
function Me(e, t, n, r) {
|
|
606
|
+
let i = z(r), a = n === "tomorrow" ? "today" : n === "nextweek" ? "week" : n, o = Y(t, e.tasks, r);
|
|
567
607
|
return {
|
|
568
608
|
tasks: [{
|
|
569
609
|
id: crypto.randomUUID(),
|
|
570
610
|
title: t.title,
|
|
571
611
|
horizon: a,
|
|
572
612
|
priority: "C",
|
|
573
|
-
order:
|
|
613
|
+
order: B(e.tasks, a, "C"),
|
|
574
614
|
habitId: t.id,
|
|
575
|
-
...
|
|
615
|
+
...T(n, r) ? { placedFor: T(n, r) } : {},
|
|
576
616
|
...t.projectId ? { projectId: t.projectId } : {},
|
|
577
617
|
...t.note ? { note: t.note } : {},
|
|
578
618
|
createdAt: i,
|
|
@@ -581,10 +621,10 @@ function Ee(e, t, n, r) {
|
|
|
581
621
|
deleteTaskIds: o && !o.doneAt ? [o.id] : []
|
|
582
622
|
};
|
|
583
623
|
}
|
|
584
|
-
function
|
|
585
|
-
let r =
|
|
624
|
+
function Ne(e, t, n) {
|
|
625
|
+
let r = W(t, n), i = d(r.period, r.checkedAt, n), a = Y(t, e.tasks, n);
|
|
586
626
|
if (!a || !!a.doneAt === i) return { habits: [r] };
|
|
587
|
-
let o =
|
|
627
|
+
let o = z(n), { doneAt: s, ...c } = a;
|
|
588
628
|
return {
|
|
589
629
|
habits: [r],
|
|
590
630
|
tasks: [i ? {
|
|
@@ -597,8 +637,8 @@ function De(e, t, n) {
|
|
|
597
637
|
}]
|
|
598
638
|
};
|
|
599
639
|
}
|
|
600
|
-
function
|
|
601
|
-
let r =
|
|
640
|
+
function Pe(e, t, n) {
|
|
641
|
+
let r = V(e, {
|
|
602
642
|
title: t.title,
|
|
603
643
|
horizon: _(t.period),
|
|
604
644
|
priority: "C",
|
|
@@ -612,10 +652,10 @@ function Oe(e, t, n) {
|
|
|
612
652
|
deleteHabitIds: [t.id]
|
|
613
653
|
};
|
|
614
654
|
}
|
|
615
|
-
function
|
|
655
|
+
function Fe(e, t) {
|
|
616
656
|
if (e.day) return b(e.day, t);
|
|
617
657
|
}
|
|
618
|
-
function
|
|
658
|
+
function Ie(e, t) {
|
|
619
659
|
let { due: n, ...r } = e, i = (/* @__PURE__ */ new Date()).toISOString();
|
|
620
660
|
return { tasks: [t ? {
|
|
621
661
|
...r,
|
|
@@ -626,7 +666,7 @@ function Ae(e, t) {
|
|
|
626
666
|
updatedAt: i
|
|
627
667
|
}] };
|
|
628
668
|
}
|
|
629
|
-
function
|
|
669
|
+
function Le(e, t) {
|
|
630
670
|
let { day: n, ...r } = e;
|
|
631
671
|
return {
|
|
632
672
|
...r,
|
|
@@ -634,8 +674,8 @@ function je(e, t) {
|
|
|
634
674
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
635
675
|
};
|
|
636
676
|
}
|
|
637
|
-
function
|
|
638
|
-
let i = n(t), a = e.history ?? [], o =
|
|
677
|
+
function Re(e, t, r) {
|
|
678
|
+
let i = n(t), a = e.history ?? [], o = z(r), c = s(e.period, t) === s(e.period, r);
|
|
639
679
|
if (a.includes(i)) {
|
|
640
680
|
let { checkedAt: t, ...r } = e, s = a.filter((e) => e !== i);
|
|
641
681
|
return {
|
|
@@ -647,17 +687,17 @@ function Me(e, t, r) {
|
|
|
647
687
|
let l = [...a, i].sort().slice(-800), u = i === n(r) ? r : new Date(t.getFullYear(), t.getMonth(), t.getDate(), 12), f = c && !d(e.period, e.checkedAt, r);
|
|
648
688
|
return {
|
|
649
689
|
...e,
|
|
650
|
-
...f ? { checkedAt:
|
|
690
|
+
...f ? { checkedAt: z(u) } : {},
|
|
651
691
|
history: l,
|
|
652
692
|
updatedAt: o
|
|
653
693
|
};
|
|
654
694
|
}
|
|
655
|
-
function
|
|
656
|
-
return
|
|
695
|
+
function ze(e, t, r, i) {
|
|
696
|
+
return U(e, t, n(r) === n(i) ? i : new Date(r.getFullYear(), r.getMonth(), r.getDate(), 12));
|
|
657
697
|
}
|
|
658
|
-
function
|
|
659
|
-
let r =
|
|
660
|
-
return
|
|
698
|
+
function Be(e, t) {
|
|
699
|
+
let r = z(t), i = n(u(t, 1));
|
|
700
|
+
return A(e) ? { tasks: [{
|
|
661
701
|
...e,
|
|
662
702
|
due: i,
|
|
663
703
|
updatedAt: r
|
|
@@ -668,9 +708,9 @@ function Pe(e, t) {
|
|
|
668
708
|
updatedAt: r
|
|
669
709
|
}] };
|
|
670
710
|
}
|
|
671
|
-
function
|
|
672
|
-
let r =
|
|
673
|
-
if (
|
|
711
|
+
function Ve(e, t) {
|
|
712
|
+
let r = z(t);
|
|
713
|
+
if (A(e)) return { tasks: [{
|
|
674
714
|
...e,
|
|
675
715
|
due: n(t),
|
|
676
716
|
updatedAt: r
|
|
@@ -687,22 +727,22 @@ function Fe(e, t) {
|
|
|
687
727
|
updatedAt: r
|
|
688
728
|
}] };
|
|
689
729
|
}
|
|
690
|
-
function
|
|
691
|
-
let n = e.tasks.filter((e) =>
|
|
730
|
+
function He(e, t) {
|
|
731
|
+
let n = e.tasks.filter((e) => j(e) && e.projectId === t), r = n.filter((e) => !e.doneAt), i = (e) => e.goalOrder ?? (e.due ? 2 ** 53 - 1 : -(2 ** 53 - 1)), a = [...r].sort((e, t) => i(e) - i(t) || e.createdAt.localeCompare(t.createdAt)), o = r.filter((e) => e.due).sort((e, t) => t.due.localeCompare(e.due) || e.createdAt.localeCompare(t.createdAt)), s = 0;
|
|
692
732
|
return {
|
|
693
733
|
open: a.map((e) => e.due ? o[s++] : e),
|
|
694
734
|
done: n.filter((e) => e.doneAt).sort((e, t) => (t.due ?? "").localeCompare(e.due ?? "") || e.createdAt.localeCompare(t.createdAt))
|
|
695
735
|
};
|
|
696
736
|
}
|
|
697
|
-
function
|
|
698
|
-
let n = e.tasks.filter((e) => e.projectId === t && e.goalOrder !== void 0).map((e) => e.goalOrder), r = e.tasks.filter((e) =>
|
|
737
|
+
function Ue(e, t) {
|
|
738
|
+
let n = e.tasks.filter((e) => e.projectId === t && e.goalOrder !== void 0).map((e) => e.goalOrder), r = e.tasks.filter((e) => j(e) && e.projectId === t).length;
|
|
699
739
|
return Math.max(r, ...n.map((e) => e + 1));
|
|
700
740
|
}
|
|
701
|
-
function
|
|
741
|
+
function We(e, t, n, r, i) {
|
|
702
742
|
let a = t.indexOf(n), o = t.indexOf(r);
|
|
703
743
|
if (a < 0 || o < 0 || a === o) return {};
|
|
704
|
-
let s = new Map(e.tasks.map((e) => [e.id, e])), c =
|
|
705
|
-
return { tasks:
|
|
744
|
+
let s = new Map(e.tasks.map((e) => [e.id, e])), c = z(i);
|
|
745
|
+
return { tasks: J(t, a, o).map((e, t) => ({
|
|
706
746
|
task: s.get(e),
|
|
707
747
|
goalOrder: t
|
|
708
748
|
})).filter((e) => !!e.task && e.task.goalOrder !== e.goalOrder).map(({ task: e, goalOrder: t }) => ({
|
|
@@ -712,22 +752,22 @@ function Re(e, t, n, r, i) {
|
|
|
712
752
|
})) };
|
|
713
753
|
}
|
|
714
754
|
// src/core/labels.ts
|
|
715
|
-
var
|
|
755
|
+
var Ge = {
|
|
716
756
|
today: "今日",
|
|
717
757
|
week: "今週",
|
|
718
758
|
month: "数か月",
|
|
719
759
|
year: "今年",
|
|
720
760
|
life: "一生"
|
|
721
|
-
},
|
|
761
|
+
}, Ke = {
|
|
722
762
|
today: "Action",
|
|
723
763
|
week: "Week",
|
|
724
764
|
month: "Month",
|
|
725
765
|
year: "Year",
|
|
726
766
|
life: "⭐"
|
|
727
|
-
},
|
|
728
|
-
...
|
|
767
|
+
}, qe = {
|
|
768
|
+
...Ge,
|
|
729
769
|
pool: "未定(置き場)"
|
|
730
|
-
},
|
|
770
|
+
}, Je = {
|
|
731
771
|
today: "今日やる",
|
|
732
772
|
tomorrow: "明日やる",
|
|
733
773
|
nextweek: "来週やる",
|
|
@@ -735,7 +775,7 @@ var Q = {
|
|
|
735
775
|
month: "数か月以内にやる",
|
|
736
776
|
year: "今年やる",
|
|
737
777
|
life: "一生のうちに"
|
|
738
|
-
},
|
|
778
|
+
}, Ye = {
|
|
739
779
|
today: "今日",
|
|
740
780
|
tomorrow: "明日",
|
|
741
781
|
nextweek: "来週",
|
|
@@ -743,25 +783,25 @@ var Q = {
|
|
|
743
783
|
month: "数か月",
|
|
744
784
|
year: "今年",
|
|
745
785
|
life: "一生"
|
|
746
|
-
},
|
|
786
|
+
}, Xe = {
|
|
747
787
|
A: "重要・緊急",
|
|
748
788
|
B: "重要",
|
|
749
789
|
C: "通常",
|
|
750
790
|
D: "低",
|
|
751
791
|
P: "Private"
|
|
752
|
-
},
|
|
792
|
+
}, Ze = {
|
|
753
793
|
day: "毎日",
|
|
754
794
|
week: "毎週",
|
|
755
795
|
month: "毎月",
|
|
756
796
|
year: "毎年"
|
|
757
797
|
};
|
|
758
798
|
// src/core/review.ts
|
|
759
|
-
function
|
|
799
|
+
function X(e) {
|
|
760
800
|
let t = new Set(e.history ?? []);
|
|
761
801
|
return e.checkedAt && t.add(n(new Date(e.checkedAt))), t;
|
|
762
802
|
}
|
|
763
|
-
function
|
|
764
|
-
let r =
|
|
803
|
+
function Qe(e, t) {
|
|
804
|
+
let r = X(e);
|
|
765
805
|
if (e.period === "day") return r.has(n(t));
|
|
766
806
|
let i = s(e.period, t);
|
|
767
807
|
for (let t of r) {
|
|
@@ -770,21 +810,59 @@ function Ge(e, t) {
|
|
|
770
810
|
}
|
|
771
811
|
return !1;
|
|
772
812
|
}
|
|
773
|
-
function
|
|
813
|
+
function Z(e) {
|
|
814
|
+
if (!e) return;
|
|
815
|
+
let t = new Date(e);
|
|
816
|
+
return Number.isNaN(t.getTime()) ? void 0 : n(t);
|
|
817
|
+
}
|
|
818
|
+
function Q(e, t) {
|
|
819
|
+
let n = Z(e.createdAt) ?? "", r = e.history ?? [], i = [...t].sort()[0];
|
|
820
|
+
return r.length >= 800 && r[0] > n ? r[0] : i && i < n ? i : n;
|
|
821
|
+
}
|
|
822
|
+
function $(e, t, n, r) {
|
|
823
|
+
if (t.has(n)) return !0;
|
|
824
|
+
if (n < r) return !1;
|
|
825
|
+
let i = Z(e.endedAt);
|
|
826
|
+
return i && n >= i ? !1 : !(e.breaks ?? []).some((e) => {
|
|
827
|
+
let t = Z(e.endedAt), r = Z(e.resumedAt);
|
|
828
|
+
return !!t && !!r && n >= t && n < r;
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
function $e(e, t) {
|
|
832
|
+
let r = X(e);
|
|
833
|
+
return $(e, r, n(t), Q(e, r));
|
|
834
|
+
}
|
|
835
|
+
function et(e, t) {
|
|
836
|
+
let r = X(e), i = Q(e, r), a = e.endedAt ? new Date(e.endedAt) : void 0, o = a && !Number.isNaN(a.getTime()) ? a : void 0, c = o ?? t, l = n(c), [d, f, p] = (i || l).split("-").map(Number), m = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set();
|
|
837
|
+
for (let t = new Date(d, f - 1, p); n(t) <= l; t = u(t, 1)) {
|
|
838
|
+
let a = n(t);
|
|
839
|
+
if (!$(e, r, a, i)) continue;
|
|
840
|
+
let o = s(e.period, t);
|
|
841
|
+
m.add(o), r.has(a) && h.add(o);
|
|
842
|
+
}
|
|
843
|
+
let g = s(e.period, c);
|
|
844
|
+
return h.has(g) || m.delete(g), {
|
|
845
|
+
start: new Date(d, f - 1, p),
|
|
846
|
+
...o ? { end: o } : {},
|
|
847
|
+
done: h.size,
|
|
848
|
+
total: m.size
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
function tt(e, t) {
|
|
774
852
|
if (e.period !== "day") return 0;
|
|
775
|
-
let r =
|
|
853
|
+
let r = X(e), i = r.has(n(t)) ? t : u(t, -1), a = 0;
|
|
776
854
|
for (; r.has(n(i));) a++, i = u(i, -1);
|
|
777
855
|
return a;
|
|
778
856
|
}
|
|
779
|
-
function
|
|
857
|
+
function nt(e, t, r) {
|
|
780
858
|
let i = n(t), a = new Map(e.projects.map((e) => [e.id, e])), o = new Set(e.tasks.filter((e) => e.parentId && e.doneAt).map((e) => e.parentId));
|
|
781
859
|
return e.tasks.filter((e) => e.doneAt && n(new Date(e.doneAt)) === i && !o.has(e.id)).sort((e, t) => e.doneAt.localeCompare(t.doneAt)).map((e) => ({
|
|
782
860
|
task: e,
|
|
783
|
-
horizon:
|
|
861
|
+
horizon: N(e, r),
|
|
784
862
|
project: e.projectId ? a.get(e.projectId) : void 0
|
|
785
863
|
}));
|
|
786
864
|
}
|
|
787
|
-
function
|
|
865
|
+
function rt(e, t) {
|
|
788
866
|
return Array.from({ length: t }, (n, r) => u(e, r - t + 1));
|
|
789
867
|
}
|
|
790
|
-
export { e as HORIZONS, l as HORIZON_HABIT_PERIOD,
|
|
868
|
+
export { be as HABIT_HISTORY_LIMIT, e as HORIZONS, l as HORIZON_HABIT_PERIOD, Ge as HORIZON_NAME, qe as HORIZON_OPTION, c as HORIZON_PERIOD, Ke as HORIZON_SUB, Ze as PERIOD_NAME, Ye as PLACED_MARK, Je as PLACE_LABEL, t as PRIORITIES, Xe as PRIORITY_NAME, F as activeChild, Y as activeHabitChild, u as addDays, De as applyChanges, w as autoDue, Ve as bringToToday, fe as buildColumns, K as childProjects, n as dayKey, v as dayLabel, h as daysUntil, nt as doneOn, m as dueLabel, ee as dueLabelWeekday, N as effectiveHorizon, de as emptyPriorityGaps, xe as endHabit, G as endedHabits, ze as finishOnDay, A as followsDue, O as goalDueNextWeek, $e as habitActiveOn, X as habitDays, Qe as habitDoneOn, je as habitPlaceTargets, et as habitRecord, Pe as habitToTask, S as hasWhen, M as horizonForDue, d as inSamePeriod, E as isExpired, D as isForNextWeek, k as isForTomorrow, oe as isMonthOnly, j as isProjectGoal, P as isVisible, rt as lastDays, q as mergeById, b as monthDayDate, a as monthKey, Fe as monthlyDueDate, Ee as moveProject, ge as moveStep, he as moveTo, ye as newHabit, Ce as newProject, V as newTask, Ue as nextGoalOrder, L as numbered, y as parseNthWeekday, x as parseYearDay, _ as periodHorizon, s as periodKey, p as periodLabel, pe as placeDown, Me as placeHabitDown, I as placeTargets, T as placedForKey, Be as postponeToTomorrow, He as projectGoals, ue as quickTarget, Te as removeProject, ve as removeTask, We as reorderGoals, ke as reorderHabits, Ae as reorderProjects, Oe as reorderTasks, Se as resumeHabit, me as returnUp, Ie as setDue, _e as setPriority, te as shortDueLabel, tt as streak, U as toggleDone, W as toggleHabit, Ne as toggleHabitAll, Re as toggleHabitOnDay, we as topProjects, r as weekKey, i as weekStart, C as whenDate, re as whenLabel, Le as withDay, ae as withWhen, o as yearKey };
|