@shiodome47/planner 0.3.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 +2 -1
- package/dist/chunks/{JumpBar-DLj7SMVP.js → JumpBar-43r8C8G3.js} +14 -12
- package/dist/core/logic.d.ts +10 -0
- package/dist/core.js +179 -171
- package/dist/projects.js +1 -1
- package/dist/style.css +1 -1
- package/dist/timeline.js +136 -89
- package/dist/ui/dnd.d.ts +4 -1
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -204,115 +204,123 @@ 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
273
|
}
|
|
274
|
-
function
|
|
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
|
+
};
|
|
281
|
+
}
|
|
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 = t.habits.filter((e) => !e.endedAt), m = u ? p.filter((e) => e.period === u).sort(
|
|
315
|
-
for (let t of p.filter((e) => e.period !== u).sort(
|
|
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)) {
|
|
316
324
|
let r = w(t, e, n);
|
|
317
325
|
r && h.push(f(t, !0, r));
|
|
318
326
|
}
|
|
@@ -320,45 +328,45 @@ function ue(t, n) {
|
|
|
320
328
|
horizon: e,
|
|
321
329
|
habitPeriod: u,
|
|
322
330
|
habits: [...m, ...h],
|
|
323
|
-
tasks:
|
|
324
|
-
tomorrow:
|
|
325
|
-
nextWeek:
|
|
326
|
-
ended: u ?
|
|
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)) : []
|
|
327
335
|
};
|
|
328
336
|
});
|
|
329
337
|
}
|
|
330
|
-
var
|
|
331
|
-
function
|
|
338
|
+
var z = (e) => e.toISOString();
|
|
339
|
+
function B(e, t, n) {
|
|
332
340
|
let r = e.filter((e) => e.horizon === t && e.priority === n);
|
|
333
341
|
return r.length === 0 ? 0 : Math.max(...r.map((e) => e.order)) + 1;
|
|
334
342
|
}
|
|
335
|
-
function
|
|
336
|
-
let r =
|
|
343
|
+
function V(e, t, n) {
|
|
344
|
+
let r = z(n);
|
|
337
345
|
return {
|
|
338
346
|
id: crypto.randomUUID(),
|
|
339
347
|
title: t.title,
|
|
340
348
|
horizon: t.horizon,
|
|
341
349
|
priority: t.priority,
|
|
342
|
-
order:
|
|
343
|
-
...t.tomorrow ? { placedFor:
|
|
344
|
-
...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) } : {},
|
|
345
353
|
...t.projectId ? { projectId: t.projectId } : {},
|
|
346
354
|
...t.due ? { due: t.due } : {},
|
|
347
355
|
createdAt: r,
|
|
348
356
|
updatedAt: r
|
|
349
357
|
};
|
|
350
358
|
}
|
|
351
|
-
function
|
|
352
|
-
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) : [];
|
|
353
361
|
return {
|
|
354
362
|
tasks: [{
|
|
355
363
|
id: crypto.randomUUID(),
|
|
356
364
|
title: t.title,
|
|
357
365
|
horizon: a,
|
|
358
366
|
priority: t.priority,
|
|
359
|
-
order:
|
|
367
|
+
order: B(e.tasks, a, t.priority),
|
|
360
368
|
parentId: t.id,
|
|
361
|
-
...
|
|
369
|
+
...T(n, r) ? { placedFor: T(n, r) } : {},
|
|
362
370
|
...t.projectId ? { projectId: t.projectId } : {},
|
|
363
371
|
...t.due ? { due: t.due } : {},
|
|
364
372
|
...t.note ? { note: t.note } : {},
|
|
@@ -368,28 +376,28 @@ function de(e, t, n, r) {
|
|
|
368
376
|
deleteTaskIds: s
|
|
369
377
|
};
|
|
370
378
|
}
|
|
371
|
-
function
|
|
372
|
-
return { deleteTaskIds: [t.id, ...
|
|
379
|
+
function me(e, t, n) {
|
|
380
|
+
return { deleteTaskIds: [t.id, ...H(e.tasks, t.id, n)] };
|
|
373
381
|
}
|
|
374
|
-
function
|
|
382
|
+
function he(e, t, n, r) {
|
|
375
383
|
if (t.horizon === n) return {};
|
|
376
384
|
let { placedFor: i, ...a } = t;
|
|
377
385
|
return { tasks: [{
|
|
378
386
|
...a,
|
|
379
387
|
horizon: n,
|
|
380
|
-
order:
|
|
381
|
-
updatedAt:
|
|
388
|
+
order: B(e.tasks, n, t.priority),
|
|
389
|
+
updatedAt: z(r)
|
|
382
390
|
}] };
|
|
383
391
|
}
|
|
384
|
-
function
|
|
392
|
+
function H(e, t, n) {
|
|
385
393
|
let r = [];
|
|
386
|
-
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));
|
|
387
395
|
return r;
|
|
388
396
|
}
|
|
389
|
-
function
|
|
390
|
-
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)]);
|
|
391
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);
|
|
392
|
-
let a =
|
|
400
|
+
let a = z(n), o = !t.doneAt, s = [...i].map((e) => r.get(e)).filter((e) => !!e).map((e) => {
|
|
393
401
|
let { doneAt: t, ...n } = e;
|
|
394
402
|
return o ? {
|
|
395
403
|
...n,
|
|
@@ -402,13 +410,13 @@ function W(e, t, n) {
|
|
|
402
410
|
}), c = t.habitId ? e.habits.find((e) => e.id === t.habitId) : void 0;
|
|
403
411
|
return c && d(c.period, c.checkedAt, n) !== o ? {
|
|
404
412
|
tasks: s,
|
|
405
|
-
habits: [
|
|
413
|
+
habits: [W(c, n)]
|
|
406
414
|
} : { tasks: s };
|
|
407
415
|
}
|
|
408
|
-
function
|
|
409
|
-
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;
|
|
410
418
|
if (a < 0 || o < 0 || o >= i.length) return {};
|
|
411
|
-
let s =
|
|
419
|
+
let s = z(r), c = [...i];
|
|
412
420
|
[c[a], c[o]] = [c[o], c[a]];
|
|
413
421
|
let l = new Map(i.map((e) => [e.id, e.order]));
|
|
414
422
|
return { tasks: c.map((e, t) => ({
|
|
@@ -417,19 +425,19 @@ function me(e, t, n, r) {
|
|
|
417
425
|
updatedAt: s
|
|
418
426
|
})).filter((e) => l.get(e.id) !== e.order) };
|
|
419
427
|
}
|
|
420
|
-
function
|
|
428
|
+
function _e(e, t, n, r) {
|
|
421
429
|
return t.priority === n ? {} : { tasks: [{
|
|
422
430
|
...t,
|
|
423
431
|
priority: n,
|
|
424
|
-
order:
|
|
425
|
-
updatedAt:
|
|
432
|
+
order: B(e.tasks, t.horizon, n),
|
|
433
|
+
updatedAt: z(r)
|
|
426
434
|
}] };
|
|
427
435
|
}
|
|
428
|
-
function
|
|
429
|
-
return { deleteTaskIds: [t.id, ...
|
|
436
|
+
function ve(e, t, n) {
|
|
437
|
+
return { deleteTaskIds: [t.id, ...H(e.tasks, t.id, n)] };
|
|
430
438
|
}
|
|
431
|
-
function
|
|
432
|
-
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);
|
|
433
441
|
return {
|
|
434
442
|
id: crypto.randomUUID(),
|
|
435
443
|
title: t.title,
|
|
@@ -440,8 +448,8 @@ function _e(e, t, n) {
|
|
|
440
448
|
updatedAt: i
|
|
441
449
|
};
|
|
442
450
|
}
|
|
443
|
-
function
|
|
444
|
-
let { checkedAt: r, ...i } = e, a =
|
|
451
|
+
function W(e, t) {
|
|
452
|
+
let { checkedAt: r, ...i } = e, a = z(t), o = e.history ?? [];
|
|
445
453
|
if (d(e.period, e.checkedAt, t)) {
|
|
446
454
|
let t = n(new Date(e.checkedAt));
|
|
447
455
|
return {
|
|
@@ -458,26 +466,26 @@ function G(e, t) {
|
|
|
458
466
|
updatedAt: a
|
|
459
467
|
};
|
|
460
468
|
}
|
|
461
|
-
var
|
|
462
|
-
function
|
|
469
|
+
var be = 800;
|
|
470
|
+
function G(e) {
|
|
463
471
|
return e.filter((e) => e.endedAt).sort((e, t) => t.endedAt.localeCompare(e.endedAt));
|
|
464
472
|
}
|
|
465
|
-
function
|
|
466
|
-
let a =
|
|
473
|
+
function xe(e, t, n, r, i) {
|
|
474
|
+
let a = z(i), { endNote: o, ...s } = t, c = r.trim(), l = {
|
|
467
475
|
...s,
|
|
468
476
|
endedAt: t.endedAt ?? a,
|
|
469
477
|
endedAs: n,
|
|
470
478
|
...c ? { endNote: c } : {},
|
|
471
479
|
updatedAt: a
|
|
472
|
-
}, u = t.endedAt ? [] : e.tasks.filter((e) => e.habitId === t.id && !e.doneAt && !
|
|
480
|
+
}, u = t.endedAt ? [] : e.tasks.filter((e) => e.habitId === t.id && !e.doneAt && !E(e, i));
|
|
473
481
|
return {
|
|
474
482
|
habits: [l],
|
|
475
483
|
...u.length ? { deleteTaskIds: u.map((e) => e.id) } : {}
|
|
476
484
|
};
|
|
477
485
|
}
|
|
478
|
-
function
|
|
486
|
+
function Se(e, t, r) {
|
|
479
487
|
if (!t.endedAt) return {};
|
|
480
|
-
let i =
|
|
488
|
+
let i = z(r), { endedAt: a, endedAs: o, endNote: s, breaks: c, ...l } = t, u = n(new Date(a)) === n(r), d = {
|
|
481
489
|
endedAt: a,
|
|
482
490
|
endedAs: o ?? "paused",
|
|
483
491
|
...s ? { endNote: s } : {},
|
|
@@ -490,8 +498,8 @@ function be(e, t, r) {
|
|
|
490
498
|
updatedAt: i
|
|
491
499
|
}] };
|
|
492
500
|
}
|
|
493
|
-
function
|
|
494
|
-
let r =
|
|
501
|
+
function Ce(e, t, n) {
|
|
502
|
+
let r = z(n), i = e.projects.filter((e) => e.parentId === t.parentId);
|
|
495
503
|
return {
|
|
496
504
|
id: crypto.randomUUID(),
|
|
497
505
|
name: t.name,
|
|
@@ -502,56 +510,56 @@ function xe(e, t, n) {
|
|
|
502
510
|
updatedAt: r
|
|
503
511
|
};
|
|
504
512
|
}
|
|
505
|
-
function
|
|
513
|
+
function K(e, t) {
|
|
506
514
|
return e.projects.filter((e) => e.parentId === t).sort((e, t) => e.order - t.order);
|
|
507
515
|
}
|
|
508
|
-
function
|
|
516
|
+
function we(e) {
|
|
509
517
|
let t = new Set(e.projects.map((e) => e.id));
|
|
510
518
|
return e.projects.filter((e) => !e.parentId || !t.has(e.parentId)).sort((e, t) => e.order - t.order);
|
|
511
519
|
}
|
|
512
|
-
function
|
|
513
|
-
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)]);
|
|
514
522
|
return {
|
|
515
523
|
deleteProjectIds: [...n],
|
|
516
524
|
deleteTaskIds: e.tasks.filter((e) => e.projectId && n.has(e.projectId)).map((e) => e.id),
|
|
517
525
|
deleteHabitIds: e.habits.filter((e) => e.projectId && n.has(e.projectId)).map((e) => e.id)
|
|
518
526
|
};
|
|
519
527
|
}
|
|
520
|
-
function
|
|
521
|
-
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 {};
|
|
522
530
|
let i = e.projects.filter((e) => e.parentId === n && e.id !== t.id), { parentId: a, ...o } = t;
|
|
523
531
|
return { projects: [{
|
|
524
532
|
...o,
|
|
525
533
|
...n ? { parentId: n } : {},
|
|
526
534
|
order: i.length === 0 ? 0 : Math.max(...i.map((e) => e.order)) + 1,
|
|
527
|
-
updatedAt:
|
|
535
|
+
updatedAt: z(r)
|
|
528
536
|
}] };
|
|
529
537
|
}
|
|
530
|
-
function
|
|
538
|
+
function q(e, t = [], n = []) {
|
|
531
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));
|
|
532
540
|
return [...a, ...o];
|
|
533
541
|
}
|
|
534
|
-
function
|
|
542
|
+
function De(e, t) {
|
|
535
543
|
return {
|
|
536
544
|
...e,
|
|
537
|
-
tasks:
|
|
538
|
-
habits:
|
|
539
|
-
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)
|
|
540
548
|
};
|
|
541
549
|
}
|
|
542
|
-
function
|
|
550
|
+
function J(e, t, n) {
|
|
543
551
|
let r = [...e], [i] = r.splice(t, 1);
|
|
544
552
|
return r.splice(n, 0, i), r;
|
|
545
553
|
}
|
|
546
|
-
function
|
|
554
|
+
function Oe(e, n, r, i, a) {
|
|
547
555
|
let o = n.indexOf(r), s = n.indexOf(i);
|
|
548
556
|
if (o < 0 || s < 0 || o === s) return {};
|
|
549
557
|
let c = new Map(e.tasks.map((e) => [e.id, e])), l = c.get(i), u = c.get(r);
|
|
550
558
|
if (!l || !u) return {};
|
|
551
|
-
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 ? {
|
|
552
560
|
...e,
|
|
553
561
|
priority: d
|
|
554
|
-
} : e), p =
|
|
562
|
+
} : e), p = z(a), m = [];
|
|
555
563
|
for (let e of t) f.filter((t) => t.priority === e).forEach((e, t) => {
|
|
556
564
|
let n = c.get(e.id);
|
|
557
565
|
(n.order !== t || n.priority !== e.priority) && m.push({
|
|
@@ -562,11 +570,11 @@ function Ee(e, n, r, i, a) {
|
|
|
562
570
|
});
|
|
563
571
|
return { tasks: m };
|
|
564
572
|
}
|
|
565
|
-
function
|
|
573
|
+
function ke(e, t, n, r, i) {
|
|
566
574
|
let a = t.indexOf(n), o = t.indexOf(r);
|
|
567
575
|
if (a < 0 || o < 0 || a === o) return {};
|
|
568
|
-
let s = new Map(e.habits.map((e) => [e.id, e])), c =
|
|
569
|
-
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) => ({
|
|
570
578
|
habit: s.get(e),
|
|
571
579
|
order: t
|
|
572
580
|
})).filter((e) => !!e.habit && e.habit.order !== e.order).map(({ habit: e, order: t }) => ({
|
|
@@ -575,11 +583,11 @@ function De(e, t, n, r, i) {
|
|
|
575
583
|
updatedAt: c
|
|
576
584
|
})) };
|
|
577
585
|
}
|
|
578
|
-
function
|
|
586
|
+
function Ae(e, t, n, r) {
|
|
579
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);
|
|
580
588
|
if (o < 0 || s < 0 || o === s) return {};
|
|
581
|
-
let c = new Map(e.projects.map((e) => [e.id, e])), l =
|
|
582
|
-
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) => ({
|
|
583
591
|
project: c.get(e),
|
|
584
592
|
order: t
|
|
585
593
|
})).filter(({ project: e, order: t }) => e.order !== t).map(({ project: e, order: t }) => ({
|
|
@@ -588,23 +596,23 @@ function Oe(e, t, n, r) {
|
|
|
588
596
|
updatedAt: l
|
|
589
597
|
})) };
|
|
590
598
|
}
|
|
591
|
-
function
|
|
592
|
-
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));
|
|
593
601
|
}
|
|
594
|
-
function
|
|
595
|
-
return
|
|
602
|
+
function je(e) {
|
|
603
|
+
return I(_(e.period));
|
|
596
604
|
}
|
|
597
|
-
function
|
|
598
|
-
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);
|
|
599
607
|
return {
|
|
600
608
|
tasks: [{
|
|
601
609
|
id: crypto.randomUUID(),
|
|
602
610
|
title: t.title,
|
|
603
611
|
horizon: a,
|
|
604
612
|
priority: "C",
|
|
605
|
-
order:
|
|
613
|
+
order: B(e.tasks, a, "C"),
|
|
606
614
|
habitId: t.id,
|
|
607
|
-
...
|
|
615
|
+
...T(n, r) ? { placedFor: T(n, r) } : {},
|
|
608
616
|
...t.projectId ? { projectId: t.projectId } : {},
|
|
609
617
|
...t.note ? { note: t.note } : {},
|
|
610
618
|
createdAt: i,
|
|
@@ -613,10 +621,10 @@ function Ae(e, t, n, r) {
|
|
|
613
621
|
deleteTaskIds: o && !o.doneAt ? [o.id] : []
|
|
614
622
|
};
|
|
615
623
|
}
|
|
616
|
-
function
|
|
617
|
-
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);
|
|
618
626
|
if (!a || !!a.doneAt === i) return { habits: [r] };
|
|
619
|
-
let o =
|
|
627
|
+
let o = z(n), { doneAt: s, ...c } = a;
|
|
620
628
|
return {
|
|
621
629
|
habits: [r],
|
|
622
630
|
tasks: [i ? {
|
|
@@ -629,8 +637,8 @@ function je(e, t, n) {
|
|
|
629
637
|
}]
|
|
630
638
|
};
|
|
631
639
|
}
|
|
632
|
-
function
|
|
633
|
-
let r =
|
|
640
|
+
function Pe(e, t, n) {
|
|
641
|
+
let r = V(e, {
|
|
634
642
|
title: t.title,
|
|
635
643
|
horizon: _(t.period),
|
|
636
644
|
priority: "C",
|
|
@@ -644,10 +652,10 @@ function Me(e, t, n) {
|
|
|
644
652
|
deleteHabitIds: [t.id]
|
|
645
653
|
};
|
|
646
654
|
}
|
|
647
|
-
function
|
|
655
|
+
function Fe(e, t) {
|
|
648
656
|
if (e.day) return b(e.day, t);
|
|
649
657
|
}
|
|
650
|
-
function
|
|
658
|
+
function Ie(e, t) {
|
|
651
659
|
let { due: n, ...r } = e, i = (/* @__PURE__ */ new Date()).toISOString();
|
|
652
660
|
return { tasks: [t ? {
|
|
653
661
|
...r,
|
|
@@ -658,7 +666,7 @@ function Pe(e, t) {
|
|
|
658
666
|
updatedAt: i
|
|
659
667
|
}] };
|
|
660
668
|
}
|
|
661
|
-
function
|
|
669
|
+
function Le(e, t) {
|
|
662
670
|
let { day: n, ...r } = e;
|
|
663
671
|
return {
|
|
664
672
|
...r,
|
|
@@ -666,8 +674,8 @@ function Fe(e, t) {
|
|
|
666
674
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
667
675
|
};
|
|
668
676
|
}
|
|
669
|
-
function
|
|
670
|
-
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);
|
|
671
679
|
if (a.includes(i)) {
|
|
672
680
|
let { checkedAt: t, ...r } = e, s = a.filter((e) => e !== i);
|
|
673
681
|
return {
|
|
@@ -679,17 +687,17 @@ function Ie(e, t, r) {
|
|
|
679
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);
|
|
680
688
|
return {
|
|
681
689
|
...e,
|
|
682
|
-
...f ? { checkedAt:
|
|
690
|
+
...f ? { checkedAt: z(u) } : {},
|
|
683
691
|
history: l,
|
|
684
692
|
updatedAt: o
|
|
685
693
|
};
|
|
686
694
|
}
|
|
687
|
-
function
|
|
688
|
-
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));
|
|
689
697
|
}
|
|
690
|
-
function
|
|
691
|
-
let r =
|
|
692
|
-
return
|
|
698
|
+
function Be(e, t) {
|
|
699
|
+
let r = z(t), i = n(u(t, 1));
|
|
700
|
+
return A(e) ? { tasks: [{
|
|
693
701
|
...e,
|
|
694
702
|
due: i,
|
|
695
703
|
updatedAt: r
|
|
@@ -700,9 +708,9 @@ function Re(e, t) {
|
|
|
700
708
|
updatedAt: r
|
|
701
709
|
}] };
|
|
702
710
|
}
|
|
703
|
-
function
|
|
704
|
-
let r =
|
|
705
|
-
if (
|
|
711
|
+
function Ve(e, t) {
|
|
712
|
+
let r = z(t);
|
|
713
|
+
if (A(e)) return { tasks: [{
|
|
706
714
|
...e,
|
|
707
715
|
due: n(t),
|
|
708
716
|
updatedAt: r
|
|
@@ -719,22 +727,22 @@ function ze(e, t) {
|
|
|
719
727
|
updatedAt: r
|
|
720
728
|
}] };
|
|
721
729
|
}
|
|
722
|
-
function
|
|
723
|
-
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;
|
|
724
732
|
return {
|
|
725
733
|
open: a.map((e) => e.due ? o[s++] : e),
|
|
726
734
|
done: n.filter((e) => e.doneAt).sort((e, t) => (t.due ?? "").localeCompare(e.due ?? "") || e.createdAt.localeCompare(t.createdAt))
|
|
727
735
|
};
|
|
728
736
|
}
|
|
729
|
-
function
|
|
730
|
-
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;
|
|
731
739
|
return Math.max(r, ...n.map((e) => e + 1));
|
|
732
740
|
}
|
|
733
|
-
function
|
|
741
|
+
function We(e, t, n, r, i) {
|
|
734
742
|
let a = t.indexOf(n), o = t.indexOf(r);
|
|
735
743
|
if (a < 0 || o < 0 || a === o) return {};
|
|
736
|
-
let s = new Map(e.tasks.map((e) => [e.id, e])), c =
|
|
737
|
-
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) => ({
|
|
738
746
|
task: s.get(e),
|
|
739
747
|
goalOrder: t
|
|
740
748
|
})).filter((e) => !!e.task && e.task.goalOrder !== e.goalOrder).map(({ task: e, goalOrder: t }) => ({
|
|
@@ -744,22 +752,22 @@ function He(e, t, n, r, i) {
|
|
|
744
752
|
})) };
|
|
745
753
|
}
|
|
746
754
|
// src/core/labels.ts
|
|
747
|
-
var
|
|
755
|
+
var Ge = {
|
|
748
756
|
today: "今日",
|
|
749
757
|
week: "今週",
|
|
750
758
|
month: "数か月",
|
|
751
759
|
year: "今年",
|
|
752
760
|
life: "一生"
|
|
753
|
-
},
|
|
761
|
+
}, Ke = {
|
|
754
762
|
today: "Action",
|
|
755
763
|
week: "Week",
|
|
756
764
|
month: "Month",
|
|
757
765
|
year: "Year",
|
|
758
766
|
life: "⭐"
|
|
759
|
-
},
|
|
760
|
-
...
|
|
767
|
+
}, qe = {
|
|
768
|
+
...Ge,
|
|
761
769
|
pool: "未定(置き場)"
|
|
762
|
-
},
|
|
770
|
+
}, Je = {
|
|
763
771
|
today: "今日やる",
|
|
764
772
|
tomorrow: "明日やる",
|
|
765
773
|
nextweek: "来週やる",
|
|
@@ -767,7 +775,7 @@ var Z = {
|
|
|
767
775
|
month: "数か月以内にやる",
|
|
768
776
|
year: "今年やる",
|
|
769
777
|
life: "一生のうちに"
|
|
770
|
-
},
|
|
778
|
+
}, Ye = {
|
|
771
779
|
today: "今日",
|
|
772
780
|
tomorrow: "明日",
|
|
773
781
|
nextweek: "来週",
|
|
@@ -775,25 +783,25 @@ var Z = {
|
|
|
775
783
|
month: "数か月",
|
|
776
784
|
year: "今年",
|
|
777
785
|
life: "一生"
|
|
778
|
-
},
|
|
786
|
+
}, Xe = {
|
|
779
787
|
A: "重要・緊急",
|
|
780
788
|
B: "重要",
|
|
781
789
|
C: "通常",
|
|
782
790
|
D: "低",
|
|
783
791
|
P: "Private"
|
|
784
|
-
},
|
|
792
|
+
}, Ze = {
|
|
785
793
|
day: "毎日",
|
|
786
794
|
week: "毎週",
|
|
787
795
|
month: "毎月",
|
|
788
796
|
year: "毎年"
|
|
789
797
|
};
|
|
790
798
|
// src/core/review.ts
|
|
791
|
-
function
|
|
799
|
+
function X(e) {
|
|
792
800
|
let t = new Set(e.history ?? []);
|
|
793
801
|
return e.checkedAt && t.add(n(new Date(e.checkedAt))), t;
|
|
794
802
|
}
|
|
795
|
-
function
|
|
796
|
-
let r =
|
|
803
|
+
function Qe(e, t) {
|
|
804
|
+
let r = X(e);
|
|
797
805
|
if (e.period === "day") return r.has(n(t));
|
|
798
806
|
let i = s(e.period, t);
|
|
799
807
|
for (let t of r) {
|
|
@@ -802,33 +810,33 @@ function Ye(e, t) {
|
|
|
802
810
|
}
|
|
803
811
|
return !1;
|
|
804
812
|
}
|
|
805
|
-
function
|
|
813
|
+
function Z(e) {
|
|
806
814
|
if (!e) return;
|
|
807
815
|
let t = new Date(e);
|
|
808
816
|
return Number.isNaN(t.getTime()) ? void 0 : n(t);
|
|
809
817
|
}
|
|
810
|
-
function
|
|
811
|
-
let n =
|
|
818
|
+
function Q(e, t) {
|
|
819
|
+
let n = Z(e.createdAt) ?? "", r = e.history ?? [], i = [...t].sort()[0];
|
|
812
820
|
return r.length >= 800 && r[0] > n ? r[0] : i && i < n ? i : n;
|
|
813
821
|
}
|
|
814
|
-
function
|
|
822
|
+
function $(e, t, n, r) {
|
|
815
823
|
if (t.has(n)) return !0;
|
|
816
824
|
if (n < r) return !1;
|
|
817
|
-
let i =
|
|
825
|
+
let i = Z(e.endedAt);
|
|
818
826
|
return i && n >= i ? !1 : !(e.breaks ?? []).some((e) => {
|
|
819
|
-
let t =
|
|
827
|
+
let t = Z(e.endedAt), r = Z(e.resumedAt);
|
|
820
828
|
return !!t && !!r && n >= t && n < r;
|
|
821
829
|
});
|
|
822
830
|
}
|
|
823
|
-
function Qe(e, t) {
|
|
824
|
-
let r = Q(e);
|
|
825
|
-
return Ze(e, r, n(t), Xe(e, r));
|
|
826
|
-
}
|
|
827
831
|
function $e(e, t) {
|
|
828
|
-
let r =
|
|
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();
|
|
829
837
|
for (let t = new Date(d, f - 1, p); n(t) <= l; t = u(t, 1)) {
|
|
830
838
|
let a = n(t);
|
|
831
|
-
if (
|
|
839
|
+
if (!$(e, r, a, i)) continue;
|
|
832
840
|
let o = s(e.period, t);
|
|
833
841
|
m.add(o), r.has(a) && h.add(o);
|
|
834
842
|
}
|
|
@@ -840,21 +848,21 @@ function $e(e, t) {
|
|
|
840
848
|
total: m.size
|
|
841
849
|
};
|
|
842
850
|
}
|
|
843
|
-
function
|
|
851
|
+
function tt(e, t) {
|
|
844
852
|
if (e.period !== "day") return 0;
|
|
845
|
-
let r =
|
|
853
|
+
let r = X(e), i = r.has(n(t)) ? t : u(t, -1), a = 0;
|
|
846
854
|
for (; r.has(n(i));) a++, i = u(i, -1);
|
|
847
855
|
return a;
|
|
848
856
|
}
|
|
849
|
-
function
|
|
857
|
+
function nt(e, t, r) {
|
|
850
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));
|
|
851
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) => ({
|
|
852
860
|
task: e,
|
|
853
|
-
horizon:
|
|
861
|
+
horizon: N(e, r),
|
|
854
862
|
project: e.projectId ? a.get(e.projectId) : void 0
|
|
855
863
|
}));
|
|
856
864
|
}
|
|
857
|
-
function
|
|
865
|
+
function rt(e, t) {
|
|
858
866
|
return Array.from({ length: t }, (n, r) => u(e, r - t + 1));
|
|
859
867
|
}
|
|
860
|
-
export {
|
|
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 };
|