@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.
@@ -1,904 +0,0 @@
1
- import { HORIZON_NAME as e, PERIOD_NAME as t, PLACED_MARK as n, PLACE_LABEL as r, PRIORITIES as i, PRIORITY_NAME as a, bringToToday as o, dayKey as s, dayLabel as c, daysUntil as l, dueLabelWeekday as u, goalDueNextWeek as d, habitPlaceTargets as f, habitToTask as p, horizonForDue as m, isForTomorrow as h, isMonthOnly as g, parseYearDay as _, periodHorizon as v, placeDown as y, placeHabitDown as b, placeTargets as x, postponeToTomorrow as S, quickTarget as ee, removeTask as te, returnUp as C, setDue as w, setPriority as T, shortDueLabel as E, toggleDone as ne, toggleHabitAll as D, whenLabel as re, withDay as O, withWhen as k } from "../core.js";
2
- import { createContext as A, useContext as j, useEffect as M, useLayoutEffect as N, useRef as P, useState as F } from "react";
3
- import { Fragment as I, jsx as L, jsxs as R } from "react/jsx-runtime";
4
- import { CalendarPlus as z, Check as ie, CornerUpLeft as ae, FileText as B, MoreHorizontal as V, X as H } from "lucide-react";
5
- import { SortableContext as oe, sortableKeyboardCoordinates as se, useSortable as ce } from "@dnd-kit/sortable";
6
- import { DndContext as le, KeyboardSensor as ue, closestCenter as de, useSensor as fe, useSensors as pe } from "@dnd-kit/core";
7
- import { CSS as me } from "@dnd-kit/utilities";
8
- import { useDragSensors as he } from "linkshelf";
9
- import { createPortal as ge } from "react-dom";
10
- // src/ui/display.tsx
11
- var U = A({ simple: !1 }), W = () => j(U);
12
- // src/ui/Root.tsx
13
- function _e({ simple: e = !1, theme: t = "system", className: n, children: r }) {
14
- return /* @__PURE__ */ L(U.Provider, {
15
- value: { simple: e },
16
- children: /* @__PURE__ */ L("div", {
17
- className: [
18
- "planner",
19
- e ? "pl-simple" : "",
20
- n ?? ""
21
- ].filter(Boolean).join(" "),
22
- "data-theme": t,
23
- children: r
24
- })
25
- });
26
- }
27
- // src/ui/dnd.tsx
28
- function ve({ ids: e, strategy: t, onMove: n, children: r }) {
29
- let i = ye();
30
- return /* @__PURE__ */ L(le, {
31
- sensors: i,
32
- collisionDetection: de,
33
- onDragEnd: ({ active: e, over: t }) => {
34
- t && e.id !== t.id && n(String(e.id), String(t.id));
35
- },
36
- children: /* @__PURE__ */ L(oe, {
37
- items: e,
38
- strategy: t,
39
- children: r
40
- })
41
- });
42
- }
43
- function G(e, t = !1) {
44
- let { attributes: n, listeners: r, setNodeRef: i, setActivatorNodeRef: a, transform: o, transition: s, isDragging: c } = ce({
45
- id: e,
46
- disabled: t
47
- });
48
- return {
49
- ref: i,
50
- activatorRef: a,
51
- style: {
52
- transform: me.Translate.toString(o),
53
- transition: s,
54
- ...c ? {
55
- position: "relative",
56
- zIndex: 5
57
- } : {}
58
- },
59
- isDragging: c,
60
- handleProps: {
61
- ...n,
62
- ...r,
63
- role: void 0,
64
- "aria-disabled": void 0
65
- }
66
- };
67
- }
68
- function ye() {
69
- return pe(...he(), fe(ue, { coordinateGetter: se }));
70
- }
71
- // src/ui/Menu.tsx
72
- var be = {
73
- position: "fixed",
74
- top: 0,
75
- left: 0,
76
- right: "auto",
77
- visibility: "hidden"
78
- };
79
- function K({ label: e, items: t, header: n }) {
80
- let [r, i] = F(!1), a = P(null), o = P(null), [s, c] = F(be);
81
- return M(() => {
82
- if (!r) return;
83
- let e = (e) => {
84
- let t = e.target;
85
- a.current?.contains(t) || o.current?.contains(t) || i(!1);
86
- }, t = (e) => {
87
- e.key === "Escape" && i(!1);
88
- }, n = (e) => {
89
- o.current?.contains(e.target) || i(!1);
90
- };
91
- return document.addEventListener("pointerdown", e), document.addEventListener("keydown", t), window.addEventListener("scroll", n, !0), window.addEventListener("resize", n), () => {
92
- document.removeEventListener("pointerdown", e), document.removeEventListener("keydown", t), window.removeEventListener("scroll", n, !0), window.removeEventListener("resize", n);
93
- };
94
- }, [r]), N(() => {
95
- if (!r) {
96
- c(be);
97
- return;
98
- }
99
- let e = a.current?.getBoundingClientRect(), t = o.current;
100
- if (!e || !t) return;
101
- let n = window.innerWidth, i = window.innerHeight, s = t.offsetHeight, l = t.offsetWidth, u = i - e.bottom - 8, d = e.top - 8, f = s > u && d > u, p = Math.min(s, Math.max(160, (f ? d : u) - 4)), m = Math.min(Math.max(8, e.right - l), n - l - 8), h = f ? Math.max(8, e.top - 4 - p) : e.bottom + 4;
102
- c({
103
- position: "fixed",
104
- top: h,
105
- left: m,
106
- right: "auto",
107
- maxHeight: p,
108
- overflowY: s > p ? "auto" : void 0
109
- });
110
- }, [r]), /* @__PURE__ */ R("div", {
111
- className: "pl-menu",
112
- ref: a,
113
- children: [/* @__PURE__ */ L("button", {
114
- type: "button",
115
- className: "pl-row-button",
116
- "aria-label": e,
117
- title: e,
118
- "aria-haspopup": "menu",
119
- "aria-expanded": r,
120
- onClick: () => i((e) => !e),
121
- children: /* @__PURE__ */ L(V, { "aria-hidden": "true" })
122
- }), r && ge(/* @__PURE__ */ L("div", {
123
- className: xe(a.current)?.className ?? "planner",
124
- "data-theme": xe(a.current)?.dataset.theme,
125
- children: /* @__PURE__ */ R("div", {
126
- className: "pl-menu-list",
127
- role: "menu",
128
- ref: o,
129
- style: s,
130
- children: [n, t.map((e, t) => e === "separator" ? /* @__PURE__ */ L("div", {
131
- className: "pl-menu-separator",
132
- role: "separator"
133
- }, `s${t}`) : /* @__PURE__ */ L("button", {
134
- type: "button",
135
- role: "menuitem",
136
- disabled: e.disabled,
137
- className: e.danger ? "pl-menu-item pl-menu-danger" : "pl-menu-item",
138
- onClick: () => {
139
- i(!1), e.onSelect();
140
- },
141
- children: e.label
142
- }, e.label))]
143
- })
144
- }), document.body)]
145
- });
146
- }
147
- function xe(e) {
148
- return e?.closest(".planner") ?? null;
149
- }
150
- // src/ui/DueChip.tsx
151
- function Se({ due: t, now: n, done: r, label: i, onChange: a, variant: o = "goal", opener: s }) {
152
- let c = P(null), f = () => {
153
- let e = c.current;
154
- if (e) try {
155
- e.showPicker();
156
- } catch {
157
- e.focus();
158
- }
159
- };
160
- s?.(f);
161
- let p = t ? l(t, n) : null, h = t ? d(t, n) ? "来週" : p === 1 ? "明日" : e[m(t, n)] : void 0, g = t ? `${u(t, n)} ${p === null || r ? "" : p > 0 ? `あと ${p} 日` : p === 0 ? "今日" : `${-p} 日過ぎ`}(時間軸の「${h}」に出ます)` : o === "goal" ? "期日を決めると、時間軸に出ます" : void 0, _ = p !== null && p <= (o === "inline" ? 0 : 7) && !r, v = o === "inline" && !t;
162
- return /* @__PURE__ */ R("span", {
163
- className: `pl-due${o === "inline" ? " pl-due-inline" : ""}${t ? "" : " pl-due-empty"}${_ ? " pl-due-soon" : ""}${v ? " pl-due-hidden" : ""}`,
164
- title: g,
165
- children: [!v && /* @__PURE__ */ L("button", {
166
- type: "button",
167
- className: "pl-due-button",
168
- "aria-label": `${i}${t ? `(${t})` : "(未定)"}を変える`,
169
- onClick: f,
170
- children: t ? o === "inline" ? u(t, n) : E(t, n) : /* @__PURE__ */ L(z, { "aria-hidden": "true" })
171
- }), /* @__PURE__ */ L("input", {
172
- ref: c,
173
- type: "date",
174
- className: "pl-due-input",
175
- value: t ?? "",
176
- tabIndex: -1,
177
- "aria-hidden": "true",
178
- onChange: (e) => a(e.target.value)
179
- })]
180
- });
181
- }
182
- // src/ui/DaySelect.tsx
183
- var Ce = [
184
- 1,
185
- 2,
186
- 3,
187
- 4,
188
- "L"
189
- ], we = [
190
- 1,
191
- 2,
192
- 3,
193
- 4,
194
- 5,
195
- 6,
196
- 0
197
- ];
198
- function Te({ value: e, label: t, onChange: n, onBlur: r, autoFocus: i, className: a = "pl-select pl-select-quiet" }) {
199
- return /* @__PURE__ */ R("select", {
200
- className: a,
201
- autoFocus: i,
202
- "aria-label": t,
203
- value: e === void 0 ? "" : String(e),
204
- onBlur: r,
205
- onChange: (e) => n(Ee(e.target.value)),
206
- children: [
207
- /* @__PURE__ */ L("option", {
208
- value: "",
209
- children: "決めない"
210
- }),
211
- /* @__PURE__ */ L("optgroup", {
212
- label: "曜日(第何週)",
213
- children: Ce.map((e) => we.map((t) => {
214
- let n = `w${e}-${t}`;
215
- return /* @__PURE__ */ R("option", {
216
- value: n,
217
- children: [c(n), "曜"]
218
- }, n);
219
- }))
220
- }),
221
- /* @__PURE__ */ R("optgroup", {
222
- label: "日にち",
223
- children: [Array.from({ length: 31 }, (e, t) => /* @__PURE__ */ R("option", {
224
- value: String(t + 1),
225
- children: [t + 1, "日"]
226
- }, t + 1)), /* @__PURE__ */ L("option", {
227
- value: "end",
228
- children: "月末"
229
- })]
230
- })
231
- ]
232
- });
233
- }
234
- function Ee(e) {
235
- if (e === "") return;
236
- if (e === "end") return "end";
237
- if (/^w[1-5L]-[0-6]$/.test(e)) return e;
238
- let t = Number(e);
239
- return Number.isInteger(t) && t >= 1 && t <= 31 ? t : void 0;
240
- }
241
- // src/ui/WhenSelect.tsx
242
- var De = [
243
- 1,
244
- 2,
245
- 3,
246
- 4,
247
- 5,
248
- 6,
249
- 0
250
- ], Oe = [
251
- "日",
252
- "月",
253
- "火",
254
- "水",
255
- "木",
256
- "金",
257
- "土"
258
- ], q = (e) => String(e).padStart(2, "0");
259
- function J({ habit: e, onChange: t, onBlur: n, autoFocus: r, className: i = "pl-select pl-select-quiet" }) {
260
- if (e.period === "month") return /* @__PURE__ */ L(Te, {
261
- className: i,
262
- autoFocus: r,
263
- label: `「${e.title}」の毎月の日`,
264
- value: e.day,
265
- onBlur: n,
266
- onChange: (n) => t(O(e, n))
267
- });
268
- if (e.period === "week") return /* @__PURE__ */ R("select", {
269
- className: i,
270
- autoFocus: r,
271
- "aria-label": `「${e.title}」の毎週の曜日`,
272
- value: e.weekday === void 0 ? "" : String(e.weekday),
273
- onBlur: n,
274
- onChange: (n) => t(k(e, n.target.value === "" ? void 0 : Number(n.target.value))),
275
- children: [/* @__PURE__ */ L("option", {
276
- value: "",
277
- children: "曜日を決めない"
278
- }), De.map((e) => /* @__PURE__ */ R("option", {
279
- value: e,
280
- children: [Oe[e], "曜"]
281
- }, e))]
282
- });
283
- if (e.period === "year") {
284
- let a = _(e.yearDay), o = (n, r) => t(k(e, n ? r ? `${q(n)}-${q(r)}` : q(n) : void 0));
285
- return /* @__PURE__ */ R("span", {
286
- className: "pl-when-year",
287
- onBlur: n,
288
- children: [/* @__PURE__ */ R("select", {
289
- className: i,
290
- autoFocus: r,
291
- "aria-label": `「${e.title}」の毎年の月`,
292
- value: a ? String(a.month) : "",
293
- onChange: (e) => o(e.target.value ? Number(e.target.value) : void 0, a?.day),
294
- children: [/* @__PURE__ */ L("option", {
295
- value: "",
296
- children: "月を決めない"
297
- }), Array.from({ length: 12 }, (e, t) => /* @__PURE__ */ R("option", {
298
- value: t + 1,
299
- children: [t + 1, "月"]
300
- }, t + 1))]
301
- }), a && /* @__PURE__ */ R("select", {
302
- className: i,
303
- "aria-label": `「${e.title}」の毎年の日`,
304
- value: a.day ? String(a.day) : "",
305
- onChange: (e) => o(a.month, e.target.value ? Number(e.target.value) : void 0),
306
- children: [/* @__PURE__ */ L("option", {
307
- value: "",
308
- children: "月だけ"
309
- }), Array.from({ length: new Date(2024, a.month, 0).getDate() }, (e, t) => /* @__PURE__ */ R("option", {
310
- value: t + 1,
311
- children: [t + 1, "日"]
312
- }, t + 1))]
313
- })]
314
- });
315
- }
316
- return null;
317
- }
318
- // src/ui/Dialog.tsx
319
- var Y = (e) => e.stopPropagation();
320
- function ke({ open: e, onClose: t, title: n, children: r, dismissible: i = !0, wide: a = !1 }) {
321
- let o = P(null);
322
- return M(() => {
323
- let t = o.current;
324
- t && (e && !t.open && t.showModal?.(), !e && t.open && t.close?.());
325
- }, [e]), /* @__PURE__ */ L("dialog", {
326
- ref: o,
327
- className: a ? "pl-dialog pl-dialog-wide" : "pl-dialog",
328
- "aria-label": n,
329
- onCancel: (e) => {
330
- e.preventDefault(), i && t();
331
- },
332
- onClick: (e) => {
333
- e.stopPropagation(), i && e.target === e.currentTarget && t();
334
- },
335
- onPointerDown: Y,
336
- onMouseDown: Y,
337
- onTouchStart: Y,
338
- onKeyDown: Y,
339
- onDoubleClick: Y,
340
- children: e && /* @__PURE__ */ R("div", {
341
- className: "pl-dialog-body",
342
- children: [/* @__PURE__ */ R("header", {
343
- className: "pl-dialog-header",
344
- children: [/* @__PURE__ */ L("h2", { children: n }), i && /* @__PURE__ */ L("button", {
345
- type: "button",
346
- className: "pl-icon-button",
347
- onClick: t,
348
- "aria-label": "閉じる",
349
- children: /* @__PURE__ */ L(H, { "aria-hidden": "true" })
350
- })]
351
- }), r]
352
- })
353
- });
354
- }
355
- // src/ui/NoteDialog.tsx
356
- var Ae = 2e4;
357
- function X({ open: e, title: t, note: n, onSave: r, onClose: i }) {
358
- let [a, o] = F(!1), [s, c] = F(""), l = P(null);
359
- M(() => {
360
- e && (c(n), o(!n));
361
- }, [e, n]), M(() => {
362
- e && a && requestAnimationFrame(() => l.current?.focus());
363
- }, [e, a]);
364
- let u = () => {
365
- r(s.trim() ? s.replace(/\s+$/, "") : ""), o(!1), s.trim() || i();
366
- };
367
- return /* @__PURE__ */ L(ke, {
368
- open: e,
369
- onClose: i,
370
- title: t,
371
- children: a ? /* @__PURE__ */ R("form", {
372
- className: "pl-stack",
373
- onSubmit: (e) => {
374
- e.preventDefault(), u();
375
- },
376
- children: [/* @__PURE__ */ L("textarea", {
377
- ref: l,
378
- className: "pl-input pl-note-input",
379
- value: s,
380
- maxLength: Ae,
381
- rows: 10,
382
- placeholder: "メモ(やり方・読む文章・手順など)",
383
- "aria-label": `「${t}」のメモ`,
384
- onChange: (e) => c(e.target.value),
385
- onKeyDown: (e) => {
386
- e.key === "Enter" && (e.metaKey || e.ctrlKey) && (e.preventDefault(), u());
387
- }
388
- }), /* @__PURE__ */ R("div", {
389
- className: "pl-row pl-row-end",
390
- children: [
391
- /* @__PURE__ */ L("span", {
392
- className: "pl-note pl-note-hint",
393
- children: "⌘Enter で保存"
394
- }),
395
- /* @__PURE__ */ L("button", {
396
- type: "button",
397
- className: "pl-button",
398
- onClick: () => {
399
- n ? (c(n), o(!1)) : i();
400
- },
401
- children: "やめる"
402
- }),
403
- /* @__PURE__ */ L("button", {
404
- type: "submit",
405
- className: "pl-button pl-button-primary",
406
- children: "保存"
407
- })
408
- ]
409
- })]
410
- }) : /* @__PURE__ */ R("div", {
411
- className: "pl-stack",
412
- children: [/* @__PURE__ */ L("div", {
413
- className: "pl-note-view",
414
- children: n
415
- }), /* @__PURE__ */ R("div", {
416
- className: "pl-row pl-row-end",
417
- children: [/* @__PURE__ */ L("button", {
418
- type: "button",
419
- className: "pl-button",
420
- onClick: () => o(!0),
421
- children: "書き換える"
422
- }), /* @__PURE__ */ L("button", {
423
- type: "button",
424
- className: "pl-button pl-button-primary",
425
- onClick: i,
426
- children: "閉じる"
427
- })]
428
- })]
429
- })
430
- });
431
- }
432
- function Z(e, t) {
433
- let n = P(void 0);
434
- return M(() => () => clearTimeout(n.current), []), {
435
- onClick: () => {
436
- clearTimeout(n.current), n.current = setTimeout(e, 250);
437
- },
438
- onDoubleClick: () => {
439
- clearTimeout(n.current), window.getSelection?.()?.removeAllRanges(), t();
440
- }
441
- };
442
- }
443
- function je({ title: e, note: t, wrap: n = !1, renameLabel: r, onRename: i, onSaveNote: a, menuOpener: o }) {
444
- let [s, c] = F(!1), [l, u] = F(!1), d = Z(() => u(!0), () => c(!0));
445
- return o?.({
446
- note: () => u(!0),
447
- rename: () => c(!0)
448
- }), /* @__PURE__ */ R(I, { children: [s ? /* @__PURE__ */ L(Q, {
449
- initial: e,
450
- label: r,
451
- onDone: (t) => {
452
- c(!1), t && t !== e && i(t);
453
- }
454
- }) : /* @__PURE__ */ R("button", {
455
- type: "button",
456
- className: `pl-task-title pl-title-button${n ? " pl-title-wrap" : ""}`,
457
- title: t ? `${e}(押すとメモ)` : e,
458
- ...d,
459
- children: [/* @__PURE__ */ L("span", {
460
- className: "pl-title-text",
461
- children: e
462
- }), t && /* @__PURE__ */ L(B, {
463
- className: "pl-note-mark",
464
- "aria-label": "メモあり"
465
- })]
466
- }), /* @__PURE__ */ L(X, {
467
- open: l,
468
- title: e,
469
- note: t ?? "",
470
- onClose: () => u(!1),
471
- onSave: a
472
- })] });
473
- }
474
- // src/ui/Rows.tsx
475
- function Me({ view: t, data: s, store: c, now: l }) {
476
- let { task: d, label: f, done: p, faded: m, placedTo: g, from: _, project: v } = t, { simple: b } = W(), [E, D] = F(!1), [re, O] = F(!1), k = G(d.id, E), A = !d.parentId && !d.habitId, j = P(null), M = Z(() => O(!0), () => D(!0)), N = x(t.horizon), I = ee(t.horizon), z = (e) => void c.apply(e), V = t.horizon === "today" && !p && !m, H = V && h(d, l), oe = [
477
- ...V ? [H ? {
478
- label: "今日やる(今日にもどす)",
479
- onSelect: () => z(o(d, l))
480
- } : {
481
- label: "明日にまわす",
482
- onSelect: () => z(S(d, l))
483
- }] : [],
484
- ...N.map((e) => ({
485
- label: r[e],
486
- onSelect: () => z(y(s, d, e, l)),
487
- disabled: p
488
- })),
489
- ...N.length ? ["separator"] : [],
490
- {
491
- label: "名前を変える",
492
- onSelect: () => D(!0)
493
- },
494
- ...A ? [{
495
- label: d.due ? "日付を変える" : "日付を決める",
496
- onSelect: () => j.current?.()
497
- }, ...d.due ? [{
498
- label: "日付を外す",
499
- onSelect: () => z(w(d, ""))
500
- }] : []] : [],
501
- {
502
- label: d.note ? "メモを見る" : "メモを書く",
503
- onSelect: () => O(!0)
504
- },
505
- "separator",
506
- ...d.parentId || d.habitId ? [{
507
- label: `${_ ? e[_] ?? "元" : "元"}に戻す`,
508
- onSelect: () => z(C(s, d, l))
509
- }] : [],
510
- {
511
- label: "消す",
512
- danger: !0,
513
- onSelect: () => z(te(s, d, l))
514
- }
515
- ];
516
- return /* @__PURE__ */ R("li", {
517
- ref: k.ref,
518
- style: k.style,
519
- className: `pl-task pl-p-${d.priority}${m ? " pl-faded" : ""}${p ? " pl-done" : ""}${k.isDragging ? " pl-dragging" : ""}`,
520
- ...k.handleProps,
521
- children: [
522
- /* @__PURE__ */ L("span", {
523
- className: "pl-task-label",
524
- children: f
525
- }),
526
- /* @__PURE__ */ L("button", {
527
- type: "button",
528
- role: "checkbox",
529
- "aria-checked": p,
530
- "aria-label": p ? `「${d.title}」を終えたのを取り消す` : `「${d.title}」を終える`,
531
- className: "pl-circle",
532
- onClick: () => z(ne(s, d, l)),
533
- children: p && /* @__PURE__ */ L(ie, { "aria-hidden": "true" })
534
- }),
535
- /* @__PURE__ */ R("div", {
536
- className: "pl-task-main",
537
- children: [E ? /* @__PURE__ */ L(Q, {
538
- initial: d.title,
539
- label: "名前",
540
- onDone: (e) => {
541
- D(!1), e && e !== d.title && z({ tasks: [{
542
- ...d,
543
- title: e,
544
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
545
- }] });
546
- }
547
- }) : /* @__PURE__ */ R("button", {
548
- type: "button",
549
- className: "pl-task-title pl-title-button",
550
- title: d.note ? `${d.title}(押すとメモ)` : d.title,
551
- ...M,
552
- children: [
553
- v && /* @__PURE__ */ L($, {
554
- name: Re(s, v),
555
- color: v.color
556
- }),
557
- /* @__PURE__ */ L("span", {
558
- className: "pl-title-text",
559
- children: d.title
560
- }),
561
- d.note && /* @__PURE__ */ L(B, {
562
- className: "pl-note-mark",
563
- "aria-label": "メモあり"
564
- })
565
- ]
566
- }), !E && /* @__PURE__ */ R("span", {
567
- className: "pl-task-meta",
568
- children: [
569
- !b && g && /* @__PURE__ */ R("span", {
570
- className: "pl-chip",
571
- children: ["→", n[g]]
572
- }),
573
- !b && _ && _ !== "pool" && /* @__PURE__ */ R("span", {
574
- className: "pl-chip",
575
- children: ["←", e[_]]
576
- }),
577
- A ? /* @__PURE__ */ L(Se, {
578
- variant: "inline",
579
- due: d.due,
580
- now: l,
581
- done: p,
582
- label: `「${d.title}」の日付`,
583
- opener: (e) => j.current = e,
584
- onChange: (e) => z(w(d, e))
585
- }) : d.due && /* @__PURE__ */ L("span", {
586
- className: "pl-chip",
587
- children: u(d.due, l)
588
- })
589
- ]
590
- })]
591
- }),
592
- /* @__PURE__ */ R("div", {
593
- className: "pl-task-actions",
594
- children: [
595
- (d.parentId || d.habitId) && /* @__PURE__ */ L("button", {
596
- type: "button",
597
- className: "pl-row-button",
598
- "aria-label": `「${d.title}」を${_ ? e[_] : "元"}に戻す`,
599
- title: `${_ ? e[_] : "元"}に戻す`,
600
- onClick: () => z(C(s, d, l)),
601
- children: /* @__PURE__ */ L(ae, { "aria-hidden": "true" })
602
- }),
603
- I && !p && !m && /* @__PURE__ */ R("button", {
604
- type: "button",
605
- className: "pl-place-button",
606
- onClick: () => z(y(s, d, I, l)),
607
- title: r[I],
608
- children: [n[I], "↓"]
609
- }),
610
- V && /* @__PURE__ */ L("button", {
611
- type: "button",
612
- className: "pl-place-button",
613
- onClick: () => z(H ? o(d, l) : S(d, l)),
614
- title: H ? "今日やる(今日にもどす)" : "明日にまわす",
615
- "aria-label": H ? `「${d.title}」を今日にもどす` : `「${d.title}」を明日にまわす`,
616
- children: H ? "今日↑" : "明日→"
617
- }),
618
- /* @__PURE__ */ L(K, {
619
- label: `「${d.title}」の操作`,
620
- items: oe,
621
- header: /* @__PURE__ */ L("div", {
622
- className: "pl-menu-priorities",
623
- role: "group",
624
- "aria-label": "優先度",
625
- children: i.map((e) => /* @__PURE__ */ L("button", {
626
- type: "button",
627
- className: `pl-pchip pl-p-${e}`,
628
- "aria-pressed": d.priority === e,
629
- title: a[e],
630
- onClick: () => z(T(s, d, e, l)),
631
- children: e
632
- }, e))
633
- })
634
- })
635
- ]
636
- }),
637
- /* @__PURE__ */ L(X, {
638
- open: re,
639
- title: d.title,
640
- note: d.note ?? "",
641
- onClose: () => O(!1),
642
- onSave: (e) => {
643
- let { note: t, ...n } = d;
644
- z({ tasks: [{
645
- ...n,
646
- ...e ? { note: e } : {},
647
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
648
- }] });
649
- }
650
- })
651
- ]
652
- });
653
- }
654
- var Ne = {
655
- week: "毎週の曜日",
656
- month: "毎月の日",
657
- year: "毎年の日付・月"
658
- };
659
- function Pe({ view: e, data: i, store: a, now: o }) {
660
- let { habit: c, checked: l, project: u, faded: d, placedTo: m, auto: h, dueDay: _ } = e, { simple: y } = W(), [x, S] = F(!1), [te, C] = F(!1), [w, T] = F(!1), E = G(h ? `auto-${c.id}` : c.id, x || h), ne = Z(() => C(!0), () => S(!0)), O = (e) => void a.apply(e), k = h ? [] : f(c), A = h ? void 0 : ee(v(c.period)), j = h && _ && !g(c) && s(_) < s(o), M = re(c);
661
- return /* @__PURE__ */ R("li", {
662
- ref: E.ref,
663
- style: E.style,
664
- className: `pl-habit${l ? " pl-done" : ""}${d ? " pl-faded" : ""}${h ? " pl-habit-auto" : ""}${E.isDragging ? " pl-dragging" : ""}`,
665
- ...E.handleProps,
666
- children: [
667
- /* @__PURE__ */ L("button", {
668
- type: "button",
669
- role: "checkbox",
670
- "aria-checked": l,
671
- "aria-label": l ? `「${c.title}」のチェックを外す` : `「${c.title}」をチェック`,
672
- className: "pl-square",
673
- onClick: () => O(D(i, c, o)),
674
- children: l && /* @__PURE__ */ L(ie, { "aria-hidden": "true" })
675
- }),
676
- x ? /* @__PURE__ */ L(Q, {
677
- initial: c.title,
678
- label: "習慣の名前",
679
- onDone: (e) => {
680
- S(!1), e && e !== c.title && O({ habits: [{
681
- ...c,
682
- title: e,
683
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
684
- }] });
685
- }
686
- }) : /* @__PURE__ */ R("button", {
687
- type: "button",
688
- className: "pl-task-title pl-title-button",
689
- title: c.note ? `${c.title}(押すとメモ)` : c.title,
690
- ...ne,
691
- children: [
692
- u && /* @__PURE__ */ L($, {
693
- name: Re(i, u),
694
- color: u.color
695
- }),
696
- /* @__PURE__ */ L("span", {
697
- className: "pl-title-text",
698
- children: c.title
699
- }),
700
- c.note && /* @__PURE__ */ L(B, {
701
- className: "pl-note-mark",
702
- "aria-label": "メモあり"
703
- })
704
- ]
705
- }),
706
- w ? /* @__PURE__ */ L(J, {
707
- autoFocus: !0,
708
- habit: c,
709
- onBlur: c.period === "year" ? void 0 : () => T(!1),
710
- onChange: (e) => {
711
- O({ habits: [e] }), c.period !== "year" && T(!1);
712
- }
713
- }) : M && /* @__PURE__ */ L("span", {
714
- className: `pl-day${j && !l ? " pl-day-over" : ""}`,
715
- title: `${t[c.period]}${M}${h && _ ? `(${_.getMonth() + 1}/${_.getDate()})` : ""}`,
716
- children: M
717
- }),
718
- w && c.period === "year" && /* @__PURE__ */ L("button", {
719
- type: "button",
720
- className: "pl-place-button",
721
- onClick: () => T(!1),
722
- children: "決定"
723
- }),
724
- !y && m && /* @__PURE__ */ R("span", {
725
- className: "pl-chip",
726
- children: ["→", n[m]]
727
- }),
728
- A && !l && !d && /* @__PURE__ */ R("button", {
729
- type: "button",
730
- className: "pl-place-button",
731
- onClick: () => O(b(i, c, A, o)),
732
- title: r[A],
733
- children: [n[A], "↓"]
734
- }),
735
- /* @__PURE__ */ L(K, {
736
- label: `「${c.title}」の操作`,
737
- items: [
738
- ...k.map((e) => ({
739
- label: r[e],
740
- onSelect: () => O(b(i, c, e, o)),
741
- disabled: l
742
- })),
743
- ...k.length ? ["separator"] : [],
744
- {
745
- label: "名前を変える",
746
- onSelect: () => S(!0)
747
- },
748
- {
749
- label: c.note ? "メモを見る" : "メモを書く",
750
- onSelect: () => C(!0)
751
- },
752
- ...c.period === "day" ? [] : [{
753
- label: M ? `${Ne[c.period]}を変える(${M})` : `${Ne[c.period]}を決める`,
754
- onSelect: () => T(!0)
755
- }],
756
- {
757
- label: "やることに移す(1 回で終わるもの)",
758
- onSelect: () => O(p(i, c, o))
759
- },
760
- "separator",
761
- {
762
- label: "消す",
763
- danger: !0,
764
- onSelect: () => O({ deleteHabitIds: [c.id] })
765
- }
766
- ]
767
- }),
768
- /* @__PURE__ */ L(X, {
769
- open: te,
770
- title: c.title,
771
- note: c.note ?? "",
772
- onClose: () => C(!1),
773
- onSave: (e) => {
774
- let { note: t, ...n } = c;
775
- O({ habits: [{
776
- ...n,
777
- ...e ? { note: e } : {},
778
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
779
- }] });
780
- }
781
- })
782
- ]
783
- });
784
- }
785
- function Q({ initial: e, label: t, onDone: n }) {
786
- let [r, i] = F(e), a = P(null), o = P(!1);
787
- M(() => {
788
- a.current?.focus(), a.current?.select();
789
- }, []);
790
- let s = (e) => {
791
- o.current || (o.current = !0, n(e.trim()));
792
- };
793
- return /* @__PURE__ */ L("input", {
794
- ref: a,
795
- className: "pl-inline-input",
796
- value: r,
797
- "aria-label": t,
798
- onChange: (e) => i(e.target.value),
799
- onKeyDown: (t) => {
800
- t.key === "Enter" && !t.nativeEvent.isComposing && s(r), t.key === "Escape" && s(e);
801
- },
802
- onBlur: () => s(r)
803
- });
804
- }
805
- function Fe({ placeholder: e, label: t, onAdd: n, priority: r, onPriority: o }) {
806
- let s = `planner:draft:${t}`, [c, l] = F(() => Ie(s)), u = (e) => {
807
- l(e), Le(s, e);
808
- }, { simple: d } = W();
809
- return /* @__PURE__ */ R("form", {
810
- className: "pl-add",
811
- onSubmit: (e) => {
812
- e.preventDefault();
813
- let t = c.trim();
814
- t && (n(t), u(""));
815
- },
816
- children: [r && o && /* @__PURE__ */ L("div", {
817
- className: "pl-add-priorities",
818
- role: "radiogroup",
819
- "aria-label": "優先度",
820
- children: i.map((e) => /* @__PURE__ */ L("button", {
821
- type: "button",
822
- role: "radio",
823
- "aria-checked": r === e,
824
- title: a[e],
825
- className: `pl-pchip pl-p-${e}`,
826
- onClick: () => o(e),
827
- children: e
828
- }, e))
829
- }), /* @__PURE__ */ R("div", {
830
- className: "pl-add-line",
831
- children: [/* @__PURE__ */ L("input", {
832
- className: "pl-add-input",
833
- value: c,
834
- placeholder: d ? "+" : e,
835
- "aria-label": t,
836
- enterKeyHint: "done",
837
- onChange: (e) => u(e.target.value),
838
- onKeyDown: (e) => {
839
- e.key === "Enter" && e.nativeEvent.isComposing && e.preventDefault();
840
- }
841
- }), c.trim() && /* @__PURE__ */ L("button", {
842
- type: "submit",
843
- className: "pl-add-submit",
844
- "aria-label": `${t}(追加)`,
845
- children: "追加"
846
- })]
847
- })]
848
- });
849
- }
850
- function Ie(e) {
851
- try {
852
- return sessionStorage.getItem(e) ?? "";
853
- } catch {
854
- return "";
855
- }
856
- }
857
- function Le(e, t) {
858
- try {
859
- t ? sessionStorage.setItem(e, t) : sessionStorage.removeItem(e);
860
- } catch {}
861
- }
862
- function Re(e, t) {
863
- let n = t.parentId ? e.projects.find((e) => e.id === t.parentId) : void 0;
864
- return n ? `${n.name}・${t.name}` : t.name;
865
- }
866
- function $({ name: e, color: t }) {
867
- return /* @__PURE__ */ L("span", {
868
- className: `pl-pdot pl-color-${t}`,
869
- role: "img",
870
- "aria-label": e,
871
- title: e
872
- });
873
- }
874
- // src/ui/JumpBar.tsx
875
- function ze({ label: e, items: t, active: n, onJump: r, className: i }) {
876
- return t.length < 2 ? null : /* @__PURE__ */ L("nav", {
877
- className: `pl-jump ${i ?? ""}`,
878
- "aria-label": e,
879
- children: /* @__PURE__ */ L("ul", { children: t.map((e) => /* @__PURE__ */ L("li", { children: /* @__PURE__ */ R("button", {
880
- type: "button",
881
- className: "pl-jump-chip",
882
- "aria-current": n === e.id ? "true" : void 0,
883
- onClick: () => r(e.id),
884
- children: [e.color && /* @__PURE__ */ L("span", {
885
- className: `pl-dot pl-color-${e.color}`,
886
- "aria-hidden": "true"
887
- }), /* @__PURE__ */ L("span", {
888
- className: "pl-jump-label",
889
- children: e.label
890
- })]
891
- }) }, e.id)) })
892
- });
893
- }
894
- function Be(e, t = !1) {
895
- e?.scrollIntoView?.(t ? {
896
- behavior: "smooth",
897
- inline: "start",
898
- block: "nearest"
899
- } : {
900
- behavior: "smooth",
901
- block: "start"
902
- });
903
- }
904
- export { Q as a, J as c, ve as d, ye as f, Pe as i, Se as l, _e as m, Be as n, Me as o, G as p, Fe as r, je as s, ze as t, K as u };