@shiodome47/planner 0.0.0-stage → 0.2.0

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.
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @shiodome47/planner/core — 時間軸とプロジェクトの土台(画面を持たない、計算だけの部品)。
3
+ *
4
+ * - データの形: やること(Task)・習慣(Habit)・プロジェクト(Project)
5
+ * - 期日から、時間軸のどの列(今日・今週・数か月・今年・人生)に出すか
6
+ * - くり返し(毎週何曜日・毎月第 2 水曜・毎年 12 月 6 日 …)の次の日付
7
+ * - 下ろす・終える・並べ替える・明日にまわす などの変更(Changes を返す。保存はアプリが行う)
8
+ * - 振り返り(その日に済ませたこと・続いた日数)
9
+ *
10
+ * 日付は端末の時刻で数える。関数には「今」(now)を渡す(テストしやすく、2 台で結果がずれないように)。
11
+ */
12
+ export * from './types';
13
+ export * from './period';
14
+ export * from './when';
15
+ export * from './logic';
16
+ export * from './labels';
17
+ export * from './review';
@@ -0,0 +1,12 @@
1
+ import type { BoardHorizon, Horizon, Period, Priority } from './types';
2
+ import type { PlaceTarget } from './logic';
3
+ export declare const HORIZON_NAME: Record<BoardHorizon, string>;
4
+ /** 列の英語の呼び名(見出しの小さな文字) */
5
+ export declare const HORIZON_SUB: Record<BoardHorizon, string>;
6
+ export declare const HORIZON_OPTION: Record<Horizon, string>;
7
+ /** 下ろすボタンの言葉 */
8
+ export declare const PLACE_LABEL: Record<PlaceTarget, string>;
9
+ /** 薄い表示のときの印(→今日 など) */
10
+ export declare const PLACED_MARK: Record<PlaceTarget, string>;
11
+ export declare const PRIORITY_NAME: Record<Priority, string>;
12
+ export declare const PERIOD_NAME: Record<Period, string>;
@@ -0,0 +1,230 @@
1
+ import { type BoardHorizon, type Habit, type Horizon, type MonthDay, type Period, type PlannerData, type Priority, type Project, type Task } from './types';
2
+ /**
3
+ * 時間軸ボードの決まりごと(画面に依存しない計算)。
4
+ *
5
+ * - 番号は列ごと・優先度ごとに 1 から(A1, A2, B1 …)
6
+ * - 「今日やる」などで下ろすと、元は列に残したまま薄く表示する。下ろした先で終えたら、元も終える
7
+ * - 下ろした先の期間(今日・今週)が過ぎて終わっていなければ、下ろした先からは消え、元の薄い表示も戻る
8
+ * - 今日の列の「明日」の欄は、日付が変わると今日の項目になる
9
+ * - 終えた項目は、その列の今の期間のあいだは取り消し線で残し、期間が変わると見えなくなる(データには残る)
10
+ *
11
+ * 日付が変わっても、保存してあるデータは書き換えない(表示のときに判断する)。
12
+ * 2 台で同時に「日付が変わったので書き換える」ことが起きず、同期で競合しないようにするため。
13
+ */
14
+ /** 下ろす先。tomorrow は今日の列の「明日」の欄 */
15
+ /** tomorrow は今日の列の「明日」の欄、nextweek は今週の列の「来週」の欄 */
16
+ export type PlaceTarget = BoardHorizon | 'tomorrow' | 'nextweek';
17
+ /** 下ろした先が、どの期間のためのものかを表す値 */
18
+ export declare function placedForKey(target: PlaceTarget, now: Date): string | undefined;
19
+ /** 下ろした先の項目の期間が過ぎたか */
20
+ export declare function isExpired(task: Task, now: Date): boolean;
21
+ /** 今日の列で、「明日」の欄に出すものか */
22
+ /** 今週の列で、「来週」の欄に出すものか(来週のために置いたもの・期日が来週の期日目標) */
23
+ export declare function isForNextWeek(task: Task, now: Date): boolean;
24
+ /** 期日が来週(次の月曜〜日曜)か */
25
+ export declare function goalDueNextWeek(due: string, now: Date): boolean;
26
+ export declare function isForTomorrow(task: Task, now: Date): boolean;
27
+ /**
28
+ * 日付(due)に合わせて列を自動で決める項目か。
29
+ * 日付のある、やること・期日目標(下ろした先のコピーや、習慣から下ろしたものは除く)
30
+ */
31
+ export declare function followsDue(task: Task): boolean;
32
+ /** プロジェクトの期日目標か(下ろした先のコピーではないもの) */
33
+ export declare function isProjectGoal(task: Task): boolean;
34
+ /**
35
+ * 期日から、時間軸のどの列に出すかを決める。
36
+ * 今日まで(過ぎたものも)・明日 → 今日(明日は「明日」の欄)/今週の日曜まで → 今週/来週 → 今週の列の「来週」の欄/
37
+ * 3 か月以内 → 数か月/1 年以内 → 今年/それより先 → 一生
38
+ */
39
+ export declare function horizonForDue(due: string, now: Date): BoardHorizon;
40
+ /**
41
+ * その項目が今いる列。
42
+ * プロジェクトの期日目標は、期日から自動で決める(期日が無ければ、プロジェクトの中だけ=pool)。
43
+ * それ以外は、保存してある列。
44
+ */
45
+ export declare function effectiveHorizon(task: Task, now: Date): Horizon;
46
+ /** 列に見せるか */
47
+ export declare function isVisible(task: Task, now: Date): boolean;
48
+ /** その項目から下ろして、今も生きている項目(無ければ undefined) */
49
+ export declare function activeChild(task: Task, tasks: Task[], now: Date): Task | undefined;
50
+ /** 下ろせる先(自分の列より短い期間の列と、明日) */
51
+ export declare function placeTargets(h: Horizon): PlaceTarget[];
52
+ /** すぐ下ろすボタンの先(1 つ短い列。今週 → 今日、数か月 → 今週、今年 → 数か月) */
53
+ export declare function quickTarget(h: Horizon): PlaceTarget | undefined;
54
+ /** 優先度ごと・順番どおりに並べ、番号(A1 など)を付ける */
55
+ export declare function numbered(tasks: Task[]): {
56
+ task: Task;
57
+ label: string;
58
+ }[];
59
+ export interface TaskView {
60
+ task: Task;
61
+ /** いま出している列(期日目標は期日から自動で決まる) */
62
+ horizon: Horizon;
63
+ /** 番号(A1 など) */
64
+ label: string;
65
+ done: boolean;
66
+ /** 下ろした先が生きているので、薄く表示する */
67
+ faded: boolean;
68
+ /** 下ろした先(薄い表示のときに「→今日」などと出す) */
69
+ placedTo?: PlaceTarget;
70
+ /** 下ろしてきた元(「←今週」などと出す) */
71
+ from?: Horizon;
72
+ project?: Project;
73
+ }
74
+ export interface HabitView {
75
+ habit: Habit;
76
+ checked: boolean;
77
+ project?: Project;
78
+ /** 下ろした先が生きているので、薄く表示する */
79
+ faded: boolean;
80
+ /** 下ろした先(「→今日」など) */
81
+ placedTo?: PlaceTarget;
82
+ /** 毎月の「その日」が近いので、この列にも自動で出しているもの(並べ替えはしない) */
83
+ auto: boolean;
84
+ /** この列での「その日」(auto のとき、または day を決めた毎月の習慣) */
85
+ dueDay?: Date;
86
+ }
87
+ export interface ColumnView {
88
+ horizon: BoardHorizon;
89
+ habitPeriod?: Period;
90
+ habits: HabitView[];
91
+ tasks: TaskView[];
92
+ /** 今日の列だけ:明日の欄 */
93
+ tomorrow: TaskView[];
94
+ /** 今週の列だけ:来週の欄 */
95
+ nextWeek: TaskView[];
96
+ }
97
+ export declare function buildColumns(data: PlannerData, now: Date): ColumnView[];
98
+ /**
99
+ * 変更(保存するもの)。関数は、データを直接は変えずに、これを返す。
100
+ * アプリは、これを保存先に書き、applyChanges で手元のデータにも当てる
101
+ */
102
+ export interface Changes {
103
+ tasks?: Task[];
104
+ habits?: Habit[];
105
+ projects?: Project[];
106
+ deleteTaskIds?: string[];
107
+ deleteHabitIds?: string[];
108
+ deleteProjectIds?: string[];
109
+ }
110
+ export declare function newTask(data: PlannerData, input: {
111
+ title: string;
112
+ horizon: Horizon;
113
+ priority: Priority;
114
+ tomorrow?: boolean;
115
+ nextWeek?: boolean;
116
+ projectId?: string;
117
+ due?: string;
118
+ }, now: Date): Task;
119
+ /**
120
+ * 下ろす(「今日やる」「明日やる」「今週やる」など)。
121
+ * 元は残したまま、下ろした先に同じ名前・同じ優先度の項目を作る。
122
+ * すでに下ろしてあって、まだ終えていなければ、そちらを動かす(2 つにはしない)。
123
+ */
124
+ export declare function placeDown(data: PlannerData, task: Task, target: PlaceTarget, now: Date): Changes;
125
+ /** 下ろした先から戻す(↩)。下ろした先の項目を消すと、元の薄い表示が戻る */
126
+ export declare function returnUp(data: PlannerData, task: Task, now: Date): Changes;
127
+ /** 列を移す(プロジェクトの置き場から列に置く、など)。下ろした先の項目は、そのまま */
128
+ export declare function moveTo(data: PlannerData, task: Task, horizon: Horizon, now: Date): Changes;
129
+ /**
130
+ * 終える・終えたのを取り消す。
131
+ * 下ろした先で終えたら、元(さらにその元)も終える。元で終えたら、生きている下ろした先も終える。
132
+ */
133
+ export declare function toggleDone(data: PlannerData, task: Task, now: Date): Changes;
134
+ /** 同じ列・同じ優先度の中で、1 つ上・下と入れ替える */
135
+ export declare function moveStep(data: PlannerData, task: Task, step: -1 | 1, now: Date): Changes;
136
+ /** 優先度を変える(新しい優先度の末尾へ) */
137
+ export declare function setPriority(data: PlannerData, task: Task, priority: Priority, now: Date): Changes;
138
+ /** 消す(下ろした先も一緒に消す) */
139
+ export declare function removeTask(data: PlannerData, task: Task, now: Date): Changes;
140
+ export declare function newHabit(data: PlannerData, input: {
141
+ title: string;
142
+ period: Period;
143
+ projectId?: string;
144
+ }, now: Date): Habit;
145
+ /** 習慣のチェックを付ける・外す(今の期間の分) */
146
+ export declare function toggleHabit(habit: Habit, now: Date): Habit;
147
+ export declare function newProject(data: PlannerData, input: {
148
+ name: string;
149
+ color: string;
150
+ parentId?: string;
151
+ }, now: Date): Project;
152
+ /** テーマの中のプロジェクト(順番どおり) */
153
+ export declare function childProjects(data: PlannerData, parentId: string): Project[];
154
+ /** いちばん上に並べるカード(テーマ・プロジェクト)。入っているテーマが見つからないものも上に出す */
155
+ export declare function topProjects(data: PlannerData): Project[];
156
+ /** プロジェクトを消す(期日目標・ルーチン目標も一緒に。列に置いたものも消す。テーマなら中のプロジェクトも) */
157
+ export declare function removeProject(data: PlannerData, project: Project): Changes;
158
+ /**
159
+ * プロジェクトをテーマの中へ入れる(parentId)・テーマから出す(undefined)。
160
+ * 中にプロジェクトがあるもの(テーマ)は、ほかのテーマには入れない(1 段だけ)
161
+ */
162
+ export declare function moveProject(data: PlannerData, project: Project, parentId: string | undefined, now: Date): Changes;
163
+ /** id で、足す・置き換える・消す(並びは今のまま。新しいものは後ろへ) */
164
+ export declare function mergeById<T extends {
165
+ id: string;
166
+ }>(list: T[], puts?: T[], dels?: string[]): T[];
167
+ /**
168
+ * 保存せずに、変更を手元のデータに当てる(画面をすぐ変えるため・テスト用)。
169
+ * データにアプリが足した項目(日記など)は、そのまま残す
170
+ */
171
+ export declare function applyChanges<D extends PlannerData>(data: D, c: Changes): D;
172
+ /**
173
+ * やることをドラッグで並べ替える。
174
+ * ids は、いま画面に並んでいる順(優先度 A → P、各優先度の中は順番どおり)。
175
+ * 落とした先の項目と同じ優先度になる(B のまとまりへ落とせば B に変わる)。
176
+ * 変わったものだけを返す。
177
+ */
178
+ export declare function reorderTasks(data: PlannerData, ids: string[], activeId: string, overId: string, now: Date): Changes;
179
+ /** 習慣をドラッグで並べ替える(ids は、いま並んでいる順) */
180
+ export declare function reorderHabits(data: PlannerData, ids: string[], activeId: string, overId: string, now: Date): Changes;
181
+ /** プロジェクトをドラッグで並べ替える(左ほど優先が高い) */
182
+ export declare function reorderProjects(data: PlannerData, activeId: string, overId: string, now: Date): Changes;
183
+ /** その習慣から下ろして、今も生きている項目(無ければ undefined) */
184
+ export declare function activeHabitChild(habit: Habit, tasks: Task[], now: Date): Task | undefined;
185
+ /** 習慣の下ろせる先(習慣の列より短い期間の列と、明日) */
186
+ export declare function habitPlaceTargets(habit: Habit): PlaceTarget[];
187
+ /**
188
+ * 習慣を下ろす(今週やる・今日やる など)。習慣はそのまま残し、下ろした先に同じ名前のやること(C)を作る。
189
+ * 下ろした先で終えたら、習慣の今の期間のチェックが付く。前に下ろして終えていないものは動かす
190
+ */
191
+ export declare function placeHabitDown(data: PlannerData, habit: Habit, target: PlaceTarget, now: Date): Changes;
192
+ /** 習慣のチェックを付ける・外す。下ろした先があれば、その「終えた」も合わせる */
193
+ export declare function toggleHabitAll(data: PlannerData, habit: Habit, now: Date): Changes;
194
+ /** 習慣を「やること」にする(1 回やれば終わるもの)。同じ期間の列の C に入れ、習慣は消す */
195
+ export declare function habitToTask(data: PlannerData, habit: Habit, now: Date): Changes;
196
+ /** 毎月の習慣の、その月の「その日」(日が無い月は月末に寄せる) */
197
+ export declare function monthlyDueDate(habit: Habit, month: Date): Date | undefined;
198
+ /** やることの日付を決める・外す(空なら外す)。日付があれば、日付に合わせて列が自動で決まる */
199
+ export declare function setDue(task: Task, due: string): Changes;
200
+ /** 毎月の習慣の「その日」を決める・外す(undefined なら外す) */
201
+ export declare function withDay(habit: Habit, day: MonthDay | undefined): Habit;
202
+ /**
203
+ * 習慣を、その日(過ぎた日も)にできた・できなかったことにする(振り返りから付け直す)。
204
+ * 今の期間の日なら、今のチェック(checkedAt)も合わせる
205
+ */
206
+ export declare function toggleHabitOnDay(habit: Habit, day: Date, now: Date): Habit;
207
+ /** やることを、その日に終えたことにする(振り返りから付け直す。今日なら今の時刻、過ぎた日ならその日の正午) */
208
+ export declare function finishOnDay(data: PlannerData, task: Task, day: Date, now: Date): Changes;
209
+ /**
210
+ * 今日の列のやることを、明日にまわす(明日の欄へ)。
211
+ * 日付のあるものは日付を明日に、それ以外は「明日の分」にする
212
+ */
213
+ export declare function postponeToTomorrow(task: Task, now: Date): Changes;
214
+ /** 明日の欄のやることを、今日にもどす */
215
+ export declare function bringToToday(task: Task, now: Date): Changes;
216
+ /**
217
+ * プロジェクトの期日目標を並べる(open: 終えていないもの、done: 終えたもの=いちばん下)。
218
+ * 並びは「席」で考える: どの目標も席(goalOrder)を持ち、
219
+ * - 日付の無いものは、ドラッグで置いた席にそのまま座る(日付のあるものの間にも置ける)
220
+ * - 日付のあるものが座る席には、いつも日付の遠い順に入れ直す(日付のルールは崩れない)
221
+ * 席がまだ無いものは、日付の無いものは上、日付のあるものは下(前の版と同じ並び)
222
+ */
223
+ export declare function projectGoals(data: PlannerData, projectId: string): {
224
+ open: Task[];
225
+ done: Task[];
226
+ };
227
+ /** 新しく足す期日目標の席(いちばん下) */
228
+ export declare function nextGoalOrder(data: PlannerData, projectId: string): number;
229
+ /** 日付の無い期日目標を、ドラッグで好きな席へ動かす(ids は今の並び。日付のあるものも含めて席を振り直す) */
230
+ export declare function reorderGoals(data: PlannerData, ids: string[], activeId: string, overId: string, now: Date): Changes;
@@ -0,0 +1,42 @@
1
+ import type { BoardHorizon, MonthDay, Period } from './types';
2
+ /** 日付(端末の時刻で YYYY-MM-DD) */
3
+ export declare function dayKey(d: Date): string;
4
+ /** 週(月曜はじまり)。その週の月曜の日付で表す(例: 2026-11-16) */
5
+ export declare function weekKey(d: Date): string;
6
+ export declare function weekStart(d: Date): Date;
7
+ export declare function monthKey(d: Date): string;
8
+ export declare function yearKey(d: Date): string;
9
+ export declare function periodKey(period: Period, d: Date): string;
10
+ /** 列ごとの「今の期間」の数え方(一生の列は年で区切る:終えたものは年が変わるまで見せる) */
11
+ export declare const HORIZON_PERIOD: Record<BoardHorizon, Period>;
12
+ /** その列に並ぶ習慣のくり返し(一生の列には習慣を置かない) */
13
+ export declare const HORIZON_HABIT_PERIOD: Partial<Record<BoardHorizon, Period>>;
14
+ export declare function addDays(d: Date, n: number): Date;
15
+ /** その日時が、今と同じ期間に入っているか */
16
+ export declare function inSamePeriod(period: Period, iso: string | undefined, now: Date): boolean;
17
+ /** 列の見出しの下に出す、今の期間(例: 11/17(火)、11/16〜11/22、11 月、2026 年) */
18
+ export declare function periodLabel(h: BoardHorizon, now: Date): string;
19
+ /** 期日(YYYY-MM-DD)を短く(例: 1/18)。今年でなければ年の下 2 けたも(例: 27/1/24) */
20
+ export declare function dueLabel(due: string, now: Date): string;
21
+ /** 期日まであと何日か(過ぎていれば負) */
22
+ export declare function daysUntil(due: string, now: Date): number | null;
23
+ /** 習慣のくり返しに対応する列(毎日 → 今日、毎週 → 今週、毎月 → 数か月、毎年 → 今年) */
24
+ export declare function periodHorizon(period: Period): BoardHorizon;
25
+ /** 毎月の「その日」の短い印(20日・月末・第2水・最終金) */
26
+ export declare function dayLabel(day: MonthDay): string;
27
+ /** 'w2-3'(第 2 水曜)・'wL-5'(最終金曜)を読む。形が違えば null */
28
+ export declare function parseNthWeekday(day: unknown): {
29
+ week: number | 'L';
30
+ weekday: number;
31
+ } | null;
32
+ /**
33
+ * その月の「その日」。日にちが無い月(31 日など)は月末に寄せる。
34
+ * 第 5 の曜日が無い月は、最終の曜日に寄せる
35
+ */
36
+ export declare function monthDayDate(day: MonthDay, month: Date): Date | undefined;
37
+ /** 日付(YYYY-MM-DD)を曜日つきで短く(例: 11/24(火)。今年でなければ 27/1/24(日)) */
38
+ export declare function dueLabelWeekday(due: string, now: Date): string;
39
+ /**
40
+ * 期日目標の日付を短く(例: 12/8)。1 年近く先(330 日より先)や過ぎた年のものだけ年を付ける(例: 27/1/24 は 2027 年でも 1/24 に)
41
+ */
42
+ export declare function shortDueLabel(due: string, now: Date): string;
@@ -0,0 +1,24 @@
1
+ import type { Habit, Horizon, PlannerData, Project, Task } from './types';
2
+ /**
3
+ * 振り返り(日ごとに、やったこと・できた習慣を見る)の計算。
4
+ * やったことは、終えた日時(doneAt)で日を決める。習慣は、チェックした日の記録(history)で決める。
5
+ */
6
+ /** 習慣をチェックした日の一覧(記録が始まる前の版でチェックしたものも含める) */
7
+ export declare function habitDays(habit: Habit): Set<string>;
8
+ /** その日に、その習慣が済んでいたか(毎週・毎月などは、その日を含む期間にチェックがあれば済み) */
9
+ export declare function habitDoneOn(habit: Habit, day: Date): boolean;
10
+ /** 続いている日数(毎日の習慣だけ。今日まだなら昨日から数える) */
11
+ export declare function streak(habit: Habit, now: Date): number;
12
+ export interface DoneItem {
13
+ task: Task;
14
+ /** 終えたときに出ていた列(期日目標は今の期日から) */
15
+ horizon: Horizon;
16
+ project?: Project;
17
+ }
18
+ /**
19
+ * その日に終えたやること。
20
+ * 下ろした先と元の両方が終わっているときは、下ろした先(実際にやった方)だけを出す。
21
+ */
22
+ export declare function doneOn(data: PlannerData, day: Date, now: Date): DoneItem[];
23
+ /** 直近 n 日(古い順。最後が今日) */
24
+ export declare function lastDays(now: Date, n: number): Date[];
@@ -0,0 +1,107 @@
1
+ /**
2
+ * 時間軸とプロジェクトのデータの形(@shiodome47/planner の土台)。
3
+ * 日付は端末の時刻で数える(YYYY-MM-DD など)。日時は ISO 8601 の文字列。
4
+ */
5
+ /** 時間軸の列。pool はプロジェクトの置き場(まだ列に置いていない) */
6
+ export type Horizon = 'today' | 'week' | 'month' | 'year' | 'life' | 'pool';
7
+ /** 列に並べる順の時間軸(pool を除く) */
8
+ export declare const HORIZONS: readonly ["today", "week", "month", "year", "life"];
9
+ export type BoardHorizon = (typeof HORIZONS)[number];
10
+ /** 重要度・優先度。A 重要・緊急/B 重要/C 通常/D 低/P Private */
11
+ export type Priority = 'A' | 'B' | 'C' | 'D' | 'P';
12
+ export declare const PRIORITIES: Priority[];
13
+ /** 習慣のくり返し(列の期間と同じ) */
14
+ export type Period = 'day' | 'week' | 'month' | 'year';
15
+ /** やること(期日目標もこれ) */
16
+ export interface Task {
17
+ id: string;
18
+ title: string;
19
+ horizon: Horizon;
20
+ priority: Priority;
21
+ /** 同じ列・同じ優先度の中での順番(小さいほど上) */
22
+ order: number;
23
+ /**
24
+ * 下ろした先の項目のとき、元の項目の id。
25
+ * 元は列に残したまま、少し薄く表示する。
26
+ */
27
+ parentId?: string;
28
+ /**
29
+ * 下ろした先の項目が、どの期間のためのものか(today なら日付、week なら週)。
30
+ * その期間が過ぎて終わっていなければ、消えた扱い(元の項目は薄い表示から戻る)。
31
+ * 今日の列では、明日の日付なら「明日」の欄に出る。
32
+ */
33
+ placedFor?: string;
34
+ /** 期日(YYYY-MM-DD)。期日目標に付ける */
35
+ due?: string;
36
+ /** どのプロジェクトのものか */
37
+ projectId?: string;
38
+ /** プロジェクトの画面での並び(日付の無い期日目標をドラッグで並べたとき。時間軸の並びとは別) */
39
+ goalOrder?: number;
40
+ /**
41
+ * 習慣から下ろした項目のとき、元の習慣の id(parentId と同じ扱い。
42
+ * 下ろした先で終えたら、習慣の今の期間のチェックが付く)
43
+ */
44
+ habitId?: string;
45
+ /** 終えた日時 */
46
+ doneAt?: string;
47
+ /** メモ(名前を押すと開く) */
48
+ note?: string;
49
+ createdAt: string;
50
+ updatedAt: string;
51
+ }
52
+ /** 習慣(ルーチン目標もこれ) */
53
+ export interface Habit {
54
+ id: string;
55
+ title: string;
56
+ period: Period;
57
+ order: number;
58
+ /** チェックした日時。今の期間(今日・今週…)のものなら済み */
59
+ checkedAt?: string;
60
+ /** チェックした日(YYYY-MM-DD)の記録。振り返りに使う(古いものから消し、最大 800 日分) */
61
+ history?: string[];
62
+ /** メモ(名前を押すと開く。アファメーションの文章・朝ルーチンの手順など) */
63
+ note?: string;
64
+ /**
65
+ * 毎月の習慣の「その日」。1〜31(日にち)、'end'(月末)、'w2-3'(第 2 水曜。曜日は 0 日曜〜6 土曜)、
66
+ * 'wL-5'(最終金曜)。決めておくと、その日がある週は今週の列に、
67
+ * その日(過ぎてチェックしていなければその後も)は今日の列にも、自動で出る
68
+ */
69
+ day?: MonthDay;
70
+ /** 毎週の習慣の曜日(0 日曜〜6 土曜)。決めておくと、その曜日から(その週にまだなら)今日の列にも出る */
71
+ weekday?: number;
72
+ /**
73
+ * 毎年の習慣の日付 'MM-DD'(例 '12-06')か、月 'MM'(例 '12')。
74
+ * 日付: その日がある週は今週の列に、その日からは今日の列にも出る。どちらも、その月は数か月の列にも出る
75
+ */
76
+ yearDay?: string;
77
+ projectId?: string;
78
+ createdAt: string;
79
+ updatedAt: string;
80
+ }
81
+ /** 毎月の「その日」(Habit.day) */
82
+ export type MonthDay = number | 'end' | `w${1 | 2 | 3 | 4 | 5 | 'L'}-${0 | 1 | 2 | 3 | 4 | 5 | 6}`;
83
+ /**
84
+ * プロジェクト(期日目標とルーチン目標の 2 本柱)。
85
+ * 「英語」「自治会」のような続けていくテーマもこれ。テーマの中に、プロジェクトを入れられる(1 段だけ)
86
+ */
87
+ export interface Project {
88
+ id: string;
89
+ name: string;
90
+ color: string;
91
+ order: number;
92
+ /** 入っているテーマ(プロジェクト)の id。無ければ、いちばん上のカード */
93
+ parentId?: string;
94
+ /** プロジェクトの画面で置いた列(0 から。ドラッグで決める。無ければ、いちばん短い列へ自動で詰める) */
95
+ column?: number;
96
+ createdAt: string;
97
+ updatedAt: string;
98
+ }
99
+ /**
100
+ * 時間軸とプロジェクトが共有するデータ。
101
+ * アプリは、これに自分の項目(日記など)を足した形で持ってよい(関数は足した項目を変えずに残す)
102
+ */
103
+ export interface PlannerData {
104
+ tasks: Task[];
105
+ habits: Habit[];
106
+ projects: Project[];
107
+ }
@@ -0,0 +1,23 @@
1
+ import type { BoardHorizon, Habit } from './types';
2
+ /** 'MM-DD' / 'MM' を読む。形が違えば null */
3
+ export declare function parseYearDay(v: string | undefined): {
4
+ month: number;
5
+ day?: number;
6
+ } | null;
7
+ /** その日を決めているか */
8
+ export declare function hasWhen(h: Habit): boolean;
9
+ /** 短い印(毎月: 20日・第2水・月末/毎週: 水曜/毎年: 12/6・12月) */
10
+ export declare function whenLabel(h: Habit): string | undefined;
11
+ /** 今の期間の「その日」(毎年の月だけのときは、その月の 1 日) */
12
+ export declare function whenDate(h: Habit, now: Date): Date | undefined;
13
+ /**
14
+ * その列に、自動で出す「その日」(出さないなら undefined)。今の期間にもうチェックしていれば出さない
15
+ * - 今日: 毎月の日・毎週の曜日・毎年の日付が、今日か、過ぎていてまだのとき
16
+ * - 今週: 毎月の日・毎年の日付が、今週のとき
17
+ * - 数か月: 毎年の日付・月が、今月のとき
18
+ */
19
+ export declare function autoDue(h: Habit, column: BoardHorizon, now: Date): Date | undefined;
20
+ /** その日を決める・外す(value は 曜日 0〜6 / 'MM-DD'・'MM'。undefined で外す。毎月は withDay を使う) */
21
+ export declare function withWhen(h: Habit, value: number | string | undefined): Habit;
22
+ /** 毎年の「月だけ」か(その月のあいだ出すだけで、過ぎた日という考えは無い) */
23
+ export declare function isMonthOnly(h: Habit): boolean;