dsh-matrix-todo 1.0.0 → 1.1.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.
- package/CHANGELOG.md +17 -0
- package/README.md +7 -2
- package/client.js +1968 -1934
- package/index.js +2 -1
- package/lib/store.js +45 -3
- package/package.json +2 -2
package/client.js
CHANGED
|
@@ -11,2064 +11,2098 @@
|
|
|
11
11
|
* Styling only uses `--dsw-alias-*` theme tokens, so light and dark appearance
|
|
12
12
|
* (and any palette layer another plugin stacks) apply without extra work.
|
|
13
13
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
14
|
+
window.__ModuleLoader__.load({
|
|
15
|
+
id: 'dsh-matrix-todo',
|
|
16
|
+
factory(require) {
|
|
17
|
+
const React = require('react');
|
|
18
|
+
const h = React.createElement;
|
|
19
|
+
const useState = React.useState;
|
|
20
|
+
const useEffect = React.useEffect;
|
|
21
|
+
const useMemo = React.useMemo;
|
|
22
|
+
const useCallback = React.useCallback;
|
|
23
|
+
const useRef = React.useRef;
|
|
24
|
+
const useSyncExternalStore = React.useSyncExternalStore;
|
|
25
|
+
|
|
26
|
+
/** Dictionary namespace owned by this plugin. */
|
|
27
|
+
const NS = 'matrixTodo';
|
|
28
|
+
/** Shared by the sidebar row and the main panel it selects. */
|
|
29
|
+
const PANEL_ID = 'matrix-todo';
|
|
30
|
+
/** Host API route prefix. */
|
|
31
|
+
const API_PREFIX = 'matrix-todo/api/';
|
|
32
|
+
/** Sidebar order: right after the shipped "todo" entry (order 20). */
|
|
33
|
+
const ORDER = 21;
|
|
34
|
+
|
|
35
|
+
/** Layout preferences, mirrored from the Host defaults. */
|
|
36
|
+
const DEFAULT_SETTINGS = {
|
|
37
|
+
urgentSide: 'right',
|
|
38
|
+
frame: 'cross',
|
|
39
|
+
radius: 10,
|
|
40
|
+
tint: 'plain',
|
|
41
|
+
fontSize: 14,
|
|
42
|
+
dueFormat: 'countdown',
|
|
43
|
+
titleStyle: 'wrap',
|
|
44
|
+
colRatio: 0.5,
|
|
45
|
+
rowRatio: 0.5,
|
|
46
|
+
navLabel: '',
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/** Author links shown at the foot of the settings panel (external, new tab). */
|
|
50
|
+
const AUTHOR_NAME = 'Zhang-Eli';
|
|
51
|
+
const AUTHOR_URL = 'https://github.com/' + AUTHOR_NAME;
|
|
52
|
+
const REPO_URL = 'https://github.com/Zhang-Eli/dsh-matrix-todo';
|
|
53
|
+
const ISSUES_URL = REPO_URL + '/issues';
|
|
54
|
+
|
|
55
|
+
/** Keep a split ratio inside the range the Host accepts. */
|
|
56
|
+
function clampRatio(value) {
|
|
57
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) return 0.5;
|
|
58
|
+
return Math.min(0.8, Math.max(0.2, Math.round(value * 1000) / 1000));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** English dictionary. */
|
|
62
|
+
const EN = {
|
|
63
|
+
'nav.label': 'Todo matrix',
|
|
64
|
+
'page.title': 'To-do',
|
|
65
|
+
'page.subtitle': 'Important × Urgent',
|
|
66
|
+
'view.matrix': 'Matrix',
|
|
67
|
+
'view.completed': 'Done',
|
|
68
|
+
'flag.important': 'Important',
|
|
69
|
+
'flag.urgent': 'Urgent',
|
|
70
|
+
'quadrant.q1': 'Do now',
|
|
71
|
+
'quadrant.q1.hint': 'Important · Urgent',
|
|
72
|
+
'quadrant.q2': 'Schedule',
|
|
73
|
+
'quadrant.q2.hint': 'Important · Not urgent',
|
|
74
|
+
'quadrant.q3': 'Delegate',
|
|
75
|
+
'quadrant.q3.hint': 'Not important · Urgent',
|
|
76
|
+
'quadrant.q4': 'Eliminate',
|
|
77
|
+
'quadrant.q4.hint': 'Not important · Not urgent',
|
|
78
|
+
'item.complete': 'Mark as done',
|
|
79
|
+
'item.restore': 'Restore',
|
|
80
|
+
'item.delete': 'Delete',
|
|
81
|
+
'item.due.set': 'Set due date',
|
|
82
|
+
'item.due.today': 'Due today',
|
|
83
|
+
'item.due.overdue': 'Overdue',
|
|
84
|
+
'item.drag': 'Drag to reorder or move to another quadrant',
|
|
85
|
+
'item.edit': 'Double-click to edit',
|
|
86
|
+
'seed.add': 'Click an empty spot or "+ Add" to create a to-do',
|
|
87
|
+
'seed.drag': 'Drag a to-do to reorder it or move it to another quadrant',
|
|
88
|
+
'seed.edit': 'Double-click the text to edit it',
|
|
89
|
+
'seed.split': 'Drag the center dot to resize quadrants; double-click resets',
|
|
90
|
+
'seed.settings': 'Use the gear to change border, tint, font size, urgent side',
|
|
91
|
+
'seed.overdue': 'Overdue items turn red',
|
|
92
|
+
'seed.date': 'Date panel: single-click to preview, double-click to confirm',
|
|
93
|
+
'quickAdd.due': 'Due date',
|
|
94
|
+
'toast.praise.1': 'Well done! Right on time.',
|
|
95
|
+
'toast.praise.2': 'Nice — done before the deadline.',
|
|
96
|
+
'toast.praise.3': 'On schedule. Great rhythm.',
|
|
97
|
+
'toast.praise.4': 'Delivered on time.',
|
|
98
|
+
'toast.praise.5': 'Well done! Plan kept.',
|
|
99
|
+
'toast.praise.6': 'Right on time — nice work.',
|
|
100
|
+
'toast.praise.7': 'On track and done. Keep it up.',
|
|
101
|
+
'toast.praise.8': 'Great job hitting the date.',
|
|
102
|
+
'toast.cheer.1': 'Done is done — next time a little earlier.',
|
|
103
|
+
'toast.cheer.2': 'Late, but finished. Keep going.',
|
|
104
|
+
'toast.cheer.3': 'You closed it out. No guilt needed.',
|
|
105
|
+
'toast.cheer.4': 'Better late than never. On to the next.',
|
|
106
|
+
'toast.cheer.5': 'One off the list — reset the pace.',
|
|
107
|
+
'toast.cheer.6': 'Finished, and that still counts.',
|
|
108
|
+
'toast.cheer.7': 'Overdue but done. That matters.',
|
|
109
|
+
'toast.cheer.8': 'Cheer up — try one day earlier next time.',
|
|
110
|
+
'empty.completed': 'No completed to-dos yet.',
|
|
111
|
+
'completed.heading': 'Completed',
|
|
112
|
+
'completed.clear': 'Clear completed',
|
|
113
|
+
'completed.confirm': 'Confirm clear',
|
|
114
|
+
'quickAdd': 'Add',
|
|
115
|
+
'quickAdd.placeholder': 'Press Enter to add here',
|
|
116
|
+
'picker.prev': 'Previous month',
|
|
117
|
+
'picker.next': 'Next month',
|
|
118
|
+
'picker.clear': 'Clear',
|
|
119
|
+
'picker.today': 'Today',
|
|
120
|
+
'picker.due': 'Due date',
|
|
121
|
+
'picker.hint': 'Click to preview the day, double-click to set it and add the to-do',
|
|
122
|
+
'settings.toggle': 'Settings',
|
|
123
|
+
'settings.axis': 'Urgent column',
|
|
124
|
+
'settings.axis.left': 'Left',
|
|
125
|
+
'settings.axis.right': 'Right',
|
|
126
|
+
'settings.frame': 'Frame',
|
|
127
|
+
'settings.frame.cards': 'Cards',
|
|
128
|
+
'settings.frame.grid': 'Grid',
|
|
129
|
+
'settings.frame.cross': 'Cross',
|
|
130
|
+
'settings.tint': 'Cell fill',
|
|
131
|
+
'settings.tint.plain': 'Plain',
|
|
132
|
+
'settings.tint.soft': 'Soft',
|
|
133
|
+
'settings.dueFormat': 'Due date as',
|
|
134
|
+
'settings.dueFormat.date': 'Date',
|
|
135
|
+
'settings.dueFormat.countdown': 'Countdown',
|
|
136
|
+
'settings.titleStyle': 'Text',
|
|
137
|
+
'settings.titleStyle.wrap': 'Wrap',
|
|
138
|
+
'settings.titleStyle.truncate': 'Truncate',
|
|
139
|
+
'settings.quadSize': 'Drag the centre handle to resize the quadrants',
|
|
140
|
+
'settings.navLabel': 'Sidebar label',
|
|
141
|
+
'settings.navLabel.placeholder': 'Eisenhower to-do',
|
|
142
|
+
'settings.radius': 'Corner radius',
|
|
143
|
+
'settings.fontSize': 'Font size',
|
|
144
|
+
'settings.reset': 'Reset',
|
|
145
|
+
'settings.about.issues': 'Feedback',
|
|
146
|
+
'settings.about.developed': 'Developed by',
|
|
147
|
+
'loading': 'Loading…',
|
|
148
|
+
'error.request': 'Request failed.',
|
|
149
|
+
'error.retry': 'Retry',
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/** Chinese dictionary. */
|
|
153
|
+
const ZH = {
|
|
154
|
+
'nav.label': '四象限待办',
|
|
155
|
+
'page.title': '待办',
|
|
156
|
+
'page.subtitle': '重要 × 紧急',
|
|
157
|
+
'view.matrix': '四象限',
|
|
158
|
+
'view.completed': '已完成',
|
|
159
|
+
'flag.important': '重要',
|
|
160
|
+
'flag.urgent': '紧急',
|
|
161
|
+
'quadrant.q1': '立即做',
|
|
162
|
+
'quadrant.q1.hint': '重要 · 紧急',
|
|
163
|
+
'quadrant.q2': '计划做',
|
|
164
|
+
'quadrant.q2.hint': '重要 · 不紧急',
|
|
165
|
+
'quadrant.q3': '委托做',
|
|
166
|
+
'quadrant.q3.hint': '不重要 · 紧急',
|
|
167
|
+
'quadrant.q4': '别做',
|
|
168
|
+
'quadrant.q4.hint': '不重要 · 不紧急',
|
|
169
|
+
'item.complete': '标记完成',
|
|
170
|
+
'item.restore': '恢复',
|
|
171
|
+
'item.delete': '删除',
|
|
172
|
+
'item.due.set': '设置截止日期',
|
|
173
|
+
'item.due.today': '今天到期',
|
|
174
|
+
'item.due.overdue': '已逾期',
|
|
175
|
+
'item.drag': '拖动可排序,或移到其他象限',
|
|
176
|
+
'item.edit': '双击编辑',
|
|
177
|
+
'seed.add': '点空白处或「+ 添加」新增待办',
|
|
178
|
+
'seed.drag': '拖拽待办可在象限内排序,或移到别的象限',
|
|
179
|
+
'seed.edit': '双击待办文字即可编辑',
|
|
180
|
+
'seed.split': '拖动中心圆点调整象限大小,双击复位',
|
|
181
|
+
'seed.settings': '右上角齿轮可改边框、底色、字号、紧急方向',
|
|
182
|
+
'seed.overdue': '未按期完成的待办会变红',
|
|
183
|
+
'seed.date': '日期面板:单击选择,双击确定',
|
|
184
|
+
'quickAdd.due': '截止日期',
|
|
185
|
+
'toast.praise.1': 'Well done! 按期完成',
|
|
186
|
+
'toast.praise.2': '漂亮,正好赶上',
|
|
187
|
+
'toast.praise.3': '按时搞定,节奏很好',
|
|
188
|
+
'toast.praise.4': '如期完成,稳稳的',
|
|
189
|
+
'toast.praise.5': 'Well done! 计划达成',
|
|
190
|
+
'toast.praise.6': '准时完成,很棒',
|
|
191
|
+
'toast.praise.7': '按计划完成,继续保持',
|
|
192
|
+
'toast.praise.8': '干得漂亮,说到做到',
|
|
193
|
+
'toast.cheer.1': '完成了就好,下次早点开始',
|
|
194
|
+
'toast.cheer.2': '虽然晚了点,但没放弃,加油',
|
|
195
|
+
'toast.cheer.3': '补上了,别自责,继续前进',
|
|
196
|
+
'toast.cheer.4': '迟到总比不到好,下一件会更好',
|
|
197
|
+
'toast.cheer.5': '搞定一件,调整节奏再来',
|
|
198
|
+
'toast.cheer.6': '完成了,给自己一点宽容',
|
|
199
|
+
'toast.cheer.7': '逾期也完成了,值得肯定',
|
|
200
|
+
'toast.cheer.8': '加油,下一次试着提前一天',
|
|
201
|
+
'empty.completed': '还没有已完成的事项。',
|
|
202
|
+
'completed.heading': '已完成',
|
|
203
|
+
'completed.clear': '清空已完成',
|
|
204
|
+
'completed.confirm': '确认清空',
|
|
205
|
+
'quickAdd': '添加',
|
|
206
|
+
'quickAdd.placeholder': '回车添加到本象限',
|
|
207
|
+
'picker.prev': '上个月',
|
|
208
|
+
'picker.next': '下个月',
|
|
209
|
+
'picker.clear': '清除',
|
|
210
|
+
'picker.today': '今天',
|
|
211
|
+
'picker.due': '截止日期',
|
|
212
|
+
'picker.hint': '单击预览日期,双击确定并添加该待办',
|
|
213
|
+
'settings.toggle': '设置',
|
|
214
|
+
'settings.axis': '紧急方向',
|
|
215
|
+
'settings.axis.left': '在左',
|
|
216
|
+
'settings.axis.right': '在右',
|
|
217
|
+
'settings.frame': '边框风格',
|
|
218
|
+
'settings.frame.cards': '卡片',
|
|
219
|
+
'settings.frame.grid': '田字格',
|
|
220
|
+
'settings.frame.cross': '十字线',
|
|
221
|
+
'settings.tint': '象限底色',
|
|
222
|
+
'settings.tint.plain': '纯色',
|
|
223
|
+
'settings.tint.soft': '淡彩',
|
|
224
|
+
'settings.dueFormat': '日期显示',
|
|
225
|
+
'settings.dueFormat.date': '日期',
|
|
226
|
+
'settings.dueFormat.countdown': '倒计时',
|
|
227
|
+
'settings.titleStyle': '文字显示',
|
|
228
|
+
'settings.titleStyle.wrap': '完整换行',
|
|
229
|
+
'settings.titleStyle.truncate': '单行截断',
|
|
230
|
+
'settings.quadSize': '拖动象限中心的圆点可调整四象限大小',
|
|
231
|
+
'settings.navLabel': '侧边栏名称',
|
|
232
|
+
'settings.navLabel.placeholder': '四象限待办',
|
|
233
|
+
'settings.radius': '圆角幅度',
|
|
234
|
+
'settings.fontSize': '字号',
|
|
235
|
+
'settings.reset': '恢复默认',
|
|
236
|
+
'settings.about.issues': '反馈问题',
|
|
237
|
+
'settings.about.developed': 'Developed by',
|
|
238
|
+
'loading': '加载中…',
|
|
239
|
+
'error.request': '请求失败。',
|
|
240
|
+
'error.retry': '重试',
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* The four cells, in reading order for the default layout.
|
|
245
|
+
* `important`/`urgent` are the two data flags; labels are locale keys.
|
|
246
|
+
*/
|
|
247
|
+
const QUADRANTS = [
|
|
248
|
+
{ id: 'q1', important: true, urgent: true },
|
|
249
|
+
{ id: 'q2', important: true, urgent: false },
|
|
250
|
+
{ id: 'q3', important: false, urgent: true },
|
|
251
|
+
{ id: 'q4', important: false, urgent: false },
|
|
252
|
+
];
|
|
253
|
+
|
|
254
|
+
/** Reading order when the urgent column moves to the right edge. */
|
|
255
|
+
const URGENT_RIGHT_ORDER = ['q2', 'q1', 'q4', 'q3'];
|
|
256
|
+
|
|
257
|
+
/** Defensive read of a settings payload from the Host. */
|
|
258
|
+
function sanitizeSettings(value) {
|
|
259
|
+
const source = value !== null && typeof value === 'object' ? value : {};
|
|
260
|
+
return {
|
|
261
|
+
urgentSide: source.urgentSide === 'right' ? 'right' : 'left',
|
|
262
|
+
frame: source.frame === 'grid' || source.frame === 'cross' ? source.frame : 'cards',
|
|
263
|
+
radius:
|
|
264
|
+
Number.isInteger(source.radius) && source.radius >= 0 && source.radius <= 24
|
|
265
|
+
? source.radius
|
|
266
|
+
: DEFAULT_SETTINGS.radius,
|
|
267
|
+
tint: source.tint === 'soft' ? 'soft' : 'plain',
|
|
268
|
+
fontSize:
|
|
269
|
+
Number.isInteger(source.fontSize) && source.fontSize >= 11 && source.fontSize <= 17
|
|
270
|
+
? source.fontSize
|
|
271
|
+
: DEFAULT_SETTINGS.fontSize,
|
|
272
|
+
dueFormat: source.dueFormat === 'countdown' ? 'countdown' : 'date',
|
|
273
|
+
titleStyle: source.titleStyle === 'truncate' ? 'truncate' : 'wrap',
|
|
274
|
+
colRatio: clampRatio(source.colRatio),
|
|
275
|
+
rowRatio: clampRatio(source.rowRatio),
|
|
276
|
+
navLabel: typeof source.navLabel === 'string' ? source.navLabel.trim().slice(0, 24) : '',
|
|
55
277
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** Build the endpoint URL, respecting a document `<base>` like the host does. */
|
|
281
|
+
function apiUrl(method) {
|
|
282
|
+
return new URL(API_PREFIX + method, document.baseURI).href;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* One API round trip. Resolves to the server's `result`; throws a readable
|
|
287
|
+
* Error whose message is already user-facing (the Host writes them).
|
|
288
|
+
*/
|
|
289
|
+
async function fetchApi(method, payload) {
|
|
290
|
+
const res = await fetch(apiUrl(method), {
|
|
291
|
+
method: 'POST',
|
|
292
|
+
headers: { 'content-type': 'application/json' },
|
|
293
|
+
body: JSON.stringify(payload ?? {}),
|
|
294
|
+
});
|
|
295
|
+
const body = await res.json().catch(() => null);
|
|
296
|
+
if (body === null || typeof body !== 'object') {
|
|
297
|
+
throw new Error('Unexpected response from the to-do store.');
|
|
67
298
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
'
|
|
121
|
-
'
|
|
122
|
-
'
|
|
123
|
-
'
|
|
124
|
-
'settings
|
|
125
|
-
'
|
|
126
|
-
'
|
|
127
|
-
'settings.frame': 'Frame',
|
|
128
|
-
'settings.frame.cards': 'Cards',
|
|
129
|
-
'settings.frame.grid': 'Grid',
|
|
130
|
-
'settings.frame.cross': 'Cross',
|
|
131
|
-
'settings.tint': 'Cell fill',
|
|
132
|
-
'settings.tint.plain': 'Plain',
|
|
133
|
-
'settings.tint.soft': 'Soft',
|
|
134
|
-
'settings.dueFormat': 'Due date as',
|
|
135
|
-
'settings.dueFormat.date': 'Date',
|
|
136
|
-
'settings.dueFormat.countdown': 'Countdown',
|
|
137
|
-
'settings.titleStyle': 'Text',
|
|
138
|
-
'settings.titleStyle.wrap': 'Wrap',
|
|
139
|
-
'settings.titleStyle.truncate': 'Truncate',
|
|
140
|
-
'settings.quadSize': 'Drag the centre handle to resize the quadrants',
|
|
141
|
-
'settings.navLabel': 'Sidebar label',
|
|
142
|
-
'settings.navLabel.placeholder': 'Eisenhower to-do',
|
|
143
|
-
'settings.radius': 'Corner radius',
|
|
144
|
-
'settings.fontSize': 'Font size',
|
|
145
|
-
'settings.reset': 'Reset',
|
|
146
|
-
'settings.about.issues': 'Feedback',
|
|
147
|
-
'settings.about.developed': 'Developed by',
|
|
148
|
-
'loading': 'Loading…',
|
|
149
|
-
'error.request': 'Request failed.',
|
|
150
|
-
'error.retry': 'Retry',
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
/** Chinese dictionary. */
|
|
154
|
-
const ZH = {
|
|
155
|
-
'nav.label': '四象限待办',
|
|
156
|
-
'page.title': '待办',
|
|
157
|
-
'page.subtitle': '重要 × 紧急',
|
|
158
|
-
'view.matrix': '四象限',
|
|
159
|
-
'view.completed': '已完成',
|
|
160
|
-
'flag.important': '重要',
|
|
161
|
-
'flag.urgent': '紧急',
|
|
162
|
-
'quadrant.q1': '立即做',
|
|
163
|
-
'quadrant.q1.hint': '重要 · 紧急',
|
|
164
|
-
'quadrant.q2': '计划做',
|
|
165
|
-
'quadrant.q2.hint': '重要 · 不紧急',
|
|
166
|
-
'quadrant.q3': '委托做',
|
|
167
|
-
'quadrant.q3.hint': '不重要 · 紧急',
|
|
168
|
-
'quadrant.q4': '别做',
|
|
169
|
-
'quadrant.q4.hint': '不重要 · 不紧急',
|
|
170
|
-
'item.complete': '标记完成',
|
|
171
|
-
'item.restore': '恢复',
|
|
172
|
-
'item.delete': '删除',
|
|
173
|
-
'item.due.set': '设置截止日期',
|
|
174
|
-
'item.due.today': '今天到期',
|
|
175
|
-
'item.due.overdue': '已逾期',
|
|
176
|
-
'item.drag': '拖动可排序,或移到其他象限',
|
|
177
|
-
'item.edit': '双击编辑',
|
|
178
|
-
'quickAdd.due': '截止日期',
|
|
179
|
-
'toast.praise.1': 'Well done! 按期完成',
|
|
180
|
-
'toast.praise.2': '漂亮,正好赶上',
|
|
181
|
-
'toast.praise.3': '按时搞定,节奏很好',
|
|
182
|
-
'toast.praise.4': '如期完成,稳稳的',
|
|
183
|
-
'toast.praise.5': 'Well done! 计划达成',
|
|
184
|
-
'toast.praise.6': '准时完成,很棒',
|
|
185
|
-
'toast.praise.7': '按计划完成,继续保持',
|
|
186
|
-
'toast.praise.8': '干得漂亮,说到做到',
|
|
187
|
-
'toast.cheer.1': '完成了就好,下次早点开始',
|
|
188
|
-
'toast.cheer.2': '虽然晚了点,但没放弃,加油',
|
|
189
|
-
'toast.cheer.3': '补上了,别自责,继续前进',
|
|
190
|
-
'toast.cheer.4': '迟到总比不到好,下一件会更好',
|
|
191
|
-
'toast.cheer.5': '搞定一件,调整节奏再来',
|
|
192
|
-
'toast.cheer.6': '完成了,给自己一点宽容',
|
|
193
|
-
'toast.cheer.7': '逾期也完成了,值得肯定',
|
|
194
|
-
'toast.cheer.8': '加油,下一次试着提前一天',
|
|
195
|
-
'empty.completed': '还没有已完成的事项。',
|
|
196
|
-
'completed.heading': '已完成',
|
|
197
|
-
'completed.clear': '清空已完成',
|
|
198
|
-
'completed.confirm': '确认清空',
|
|
199
|
-
'quickAdd': '添加',
|
|
200
|
-
'quickAdd.placeholder': '回车添加到本象限',
|
|
201
|
-
'picker.prev': '上个月',
|
|
202
|
-
'picker.next': '下个月',
|
|
203
|
-
'picker.clear': '清除',
|
|
204
|
-
'picker.today': '今天',
|
|
205
|
-
'picker.due': '截止日期',
|
|
206
|
-
'picker.hint': '单击预览日期,双击确定并添加该待办',
|
|
207
|
-
'settings.toggle': '设置',
|
|
208
|
-
'settings.axis': '紧急方向',
|
|
209
|
-
'settings.axis.left': '在左',
|
|
210
|
-
'settings.axis.right': '在右',
|
|
211
|
-
'settings.frame': '边框风格',
|
|
212
|
-
'settings.frame.cards': '卡片',
|
|
213
|
-
'settings.frame.grid': '田字格',
|
|
214
|
-
'settings.frame.cross': '十字线',
|
|
215
|
-
'settings.tint': '象限底色',
|
|
216
|
-
'settings.tint.plain': '纯色',
|
|
217
|
-
'settings.tint.soft': '淡彩',
|
|
218
|
-
'settings.dueFormat': '日期显示',
|
|
219
|
-
'settings.dueFormat.date': '日期',
|
|
220
|
-
'settings.dueFormat.countdown': '倒计时',
|
|
221
|
-
'settings.titleStyle': '文字显示',
|
|
222
|
-
'settings.titleStyle.wrap': '完整换行',
|
|
223
|
-
'settings.titleStyle.truncate': '单行截断',
|
|
224
|
-
'settings.quadSize': '拖动象限中心的圆点可调整四象限大小',
|
|
225
|
-
'settings.navLabel': '侧边栏名称',
|
|
226
|
-
'settings.navLabel.placeholder': '四象限待办',
|
|
227
|
-
'settings.radius': '圆角幅度',
|
|
228
|
-
'settings.fontSize': '字号',
|
|
229
|
-
'settings.reset': '恢复默认',
|
|
230
|
-
'settings.about.issues': '反馈问题',
|
|
231
|
-
'settings.about.developed': 'Developed by',
|
|
232
|
-
'loading': '加载中…',
|
|
233
|
-
'error.request': '请求失败。',
|
|
234
|
-
'error.retry': '重试',
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* The four cells, in reading order for the default layout.
|
|
239
|
-
* `important`/`urgent` are the two data flags; labels are locale keys.
|
|
240
|
-
*/
|
|
241
|
-
const QUADRANTS = [
|
|
242
|
-
{ id: 'q1', important: true, urgent: true },
|
|
243
|
-
{ id: 'q2', important: true, urgent: false },
|
|
244
|
-
{ id: 'q3', important: false, urgent: true },
|
|
245
|
-
{ id: 'q4', important: false, urgent: false },
|
|
299
|
+
if (!body.ok) {
|
|
300
|
+
const message = body.error && body.error.message;
|
|
301
|
+
throw new Error(typeof message === 'string' && message !== '' ? message : 'The to-do store refused the request.');
|
|
302
|
+
}
|
|
303
|
+
return body.result ?? {};
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/** `MM-DD`, with the year added only when it is not the current one. */
|
|
307
|
+
function formatDay(iso) {
|
|
308
|
+
if (typeof iso !== 'string' || iso === '') return '';
|
|
309
|
+
const date = new Date(iso);
|
|
310
|
+
if (Number.isNaN(date.getTime())) return '';
|
|
311
|
+
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
312
|
+
const day = String(date.getDate()).padStart(2, '0');
|
|
313
|
+
const year = date.getFullYear();
|
|
314
|
+
return year === new Date().getFullYear() ? month + '-' + day : year + '-' + month + '-' + day;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/** Local calendar day key (YYYY-MM-DD), used for due-date comparison. */
|
|
318
|
+
function dayKeyOf(date) {
|
|
319
|
+
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
320
|
+
const day = String(date.getDate()).padStart(2, '0');
|
|
321
|
+
return date.getFullYear() + '-' + month + '-' + day;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/** Today as a local day key; re-read on every render so a stale page still compares correctly. */
|
|
325
|
+
function todayKey() {
|
|
326
|
+
return dayKeyOf(new Date());
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/** Format a stored YYYY-MM-DD key without timezone shifts. */
|
|
330
|
+
function formatDayKey(key) {
|
|
331
|
+
const parts = String(key).split('-');
|
|
332
|
+
if (parts.length !== 3) return key;
|
|
333
|
+
const year = Number(parts[0]);
|
|
334
|
+
return year === new Date().getFullYear() ? parts[1] + '-' + parts[2] : key;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/** Day key `offset` days from today (negative = past). */
|
|
338
|
+
function dayKeyOffset(offset) {
|
|
339
|
+
const date = new Date();
|
|
340
|
+
date.setDate(date.getDate() + offset);
|
|
341
|
+
return dayKeyOf(date);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* First-run guide rows, sent once to the Host with localized titles. They
|
|
346
|
+
* demonstrate all four quadrants, including an overdue row and a date-picker
|
|
347
|
+
* row; the Host flag makes them one-shot, so deleting them sticks.
|
|
348
|
+
*/
|
|
349
|
+
function seedItems(t) {
|
|
350
|
+
return [
|
|
351
|
+
{ title: t('seed.add'), important: true, urgent: true },
|
|
352
|
+
{ title: t('seed.drag'), important: true, urgent: false },
|
|
353
|
+
{ title: t('seed.edit'), important: true, urgent: false },
|
|
354
|
+
{ title: t('seed.split'), important: true, urgent: false },
|
|
355
|
+
{ title: t('seed.settings'), important: false, urgent: true },
|
|
356
|
+
{ title: t('seed.overdue'), important: false, urgent: true, dueDate: dayKeyOffset(-3) },
|
|
357
|
+
{ title: t('seed.date'), important: false, urgent: false, dueDate: dayKeyOffset(30) },
|
|
246
358
|
];
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/** `overdue` / `today` / `future` for an open todo's due date. */
|
|
362
|
+
function dueStateOf(dueDate) {
|
|
363
|
+
if (typeof dueDate !== 'string' || dueDate === '') return null;
|
|
364
|
+
const today = todayKey();
|
|
365
|
+
if (dueDate < today) return 'overdue';
|
|
366
|
+
return dueDate === today ? 'today' : 'future';
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/** Whole days between two `YYYY-MM-DD` keys (positive = `a` is later). UTC math avoids DST drift. */
|
|
370
|
+
function daysBetween(a, b) {
|
|
371
|
+
const left = String(a).split('-').map(Number);
|
|
372
|
+
const right = String(b).split('-').map(Number);
|
|
373
|
+
if (left.length !== 3 || right.length !== 3) return 0;
|
|
374
|
+
const ms = Date.UTC(left[0], left[1] - 1, left[2]) - Date.UTC(right[0], right[1] - 1, right[2]);
|
|
375
|
+
return Math.round(ms / 86400000);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/** `7d` in the future, `0d` today, `-3d` when overdue. */
|
|
379
|
+
function formatCountdown(dueDate) {
|
|
380
|
+
const diff = daysBetween(dueDate, todayKey());
|
|
381
|
+
return (diff > 0 ? String(diff) : diff === 0 ? '0' : String(diff)) + 'd';
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/** Local Date from a `YYYY-MM-DD` key. */
|
|
385
|
+
function dateOfKey(key) {
|
|
386
|
+
const parts = String(key).split('-').map(Number);
|
|
387
|
+
return new Date(parts[0], parts[1] - 1, parts[2]);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/** `YYYY-MM-DD` from a full year, a 0-based month, and a day of month. */
|
|
391
|
+
function keyOfDate(year, monthIndex, day) {
|
|
392
|
+
return year + '-' + String(monthIndex + 1).padStart(2, '0') + '-' + String(day).padStart(2, '0');
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/** Day cells of one month, Monday first; nulls pad the leading week. */
|
|
396
|
+
function monthCells(year, monthIndex) {
|
|
397
|
+
const offset = (new Date(year, monthIndex, 1).getDay() + 6) % 7;
|
|
398
|
+
const total = new Date(year, monthIndex + 1, 0).getDate();
|
|
399
|
+
const cells = [];
|
|
400
|
+
for (let index = 0; index < offset; index += 1) cells.push(null);
|
|
401
|
+
for (let day = 1; day <= total; day += 1) cells.push(day);
|
|
402
|
+
return cells;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/** Narrow weekday labels in the user's locale, Monday first (2024-01-01 was a Monday). */
|
|
406
|
+
const WEEKDAY_LABELS = (() => {
|
|
407
|
+
const format = new Intl.DateTimeFormat(undefined, { weekday: 'narrow' });
|
|
408
|
+
return Array.from({ length: 7 }, (_, index) => format.format(new Date(2024, 0, 1 + index)));
|
|
409
|
+
})();
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Fixed-position coordinates for the calendar panel anchored to a control,
|
|
413
|
+
* flipped above it when there is not enough room below.
|
|
414
|
+
*/
|
|
415
|
+
function panelPositionFor(rect) {
|
|
416
|
+
const width = 252;
|
|
417
|
+
const height = 330;
|
|
418
|
+
const left = Math.max(8, Math.min(rect.right - width, window.innerWidth - width - 8));
|
|
419
|
+
const top =
|
|
420
|
+
rect.bottom + 6 + height > window.innerHeight - 8 ? Math.max(8, rect.top - height - 6) : rect.bottom + 6;
|
|
421
|
+
return { left, top };
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* A small month calendar. A single click previews a day without closing;
|
|
426
|
+
* a double-click confirms it, closes, and lets the caller add the to-do.
|
|
427
|
+
*/
|
|
428
|
+
function DatePickerPanel(props) {
|
|
429
|
+
const t = props.t;
|
|
430
|
+
const value = props.value;
|
|
431
|
+
const anchor = props.anchor;
|
|
432
|
+
const panelRef = useRef(null);
|
|
433
|
+
const [view, setView] = useState(() => {
|
|
434
|
+
const base = value !== '' ? dateOfKey(value) : new Date();
|
|
435
|
+
return { year: base.getFullYear(), month: base.getMonth() };
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
const dismiss = props.onDismiss;
|
|
439
|
+
|
|
440
|
+
useEffect(() => {
|
|
441
|
+
const onPointerDown = (event) => {
|
|
442
|
+
if (panelRef.current !== null && panelRef.current.contains(event.target)) return;
|
|
443
|
+
const target = event.target;
|
|
444
|
+
if (target instanceof Element) {
|
|
445
|
+
const anchorElement = target.closest('[data-ez-date-anchor]');
|
|
446
|
+
// Its own anchor toggles the panel closed via click, so leave it alone;
|
|
447
|
+
// any other anchor dismisses this panel and opens its own.
|
|
448
|
+
if (anchorElement !== null && anchorElement.getAttribute('data-ez-date-anchor') === anchor) return;
|
|
449
|
+
}
|
|
450
|
+
dismiss();
|
|
271
451
|
};
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
*/
|
|
283
|
-
async function fetchApi(method, payload) {
|
|
284
|
-
const res = await fetch(apiUrl(method), {
|
|
285
|
-
method: 'POST',
|
|
286
|
-
headers: { 'content-type': 'application/json' },
|
|
287
|
-
body: JSON.stringify(payload ?? {}),
|
|
288
|
-
});
|
|
289
|
-
const body = await res.json().catch(() => null);
|
|
290
|
-
if (body === null || typeof body !== 'object') {
|
|
291
|
-
throw new Error('Unexpected response from the to-do store.');
|
|
292
|
-
}
|
|
293
|
-
if (!body.ok) {
|
|
294
|
-
const message = body.error && body.error.message;
|
|
295
|
-
throw new Error(typeof message === 'string' && message !== '' ? message : 'The to-do store refused the request.');
|
|
296
|
-
}
|
|
297
|
-
return body.result ?? {};
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
/** `MM-DD`, with the year added only when it is not the current one. */
|
|
301
|
-
function formatDay(iso) {
|
|
302
|
-
if (typeof iso !== 'string' || iso === '') return '';
|
|
303
|
-
const date = new Date(iso);
|
|
304
|
-
if (Number.isNaN(date.getTime())) return '';
|
|
305
|
-
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
306
|
-
const day = String(date.getDate()).padStart(2, '0');
|
|
307
|
-
const year = date.getFullYear();
|
|
308
|
-
return year === new Date().getFullYear() ? month + '-' + day : year + '-' + month + '-' + day;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
/** Local calendar day key (YYYY-MM-DD), used for due-date comparison. */
|
|
312
|
-
function dayKeyOf(date) {
|
|
313
|
-
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
314
|
-
const day = String(date.getDate()).padStart(2, '0');
|
|
315
|
-
return date.getFullYear() + '-' + month + '-' + day;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
/** Today as a local day key; re-read on every render so a stale page still compares correctly. */
|
|
319
|
-
function todayKey() {
|
|
320
|
-
return dayKeyOf(new Date());
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
/** Format a stored YYYY-MM-DD key without timezone shifts. */
|
|
324
|
-
function formatDayKey(key) {
|
|
325
|
-
const parts = String(key).split('-');
|
|
326
|
-
if (parts.length !== 3) return key;
|
|
327
|
-
const year = Number(parts[0]);
|
|
328
|
-
return year === new Date().getFullYear() ? parts[1] + '-' + parts[2] : key;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
/** `overdue` / `today` / `future` for an open todo's due date. */
|
|
332
|
-
function dueStateOf(dueDate) {
|
|
333
|
-
if (typeof dueDate !== 'string' || dueDate === '') return null;
|
|
334
|
-
const today = todayKey();
|
|
335
|
-
if (dueDate < today) return 'overdue';
|
|
336
|
-
return dueDate === today ? 'today' : 'future';
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
/** Whole days between two `YYYY-MM-DD` keys (positive = `a` is later). UTC math avoids DST drift. */
|
|
340
|
-
function daysBetween(a, b) {
|
|
341
|
-
const left = String(a).split('-').map(Number);
|
|
342
|
-
const right = String(b).split('-').map(Number);
|
|
343
|
-
if (left.length !== 3 || right.length !== 3) return 0;
|
|
344
|
-
const ms = Date.UTC(left[0], left[1] - 1, left[2]) - Date.UTC(right[0], right[1] - 1, right[2]);
|
|
345
|
-
return Math.round(ms / 86400000);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
/** `7d` in the future, `0d` today, `-3d` when overdue. */
|
|
349
|
-
function formatCountdown(dueDate) {
|
|
350
|
-
const diff = daysBetween(dueDate, todayKey());
|
|
351
|
-
return (diff > 0 ? String(diff) : diff === 0 ? '0' : String(diff)) + 'd';
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
/** Local Date from a `YYYY-MM-DD` key. */
|
|
355
|
-
function dateOfKey(key) {
|
|
356
|
-
const parts = String(key).split('-').map(Number);
|
|
357
|
-
return new Date(parts[0], parts[1] - 1, parts[2]);
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
/** `YYYY-MM-DD` from a full year, a 0-based month, and a day of month. */
|
|
361
|
-
function keyOfDate(year, monthIndex, day) {
|
|
362
|
-
return year + '-' + String(monthIndex + 1).padStart(2, '0') + '-' + String(day).padStart(2, '0');
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
/** Day cells of one month, Monday first; nulls pad the leading week. */
|
|
366
|
-
function monthCells(year, monthIndex) {
|
|
367
|
-
const offset = (new Date(year, monthIndex, 1).getDay() + 6) % 7;
|
|
368
|
-
const total = new Date(year, monthIndex + 1, 0).getDate();
|
|
369
|
-
const cells = [];
|
|
370
|
-
for (let index = 0; index < offset; index += 1) cells.push(null);
|
|
371
|
-
for (let day = 1; day <= total; day += 1) cells.push(day);
|
|
372
|
-
return cells;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
/** Narrow weekday labels in the user's locale, Monday first (2024-01-01 was a Monday). */
|
|
376
|
-
const WEEKDAY_LABELS = (() => {
|
|
377
|
-
const format = new Intl.DateTimeFormat(undefined, { weekday: 'narrow' });
|
|
378
|
-
return Array.from({ length: 7 }, (_, index) => format.format(new Date(2024, 0, 1 + index)));
|
|
379
|
-
})();
|
|
380
|
-
|
|
381
|
-
/**
|
|
382
|
-
* Fixed-position coordinates for the calendar panel anchored to a control,
|
|
383
|
-
* flipped above it when there is not enough room below.
|
|
384
|
-
*/
|
|
385
|
-
function panelPositionFor(rect) {
|
|
386
|
-
const width = 252;
|
|
387
|
-
const height = 330;
|
|
388
|
-
const left = Math.max(8, Math.min(rect.right - width, window.innerWidth - width - 8));
|
|
389
|
-
const top =
|
|
390
|
-
rect.bottom + 6 + height > window.innerHeight - 8 ? Math.max(8, rect.top - height - 6) : rect.bottom + 6;
|
|
391
|
-
return { left, top };
|
|
392
|
-
}
|
|
452
|
+
const onKeyDown = (event) => {
|
|
453
|
+
if (event.key === 'Escape') dismiss();
|
|
454
|
+
};
|
|
455
|
+
document.addEventListener('mousedown', onPointerDown, true);
|
|
456
|
+
document.addEventListener('keydown', onKeyDown, true);
|
|
457
|
+
return () => {
|
|
458
|
+
document.removeEventListener('mousedown', onPointerDown, true);
|
|
459
|
+
document.removeEventListener('keydown', onKeyDown, true);
|
|
460
|
+
};
|
|
461
|
+
}, [dismiss, anchor]);
|
|
393
462
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
*/
|
|
398
|
-
function DatePickerPanel(props) {
|
|
399
|
-
const t = props.t;
|
|
400
|
-
const value = props.value;
|
|
401
|
-
const anchor = props.anchor;
|
|
402
|
-
const panelRef = useRef(null);
|
|
403
|
-
const [view, setView] = useState(() => {
|
|
404
|
-
const base = value !== '' ? dateOfKey(value) : new Date();
|
|
463
|
+
const shift = (delta) => {
|
|
464
|
+
setView((current) => {
|
|
465
|
+
const base = new Date(current.year, current.month + delta, 1);
|
|
405
466
|
return { year: base.getFullYear(), month: base.getMonth() };
|
|
406
467
|
});
|
|
468
|
+
};
|
|
407
469
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
const target = event.target;
|
|
414
|
-
if (target instanceof Element) {
|
|
415
|
-
const anchorElement = target.closest('[data-ez-date-anchor]');
|
|
416
|
-
// Its own anchor toggles the panel closed via click, so leave it alone;
|
|
417
|
-
// any other anchor dismisses this panel and opens its own.
|
|
418
|
-
if (anchorElement !== null && anchorElement.getAttribute('data-ez-date-anchor') === anchor) return;
|
|
419
|
-
}
|
|
420
|
-
dismiss();
|
|
421
|
-
};
|
|
422
|
-
const onKeyDown = (event) => {
|
|
423
|
-
if (event.key === 'Escape') dismiss();
|
|
424
|
-
};
|
|
425
|
-
document.addEventListener('mousedown', onPointerDown, true);
|
|
426
|
-
document.addEventListener('keydown', onKeyDown, true);
|
|
427
|
-
return () => {
|
|
428
|
-
document.removeEventListener('mousedown', onPointerDown, true);
|
|
429
|
-
document.removeEventListener('keydown', onKeyDown, true);
|
|
430
|
-
};
|
|
431
|
-
}, [dismiss, anchor]);
|
|
432
|
-
|
|
433
|
-
const shift = (delta) => {
|
|
434
|
-
setView((current) => {
|
|
435
|
-
const base = new Date(current.year, current.month + delta, 1);
|
|
436
|
-
return { year: base.getFullYear(), month: base.getMonth() };
|
|
437
|
-
});
|
|
438
|
-
};
|
|
439
|
-
|
|
440
|
-
const today = todayKey();
|
|
441
|
-
const cells = monthCells(view.year, view.month);
|
|
442
|
-
const monthLabel = new Intl.DateTimeFormat(undefined, { year: 'numeric', month: 'long' }).format(
|
|
443
|
-
new Date(view.year, view.month, 1),
|
|
444
|
-
);
|
|
470
|
+
const today = todayKey();
|
|
471
|
+
const cells = monthCells(view.year, view.month);
|
|
472
|
+
const monthLabel = new Intl.DateTimeFormat(undefined, { year: 'numeric', month: 'long' }).format(
|
|
473
|
+
new Date(view.year, view.month, 1),
|
|
474
|
+
);
|
|
445
475
|
|
|
446
|
-
|
|
476
|
+
return h(
|
|
477
|
+
'div',
|
|
478
|
+
{ className: 'ez-picker', ref: panelRef, style: props.style, role: 'dialog', 'aria-label': t('picker.due') },
|
|
479
|
+
h(
|
|
447
480
|
'div',
|
|
448
|
-
{ className: 'ez-picker
|
|
481
|
+
{ className: 'ez-picker-head' },
|
|
449
482
|
h(
|
|
450
|
-
'
|
|
451
|
-
{
|
|
452
|
-
|
|
453
|
-
'
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
483
|
+
'button',
|
|
484
|
+
{
|
|
485
|
+
type: 'button',
|
|
486
|
+
className: 'ez-picker-nav',
|
|
487
|
+
title: t('picker.prev'),
|
|
488
|
+
'aria-label': t('picker.prev'),
|
|
489
|
+
onClick: () => shift(-1),
|
|
490
|
+
},
|
|
491
|
+
'‹',
|
|
492
|
+
),
|
|
493
|
+
h('span', { className: 'ez-picker-title' }, monthLabel),
|
|
494
|
+
h(
|
|
495
|
+
'button',
|
|
496
|
+
{
|
|
497
|
+
type: 'button',
|
|
498
|
+
className: 'ez-picker-nav',
|
|
499
|
+
title: t('picker.next'),
|
|
500
|
+
'aria-label': t('picker.next'),
|
|
501
|
+
onClick: () => shift(1),
|
|
502
|
+
},
|
|
503
|
+
'›',
|
|
504
|
+
),
|
|
505
|
+
),
|
|
506
|
+
h(
|
|
507
|
+
'div',
|
|
508
|
+
{ className: 'ez-picker-grid ez-picker-grid--wd' },
|
|
509
|
+
WEEKDAY_LABELS.map((label, index) => h('span', { key: 'wd-' + index, className: 'ez-picker-wd' }, label)),
|
|
510
|
+
),
|
|
511
|
+
h(
|
|
512
|
+
'div',
|
|
513
|
+
{ className: 'ez-picker-grid' },
|
|
514
|
+
cells.map((day, index) => {
|
|
515
|
+
if (day === null) return h('span', { key: 'pad-' + index, className: 'ez-picker-cell' });
|
|
516
|
+
const key = keyOfDate(view.year, view.month, day);
|
|
517
|
+
const selected = key === value;
|
|
518
|
+
return h(
|
|
465
519
|
'button',
|
|
466
520
|
{
|
|
521
|
+
key,
|
|
467
522
|
type: 'button',
|
|
468
|
-
className:
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
523
|
+
className:
|
|
524
|
+
'ez-picker-day' + (selected ? ' is-selected' : '') + (key === today ? ' is-today' : ''),
|
|
525
|
+
title: t('picker.hint'),
|
|
526
|
+
'aria-label': key,
|
|
527
|
+
'aria-pressed': selected,
|
|
528
|
+
onClick: () => props.onPick(key),
|
|
529
|
+
onDoubleClick: () => props.onCommit(key),
|
|
472
530
|
},
|
|
473
|
-
|
|
474
|
-
)
|
|
475
|
-
),
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
),
|
|
531
|
+
String(day),
|
|
532
|
+
);
|
|
533
|
+
}),
|
|
534
|
+
),
|
|
535
|
+
h(
|
|
536
|
+
'div',
|
|
537
|
+
{ className: 'ez-picker-foot' },
|
|
481
538
|
h(
|
|
482
|
-
'
|
|
483
|
-
{ className: 'ez-picker-
|
|
484
|
-
|
|
485
|
-
if (day === null) return h('span', { key: 'pad-' + index, className: 'ez-picker-cell' });
|
|
486
|
-
const key = keyOfDate(view.year, view.month, day);
|
|
487
|
-
const selected = key === value;
|
|
488
|
-
return h(
|
|
489
|
-
'button',
|
|
490
|
-
{
|
|
491
|
-
key,
|
|
492
|
-
type: 'button',
|
|
493
|
-
className:
|
|
494
|
-
'ez-picker-day' + (selected ? ' is-selected' : '') + (key === today ? ' is-today' : ''),
|
|
495
|
-
title: t('picker.hint'),
|
|
496
|
-
'aria-label': key,
|
|
497
|
-
'aria-pressed': selected,
|
|
498
|
-
onClick: () => props.onPick(key),
|
|
499
|
-
onDoubleClick: () => props.onCommit(key),
|
|
500
|
-
},
|
|
501
|
-
String(day),
|
|
502
|
-
);
|
|
503
|
-
}),
|
|
539
|
+
'button',
|
|
540
|
+
{ type: 'button', className: 'ez-picker-link', disabled: value === '', onClick: props.onClear },
|
|
541
|
+
t('picker.clear'),
|
|
504
542
|
),
|
|
505
543
|
h(
|
|
506
|
-
'
|
|
507
|
-
{
|
|
508
|
-
|
|
509
|
-
'
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
'button',
|
|
515
|
-
{
|
|
516
|
-
type: 'button',
|
|
517
|
-
className: 'ez-picker-link',
|
|
518
|
-
onClick: () => {
|
|
519
|
-
const now = new Date();
|
|
520
|
-
setView({ year: now.getFullYear(), month: now.getMonth() });
|
|
521
|
-
props.onPick(today);
|
|
522
|
-
},
|
|
544
|
+
'button',
|
|
545
|
+
{
|
|
546
|
+
type: 'button',
|
|
547
|
+
className: 'ez-picker-link',
|
|
548
|
+
onClick: () => {
|
|
549
|
+
const now = new Date();
|
|
550
|
+
setView({ year: now.getFullYear(), month: now.getMonth() });
|
|
551
|
+
props.onPick(today);
|
|
523
552
|
},
|
|
524
|
-
|
|
525
|
-
),
|
|
553
|
+
},
|
|
554
|
+
t('picker.today'),
|
|
526
555
|
),
|
|
527
|
-
)
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
},
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
)
|
|
556
|
+
),
|
|
557
|
+
);
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/** Sidebar glyph: a 2×2 matrix with one filled cell. */
|
|
561
|
+
function PanelIcon(props) {
|
|
562
|
+
const edge = typeof props.size === 'number' ? props.size : 16;
|
|
563
|
+
return h(
|
|
564
|
+
'svg',
|
|
565
|
+
{
|
|
566
|
+
width: edge,
|
|
567
|
+
height: edge,
|
|
568
|
+
viewBox: '0 0 16 16',
|
|
569
|
+
fill: 'none',
|
|
570
|
+
'aria-hidden': 'true',
|
|
571
|
+
focusable: 'false',
|
|
572
|
+
style: { display: 'block' },
|
|
573
|
+
},
|
|
574
|
+
h('rect', { x: 2.1, y: 2.1, width: 5, height: 5, rx: 1.2, fill: 'currentColor' }),
|
|
575
|
+
h('rect', { x: 8.9, y: 2.1, width: 5, height: 5, rx: 1.2, stroke: 'currentColor', strokeWidth: 1.1 }),
|
|
576
|
+
h('rect', { x: 2.1, y: 8.9, width: 5, height: 5, rx: 1.2, stroke: 'currentColor', strokeWidth: 1.1 }),
|
|
577
|
+
h('rect', { x: 8.9, y: 8.9, width: 5, height: 5, rx: 1.2, stroke: 'currentColor', strokeWidth: 1.1 }),
|
|
578
|
+
);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
/** Small inline glyph factory: stroked `paths` in `currentColor`. */
|
|
582
|
+
function glyph(paths, size) {
|
|
583
|
+
const edge = size ?? 14;
|
|
584
|
+
return h(
|
|
585
|
+
'svg',
|
|
586
|
+
{
|
|
587
|
+
width: edge,
|
|
588
|
+
height: edge,
|
|
589
|
+
viewBox: '0 0 16 16',
|
|
590
|
+
fill: 'none',
|
|
591
|
+
stroke: 'currentColor',
|
|
592
|
+
strokeWidth: 1.3,
|
|
593
|
+
strokeLinecap: 'round',
|
|
594
|
+
strokeLinejoin: 'round',
|
|
595
|
+
'aria-hidden': 'true',
|
|
596
|
+
focusable: 'false',
|
|
597
|
+
style: { display: 'block' },
|
|
598
|
+
},
|
|
599
|
+
paths.map((d, index) => h('path', { key: String(index), d: d })),
|
|
600
|
+
);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
const FlagGlyph = () =>
|
|
604
|
+
h(
|
|
605
|
+
'svg',
|
|
606
|
+
{
|
|
607
|
+
width: 14,
|
|
608
|
+
height: 14,
|
|
609
|
+
viewBox: '0 0 16 16',
|
|
610
|
+
fill: 'none',
|
|
611
|
+
stroke: 'currentColor',
|
|
612
|
+
strokeWidth: 1.3,
|
|
613
|
+
strokeLinecap: 'round',
|
|
614
|
+
strokeLinejoin: 'round',
|
|
615
|
+
'aria-hidden': 'true',
|
|
616
|
+
focusable: 'false',
|
|
617
|
+
style: { display: 'block' },
|
|
618
|
+
},
|
|
619
|
+
h('path', { d: 'M4.4 13.6V2.6' }),
|
|
620
|
+
h('path', { d: 'M4.4 3.2h6.1l-1.2 2.2 1.2 2.2H4.4' }),
|
|
621
|
+
);
|
|
622
|
+
|
|
623
|
+
const BoltGlyph = () =>
|
|
624
|
+
h(
|
|
625
|
+
'svg',
|
|
626
|
+
{
|
|
627
|
+
width: 14,
|
|
628
|
+
height: 14,
|
|
629
|
+
viewBox: '0 0 16 16',
|
|
630
|
+
fill: 'none',
|
|
631
|
+
stroke: 'currentColor',
|
|
632
|
+
strokeWidth: 1.3,
|
|
633
|
+
strokeLinecap: 'round',
|
|
634
|
+
strokeLinejoin: 'round',
|
|
635
|
+
'aria-hidden': 'true',
|
|
636
|
+
focusable: 'false',
|
|
637
|
+
style: { display: 'block' },
|
|
638
|
+
},
|
|
639
|
+
h('path', { d: 'M8.9 1.8 3.6 9h3.6l-1 5.2L11.4 7H7.8Z' }),
|
|
640
|
+
);
|
|
641
|
+
|
|
642
|
+
const CloseGlyph = () => glyph(['M4.2 4.2l7.6 7.6', 'M11.8 4.2l-7.6 7.6'], 13);
|
|
643
|
+
|
|
644
|
+
const RestoreGlyph = () => glyph(['M3.2 6.2h4V2.6', 'M3.4 10.6a5.2 5.2 0 1 0 .6-6.2'], 13);
|
|
645
|
+
|
|
646
|
+
const CalendarGlyph = ({ size = 13 } = {}) =>
|
|
647
|
+
h(
|
|
648
|
+
'svg',
|
|
649
|
+
{
|
|
650
|
+
width: size,
|
|
651
|
+
height: size,
|
|
652
|
+
viewBox: '0 0 16 16',
|
|
653
|
+
fill: 'none',
|
|
654
|
+
stroke: 'currentColor',
|
|
655
|
+
strokeWidth: 1.3,
|
|
656
|
+
strokeLinecap: 'round',
|
|
657
|
+
'aria-hidden': 'true',
|
|
658
|
+
focusable: 'false',
|
|
659
|
+
style: { display: 'block' },
|
|
660
|
+
},
|
|
661
|
+
h('rect', { x: 2.4, y: 3.4, width: 11.2, height: 10.2, rx: 1.8 }),
|
|
662
|
+
h('path', { d: 'M2.4 6.6h11.2M5.6 1.9v3M10.4 1.9v3' }),
|
|
663
|
+
);
|
|
664
|
+
|
|
665
|
+
const GearGlyph = () =>
|
|
666
|
+
h(
|
|
667
|
+
'svg',
|
|
668
|
+
{
|
|
669
|
+
width: 15,
|
|
670
|
+
height: 15,
|
|
671
|
+
viewBox: '0 0 16 16',
|
|
672
|
+
fill: 'none',
|
|
673
|
+
stroke: 'currentColor',
|
|
674
|
+
strokeWidth: 1.25,
|
|
675
|
+
strokeLinecap: 'round',
|
|
676
|
+
'aria-hidden': 'true',
|
|
677
|
+
focusable: 'false',
|
|
678
|
+
style: { display: 'block' },
|
|
679
|
+
},
|
|
680
|
+
h('circle', { cx: 8, cy: 8, r: 2.1 }),
|
|
681
|
+
h('path', { d: 'M8 1.9v1.5M8 12.6v1.5M1.9 8h1.5M12.6 8h1.5M3.7 3.7l1.1 1.1M11.2 11.2l1.1 1.1M12.3 3.7l-1.1 1.1M4.8 11.2l-1.1 1.1' }),
|
|
682
|
+
);
|
|
683
|
+
|
|
684
|
+
/** Feedback glyph for the settings footer. */
|
|
685
|
+
const ChatGlyph = () =>
|
|
686
|
+
glyph(['M13.2 8c0 2.5-2.3 4.5-5.2 4.5-.7 0-1.3-.1-1.9-.3l-2.9 1 .9-2.4c-.7-.7-1.2-1.7-1.2-2.8 0-2.5 2.3-4.5 5.1-4.5s5.2 2 5.2 4.5Z'], 13);
|
|
687
|
+
|
|
688
|
+
/** A small icon button used for per-row and header actions. */
|
|
689
|
+
function MiniButton(props) {
|
|
690
|
+
const attrs = {
|
|
691
|
+
type: 'button',
|
|
692
|
+
className: props.active ? 'ez-mini is-on' : 'ez-mini',
|
|
693
|
+
title: props.label,
|
|
694
|
+
'aria-label': props.label,
|
|
695
|
+
onClick: props.onClick,
|
|
696
|
+
};
|
|
697
|
+
// Opening the shared calendar reports itself so the panel can tell a click
|
|
698
|
+
// on its own anchor from a click elsewhere.
|
|
699
|
+
if (props.anchor !== undefined) {
|
|
700
|
+
attrs['data-ez-date-anchor'] = props.anchor;
|
|
701
|
+
attrs['aria-haspopup'] = 'dialog';
|
|
702
|
+
attrs['aria-expanded'] = props.expanded === true;
|
|
549
703
|
}
|
|
704
|
+
return h('button', attrs, props.children);
|
|
705
|
+
}
|
|
550
706
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
'svg',
|
|
556
|
-
{
|
|
557
|
-
width: edge,
|
|
558
|
-
height: edge,
|
|
559
|
-
viewBox: '0 0 16 16',
|
|
560
|
-
fill: 'none',
|
|
561
|
-
stroke: 'currentColor',
|
|
562
|
-
strokeWidth: 1.3,
|
|
563
|
-
strokeLinecap: 'round',
|
|
564
|
-
strokeLinejoin: 'round',
|
|
565
|
-
'aria-hidden': 'true',
|
|
566
|
-
focusable: 'false',
|
|
567
|
-
style: { display: 'block' },
|
|
568
|
-
},
|
|
569
|
-
paths.map((d, index) => h('path', { key: String(index), d: d })),
|
|
570
|
-
);
|
|
571
|
-
}
|
|
707
|
+
/** The settings panel: axis side, frame style, cell fill, radius, font size. */
|
|
708
|
+
function SettingsPanel(props) {
|
|
709
|
+
const t = props.t;
|
|
710
|
+
const settings = props.settings;
|
|
572
711
|
|
|
573
|
-
const
|
|
712
|
+
const row = (label, control, trailing) =>
|
|
574
713
|
h(
|
|
575
|
-
'
|
|
576
|
-
{
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
fill: 'none',
|
|
581
|
-
stroke: 'currentColor',
|
|
582
|
-
strokeWidth: 1.3,
|
|
583
|
-
strokeLinecap: 'round',
|
|
584
|
-
strokeLinejoin: 'round',
|
|
585
|
-
'aria-hidden': 'true',
|
|
586
|
-
focusable: 'false',
|
|
587
|
-
style: { display: 'block' },
|
|
588
|
-
},
|
|
589
|
-
h('path', { d: 'M4.4 13.6V2.6' }),
|
|
590
|
-
h('path', { d: 'M4.4 3.2h6.1l-1.2 2.2 1.2 2.2H4.4' }),
|
|
714
|
+
'div',
|
|
715
|
+
{ className: 'ez-set-row' },
|
|
716
|
+
h('span', { className: 'ez-set-label' }, label),
|
|
717
|
+
control,
|
|
718
|
+
trailing === undefined ? null : trailing,
|
|
591
719
|
);
|
|
592
720
|
|
|
593
|
-
const
|
|
721
|
+
const seg = (options, current, onPick) =>
|
|
594
722
|
h(
|
|
595
|
-
'
|
|
596
|
-
{
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
723
|
+
'div',
|
|
724
|
+
{ className: 'ez-seg ez-seg--sm', role: 'group' },
|
|
725
|
+
options.map((option) =>
|
|
726
|
+
h(
|
|
727
|
+
'button',
|
|
728
|
+
{
|
|
729
|
+
key: option[0],
|
|
730
|
+
type: 'button',
|
|
731
|
+
className: option[0] === current ? 'ez-seg-btn is-active' : 'ez-seg-btn',
|
|
732
|
+
'aria-pressed': option[0] === current,
|
|
733
|
+
onClick: () => onPick(option[0]),
|
|
734
|
+
},
|
|
735
|
+
option[1],
|
|
736
|
+
),
|
|
737
|
+
),
|
|
610
738
|
);
|
|
611
739
|
|
|
612
|
-
const
|
|
613
|
-
|
|
614
|
-
const RestoreGlyph = () => glyph(['M3.2 6.2h4V2.6', 'M3.4 10.6a5.2 5.2 0 1 0 .6-6.2'], 13);
|
|
615
|
-
|
|
616
|
-
const CalendarGlyph = ({ size = 13 } = {}) =>
|
|
740
|
+
const slider = (label, value, min, max, step, onInput) =>
|
|
617
741
|
h(
|
|
618
|
-
'
|
|
619
|
-
{
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
'aria-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
},
|
|
631
|
-
h('rect', { x: 2.4, y: 3.4, width: 11.2, height: 10.2, rx: 1.8 }),
|
|
632
|
-
h('path', { d: 'M2.4 6.6h11.2M5.6 1.9v3M10.4 1.9v3' }),
|
|
742
|
+
'div',
|
|
743
|
+
{ className: 'ez-set-slider' },
|
|
744
|
+
h('input', {
|
|
745
|
+
className: 'ez-range',
|
|
746
|
+
type: 'range',
|
|
747
|
+
min,
|
|
748
|
+
max,
|
|
749
|
+
step,
|
|
750
|
+
value,
|
|
751
|
+
'aria-label': label,
|
|
752
|
+
onChange: (event) => onInput(Number(event.target.value)),
|
|
753
|
+
}),
|
|
754
|
+
h('span', { className: 'ez-set-value' }, value + ' px'),
|
|
633
755
|
);
|
|
634
756
|
|
|
635
|
-
|
|
757
|
+
/**
|
|
758
|
+
* An external link with a glyph. The desktop shell turns a target="_blank"
|
|
759
|
+
* https link into a browser open, so the page itself never navigates away.
|
|
760
|
+
*/
|
|
761
|
+
const aboutLink = (href, Glyph, label, extraClass) =>
|
|
636
762
|
h(
|
|
637
|
-
'
|
|
763
|
+
'a',
|
|
638
764
|
{
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
strokeLinecap: 'round',
|
|
646
|
-
'aria-hidden': 'true',
|
|
647
|
-
focusable: 'false',
|
|
648
|
-
style: { display: 'block' },
|
|
765
|
+
className: extraClass ? 'ez-about-link ' + extraClass : 'ez-about-link',
|
|
766
|
+
href,
|
|
767
|
+
target: '_blank',
|
|
768
|
+
rel: 'noreferrer noopener',
|
|
769
|
+
title: label + ' · ' + href,
|
|
770
|
+
'aria-label': label + ' · ' + href,
|
|
649
771
|
},
|
|
650
|
-
h(
|
|
651
|
-
|
|
772
|
+
h(Glyph),
|
|
773
|
+
label,
|
|
652
774
|
);
|
|
653
775
|
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
};
|
|
667
|
-
// Opening the shared calendar reports itself so the panel can tell a click
|
|
668
|
-
// on its own anchor from a click elsewhere.
|
|
669
|
-
if (props.anchor !== undefined) {
|
|
670
|
-
attrs['data-ez-date-anchor'] = props.anchor;
|
|
671
|
-
attrs['aria-haspopup'] = 'dialog';
|
|
672
|
-
attrs['aria-expanded'] = props.expanded === true;
|
|
673
|
-
}
|
|
674
|
-
return h('button', attrs, props.children);
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
/** The settings panel: axis side, frame style, cell fill, radius, font size. */
|
|
678
|
-
function SettingsPanel(props) {
|
|
679
|
-
const t = props.t;
|
|
680
|
-
const settings = props.settings;
|
|
681
|
-
|
|
682
|
-
const row = (label, control, trailing) =>
|
|
683
|
-
h(
|
|
684
|
-
'div',
|
|
685
|
-
{ className: 'ez-set-row' },
|
|
686
|
-
h('span', { className: 'ez-set-label' }, label),
|
|
687
|
-
control,
|
|
688
|
-
trailing === undefined ? null : trailing,
|
|
689
|
-
);
|
|
690
|
-
|
|
691
|
-
const seg = (options, current, onPick) =>
|
|
692
|
-
h(
|
|
693
|
-
'div',
|
|
694
|
-
{ className: 'ez-seg ez-seg--sm', role: 'group' },
|
|
695
|
-
options.map((option) =>
|
|
696
|
-
h(
|
|
697
|
-
'button',
|
|
698
|
-
{
|
|
699
|
-
key: option[0],
|
|
700
|
-
type: 'button',
|
|
701
|
-
className: option[0] === current ? 'ez-seg-btn is-active' : 'ez-seg-btn',
|
|
702
|
-
'aria-pressed': option[0] === current,
|
|
703
|
-
onClick: () => onPick(option[0]),
|
|
704
|
-
},
|
|
705
|
-
option[1],
|
|
706
|
-
),
|
|
707
|
-
),
|
|
708
|
-
);
|
|
709
|
-
|
|
710
|
-
const slider = (label, value, min, max, step, onInput) =>
|
|
711
|
-
h(
|
|
712
|
-
'div',
|
|
713
|
-
{ className: 'ez-set-slider' },
|
|
714
|
-
h('input', {
|
|
715
|
-
className: 'ez-range',
|
|
716
|
-
type: 'range',
|
|
717
|
-
min,
|
|
718
|
-
max,
|
|
719
|
-
step,
|
|
720
|
-
value,
|
|
721
|
-
'aria-label': label,
|
|
722
|
-
onChange: (event) => onInput(Number(event.target.value)),
|
|
723
|
-
}),
|
|
724
|
-
h('span', { className: 'ez-set-value' }, value + ' px'),
|
|
725
|
-
);
|
|
726
|
-
|
|
727
|
-
/**
|
|
728
|
-
* An external link with a glyph. The desktop shell turns a target="_blank"
|
|
729
|
-
* https link into a browser open, so the page itself never navigates away.
|
|
730
|
-
*/
|
|
731
|
-
const aboutLink = (href, Glyph, label, extraClass) =>
|
|
732
|
-
h(
|
|
733
|
-
'a',
|
|
734
|
-
{
|
|
735
|
-
className: extraClass ? 'ez-about-link ' + extraClass : 'ez-about-link',
|
|
736
|
-
href,
|
|
737
|
-
target: '_blank',
|
|
738
|
-
rel: 'noreferrer noopener',
|
|
739
|
-
title: label + ' · ' + href,
|
|
740
|
-
'aria-label': label + ' · ' + href,
|
|
741
|
-
},
|
|
742
|
-
h(Glyph),
|
|
743
|
-
label,
|
|
744
|
-
);
|
|
745
|
-
|
|
746
|
-
return h(
|
|
747
|
-
'div',
|
|
748
|
-
{ className: 'ez-settings', id: 'ez-settings-panel' },
|
|
749
|
-
row(
|
|
750
|
-
t('settings.axis'),
|
|
751
|
-
seg(
|
|
752
|
-
[
|
|
753
|
-
['left', t('settings.axis.left')],
|
|
754
|
-
['right', t('settings.axis.right')],
|
|
755
|
-
],
|
|
756
|
-
settings.urgentSide,
|
|
757
|
-
(value) => props.onPatch({ urgentSide: value }),
|
|
758
|
-
),
|
|
759
|
-
),
|
|
760
|
-
row(
|
|
761
|
-
t('settings.frame'),
|
|
762
|
-
seg(
|
|
763
|
-
[
|
|
764
|
-
['cards', t('settings.frame.cards')],
|
|
765
|
-
['grid', t('settings.frame.grid')],
|
|
766
|
-
['cross', t('settings.frame.cross')],
|
|
767
|
-
],
|
|
768
|
-
settings.frame,
|
|
769
|
-
(value) => props.onPatch({ frame: value }),
|
|
770
|
-
),
|
|
771
|
-
),
|
|
772
|
-
row(
|
|
773
|
-
t('settings.tint'),
|
|
774
|
-
seg(
|
|
775
|
-
[
|
|
776
|
-
['plain', t('settings.tint.plain')],
|
|
777
|
-
['soft', t('settings.tint.soft')],
|
|
778
|
-
],
|
|
779
|
-
settings.tint,
|
|
780
|
-
(value) => props.onPatch({ tint: value }),
|
|
781
|
-
),
|
|
776
|
+
return h(
|
|
777
|
+
'div',
|
|
778
|
+
{ className: 'ez-settings', id: 'ez-settings-panel' },
|
|
779
|
+
row(
|
|
780
|
+
t('settings.axis'),
|
|
781
|
+
seg(
|
|
782
|
+
[
|
|
783
|
+
['left', t('settings.axis.left')],
|
|
784
|
+
['right', t('settings.axis.right')],
|
|
785
|
+
],
|
|
786
|
+
settings.urgentSide,
|
|
787
|
+
(value) => props.onPatch({ urgentSide: value }),
|
|
782
788
|
),
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
],
|
|
790
|
-
settings.
|
|
791
|
-
|
|
792
|
-
|
|
789
|
+
),
|
|
790
|
+
row(
|
|
791
|
+
t('settings.frame'),
|
|
792
|
+
seg(
|
|
793
|
+
[
|
|
794
|
+
['cards', t('settings.frame.cards')],
|
|
795
|
+
['grid', t('settings.frame.grid')],
|
|
796
|
+
['cross', t('settings.frame.cross')],
|
|
797
|
+
],
|
|
798
|
+
settings.frame,
|
|
799
|
+
(value) => props.onPatch({ frame: value }),
|
|
793
800
|
),
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
],
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
),
|
|
801
|
+
),
|
|
802
|
+
row(
|
|
803
|
+
t('settings.tint'),
|
|
804
|
+
seg(
|
|
805
|
+
[
|
|
806
|
+
['plain', t('settings.tint.plain')],
|
|
807
|
+
['soft', t('settings.tint.soft')],
|
|
808
|
+
],
|
|
809
|
+
settings.tint,
|
|
810
|
+
(value) => props.onPatch({ tint: value }),
|
|
804
811
|
),
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
}),
|
|
812
|
+
),
|
|
813
|
+
row(
|
|
814
|
+
t('settings.dueFormat'),
|
|
815
|
+
seg(
|
|
816
|
+
[
|
|
817
|
+
['date', t('settings.dueFormat.date')],
|
|
818
|
+
['countdown', t('settings.dueFormat.countdown')],
|
|
819
|
+
],
|
|
820
|
+
settings.dueFormat,
|
|
821
|
+
(value) => props.onPatch({ dueFormat: value }),
|
|
816
822
|
),
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
823
|
+
),
|
|
824
|
+
row(
|
|
825
|
+
t('settings.titleStyle'),
|
|
826
|
+
seg(
|
|
827
|
+
[
|
|
828
|
+
['wrap', t('settings.titleStyle.wrap')],
|
|
829
|
+
['truncate', t('settings.titleStyle.truncate')],
|
|
830
|
+
],
|
|
831
|
+
settings.titleStyle,
|
|
832
|
+
(value) => props.onPatch({ titleStyle: value }),
|
|
820
833
|
),
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
834
|
+
),
|
|
835
|
+
row(
|
|
836
|
+
t('settings.navLabel'),
|
|
837
|
+
h('input', {
|
|
838
|
+
className: 'ez-text-field',
|
|
839
|
+
type: 'text',
|
|
840
|
+
value: settings.navLabel,
|
|
841
|
+
maxLength: 24,
|
|
842
|
+
placeholder: t('settings.navLabel.placeholder'),
|
|
843
|
+
'aria-label': t('settings.navLabel'),
|
|
844
|
+
onChange: (event) => props.onPatch({ navLabel: event.target.value }),
|
|
845
|
+
}),
|
|
846
|
+
),
|
|
847
|
+
row(
|
|
848
|
+
t('settings.radius'),
|
|
849
|
+
slider(t('settings.radius'), settings.radius, 0, 24, 2, (value) => props.onPatch({ radius: value })),
|
|
850
|
+
),
|
|
851
|
+
row(
|
|
852
|
+
t('settings.fontSize'),
|
|
853
|
+
slider(t('settings.fontSize'), settings.fontSize, 11, 17, 1, (value) => props.onPatch({ fontSize: value })),
|
|
854
|
+
h(
|
|
855
|
+
'button',
|
|
856
|
+
{ type: 'button', className: 'ez-reset ez-reset--inline', onClick: props.onReset },
|
|
857
|
+
t('settings.reset'),
|
|
829
858
|
),
|
|
859
|
+
),
|
|
860
|
+
h(
|
|
861
|
+
'footer',
|
|
862
|
+
{ className: 'ez-set-about' },
|
|
863
|
+
aboutLink(ISSUES_URL, ChatGlyph, t('settings.about.issues')),
|
|
830
864
|
h(
|
|
831
|
-
'
|
|
832
|
-
{ className: 'ez-
|
|
833
|
-
|
|
865
|
+
'span',
|
|
866
|
+
{ className: 'ez-about-dev' },
|
|
867
|
+
h('span', { className: 'ez-about-dev-label' }, t('settings.about.developed')),
|
|
868
|
+
h('img', {
|
|
869
|
+
className: 'ez-about-avatar',
|
|
870
|
+
src: 'https://github.com/' + AUTHOR_NAME + '.png?size=32',
|
|
871
|
+
alt: '',
|
|
872
|
+
width: 16,
|
|
873
|
+
height: 16,
|
|
874
|
+
loading: 'lazy',
|
|
875
|
+
draggable: false,
|
|
876
|
+
onError: (event) => {
|
|
877
|
+
event.currentTarget.style.display = 'none';
|
|
878
|
+
},
|
|
879
|
+
}),
|
|
834
880
|
h(
|
|
835
|
-
'
|
|
836
|
-
{
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
draggable: false,
|
|
846
|
-
onError: (event) => {
|
|
847
|
-
event.currentTarget.style.display = 'none';
|
|
848
|
-
},
|
|
849
|
-
}),
|
|
850
|
-
h(
|
|
851
|
-
'a',
|
|
852
|
-
{
|
|
853
|
-
className: 'ez-about-link ez-about-dev-name',
|
|
854
|
-
href: AUTHOR_URL,
|
|
855
|
-
target: '_blank',
|
|
856
|
-
rel: 'noreferrer noopener',
|
|
857
|
-
title: AUTHOR_NAME + ' · ' + AUTHOR_URL,
|
|
858
|
-
'aria-label': AUTHOR_NAME + ' · ' + AUTHOR_URL,
|
|
859
|
-
},
|
|
860
|
-
AUTHOR_NAME,
|
|
861
|
-
),
|
|
881
|
+
'a',
|
|
882
|
+
{
|
|
883
|
+
className: 'ez-about-link ez-about-dev-name',
|
|
884
|
+
href: AUTHOR_URL,
|
|
885
|
+
target: '_blank',
|
|
886
|
+
rel: 'noreferrer noopener',
|
|
887
|
+
title: AUTHOR_NAME + ' · ' + AUTHOR_URL,
|
|
888
|
+
'aria-label': AUTHOR_NAME + ' · ' + AUTHOR_URL,
|
|
889
|
+
},
|
|
890
|
+
AUTHOR_NAME,
|
|
862
891
|
),
|
|
863
892
|
),
|
|
864
|
-
)
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
/** Leave edit mode; `save` false means the gesture was cancelled. */
|
|
896
|
-
const settleEdit = (save) => {
|
|
897
|
-
if (editSettledRef.current) return;
|
|
898
|
-
editSettledRef.current = true;
|
|
899
|
-
setEditing(false);
|
|
900
|
-
const value = draftTitle.trim();
|
|
901
|
-
if (!save || value === '' || value === todo.title) return;
|
|
902
|
-
props.onPatch(todo.id, { title: value });
|
|
903
|
-
};
|
|
904
|
-
// Tooltip lead: the date state when it is meaningful, otherwise the date
|
|
905
|
-
// itself. Falling back to "set due date" here duplicated the action text.
|
|
906
|
-
const dueLabel =
|
|
907
|
-
dueState === 'overdue'
|
|
908
|
-
? t('item.due.overdue')
|
|
909
|
-
: dueState === 'today'
|
|
910
|
-
? t('item.due.today')
|
|
911
|
-
: formatDayKey(todo.dueDate);
|
|
912
|
-
const anchor = 'row-' + todo.id;
|
|
913
|
-
const hasDue = todo.dueDate !== null && todo.dueDate !== undefined;
|
|
914
|
-
|
|
915
|
-
const dismissPicker = useCallback(() => setPickerOpen(false), []);
|
|
916
|
-
|
|
917
|
-
/** Open the shared calendar under the clicked control; a second click closes it. */
|
|
918
|
-
const togglePicker = (event) => {
|
|
919
|
-
if (pickerOpen) {
|
|
920
|
-
setPickerOpen(false);
|
|
921
|
-
return;
|
|
922
|
-
}
|
|
923
|
-
setDraftDue(hasDue ? todo.dueDate : '');
|
|
924
|
-
setPickerPos(panelPositionFor(event.currentTarget.getBoundingClientRect()));
|
|
925
|
-
setPickerOpen(true);
|
|
926
|
-
};
|
|
893
|
+
),
|
|
894
|
+
);
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
/** One open todo row: checkbox, title, due-date mark, hover actions, drag handle. */
|
|
898
|
+
function TodoRow(props) {
|
|
899
|
+
const todo = props.todo;
|
|
900
|
+
const t = props.t;
|
|
901
|
+
const [pickerOpen, setPickerOpen] = useState(false);
|
|
902
|
+
const [pickerPos, setPickerPos] = useState(null);
|
|
903
|
+
const [draftDue, setDraftDue] = useState('');
|
|
904
|
+
const [editing, setEditing] = useState(false);
|
|
905
|
+
const [draftTitle, setDraftTitle] = useState(todo.title);
|
|
906
|
+
const editInputRef = useRef(null);
|
|
907
|
+
// Enter, Escape and blur can all fire for one gesture; settle only once.
|
|
908
|
+
const editSettledRef = useRef(false);
|
|
909
|
+
const dueState = dueStateOf(todo.dueDate);
|
|
910
|
+
|
|
911
|
+
useEffect(() => {
|
|
912
|
+
const input = editInputRef.current;
|
|
913
|
+
if (!editing || input === null) return;
|
|
914
|
+
input.focus();
|
|
915
|
+
const end = input.value.length;
|
|
916
|
+
input.setSelectionRange(end, end);
|
|
917
|
+
}, [editing]);
|
|
918
|
+
|
|
919
|
+
const startEdit = () => {
|
|
920
|
+
editSettledRef.current = false;
|
|
921
|
+
setDraftTitle(todo.title);
|
|
922
|
+
setEditing(true);
|
|
923
|
+
};
|
|
927
924
|
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
925
|
+
/** Leave edit mode; `save` false means the gesture was cancelled. */
|
|
926
|
+
const settleEdit = (save) => {
|
|
927
|
+
if (editSettledRef.current) return;
|
|
928
|
+
editSettledRef.current = true;
|
|
929
|
+
setEditing(false);
|
|
930
|
+
const value = draftTitle.trim();
|
|
931
|
+
if (!save || value === '' || value === todo.title) return;
|
|
932
|
+
props.onPatch(todo.id, { title: value });
|
|
933
|
+
};
|
|
934
|
+
// Tooltip lead: the date state when it is meaningful, otherwise the date
|
|
935
|
+
// itself. Falling back to "set due date" here duplicated the action text.
|
|
936
|
+
const dueLabel =
|
|
937
|
+
dueState === 'overdue'
|
|
938
|
+
? t('item.due.overdue')
|
|
939
|
+
: dueState === 'today'
|
|
940
|
+
? t('item.due.today')
|
|
941
|
+
: formatDayKey(todo.dueDate);
|
|
942
|
+
const anchor = 'row-' + todo.id;
|
|
943
|
+
const hasDue = todo.dueDate !== null && todo.dueDate !== undefined;
|
|
944
|
+
|
|
945
|
+
const dismissPicker = useCallback(() => setPickerOpen(false), []);
|
|
946
|
+
|
|
947
|
+
/** Open the shared calendar under the clicked control; a second click closes it. */
|
|
948
|
+
const togglePicker = (event) => {
|
|
949
|
+
if (pickerOpen) {
|
|
950
|
+
setPickerOpen(false);
|
|
951
|
+
return;
|
|
952
|
+
}
|
|
953
|
+
setDraftDue(hasDue ? todo.dueDate : '');
|
|
954
|
+
setPickerPos(panelPositionFor(event.currentTarget.getBoundingClientRect()));
|
|
955
|
+
setPickerOpen(true);
|
|
956
|
+
};
|
|
933
957
|
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
958
|
+
const className =
|
|
959
|
+
'ez-row' +
|
|
960
|
+
(props.dragging ? ' is-dragging' : '') +
|
|
961
|
+
(props.dropBefore ? ' is-drop-before' : '') +
|
|
962
|
+
(dueState === 'overdue' ? ' is-overdue' : '');
|
|
963
|
+
|
|
964
|
+
return h(
|
|
965
|
+
'li',
|
|
966
|
+
{
|
|
967
|
+
className,
|
|
968
|
+
draggable: !editing,
|
|
969
|
+
'data-todo-id': todo.id,
|
|
970
|
+
title: t('item.drag'),
|
|
971
|
+
onDragStart: (event) => {
|
|
972
|
+
event.dataTransfer.effectAllowed = 'move';
|
|
973
|
+
event.dataTransfer.setData('text/plain', todo.id);
|
|
974
|
+
props.onDragStart(todo.id);
|
|
947
975
|
},
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
onDragStart: (event) => event.preventDefault(),
|
|
978
|
-
})
|
|
979
|
-
: h(
|
|
980
|
-
'span',
|
|
981
|
-
{ className: 'ez-title', title: todo.title + ' · ' + t('item.edit'), onDoubleClick: startEdit },
|
|
982
|
-
todo.title,
|
|
983
|
-
),
|
|
984
|
-
h(
|
|
985
|
-
'div',
|
|
986
|
-
{ className: 'ez-actions' },
|
|
987
|
-
// A due date that exists is edited through its own mark, so the
|
|
988
|
-
// calendar button only appears as the entry point when there is none.
|
|
989
|
-
hasDue
|
|
990
|
-
? null
|
|
991
|
-
: h(
|
|
992
|
-
MiniButton,
|
|
993
|
-
{
|
|
994
|
-
label: t('item.due.set'),
|
|
995
|
-
anchor,
|
|
996
|
-
expanded: pickerOpen,
|
|
997
|
-
onClick: togglePicker,
|
|
998
|
-
},
|
|
999
|
-
h(CalendarGlyph),
|
|
1000
|
-
),
|
|
1001
|
-
h(
|
|
1002
|
-
MiniButton,
|
|
1003
|
-
{
|
|
1004
|
-
active: todo.important === true,
|
|
1005
|
-
label: t('flag.important'),
|
|
1006
|
-
onClick: () => props.onPatch(todo.id, { important: !todo.important }),
|
|
1007
|
-
},
|
|
1008
|
-
h(FlagGlyph),
|
|
1009
|
-
),
|
|
1010
|
-
h(
|
|
1011
|
-
MiniButton,
|
|
1012
|
-
{
|
|
1013
|
-
active: todo.urgent === true,
|
|
1014
|
-
label: t('flag.urgent'),
|
|
1015
|
-
onClick: () => props.onPatch(todo.id, { urgent: !todo.urgent }),
|
|
976
|
+
onDragEnd: () => props.onDragEnd(),
|
|
977
|
+
},
|
|
978
|
+
h('input', {
|
|
979
|
+
className: 'ez-check',
|
|
980
|
+
type: 'checkbox',
|
|
981
|
+
checked: false,
|
|
982
|
+
title: t('item.complete'),
|
|
983
|
+
'aria-label': t('item.complete'),
|
|
984
|
+
onChange: () => props.onToggle(todo.id),
|
|
985
|
+
}),
|
|
986
|
+
editing
|
|
987
|
+
? h('input', {
|
|
988
|
+
className: 'ez-title-input',
|
|
989
|
+
ref: editInputRef,
|
|
990
|
+
type: 'text',
|
|
991
|
+
value: draftTitle,
|
|
992
|
+
maxLength: 200,
|
|
993
|
+
title: t('item.edit'),
|
|
994
|
+
'aria-label': t('item.edit'),
|
|
995
|
+
onChange: (event) => setDraftTitle(event.target.value),
|
|
996
|
+
onKeyDown: (event) => {
|
|
997
|
+
event.stopPropagation();
|
|
998
|
+
if (event.key === 'Enter') {
|
|
999
|
+
event.preventDefault();
|
|
1000
|
+
settleEdit(true);
|
|
1001
|
+
} else if (event.key === 'Escape') {
|
|
1002
|
+
event.preventDefault();
|
|
1003
|
+
settleEdit(false);
|
|
1004
|
+
}
|
|
1016
1005
|
},
|
|
1017
|
-
|
|
1006
|
+
onBlur: () => settleEdit(true),
|
|
1007
|
+
onDragStart: (event) => event.preventDefault(),
|
|
1008
|
+
})
|
|
1009
|
+
: h(
|
|
1010
|
+
'span',
|
|
1011
|
+
{ className: 'ez-title', title: todo.title + ' · ' + t('item.edit'), onDoubleClick: startEdit },
|
|
1012
|
+
todo.title,
|
|
1018
1013
|
),
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
//
|
|
1014
|
+
h(
|
|
1015
|
+
'div',
|
|
1016
|
+
{ className: 'ez-actions' },
|
|
1017
|
+
// A due date that exists is edited through its own mark, so the
|
|
1018
|
+
// calendar button only appears as the entry point when there is none.
|
|
1023
1019
|
hasDue
|
|
1024
|
-
?
|
|
1025
|
-
|
|
1020
|
+
? null
|
|
1021
|
+
: h(
|
|
1022
|
+
MiniButton,
|
|
1026
1023
|
{
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
'aria-label': dueLabel + ' · ' + t('item.due.set'),
|
|
1031
|
-
'data-ez-date-anchor': anchor,
|
|
1032
|
-
'aria-haspopup': 'dialog',
|
|
1033
|
-
'aria-expanded': pickerOpen,
|
|
1024
|
+
label: t('item.due.set'),
|
|
1025
|
+
anchor,
|
|
1026
|
+
expanded: pickerOpen,
|
|
1034
1027
|
onClick: togglePicker,
|
|
1035
|
-
onDoubleClick: () => setPickerOpen(false),
|
|
1036
|
-
},
|
|
1037
|
-
props.dueFormat === 'countdown' ? formatCountdown(todo.dueDate) : formatDayKey(todo.dueDate),
|
|
1038
|
-
)
|
|
1039
|
-
: null,
|
|
1040
|
-
pickerOpen && pickerPos !== null
|
|
1041
|
-
? h(DatePickerPanel, {
|
|
1042
|
-
t,
|
|
1043
|
-
value: draftDue,
|
|
1044
|
-
anchor,
|
|
1045
|
-
style: { left: pickerPos.left + 'px', top: pickerPos.top + 'px' },
|
|
1046
|
-
onPick: setDraftDue,
|
|
1047
|
-
onCommit: (key) => {
|
|
1048
|
-
setPickerOpen(false);
|
|
1049
|
-
props.onDue(todo.id, key);
|
|
1050
|
-
},
|
|
1051
|
-
onClear: () => {
|
|
1052
|
-
setPickerOpen(false);
|
|
1053
|
-
props.onDue(todo.id, null);
|
|
1054
1028
|
},
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
: null,
|
|
1058
|
-
);
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1061
|
-
/** One completed todo row: checked box, struck title, completion day, restore/delete. */
|
|
1062
|
-
function CompletedRow(props) {
|
|
1063
|
-
const todo = props.todo;
|
|
1064
|
-
const t = props.t;
|
|
1065
|
-
return h(
|
|
1066
|
-
'li',
|
|
1067
|
-
{ className: 'ez-row ez-row--done' },
|
|
1068
|
-
h('input', {
|
|
1069
|
-
className: 'ez-check',
|
|
1070
|
-
type: 'checkbox',
|
|
1071
|
-
checked: true,
|
|
1072
|
-
title: t('item.restore'),
|
|
1073
|
-
'aria-label': t('item.restore'),
|
|
1074
|
-
onChange: () => props.onToggle(todo.id),
|
|
1075
|
-
}),
|
|
1076
|
-
h('span', { className: 'ez-title ez-title--done', title: todo.title }, todo.title),
|
|
1077
|
-
h('span', { className: 'ez-date' }, formatDay(todo.completedAt ?? todo.updatedAt)),
|
|
1029
|
+
h(CalendarGlyph),
|
|
1030
|
+
),
|
|
1078
1031
|
h(
|
|
1079
|
-
|
|
1080
|
-
{
|
|
1081
|
-
|
|
1082
|
-
|
|
1032
|
+
MiniButton,
|
|
1033
|
+
{
|
|
1034
|
+
active: todo.important === true,
|
|
1035
|
+
label: t('flag.important'),
|
|
1036
|
+
onClick: () => props.onPatch(todo.id, { important: !todo.important }),
|
|
1037
|
+
},
|
|
1038
|
+
h(FlagGlyph),
|
|
1083
1039
|
),
|
|
1084
|
-
|
|
1085
|
-
|
|
1040
|
+
h(
|
|
1041
|
+
MiniButton,
|
|
1042
|
+
{
|
|
1043
|
+
active: todo.urgent === true,
|
|
1044
|
+
label: t('flag.urgent'),
|
|
1045
|
+
onClick: () => props.onPatch(todo.id, { urgent: !todo.urgent }),
|
|
1046
|
+
},
|
|
1047
|
+
h(BoltGlyph),
|
|
1048
|
+
),
|
|
1049
|
+
h(MiniButton, { label: t('item.delete'), onClick: () => props.onRemove(todo.id) }, h(CloseGlyph)),
|
|
1050
|
+
),
|
|
1051
|
+
// The due mark is the last child so it always sits flush with the row's
|
|
1052
|
+
// right edge, whether or not the hover actions are occupying space.
|
|
1053
|
+
hasDue
|
|
1054
|
+
? h(
|
|
1055
|
+
'button',
|
|
1056
|
+
{
|
|
1057
|
+
type: 'button',
|
|
1058
|
+
className: 'ez-due ez-due--' + dueState,
|
|
1059
|
+
title: dueLabel + ' · ' + t('item.due.set'),
|
|
1060
|
+
'aria-label': dueLabel + ' · ' + t('item.due.set'),
|
|
1061
|
+
'data-ez-date-anchor': anchor,
|
|
1062
|
+
'aria-haspopup': 'dialog',
|
|
1063
|
+
'aria-expanded': pickerOpen,
|
|
1064
|
+
onClick: togglePicker,
|
|
1065
|
+
onDoubleClick: () => setPickerOpen(false),
|
|
1066
|
+
},
|
|
1067
|
+
props.dueFormat === 'countdown' ? formatCountdown(todo.dueDate) : formatDayKey(todo.dueDate),
|
|
1068
|
+
)
|
|
1069
|
+
: null,
|
|
1070
|
+
pickerOpen && pickerPos !== null
|
|
1071
|
+
? h(DatePickerPanel, {
|
|
1072
|
+
t,
|
|
1073
|
+
value: draftDue,
|
|
1074
|
+
anchor,
|
|
1075
|
+
style: { left: pickerPos.left + 'px', top: pickerPos.top + 'px' },
|
|
1076
|
+
onPick: setDraftDue,
|
|
1077
|
+
onCommit: (key) => {
|
|
1078
|
+
setPickerOpen(false);
|
|
1079
|
+
props.onDue(todo.id, key);
|
|
1080
|
+
},
|
|
1081
|
+
onClear: () => {
|
|
1082
|
+
setPickerOpen(false);
|
|
1083
|
+
props.onDue(todo.id, null);
|
|
1084
|
+
},
|
|
1085
|
+
onDismiss: dismissPicker,
|
|
1086
|
+
})
|
|
1087
|
+
: null,
|
|
1088
|
+
);
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
/** One completed todo row: checked box, struck title, completion day, restore/delete. */
|
|
1092
|
+
function CompletedRow(props) {
|
|
1093
|
+
const todo = props.todo;
|
|
1094
|
+
const t = props.t;
|
|
1095
|
+
return h(
|
|
1096
|
+
'li',
|
|
1097
|
+
{ className: 'ez-row ez-row--done' },
|
|
1098
|
+
h('input', {
|
|
1099
|
+
className: 'ez-check',
|
|
1100
|
+
type: 'checkbox',
|
|
1101
|
+
checked: true,
|
|
1102
|
+
title: t('item.restore'),
|
|
1103
|
+
'aria-label': t('item.restore'),
|
|
1104
|
+
onChange: () => props.onToggle(todo.id),
|
|
1105
|
+
}),
|
|
1106
|
+
h('span', { className: 'ez-title ez-title--done', title: todo.title }, todo.title),
|
|
1107
|
+
h('span', { className: 'ez-date' }, formatDay(todo.completedAt ?? todo.updatedAt)),
|
|
1108
|
+
h(
|
|
1109
|
+
'div',
|
|
1110
|
+
{ className: 'ez-actions' },
|
|
1111
|
+
h(MiniButton, { label: t('item.restore'), onClick: () => props.onToggle(todo.id) }, h(RestoreGlyph)),
|
|
1112
|
+
h(MiniButton, { label: t('item.delete'), onClick: () => props.onRemove(todo.id) }, h(CloseGlyph)),
|
|
1113
|
+
),
|
|
1114
|
+
);
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
/** One matrix cell: header, scrollable item list with drop support, and inline add. */
|
|
1118
|
+
function QuadrantCard(props) {
|
|
1119
|
+
const quadrant = props.quadrant;
|
|
1120
|
+
const t = props.t;
|
|
1121
|
+
const items = props.items;
|
|
1122
|
+
const [adding, setAdding] = useState(false);
|
|
1123
|
+
const [draft, setDraft] = useState('');
|
|
1124
|
+
const [draftDue, setDraftDue] = useState('');
|
|
1125
|
+
const [pickerOpen, setPickerOpen] = useState(false);
|
|
1126
|
+
const [pickerPos, setPickerPos] = useState(null);
|
|
1127
|
+
const inputRef = useRef(null);
|
|
1128
|
+
const dateButtonRef = useRef(null);
|
|
1129
|
+
const pendingRef = useRef(false);
|
|
1130
|
+
const pickerOpenRef = useRef(false);
|
|
1131
|
+
|
|
1132
|
+
const name = t('quadrant.' + quadrant.id);
|
|
1133
|
+
|
|
1134
|
+
useEffect(() => {
|
|
1135
|
+
pickerOpenRef.current = pickerOpen;
|
|
1136
|
+
}, [pickerOpen]);
|
|
1137
|
+
|
|
1138
|
+
useEffect(() => {
|
|
1139
|
+
if (adding && inputRef.current !== null) inputRef.current.focus();
|
|
1140
|
+
}, [adding]);
|
|
1141
|
+
|
|
1142
|
+
const start = () => {
|
|
1143
|
+
setDraft('');
|
|
1144
|
+
setDraftDue('');
|
|
1145
|
+
setPickerOpen(false);
|
|
1146
|
+
setAdding(true);
|
|
1147
|
+
};
|
|
1086
1148
|
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
const [draft, setDraft] = useState('');
|
|
1094
|
-
const [draftDue, setDraftDue] = useState('');
|
|
1095
|
-
const [pickerOpen, setPickerOpen] = useState(false);
|
|
1096
|
-
const [pickerPos, setPickerPos] = useState(null);
|
|
1097
|
-
const inputRef = useRef(null);
|
|
1098
|
-
const dateButtonRef = useRef(null);
|
|
1099
|
-
const pendingRef = useRef(false);
|
|
1100
|
-
const pickerOpenRef = useRef(false);
|
|
1101
|
-
|
|
1102
|
-
const name = t('quadrant.' + quadrant.id);
|
|
1103
|
-
|
|
1104
|
-
useEffect(() => {
|
|
1105
|
-
pickerOpenRef.current = pickerOpen;
|
|
1106
|
-
}, [pickerOpen]);
|
|
1107
|
-
|
|
1108
|
-
useEffect(() => {
|
|
1109
|
-
if (adding && inputRef.current !== null) inputRef.current.focus();
|
|
1110
|
-
}, [adding]);
|
|
1111
|
-
|
|
1112
|
-
const start = () => {
|
|
1113
|
-
setDraft('');
|
|
1114
|
-
setDraftDue('');
|
|
1115
|
-
setPickerOpen(false);
|
|
1116
|
-
setAdding(true);
|
|
1117
|
-
};
|
|
1149
|
+
const stop = () => {
|
|
1150
|
+
setAdding(false);
|
|
1151
|
+
setDraft('');
|
|
1152
|
+
setDraftDue('');
|
|
1153
|
+
setPickerOpen(false);
|
|
1154
|
+
};
|
|
1118
1155
|
|
|
1119
|
-
|
|
1120
|
-
|
|
1156
|
+
/**
|
|
1157
|
+
* Create the to-do with an explicit due date (empty string means none).
|
|
1158
|
+
* Guarded by a ref so a fast double Enter or a double-click cannot create
|
|
1159
|
+
* two rows from one draft.
|
|
1160
|
+
*/
|
|
1161
|
+
const submitWithDate = async (dueValue) => {
|
|
1162
|
+
const value = draft.trim();
|
|
1163
|
+
if (value === '' || pendingRef.current) return false;
|
|
1164
|
+
pendingRef.current = true;
|
|
1165
|
+
const ok = await props.onAdd(quadrant, value, dueValue === '' ? null : dueValue);
|
|
1166
|
+
pendingRef.current = false;
|
|
1167
|
+
if (ok) {
|
|
1121
1168
|
setDraft('');
|
|
1122
1169
|
setDraftDue('');
|
|
1123
1170
|
setPickerOpen(false);
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
* Guarded by a ref so a fast double Enter or a double-click cannot create
|
|
1129
|
-
* two rows from one draft.
|
|
1130
|
-
*/
|
|
1131
|
-
const submitWithDate = async (dueValue) => {
|
|
1132
|
-
const value = draft.trim();
|
|
1133
|
-
if (value === '' || pendingRef.current) return false;
|
|
1134
|
-
pendingRef.current = true;
|
|
1135
|
-
const ok = await props.onAdd(quadrant, value, dueValue === '' ? null : dueValue);
|
|
1136
|
-
pendingRef.current = false;
|
|
1137
|
-
if (ok) {
|
|
1138
|
-
setDraft('');
|
|
1139
|
-
setDraftDue('');
|
|
1140
|
-
setPickerOpen(false);
|
|
1141
|
-
if (inputRef.current !== null) inputRef.current.focus();
|
|
1142
|
-
}
|
|
1143
|
-
return ok;
|
|
1144
|
-
};
|
|
1171
|
+
if (inputRef.current !== null) inputRef.current.focus();
|
|
1172
|
+
}
|
|
1173
|
+
return ok;
|
|
1174
|
+
};
|
|
1145
1175
|
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1176
|
+
const submit = (event) => {
|
|
1177
|
+
if (event !== undefined) event.preventDefault();
|
|
1178
|
+
void submitWithDate(draftDue);
|
|
1179
|
+
};
|
|
1150
1180
|
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1181
|
+
/** Toggle the calendar: anchored to the button, flipped up when space runs out. */
|
|
1182
|
+
const togglePicker = (event) => {
|
|
1183
|
+
if (pickerOpen) {
|
|
1184
|
+
setPickerOpen(false);
|
|
1185
|
+
return;
|
|
1186
|
+
}
|
|
1187
|
+
setPickerPos(panelPositionFor(event.currentTarget.getBoundingClientRect()));
|
|
1188
|
+
setPickerOpen(true);
|
|
1189
|
+
};
|
|
1160
1190
|
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1191
|
+
/** Single click previews; double-click confirms, closes, and adds the to-do. */
|
|
1192
|
+
const commitDate = (key) => {
|
|
1193
|
+
setDraftDue(key);
|
|
1194
|
+
if (draft.trim() === '') {
|
|
1195
|
+
setPickerOpen(false);
|
|
1196
|
+
return;
|
|
1197
|
+
}
|
|
1198
|
+
void submitWithDate(key);
|
|
1199
|
+
};
|
|
1170
1200
|
|
|
1171
|
-
|
|
1172
|
-
|
|
1201
|
+
/** Stable dismiss so the panel's document listeners are not rebound each render. */
|
|
1202
|
+
const dismissPicker = useCallback(() => setPickerOpen(false), []);
|
|
1173
1203
|
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1204
|
+
/** Clicking empty space in the cell opens (or refocuses) the inline input. */
|
|
1205
|
+
const onListClick = (event) => {
|
|
1206
|
+
if (event.target !== event.currentTarget) return;
|
|
1207
|
+
if (adding) {
|
|
1208
|
+
if (inputRef.current !== null) inputRef.current.focus();
|
|
1209
|
+
return;
|
|
1210
|
+
}
|
|
1211
|
+
start();
|
|
1212
|
+
};
|
|
1183
1213
|
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1214
|
+
/**
|
|
1215
|
+
* The row the dragged item should be inserted above, decided by comparing
|
|
1216
|
+
* the pointer against each row's vertical midpoint. Null means "at the end".
|
|
1217
|
+
*/
|
|
1218
|
+
const beforeIdAt = (list, clientY) => {
|
|
1219
|
+
const rows = list.querySelectorAll('[data-todo-id]');
|
|
1220
|
+
for (const row of rows) {
|
|
1221
|
+
const rect = row.getBoundingClientRect();
|
|
1222
|
+
if (clientY < rect.top + rect.height / 2) return row.dataset.todoId;
|
|
1223
|
+
}
|
|
1224
|
+
return null;
|
|
1225
|
+
};
|
|
1196
1226
|
|
|
1197
|
-
|
|
1227
|
+
const dropActive = props.dropTarget !== null && props.dropTarget.quadrantId === quadrant.id;
|
|
1198
1228
|
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
},
|
|
1222
|
-
onDrop: (event) => {
|
|
1223
|
-
if (props.dragId === null) return;
|
|
1224
|
-
event.preventDefault();
|
|
1225
|
-
props.onMove(quadrant, beforeIdAt(event.currentTarget, event.clientY));
|
|
1226
|
-
},
|
|
1229
|
+
return h(
|
|
1230
|
+
'section',
|
|
1231
|
+
{ className: dropActive ? 'ez-quad ez-quad--' + quadrant.id + ' is-drop-target' : 'ez-quad ez-quad--' + quadrant.id, 'aria-label': name },
|
|
1232
|
+
h(
|
|
1233
|
+
'header',
|
|
1234
|
+
{ className: 'ez-quad-head' },
|
|
1235
|
+
h('span', { className: 'ez-dot', 'aria-hidden': 'true' }),
|
|
1236
|
+
h('h2', { className: 'ez-quad-name' }, name),
|
|
1237
|
+
h('span', { className: 'ez-quad-hint' }, t('quadrant.' + quadrant.id + '.hint')),
|
|
1238
|
+
h('span', { className: 'ez-quad-count' }, String(items.length)),
|
|
1239
|
+
),
|
|
1240
|
+
h(
|
|
1241
|
+
'ul',
|
|
1242
|
+
{
|
|
1243
|
+
className:
|
|
1244
|
+
'ez-list' + (dropActive && props.dropTarget.beforeId === null && items.length > 0 ? ' is-drop-end' : ''),
|
|
1245
|
+
onClick: onListClick,
|
|
1246
|
+
onDragOver: (event) => {
|
|
1247
|
+
if (props.dragId === null) return;
|
|
1248
|
+
event.preventDefault();
|
|
1249
|
+
event.dataTransfer.dropEffect = 'move';
|
|
1250
|
+
props.onDragOver(quadrant.id, beforeIdAt(event.currentTarget, event.clientY));
|
|
1227
1251
|
},
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1252
|
+
onDrop: (event) => {
|
|
1253
|
+
if (props.dragId === null) return;
|
|
1254
|
+
event.preventDefault();
|
|
1255
|
+
props.onMove(quadrant, beforeIdAt(event.currentTarget, event.clientY));
|
|
1256
|
+
},
|
|
1257
|
+
},
|
|
1258
|
+
items.map((todo) =>
|
|
1259
|
+
h(TodoRow, {
|
|
1260
|
+
key: todo.id,
|
|
1261
|
+
todo,
|
|
1262
|
+
t,
|
|
1263
|
+
onToggle: props.onToggle,
|
|
1264
|
+
onPatch: props.onPatch,
|
|
1265
|
+
onRemove: props.onRemove,
|
|
1266
|
+
onDue: props.onDue,
|
|
1267
|
+
dueFormat: props.dueFormat,
|
|
1268
|
+
dragging: props.dragId === todo.id,
|
|
1269
|
+
dropBefore: dropActive && props.dropTarget.beforeId === todo.id,
|
|
1270
|
+
onDragStart: props.onDragStart,
|
|
1271
|
+
onDragEnd: props.onDragEnd,
|
|
1272
|
+
}),
|
|
1244
1273
|
),
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
{
|
|
1275
|
-
key: 'due',
|
|
1276
|
-
ref: dateButtonRef,
|
|
1277
|
-
type: 'button',
|
|
1278
|
-
className:
|
|
1279
|
-
draftDue === '' ? 'ez-date-field ez-date-field--empty' : 'ez-date-field ez-date-field--set',
|
|
1280
|
-
title: draftDue === '' ? t('quickAdd.due') : formatDayKey(draftDue),
|
|
1281
|
-
'aria-label': t('quickAdd.due'),
|
|
1282
|
-
'aria-expanded': pickerOpen,
|
|
1283
|
-
'aria-haspopup': 'dialog',
|
|
1284
|
-
'data-ez-date-anchor': 'add-' + quadrant.id,
|
|
1285
|
-
onClick: togglePicker,
|
|
1286
|
-
},
|
|
1287
|
-
h(CalendarGlyph, { size: draftDue === '' ? 18 : 14 }),
|
|
1288
|
-
draftDue === '' ? null : h('span', { className: 'ez-date-field-text' }, formatDayKey(draftDue)),
|
|
1289
|
-
),
|
|
1290
|
-
]
|
|
1291
|
-
: h(
|
|
1274
|
+
),
|
|
1275
|
+
h(
|
|
1276
|
+
'form',
|
|
1277
|
+
{ className: 'ez-add-area', onSubmit: submit },
|
|
1278
|
+
adding
|
|
1279
|
+
? [
|
|
1280
|
+
h('input', {
|
|
1281
|
+
key: 'title',
|
|
1282
|
+
ref: inputRef,
|
|
1283
|
+
className: 'ez-add-input',
|
|
1284
|
+
type: 'text',
|
|
1285
|
+
value: draft,
|
|
1286
|
+
maxLength: 200,
|
|
1287
|
+
placeholder: t('quickAdd.placeholder'),
|
|
1288
|
+
'aria-label': t('quickAdd.placeholder'),
|
|
1289
|
+
onChange: (event) => setDraft(event.target.value),
|
|
1290
|
+
onKeyDown: (event) => {
|
|
1291
|
+
if (event.key === 'Escape') stop();
|
|
1292
|
+
},
|
|
1293
|
+
onBlur: (event) => {
|
|
1294
|
+
if (pickerOpenRef.current) return;
|
|
1295
|
+
const next = event.relatedTarget;
|
|
1296
|
+
if (next !== null && dateButtonRef.current !== null && dateButtonRef.current.contains(next)) {
|
|
1297
|
+
return;
|
|
1298
|
+
}
|
|
1299
|
+
if (draft.trim() === '' && draftDue === '') stop();
|
|
1300
|
+
},
|
|
1301
|
+
}),
|
|
1302
|
+
h(
|
|
1292
1303
|
'button',
|
|
1293
1304
|
{
|
|
1305
|
+
key: 'due',
|
|
1306
|
+
ref: dateButtonRef,
|
|
1294
1307
|
type: 'button',
|
|
1295
|
-
className:
|
|
1296
|
-
|
|
1297
|
-
|
|
1308
|
+
className:
|
|
1309
|
+
draftDue === '' ? 'ez-date-field ez-date-field--empty' : 'ez-date-field ez-date-field--set',
|
|
1310
|
+
title: draftDue === '' ? t('quickAdd.due') : formatDayKey(draftDue),
|
|
1311
|
+
'aria-label': t('quickAdd.due'),
|
|
1312
|
+
'aria-expanded': pickerOpen,
|
|
1313
|
+
'aria-haspopup': 'dialog',
|
|
1314
|
+
'data-ez-date-anchor': 'add-' + quadrant.id,
|
|
1315
|
+
onClick: togglePicker,
|
|
1298
1316
|
},
|
|
1299
|
-
h(
|
|
1300
|
-
|
|
1317
|
+
h(CalendarGlyph, { size: draftDue === '' ? 18 : 14 }),
|
|
1318
|
+
draftDue === '' ? null : h('span', { className: 'ez-date-field-text' }, formatDayKey(draftDue)),
|
|
1301
1319
|
),
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1320
|
+
]
|
|
1321
|
+
: h(
|
|
1322
|
+
'button',
|
|
1323
|
+
{
|
|
1324
|
+
type: 'button',
|
|
1325
|
+
className: 'ez-quick-add',
|
|
1326
|
+
title: t('quickAdd'),
|
|
1327
|
+
onClick: start,
|
|
1328
|
+
},
|
|
1329
|
+
h('span', { className: 'ez-quick-plus', 'aria-hidden': 'true' }, '+'),
|
|
1330
|
+
t('quickAdd'),
|
|
1331
|
+
),
|
|
1332
|
+
),
|
|
1333
|
+
pickerOpen && pickerPos !== null
|
|
1334
|
+
? h(DatePickerPanel, {
|
|
1335
|
+
t,
|
|
1336
|
+
value: draftDue,
|
|
1337
|
+
anchor: 'add-' + quadrant.id,
|
|
1338
|
+
style: { left: pickerPos.left + 'px', top: pickerPos.top + 'px' },
|
|
1339
|
+
onPick: setDraftDue,
|
|
1340
|
+
onCommit: commitDate,
|
|
1341
|
+
onClear: () => setDraftDue(''),
|
|
1342
|
+
onDismiss: dismissPicker,
|
|
1343
|
+
})
|
|
1344
|
+
: null,
|
|
1345
|
+
);
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
/** The completed list plus its guarded "clear" control. */
|
|
1349
|
+
function CompletedList(props) {
|
|
1350
|
+
const t = props.t;
|
|
1351
|
+
const items = props.items;
|
|
1352
|
+
const [confirming, setConfirming] = useState(false);
|
|
1353
|
+
|
|
1354
|
+
useEffect(() => {
|
|
1355
|
+
if (!confirming) return undefined;
|
|
1356
|
+
const timer = window.setTimeout(() => setConfirming(false), 3200);
|
|
1357
|
+
return () => window.clearTimeout(timer);
|
|
1358
|
+
}, [confirming]);
|
|
1359
|
+
|
|
1360
|
+
const clear = () => {
|
|
1361
|
+
if (!confirming) {
|
|
1362
|
+
setConfirming(true);
|
|
1363
|
+
return;
|
|
1364
|
+
}
|
|
1365
|
+
setConfirming(false);
|
|
1366
|
+
props.onClear();
|
|
1367
|
+
};
|
|
1338
1368
|
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
? h(
|
|
1349
|
-
'button',
|
|
1350
|
-
{ type: 'button', className: confirming ? 'ez-clear is-confirming' : 'ez-clear', onClick: clear },
|
|
1351
|
-
t(confirming ? 'completed.confirm' : 'completed.clear'),
|
|
1352
|
-
)
|
|
1353
|
-
: null,
|
|
1354
|
-
),
|
|
1355
|
-
items.length === 0
|
|
1369
|
+
return h(
|
|
1370
|
+
'section',
|
|
1371
|
+
{ className: 'ez-completed', 'aria-label': t('completed.heading') },
|
|
1372
|
+
h(
|
|
1373
|
+
'header',
|
|
1374
|
+
{ className: 'ez-completed-head' },
|
|
1375
|
+
h('h2', { className: 'ez-completed-title' }, t('completed.heading')),
|
|
1376
|
+
h('span', { className: 'ez-completed-count' }, String(items.length)),
|
|
1377
|
+
items.length > 0
|
|
1356
1378
|
? h(
|
|
1357
|
-
'
|
|
1358
|
-
{ className: 'ez-
|
|
1359
|
-
|
|
1379
|
+
'button',
|
|
1380
|
+
{ type: 'button', className: confirming ? 'ez-clear is-confirming' : 'ez-clear', onClick: clear },
|
|
1381
|
+
t(confirming ? 'completed.confirm' : 'completed.clear'),
|
|
1360
1382
|
)
|
|
1361
|
-
:
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1383
|
+
: null,
|
|
1384
|
+
),
|
|
1385
|
+
items.length === 0
|
|
1386
|
+
? h(
|
|
1387
|
+
'div',
|
|
1388
|
+
{ className: 'ez-completed-body' },
|
|
1389
|
+
h('p', { className: 'ez-blank' }, t('empty.completed')),
|
|
1390
|
+
)
|
|
1391
|
+
: h(
|
|
1392
|
+
'ul',
|
|
1393
|
+
{ className: 'ez-list' },
|
|
1394
|
+
items.map((todo) =>
|
|
1395
|
+
h(CompletedRow, { key: todo.id, todo, t, onToggle: props.onToggle, onRemove: props.onRemove }),
|
|
1367
1396
|
),
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1397
|
+
),
|
|
1398
|
+
);
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
/** The main panel: header, settings, and the selected view. */
|
|
1402
|
+
function TodoPage(props) {
|
|
1403
|
+
const t = props.t;
|
|
1404
|
+
const localeSource = props.localeSource;
|
|
1405
|
+
const [todos, setTodos] = useState(null);
|
|
1406
|
+
const [settings, setSettings] = useState(DEFAULT_SETTINGS);
|
|
1407
|
+
const [settingsOpen, setSettingsOpen] = useState(false);
|
|
1408
|
+
const [loaded, setLoaded] = useState(false);
|
|
1409
|
+
const [error, setError] = useState(null);
|
|
1410
|
+
const [view, setView] = useState('matrix');
|
|
1411
|
+
const [dragId, setDragId] = useState(null);
|
|
1412
|
+
const [dropTarget, setDropTarget] = useState(null);
|
|
1413
|
+
const [toast, setToast] = useState(null);
|
|
1414
|
+
const [splitDragging, setSplitDragging] = useState(false);
|
|
1415
|
+
const [splitHot, setSplitHot] = useState(false);
|
|
1416
|
+
const matrixRef = useRef(null);
|
|
1417
|
+
const pageRef = useRef(null);
|
|
1418
|
+
const dropTargetRef = useRef(null);
|
|
1419
|
+
const toastTimer = useRef(null);
|
|
1420
|
+
const lastPraise = useRef({ praise: -1, cheer: -1 });
|
|
1421
|
+
|
|
1422
|
+
useSyncExternalStore(localeSource.subscribe, localeSource.getSnapshot);
|
|
1423
|
+
|
|
1424
|
+
/** Read a user-facing message off a thrown error, localizing transport failures. */
|
|
1425
|
+
const messageOf = useCallback(
|
|
1426
|
+
(err) => {
|
|
1427
|
+
const text = err && typeof err.message === 'string' ? err.message : '';
|
|
1428
|
+
if (text === '' || (err && err.name === 'TypeError')) return t('error.request');
|
|
1429
|
+
return text;
|
|
1430
|
+
},
|
|
1431
|
+
[t],
|
|
1432
|
+
);
|
|
1433
|
+
|
|
1434
|
+
// Layout preferences: local state updates immediately and the Host write is
|
|
1435
|
+
// debounced. `settingsDirty` guards against a concurrent todo response
|
|
1436
|
+
// (which also carries settings) overwriting an unsaved local change.
|
|
1437
|
+
const latestSettings = useRef(DEFAULT_SETTINGS);
|
|
1438
|
+
latestSettings.current = settings;
|
|
1439
|
+
const settingsDirty = useRef(false);
|
|
1440
|
+
const saveTimer = useRef(null);
|
|
1441
|
+
|
|
1442
|
+
const applyResult = useCallback((result) => {
|
|
1443
|
+
setTodos(Array.isArray(result.todos) ? result.todos : []);
|
|
1444
|
+
if (result.settings !== undefined && settingsDirty.current !== true) {
|
|
1445
|
+
const next = sanitizeSettings(result.settings);
|
|
1446
|
+
setSettings(next);
|
|
1447
|
+
if (typeof props.setNavLabel === 'function') props.setNavLabel(next.navLabel);
|
|
1448
|
+
}
|
|
1449
|
+
setError(null);
|
|
1450
|
+
}, [props.setNavLabel]);
|
|
1451
|
+
|
|
1452
|
+
const load = useCallback(async () => {
|
|
1453
|
+
try {
|
|
1454
|
+
let result = await fetchApi('list');
|
|
1455
|
+
// Brand-new store: ask the Host to write the localized guide rows once.
|
|
1456
|
+
if (result.seeded === false && Array.isArray(result.todos) && result.todos.length === 0) {
|
|
1457
|
+
result = await fetchApi('seed', { items: seedItems(t) });
|
|
1418
1458
|
}
|
|
1419
|
-
|
|
1420
|
-
}
|
|
1459
|
+
applyResult(result);
|
|
1460
|
+
} catch (err) {
|
|
1461
|
+
setError(messageOf(err));
|
|
1462
|
+
setTodos((current) => (current === null ? [] : current));
|
|
1463
|
+
} finally {
|
|
1464
|
+
setLoaded(true);
|
|
1465
|
+
}
|
|
1466
|
+
}, [applyResult, messageOf, t]);
|
|
1467
|
+
|
|
1468
|
+
useEffect(() => {
|
|
1469
|
+
void load();
|
|
1470
|
+
}, [load]);
|
|
1421
1471
|
|
|
1422
|
-
|
|
1472
|
+
const mutate = useCallback(
|
|
1473
|
+
async (method, payload) => {
|
|
1423
1474
|
try {
|
|
1424
|
-
applyResult(await fetchApi(
|
|
1475
|
+
applyResult(await fetchApi(method, payload));
|
|
1476
|
+
return true;
|
|
1425
1477
|
} catch (err) {
|
|
1426
1478
|
setError(messageOf(err));
|
|
1427
|
-
|
|
1428
|
-
} finally {
|
|
1429
|
-
setLoaded(true);
|
|
1479
|
+
return false;
|
|
1430
1480
|
}
|
|
1431
|
-
},
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1481
|
+
},
|
|
1482
|
+
[applyResult, messageOf],
|
|
1483
|
+
);
|
|
1484
|
+
|
|
1485
|
+
// Settings save: local state updates immediately, the Host is written once
|
|
1486
|
+
// after a short pause; a pending write is flushed when the panel closes.
|
|
1487
|
+
const commitSettings = useCallback(
|
|
1488
|
+
(patch) => {
|
|
1489
|
+
settingsDirty.current = true;
|
|
1490
|
+
setSettings((current) => ({ ...current, ...patch }));
|
|
1491
|
+
// The sidebar label is page chrome, so apply it without waiting for the
|
|
1492
|
+
// debounced save round trip.
|
|
1493
|
+
if (patch.navLabel !== undefined && typeof props.setNavLabel === 'function') {
|
|
1494
|
+
props.setNavLabel(patch.navLabel);
|
|
1495
|
+
}
|
|
1496
|
+
},
|
|
1497
|
+
[props.setNavLabel],
|
|
1498
|
+
);
|
|
1499
|
+
|
|
1500
|
+
useEffect(() => {
|
|
1501
|
+
if (!loaded || !settingsDirty.current) return undefined;
|
|
1502
|
+
if (saveTimer.current !== null) window.clearTimeout(saveTimer.current);
|
|
1503
|
+
saveTimer.current = window.setTimeout(() => {
|
|
1504
|
+
saveTimer.current = null;
|
|
1505
|
+
settingsDirty.current = false;
|
|
1506
|
+
void mutate('saveSettings', latestSettings.current);
|
|
1507
|
+
}, 350);
|
|
1508
|
+
return () => {
|
|
1509
|
+
if (saveTimer.current !== null) {
|
|
1510
|
+
window.clearTimeout(saveTimer.current);
|
|
1511
|
+
saveTimer.current = null;
|
|
1512
|
+
}
|
|
1513
|
+
};
|
|
1514
|
+
}, [settings, loaded, mutate]);
|
|
1464
1515
|
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
if (saveTimer.current !== null
|
|
1468
|
-
|
|
1516
|
+
useEffect(
|
|
1517
|
+
() => () => {
|
|
1518
|
+
if (saveTimer.current !== null && settingsDirty.current) {
|
|
1519
|
+
window.clearTimeout(saveTimer.current);
|
|
1469
1520
|
saveTimer.current = null;
|
|
1470
1521
|
settingsDirty.current = false;
|
|
1471
1522
|
void mutate('saveSettings', latestSettings.current);
|
|
1472
|
-
}
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
void mutate('saveSettings', latestSettings.current);
|
|
1488
|
-
}
|
|
1489
|
-
},
|
|
1490
|
-
[mutate],
|
|
1491
|
-
);
|
|
1523
|
+
}
|
|
1524
|
+
},
|
|
1525
|
+
[mutate],
|
|
1526
|
+
);
|
|
1527
|
+
|
|
1528
|
+
const onAddToQuadrant = useCallback(
|
|
1529
|
+
(quadrant, title, dueDate) =>
|
|
1530
|
+
mutate('create', { title, important: quadrant.important, urgent: quadrant.urgent, dueDate }),
|
|
1531
|
+
[mutate],
|
|
1532
|
+
);
|
|
1533
|
+
const onDue = useCallback((id, dueDate) => mutate('update', { id, dueDate }), [mutate]);
|
|
1534
|
+
const onRemove = useCallback((id) => mutate('remove', { id }), [mutate]);
|
|
1535
|
+
const onPatch = useCallback((id, patch) => mutate('update', { id, ...patch }), [mutate]);
|
|
1536
|
+
const onClear = useCallback(() => mutate('clearCompleted', {}), [mutate]);
|
|
1537
|
+
const onResetSettings = useCallback(() => commitSettings({ ...DEFAULT_SETTINGS }), [commitSettings]);
|
|
1492
1538
|
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
const
|
|
1500
|
-
const
|
|
1501
|
-
const
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
const
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
const top = rect === null ? window.innerHeight / 2 : rect.top + rect.height / 2;
|
|
1522
|
-
setToast({ id: Date.now(), mood: group, text: t('toast.' + group + '.' + (index + 1)), left, top });
|
|
1539
|
+
/**
|
|
1540
|
+
* Short feedback after an item is completed. `mood` is `praise` when the due
|
|
1541
|
+
* date was met (or there was none) and `cheer` when the item was overdue, so
|
|
1542
|
+
* the two cases never share wording.
|
|
1543
|
+
*/
|
|
1544
|
+
const showFeedback = useCallback((mood) => {
|
|
1545
|
+
const group = mood === 'cheer' ? 'cheer' : 'praise';
|
|
1546
|
+
const count = 8;
|
|
1547
|
+
const previous = lastPraise.current[group];
|
|
1548
|
+
let index = Math.floor(Math.random() * count);
|
|
1549
|
+
// Avoid repeating the same line twice in a row inside one group.
|
|
1550
|
+
if (index === previous) index = (index + 1 + Math.floor(Math.random() * (count - 1))) % count;
|
|
1551
|
+
lastPraise.current[group] = index;
|
|
1552
|
+
// Centre on the plugin panel, not on the whole window: the panel sits to
|
|
1553
|
+
// the right of the app sidebar, so a viewport centre reads as up-left.
|
|
1554
|
+
const rect = pageRef.current === null ? null : pageRef.current.getBoundingClientRect();
|
|
1555
|
+
const left = rect === null ? window.innerWidth / 2 : rect.left + rect.width / 2;
|
|
1556
|
+
const top = rect === null ? window.innerHeight / 2 : rect.top + rect.height / 2;
|
|
1557
|
+
setToast({ id: Date.now(), mood: group, text: t('toast.' + group + '.' + (index + 1)), left, top });
|
|
1558
|
+
if (toastTimer.current !== null) window.clearTimeout(toastTimer.current);
|
|
1559
|
+
toastTimer.current = window.setTimeout(() => {
|
|
1560
|
+
toastTimer.current = null;
|
|
1561
|
+
setToast(null);
|
|
1562
|
+
}, 2600);
|
|
1563
|
+
}, [t]);
|
|
1564
|
+
|
|
1565
|
+
useEffect(
|
|
1566
|
+
() => () => {
|
|
1523
1567
|
if (toastTimer.current !== null) window.clearTimeout(toastTimer.current);
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
)
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
/** Live grid template from the draggable split ratios. */
|
|
1627
|
-
const matrixStyle = {
|
|
1628
|
-
'--ez-radius': String(settings.radius) + 'px',
|
|
1629
|
-
'--ez-col-ratio': String(settings.colRatio),
|
|
1630
|
-
'--ez-row-ratio': String(settings.rowRatio),
|
|
1631
|
-
gridTemplateColumns: settings.colRatio + 'fr ' + String(1 - settings.colRatio) + 'fr',
|
|
1632
|
-
gridTemplateRows: settings.rowRatio + 'fr ' + String(1 - settings.rowRatio) + 'fr',
|
|
1633
|
-
};
|
|
1568
|
+
},
|
|
1569
|
+
[],
|
|
1570
|
+
);
|
|
1571
|
+
|
|
1572
|
+
const onToggle = useCallback(
|
|
1573
|
+
async (id) => {
|
|
1574
|
+
const target = todos === null ? undefined : todos.find((todo) => todo.id === id);
|
|
1575
|
+
const completing = target !== undefined && target.done !== true;
|
|
1576
|
+
const ok = await mutate('toggle', { id });
|
|
1577
|
+
if (ok && completing) {
|
|
1578
|
+
// Completed today: the deadline is met while it is today or later.
|
|
1579
|
+
const deadlineMissed =
|
|
1580
|
+
typeof target.dueDate === 'string' && target.dueDate !== '' && target.dueDate < todayKey();
|
|
1581
|
+
showFeedback(deadlineMissed ? 'cheer' : 'praise');
|
|
1582
|
+
}
|
|
1583
|
+
},
|
|
1584
|
+
[todos, mutate, showFeedback],
|
|
1585
|
+
);
|
|
1586
|
+
|
|
1587
|
+
/** Remember the drop line, re-rendering only when the target actually changes. */
|
|
1588
|
+
const reportDropTarget = useCallback((quadrantId, beforeId) => {
|
|
1589
|
+
const previous = dropTargetRef.current;
|
|
1590
|
+
if (previous !== null && previous.quadrantId === quadrantId && previous.beforeId === beforeId) return;
|
|
1591
|
+
dropTargetRef.current = { quadrantId, beforeId };
|
|
1592
|
+
setDropTarget(dropTargetRef.current);
|
|
1593
|
+
}, []);
|
|
1594
|
+
|
|
1595
|
+
const endDrag = useCallback(() => {
|
|
1596
|
+
dropTargetRef.current = null;
|
|
1597
|
+
setDragId(null);
|
|
1598
|
+
setDropTarget(null);
|
|
1599
|
+
}, []);
|
|
1600
|
+
|
|
1601
|
+
const onMove = useCallback(
|
|
1602
|
+
async (quadrant, beforeId) => {
|
|
1603
|
+
if (dragId === null) return;
|
|
1604
|
+
const id = dragId;
|
|
1605
|
+
endDrag();
|
|
1606
|
+
// Dropping onto itself is a no-op; the Host would otherwise report a
|
|
1607
|
+
// missing insertion anchor (the row is detached before the lookup).
|
|
1608
|
+
if (beforeId === id) return;
|
|
1609
|
+
await mutate('reorder', {
|
|
1610
|
+
id,
|
|
1611
|
+
important: quadrant.important,
|
|
1612
|
+
urgent: quadrant.urgent,
|
|
1613
|
+
beforeId,
|
|
1614
|
+
});
|
|
1615
|
+
},
|
|
1616
|
+
[dragId, endDrag, mutate],
|
|
1617
|
+
);
|
|
1618
|
+
|
|
1619
|
+
const open = useMemo(() => (todos === null ? [] : todos.filter((todo) => todo.done !== true)), [todos]);
|
|
1620
|
+
const completed = useMemo(
|
|
1621
|
+
() =>
|
|
1622
|
+
todos === null
|
|
1623
|
+
? []
|
|
1624
|
+
: todos
|
|
1625
|
+
.filter((todo) => todo.done === true)
|
|
1626
|
+
.slice()
|
|
1627
|
+
.sort((a, b) => String(b.completedAt ?? '').localeCompare(String(a.completedAt ?? ''))),
|
|
1628
|
+
[todos],
|
|
1629
|
+
);
|
|
1630
|
+
|
|
1631
|
+
const cellOrder = useMemo(() => {
|
|
1632
|
+
const byId = new Map(QUADRANTS.map((quadrant) => [quadrant.id, quadrant]));
|
|
1633
|
+
const order =
|
|
1634
|
+
settings.urgentSide === 'right' ? URGENT_RIGHT_ORDER : QUADRANTS.map((quadrant) => quadrant.id);
|
|
1635
|
+
return order.map((id) => byId.get(id));
|
|
1636
|
+
}, [settings.urgentSide]);
|
|
1637
|
+
|
|
1638
|
+
const cells = useMemo(
|
|
1639
|
+
() =>
|
|
1640
|
+
cellOrder.map((quadrant) => ({
|
|
1641
|
+
quadrant,
|
|
1642
|
+
items: open.filter(
|
|
1643
|
+
(todo) =>
|
|
1644
|
+
(todo.important === true) === quadrant.important &&
|
|
1645
|
+
(todo.urgent === true) === quadrant.urgent,
|
|
1646
|
+
),
|
|
1647
|
+
})),
|
|
1648
|
+
[cellOrder, open],
|
|
1649
|
+
);
|
|
1650
|
+
|
|
1651
|
+
const errorText = error === null ? null : error;
|
|
1652
|
+
|
|
1653
|
+
// Frame classes: `cards` | `grid` (田字格) | `cross` (no outer border),
|
|
1654
|
+
// plus the optional soft cell fill.
|
|
1655
|
+
const matrixClass =
|
|
1656
|
+
'ez-matrix ez-matrix--' +
|
|
1657
|
+
settings.frame +
|
|
1658
|
+
(settings.tint === 'soft' ? ' ez-matrix--tint' : '') +
|
|
1659
|
+
(settings.titleStyle === 'truncate' ? ' ez-matrix--truncate' : ' ez-matrix--wrap');
|
|
1660
|
+
|
|
1661
|
+
/** Live grid template from the draggable split ratios. */
|
|
1662
|
+
const matrixStyle = {
|
|
1663
|
+
'--ez-radius': String(settings.radius) + 'px',
|
|
1664
|
+
'--ez-col-ratio': String(settings.colRatio),
|
|
1665
|
+
'--ez-row-ratio': String(settings.rowRatio),
|
|
1666
|
+
gridTemplateColumns: settings.colRatio + 'fr ' + String(1 - settings.colRatio) + 'fr',
|
|
1667
|
+
gridTemplateRows: settings.rowRatio + 'fr ' + String(1 - settings.rowRatio) + 'fr',
|
|
1668
|
+
};
|
|
1634
1669
|
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1670
|
+
/** True while the drag sits inside the snap zone around the even split. */
|
|
1671
|
+
const snapActive =
|
|
1672
|
+
Math.abs(settings.colRatio - 0.5) <= 0.025 && Math.abs(settings.rowRatio - 0.5) <= 0.025;
|
|
1638
1673
|
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1674
|
+
/** Resize the quadrants by dragging the handle at the cross centre. */
|
|
1675
|
+
const onSplitPointerDown = (event) => {
|
|
1676
|
+
event.preventDefault();
|
|
1677
|
+
event.stopPropagation();
|
|
1678
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
1679
|
+
setSplitDragging(true);
|
|
1680
|
+
};
|
|
1646
1681
|
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1682
|
+
/** Reveal the handle only while the pointer is near the current centre. */
|
|
1683
|
+
const onMatrixPointerMove = (event) => {
|
|
1684
|
+
if (splitDragging) return;
|
|
1685
|
+
const rect = matrixRef.current === null ? null : matrixRef.current.getBoundingClientRect();
|
|
1686
|
+
if (rect === null || rect.width === 0 || rect.height === 0) return;
|
|
1687
|
+
const centerX = rect.left + rect.width * settings.colRatio;
|
|
1688
|
+
const centerY = rect.top + rect.height * settings.rowRatio;
|
|
1689
|
+
const near = Math.hypot(event.clientX - centerX, event.clientY - centerY) <= 56;
|
|
1690
|
+
setSplitHot(near);
|
|
1691
|
+
};
|
|
1657
1692
|
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1693
|
+
const onMatrixPointerLeave = () => {
|
|
1694
|
+
if (!splitDragging) setSplitHot(false);
|
|
1695
|
+
};
|
|
1661
1696
|
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1697
|
+
/** Gentle snap so the default even split is easy to hit again. */
|
|
1698
|
+
const snapRatio = (value) => (Math.abs(value - 0.5) <= 0.025 ? 0.5 : clampRatio(value));
|
|
1699
|
+
|
|
1700
|
+
const onSplitPointerMove = (event) => {
|
|
1701
|
+
if (!splitDragging) return;
|
|
1702
|
+
const rect = matrixRef.current === null ? null : matrixRef.current.getBoundingClientRect();
|
|
1703
|
+
if (rect === null || rect.width === 0 || rect.height === 0) return;
|
|
1704
|
+
event.preventDefault();
|
|
1705
|
+
commitSettings({
|
|
1706
|
+
colRatio: snapRatio((event.clientX - rect.left) / rect.width),
|
|
1707
|
+
rowRatio: snapRatio((event.clientY - rect.top) / rect.height),
|
|
1708
|
+
});
|
|
1709
|
+
};
|
|
1675
1710
|
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1711
|
+
const onSplitPointerUp = (event) => {
|
|
1712
|
+
if (!splitDragging) return;
|
|
1713
|
+
setSplitDragging(false);
|
|
1714
|
+
if (typeof event.currentTarget.releasePointerCapture === 'function') {
|
|
1715
|
+
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
1716
|
+
}
|
|
1717
|
+
};
|
|
1683
1718
|
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1719
|
+
const tab = (id, label, count) =>
|
|
1720
|
+
h(
|
|
1721
|
+
'button',
|
|
1722
|
+
{
|
|
1723
|
+
type: 'button',
|
|
1724
|
+
className: view === id ? 'ez-seg-btn is-active' : 'ez-seg-btn',
|
|
1725
|
+
'aria-pressed': view === id,
|
|
1726
|
+
onClick: () => setView(id),
|
|
1727
|
+
},
|
|
1728
|
+
label,
|
|
1729
|
+
count > 0 ? h('span', { className: 'ez-count' }, String(count)) : null,
|
|
1730
|
+
);
|
|
1696
1731
|
|
|
1697
|
-
|
|
1732
|
+
return h(
|
|
1733
|
+
'div',
|
|
1734
|
+
{ className: 'ez-page', ref: pageRef, style: { '--ez-font-size': String(settings.fontSize) + 'px' } },
|
|
1735
|
+
h('style', { dangerouslySetInnerHTML: { __html: CSS } }),
|
|
1736
|
+
h(
|
|
1698
1737
|
'div',
|
|
1699
|
-
{ className: 'ez-
|
|
1700
|
-
h('style', { dangerouslySetInnerHTML: { __html: CSS } }),
|
|
1738
|
+
{ className: 'ez-inner' },
|
|
1701
1739
|
h(
|
|
1702
|
-
'
|
|
1703
|
-
{ className: 'ez-
|
|
1740
|
+
'header',
|
|
1741
|
+
{ className: 'ez-head' },
|
|
1742
|
+
h(
|
|
1743
|
+
'div',
|
|
1744
|
+
{ className: 'ez-heading' },
|
|
1745
|
+
h('h1', { className: 'ez-page-title' }, t('page.title')),
|
|
1746
|
+
h('p', { className: 'ez-sub' }, t('page.subtitle')),
|
|
1747
|
+
),
|
|
1704
1748
|
h(
|
|
1705
|
-
'
|
|
1706
|
-
{ className: 'ez-head' },
|
|
1749
|
+
'div',
|
|
1750
|
+
{ className: 'ez-head-actions' },
|
|
1707
1751
|
h(
|
|
1708
1752
|
'div',
|
|
1709
|
-
{ className: 'ez-
|
|
1710
|
-
|
|
1711
|
-
|
|
1753
|
+
{ className: 'ez-seg', role: 'group', 'aria-label': t('page.subtitle') },
|
|
1754
|
+
tab('matrix', t('view.matrix'), open.length),
|
|
1755
|
+
tab('completed', t('view.completed'), completed.length),
|
|
1712
1756
|
),
|
|
1713
1757
|
h(
|
|
1758
|
+
'button',
|
|
1759
|
+
{
|
|
1760
|
+
type: 'button',
|
|
1761
|
+
className: settingsOpen ? 'ez-icon-btn is-on' : 'ez-icon-btn',
|
|
1762
|
+
title: t('settings.toggle'),
|
|
1763
|
+
'aria-label': t('settings.toggle'),
|
|
1764
|
+
'aria-expanded': settingsOpen,
|
|
1765
|
+
'aria-controls': 'ez-settings-panel',
|
|
1766
|
+
onClick: () => setSettingsOpen((value) => !value),
|
|
1767
|
+
},
|
|
1768
|
+
h(GearGlyph),
|
|
1769
|
+
),
|
|
1770
|
+
),
|
|
1771
|
+
),
|
|
1772
|
+
settingsOpen
|
|
1773
|
+
? h(SettingsPanel, {
|
|
1774
|
+
t,
|
|
1775
|
+
settings,
|
|
1776
|
+
onPatch: commitSettings,
|
|
1777
|
+
onReset: onResetSettings,
|
|
1778
|
+
})
|
|
1779
|
+
: null,
|
|
1780
|
+
errorText === null
|
|
1781
|
+
? null
|
|
1782
|
+
: h(
|
|
1714
1783
|
'div',
|
|
1715
|
-
{ className: 'ez-
|
|
1716
|
-
h(
|
|
1784
|
+
{ className: 'ez-error', role: 'alert' },
|
|
1785
|
+
h('span', null, errorText),
|
|
1786
|
+
h('button', { type: 'button', className: 'ez-retry', onClick: () => void load() }, t('error.retry')),
|
|
1787
|
+
),
|
|
1788
|
+
!loaded
|
|
1789
|
+
? h('div', { className: 'ez-body' }, h('p', { className: 'ez-blank' }, t('loading')))
|
|
1790
|
+
: view === 'matrix'
|
|
1791
|
+
? h(
|
|
1717
1792
|
'div',
|
|
1718
|
-
{ className: 'ez-seg', role: 'group', 'aria-label': t('page.subtitle') },
|
|
1719
|
-
tab('matrix', t('view.matrix'), open.length),
|
|
1720
|
-
tab('completed', t('view.completed'), completed.length),
|
|
1721
|
-
),
|
|
1722
|
-
h(
|
|
1723
|
-
'button',
|
|
1724
1793
|
{
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
'aria-controls': 'ez-settings-panel',
|
|
1731
|
-
onClick: () => setSettingsOpen((value) => !value),
|
|
1794
|
+
className: matrixClass,
|
|
1795
|
+
ref: matrixRef,
|
|
1796
|
+
style: matrixStyle,
|
|
1797
|
+
onPointerMove: onMatrixPointerMove,
|
|
1798
|
+
onPointerLeave: onMatrixPointerLeave,
|
|
1732
1799
|
},
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
: view === 'matrix'
|
|
1756
|
-
? h(
|
|
1757
|
-
'div',
|
|
1800
|
+
cells.map((cell) =>
|
|
1801
|
+
h(QuadrantCard, {
|
|
1802
|
+
key: cell.quadrant.id,
|
|
1803
|
+
quadrant: cell.quadrant,
|
|
1804
|
+
items: cell.items,
|
|
1805
|
+
t,
|
|
1806
|
+
onAdd: onAddToQuadrant,
|
|
1807
|
+
onToggle,
|
|
1808
|
+
onPatch,
|
|
1809
|
+
onRemove,
|
|
1810
|
+
onDue,
|
|
1811
|
+
dueFormat: settings.dueFormat,
|
|
1812
|
+
dragId,
|
|
1813
|
+
dropTarget,
|
|
1814
|
+
onDragStart: setDragId,
|
|
1815
|
+
onDragEnd: endDrag,
|
|
1816
|
+
onDragOver: reportDropTarget,
|
|
1817
|
+
onMove,
|
|
1818
|
+
}),
|
|
1819
|
+
),
|
|
1820
|
+
h(
|
|
1821
|
+
'button',
|
|
1758
1822
|
{
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1823
|
+
type: 'button',
|
|
1824
|
+
className:
|
|
1825
|
+
'ez-split' +
|
|
1826
|
+
(splitHot || splitDragging ? ' is-visible' : '') +
|
|
1827
|
+
(splitDragging ? ' is-dragging' : '') +
|
|
1828
|
+
(splitDragging && snapActive ? ' is-snap' : ''),
|
|
1829
|
+
title: t('settings.quadSize'),
|
|
1830
|
+
'aria-label': t('settings.quadSize'),
|
|
1831
|
+
onPointerDown: onSplitPointerDown,
|
|
1832
|
+
onPointerMove: onSplitPointerMove,
|
|
1833
|
+
onPointerUp: onSplitPointerUp,
|
|
1834
|
+
onPointerCancel: onSplitPointerUp,
|
|
1835
|
+
onDoubleClick: () => commitSettings({ colRatio: 0.5, rowRatio: 0.5 }),
|
|
1764
1836
|
},
|
|
1765
|
-
|
|
1766
|
-
h(QuadrantCard, {
|
|
1767
|
-
key: cell.quadrant.id,
|
|
1768
|
-
quadrant: cell.quadrant,
|
|
1769
|
-
items: cell.items,
|
|
1770
|
-
t,
|
|
1771
|
-
onAdd: onAddToQuadrant,
|
|
1772
|
-
onToggle,
|
|
1773
|
-
onPatch,
|
|
1774
|
-
onRemove,
|
|
1775
|
-
onDue,
|
|
1776
|
-
dueFormat: settings.dueFormat,
|
|
1777
|
-
dragId,
|
|
1778
|
-
dropTarget,
|
|
1779
|
-
onDragStart: setDragId,
|
|
1780
|
-
onDragEnd: endDrag,
|
|
1781
|
-
onDragOver: reportDropTarget,
|
|
1782
|
-
onMove,
|
|
1783
|
-
}),
|
|
1784
|
-
),
|
|
1785
|
-
h(
|
|
1786
|
-
'button',
|
|
1787
|
-
{
|
|
1788
|
-
type: 'button',
|
|
1789
|
-
className:
|
|
1790
|
-
'ez-split' +
|
|
1791
|
-
(splitHot || splitDragging ? ' is-visible' : '') +
|
|
1792
|
-
(splitDragging ? ' is-dragging' : '') +
|
|
1793
|
-
(splitDragging && snapActive ? ' is-snap' : ''),
|
|
1794
|
-
title: t('settings.quadSize'),
|
|
1795
|
-
'aria-label': t('settings.quadSize'),
|
|
1796
|
-
onPointerDown: onSplitPointerDown,
|
|
1797
|
-
onPointerMove: onSplitPointerMove,
|
|
1798
|
-
onPointerUp: onSplitPointerUp,
|
|
1799
|
-
onPointerCancel: onSplitPointerUp,
|
|
1800
|
-
onDoubleClick: () => commitSettings({ colRatio: 0.5, rowRatio: 0.5 }),
|
|
1801
|
-
},
|
|
1802
|
-
h('span', { className: 'ez-split-dot', 'aria-hidden': 'true' }),
|
|
1803
|
-
),
|
|
1804
|
-
splitDragging
|
|
1805
|
-
? h(
|
|
1806
|
-
'div',
|
|
1807
|
-
{
|
|
1808
|
-
className: snapActive ? 'ez-split-center is-active' : 'ez-split-center',
|
|
1809
|
-
'aria-hidden': 'true',
|
|
1810
|
-
},
|
|
1811
|
-
h('span', { className: 'ez-split-center-h' }),
|
|
1812
|
-
h('span', { className: 'ez-split-center-v' }),
|
|
1813
|
-
h('span', { className: 'ez-split-center-dot' }),
|
|
1814
|
-
)
|
|
1815
|
-
: null,
|
|
1816
|
-
)
|
|
1817
|
-
: h(CompletedList, { t, items: completed, onToggle, onRemove, onClear }),
|
|
1818
|
-
toast === null
|
|
1819
|
-
? null
|
|
1820
|
-
: h(
|
|
1821
|
-
'div',
|
|
1822
|
-
{
|
|
1823
|
-
className: toast.mood === 'cheer' ? 'ez-toast ez-toast--cheer' : 'ez-toast ez-toast--praise',
|
|
1824
|
-
key: toast.id,
|
|
1825
|
-
style: { left: toast.left + 'px', top: toast.top + 'px' },
|
|
1826
|
-
role: 'status',
|
|
1827
|
-
'aria-live': 'polite',
|
|
1828
|
-
},
|
|
1829
|
-
h(
|
|
1830
|
-
'span',
|
|
1831
|
-
{ className: 'ez-toast-mark', 'aria-hidden': 'true' },
|
|
1832
|
-
toast.mood === 'cheer' ? '↗' : '✓',
|
|
1837
|
+
h('span', { className: 'ez-split-dot', 'aria-hidden': 'true' }),
|
|
1833
1838
|
),
|
|
1834
|
-
|
|
1839
|
+
splitDragging
|
|
1840
|
+
? h(
|
|
1841
|
+
'div',
|
|
1842
|
+
{
|
|
1843
|
+
className: snapActive ? 'ez-split-center is-active' : 'ez-split-center',
|
|
1844
|
+
'aria-hidden': 'true',
|
|
1845
|
+
},
|
|
1846
|
+
h('span', { className: 'ez-split-center-h' }),
|
|
1847
|
+
h('span', { className: 'ez-split-center-v' }),
|
|
1848
|
+
h('span', { className: 'ez-split-center-dot' }),
|
|
1849
|
+
)
|
|
1850
|
+
: null,
|
|
1851
|
+
)
|
|
1852
|
+
: h(CompletedList, { t, items: completed, onToggle, onRemove, onClear }),
|
|
1853
|
+
toast === null
|
|
1854
|
+
? null
|
|
1855
|
+
: h(
|
|
1856
|
+
'div',
|
|
1857
|
+
{
|
|
1858
|
+
className: toast.mood === 'cheer' ? 'ez-toast ez-toast--cheer' : 'ez-toast ez-toast--praise',
|
|
1859
|
+
key: toast.id,
|
|
1860
|
+
style: { left: toast.left + 'px', top: toast.top + 'px' },
|
|
1861
|
+
role: 'status',
|
|
1862
|
+
'aria-live': 'polite',
|
|
1863
|
+
},
|
|
1864
|
+
h(
|
|
1865
|
+
'span',
|
|
1866
|
+
{ className: 'ez-toast-mark', 'aria-hidden': 'true' },
|
|
1867
|
+
toast.mood === 'cheer' ? '↗' : '✓',
|
|
1835
1868
|
),
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1869
|
+
h('span', null, toast.text),
|
|
1870
|
+
),
|
|
1871
|
+
),
|
|
1872
|
+
);
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1875
|
+
/** Page-scoped stylesheet; every color is a theme token. */
|
|
1876
|
+
const CSS = [
|
|
1877
|
+
'.ez-page{box-sizing:border-box;display:flex;flex-direction:column;flex:1 1 auto;height:100%;min-height:0;overflow-y:auto;background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary)}',
|
|
1878
|
+
'.ez-inner{box-sizing:border-box;display:flex;flex-direction:column;flex:1 1 auto;width:100%;max-width:1100px;min-height:0;margin:0 auto;padding:22px 24px 20px}',
|
|
1879
|
+
'html[data-platform=darwin] .ez-inner{padding-top:calc(22px + var(--dsh-frame-top-clearance,48px))}',
|
|
1880
|
+
'.ez-head{display:flex;flex:none;align-items:flex-end;justify-content:space-between;gap:16px;flex-wrap:wrap}',
|
|
1881
|
+
'.ez-heading{display:flex;flex-direction:column;gap:4px;min-width:0}',
|
|
1882
|
+
'.ez-head-actions{display:flex;flex:none;align-items:center;gap:10px}',
|
|
1883
|
+
'.ez-page-title{margin:0;font-size:20px;line-height:28px;font-weight:600;letter-spacing:-.01em}',
|
|
1884
|
+
'.ez-sub{margin:0;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary);letter-spacing:.02em}',
|
|
1885
|
+
'.ez-seg{display:inline-flex;flex:none;gap:2px;padding:2px;border:.5px solid var(--dsw-alias-border-l2);border-radius:9px;background:var(--dsw-alias-bg-layer-1)}',
|
|
1886
|
+
'.ez-seg-btn{box-sizing:border-box;display:inline-flex;align-items:center;gap:6px;height:26px;margin:0;padding:0 11px;border:0;border-radius:7px;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:12.5px;line-height:1;cursor:pointer;appearance:none;-webkit-appearance:none}',
|
|
1887
|
+
'.ez-seg-btn:hover{color:var(--dsw-alias-label-primary)}',
|
|
1888
|
+
'.ez-seg-btn.is-active{background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary)}',
|
|
1889
|
+
'.ez-seg-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}',
|
|
1890
|
+
'.ez-seg--sm .ez-seg-btn{height:24px;padding:0 9px;font-size:11.5px}',
|
|
1891
|
+
'.ez-count{font-size:11px;line-height:1;color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums}',
|
|
1892
|
+
'.ez-icon-btn{box-sizing:border-box;display:grid;place-items:center;width:28px;height:28px;margin:0;padding:0;border:.5px solid var(--dsw-alias-border-l2);border-radius:8px;background:transparent;color:var(--dsw-alias-label-secondary);cursor:pointer;appearance:none;-webkit-appearance:none}',
|
|
1893
|
+
'.ez-icon-btn:hover{background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary)}',
|
|
1894
|
+
'.ez-icon-btn.is-on{background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary)}',
|
|
1895
|
+
'.ez-icon-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}',
|
|
1896
|
+
'.ez-settings{display:flex;flex:none;flex-direction:column;gap:10px;margin-top:14px;padding:12px 14px;border:.5px solid var(--dsw-alias-border-l1);border-radius:10px;background:var(--dsw-alias-bg-layer-1)}',
|
|
1897
|
+
'.ez-set-row{display:flex;align-items:center;gap:12px;flex-wrap:wrap}',
|
|
1898
|
+
'.ez-set-about{display:flex;align-items:center;flex-wrap:wrap;gap:6px 14px;margin-top:4px;padding-top:10px;border-top:.5px solid var(--dsw-alias-border-l1)}',
|
|
1899
|
+
'.ez-about-dev{display:inline-flex;align-items:center;gap:5px;margin-left:auto;font-size:12px;line-height:1;color:var(--dsw-alias-label-secondary)}',
|
|
1900
|
+
'.ez-about-dev-label{font-style:italic}',
|
|
1901
|
+
'.ez-about-avatar{width:16px;height:16px;flex:0 0 auto;border-radius:50%;object-fit:cover;background:var(--dsw-alias-bg-layer-2)}',
|
|
1902
|
+
'.ez-about-link{display:inline-flex;align-items:center;gap:5px;padding:1px 0;border-radius:5px;color:var(--dsw-alias-label-secondary);font-size:12px;line-height:1;text-decoration:none;cursor:pointer;transition:color .16s ease}',
|
|
1903
|
+
'.ez-about-link:hover,.ez-about-link:focus-visible{color:var(--dsw-alias-brand-primary);text-decoration:underline;text-underline-offset:3px;outline:none}',
|
|
1904
|
+
'.ez-set-label{flex:none;width:68px;font-size:12px;line-height:1;color:var(--dsw-alias-label-secondary)}',
|
|
1905
|
+
'.ez-set-slider{display:flex;flex:1 1 auto;align-items:center;gap:10px;min-width:0}',
|
|
1906
|
+
'.ez-range{flex:1 1 120px;max-width:240px;height:18px;margin:0;accent-color:var(--dsw-alias-brand-primary);background:transparent}',
|
|
1907
|
+
'.ez-set-value{flex:none;width:44px;text-align:right;font-size:11px;line-height:1;color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums}',
|
|
1908
|
+
'.ez-text-field{box-sizing:border-box;flex:0 1 260px;min-width:0;height:28px;margin:0;padding:0 9px;border:.5px solid var(--dsw-alias-border-l2);border-radius:7px;background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);font:inherit;font-size:12px;outline:none}',
|
|
1909
|
+
'.ez-text-field::placeholder{color:var(--dsw-alias-state-idle-primary)}',
|
|
1910
|
+
'.ez-text-field:focus{border-color:var(--dsw-alias-brand-primary)}',
|
|
1911
|
+
'.ez-reset--inline{margin-left:auto}',
|
|
1912
|
+
'.ez-reset{box-sizing:border-box;margin:0;padding:4px 9px;border:.5px solid var(--dsw-alias-border-l2);border-radius:7px;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:11.5px;line-height:1;cursor:pointer;appearance:none;-webkit-appearance:none}',
|
|
1913
|
+
'.ez-reset:hover{background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary)}',
|
|
1914
|
+
'.ez-reset:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}',
|
|
1915
|
+
'.ez-error{display:flex;flex:none;align-items:center;gap:10px;margin-top:10px;font-size:12px;line-height:18px;color:var(--dsw-alias-state-error-primary)}',
|
|
1916
|
+
'.ez-retry{box-sizing:border-box;margin:0;padding:0;border:0;background:transparent;color:inherit;font:inherit;font-size:12px;text-decoration:underline;text-underline-offset:2px;cursor:pointer;appearance:none;-webkit-appearance:none}',
|
|
1917
|
+
'.ez-retry:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px}',
|
|
1918
|
+
'.ez-body{display:flex;flex:1 1 auto;min-height:0}',
|
|
1919
|
+
'.ez-matrix{position:relative;display:grid;flex:1 1 auto;min-height:340px;grid-template-columns:1fr 1fr;grid-template-rows:1fr 1fr;margin-top:16px}',
|
|
1920
|
+
'.ez-matrix--cards{gap:14px}',
|
|
1921
|
+
'.ez-matrix--grid{gap:1px;border:.5px solid var(--dsw-alias-border-l1);border-radius:var(--ez-radius,10px);background:var(--dsw-alias-border-l1);overflow:hidden}',
|
|
1922
|
+
'.ez-matrix--cross{gap:0;border:0;border-radius:var(--ez-radius,10px);overflow:hidden}',
|
|
1923
|
+
'.ez-matrix--cross::before{content:"";position:absolute;top:0;bottom:0;left:calc(var(--ez-col-ratio,.5) * 100%);width:1px;margin-left:-.5px;background:var(--dsw-alias-border-l1);z-index:1;pointer-events:none}',
|
|
1924
|
+
'.ez-matrix--cross::after{content:"";position:absolute;left:0;right:0;top:calc(var(--ez-row-ratio,.5) * 100%);height:1px;margin-top:-.5px;background:var(--dsw-alias-border-l1);z-index:1;pointer-events:none}',
|
|
1925
|
+
'.ez-split{position:absolute;left:calc(var(--ez-col-ratio,.5) * 100%);top:calc(var(--ez-row-ratio,.5) * 100%);z-index:6;box-sizing:border-box;display:grid;place-items:center;width:20px;height:20px;margin:-10px 0 0 -10px;padding:0;border:.5px solid var(--dsw-alias-border-l2);border-radius:50%;background:var(--dsw-alias-bg-overlay);color:var(--dsw-alias-label-secondary);cursor:move;opacity:0;transition:opacity .12s ease,border-color .12s ease,color .12s ease;appearance:none;-webkit-appearance:none}',
|
|
1926
|
+
'.ez-split.is-visible,.ez-split:focus-visible{opacity:1}',
|
|
1927
|
+
'.ez-split-dot{display:block;width:6px;height:6px;border-radius:50%;background:currentColor}',
|
|
1928
|
+
'.ez-split:hover{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-brand-primary)}',
|
|
1929
|
+
'.ez-split:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}',
|
|
1930
|
+
'.ez-split.is-dragging{opacity:1;border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-brand-primary)}',
|
|
1931
|
+
'.ez-split.is-snap{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-brand-primary);box-shadow:0 0 0 4px color-mix(in srgb,var(--dsw-alias-brand-primary) 20%,transparent)}',
|
|
1932
|
+
'.ez-split-center{position:absolute;left:50%;top:50%;z-index:5;width:0;height:0;pointer-events:none;color:var(--dsw-alias-brand-primary);opacity:.85;transition:opacity .12s ease}',
|
|
1933
|
+
'.ez-split-center-h{position:absolute;left:-28px;top:-.5px;width:56px;height:1px;background:linear-gradient(to right,transparent,currentColor 22%,currentColor 78%,transparent);opacity:.55;transition:opacity .12s ease}',
|
|
1934
|
+
'.ez-split-center-v{position:absolute;top:-28px;left:-.5px;height:56px;width:1px;background:linear-gradient(to bottom,transparent,currentColor 22%,currentColor 78%,transparent);opacity:.55;transition:opacity .12s ease}',
|
|
1935
|
+
'.ez-split-center-dot{position:absolute;left:-3px;top:-3px;width:6px;height:6px;border-radius:50%;background:currentColor;opacity:.9;transition:transform .12s ease,box-shadow .12s ease,opacity .12s ease}',
|
|
1936
|
+
'.ez-split-center.is-active{opacity:1}',
|
|
1937
|
+
'.ez-split-center.is-active .ez-split-center-h,.ez-split-center.is-active .ez-split-center-v{opacity:.95}',
|
|
1938
|
+
'.ez-split-center.is-active .ez-split-center-dot{opacity:1;transform:scale(1.35);box-shadow:0 0 0 4px color-mix(in srgb,var(--dsw-alias-brand-primary) 22%,transparent)}',
|
|
1939
|
+
'@media (hover:none){.ez-split{opacity:1}}',
|
|
1940
|
+
'.ez-matrix--truncate .ez-title{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;overflow-wrap:normal;word-break:normal}',
|
|
1941
|
+
'.ez-quad{box-sizing:border-box;display:flex;flex-direction:column;min-width:0;min-height:0;overflow:hidden}',
|
|
1942
|
+
'.ez-matrix--cards .ez-quad{padding:12px 13px 9px;border:.5px solid var(--dsw-alias-border-l1);border-radius:var(--ez-radius,10px);background:var(--dsw-alias-bg-layer-1)}',
|
|
1943
|
+
'.ez-matrix--grid .ez-quad{padding:12px 13px 9px;border:0;border-radius:0;background:var(--dsw-alias-bg-layer-1)}',
|
|
1944
|
+
'.ez-matrix--cross .ez-quad{padding:12px 13px 9px;border:0;border-radius:0;background:transparent}',
|
|
1945
|
+
'.ez-matrix--tint .ez-quad--q1{background:var(--dsw-alias-bg-layer-1);background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 8%,var(--dsw-alias-bg-layer-1))}',
|
|
1946
|
+
'.ez-matrix--tint .ez-quad--q2{background:var(--dsw-alias-bg-layer-1);background:color-mix(in srgb,var(--dsw-alias-brand-primary) 7%,var(--dsw-alias-bg-layer-1))}',
|
|
1947
|
+
'.ez-matrix--tint .ez-quad--q3{background:var(--dsw-alias-bg-layer-1);background:color-mix(in srgb,var(--dsw-alias-state-warn-primary) 9%,var(--dsw-alias-bg-layer-1))}',
|
|
1948
|
+
'.ez-matrix--tint .ez-quad--q4{background:var(--dsw-alias-bg-layer-1);background:color-mix(in srgb,var(--dsw-alias-state-idle-primary) 9%,var(--dsw-alias-bg-layer-1))}',
|
|
1949
|
+
'.ez-quad-head{display:flex;flex:none;align-items:center;gap:7px;height:24px}',
|
|
1950
|
+
'.ez-dot{flex:none;width:6px;height:6px;border-radius:50%}',
|
|
1951
|
+
'.ez-quad--q1 .ez-dot{background:var(--dsw-alias-state-error-primary)}',
|
|
1952
|
+
'.ez-quad--q2 .ez-dot{background:var(--dsw-alias-brand-primary)}',
|
|
1953
|
+
'.ez-quad--q3 .ez-dot{background:var(--dsw-alias-state-warn-primary)}',
|
|
1954
|
+
'.ez-quad--q4 .ez-dot{background:var(--dsw-alias-state-idle-primary)}',
|
|
1955
|
+
'.ez-quad-name{margin:0;font-size:13px;line-height:1;font-weight:600;letter-spacing:.01em;white-space:nowrap}',
|
|
1956
|
+
'.ez-quad-hint{min-width:0;font-size:11px;line-height:1;color:var(--dsw-alias-label-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
|
|
1957
|
+
'.ez-quad-count{margin-left:auto;font-size:11px;line-height:1;color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums}',
|
|
1958
|
+
'.ez-list{display:flex;flex:1 1 auto;flex-direction:column;gap:1px;min-height:0;margin:6px 0 0;padding:0;list-style:none;overflow-y:auto}',
|
|
1959
|
+
'.ez-row{display:flex;flex:none;align-items:flex-start;gap:8px;min-height:30px;padding:4px 2px 4px 3px;border-radius:7px}',
|
|
1960
|
+
'.ez-row:hover{background:var(--dsw-alias-bg-layer-2)}',
|
|
1961
|
+
'.ez-check{box-sizing:border-box;flex:none;width:15px;height:15px;margin:calc((var(--ez-font-size,13px) * 1.55 - 15px) / 2) 0 0 0;padding:0;accent-color:var(--dsw-alias-brand-primary);cursor:pointer}',
|
|
1962
|
+
'.ez-check:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px}',
|
|
1963
|
+
'.ez-title{flex:1 1 auto;min-width:0;font-size:var(--ez-font-size,13px);line-height:1.55;white-space:normal;overflow-wrap:anywhere;word-break:break-word;cursor:text}',
|
|
1964
|
+
'.ez-title-input{flex:1 1 auto;min-width:0;margin:0;padding:0 0 1px;border:0;border-bottom:1px solid var(--dsw-alias-brand-primary,currentColor);border-radius:0;background:transparent;color:inherit;font:inherit;font-size:var(--ez-font-size,13px);line-height:1.55;outline:none;white-space:normal;overflow-wrap:anywhere;word-break:break-word}',
|
|
1965
|
+
'.ez-title--done{color:var(--dsw-alias-label-secondary);text-decoration:line-through;text-decoration-thickness:.5px}',
|
|
1966
|
+
'.ez-date{flex:none;margin-top:calc((var(--ez-font-size,13px) * 1.55 - 22px) / 2);font-size:calc(var(--ez-font-size,13px) * .82);line-height:22px;color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums}',
|
|
1967
|
+
'.ez-actions{display:flex;flex:none;align-items:center;justify-content:flex-end;gap:2px;width:0;overflow:hidden;margin-top:calc((var(--ez-font-size,13px) * 1.55 - 22px) / 2);opacity:0;transition:width .13s ease,opacity .13s ease}',
|
|
1968
|
+
'.ez-row:hover .ez-actions,.ez-row:focus-within .ez-actions{width:96px;opacity:1}',
|
|
1969
|
+
'@media (hover:none){.ez-actions{width:96px;opacity:1}}',
|
|
1970
|
+
'.ez-mini{box-sizing:border-box;display:grid;place-items:center;width:22px;height:22px;margin:0;padding:0;border:0;border-radius:5px;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;cursor:pointer;appearance:none;-webkit-appearance:none}',
|
|
1971
|
+
'.ez-mini:hover{background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary)}',
|
|
1972
|
+
'.ez-mini.is-on{color:var(--dsw-alias-brand-primary)}',
|
|
1973
|
+
'.ez-mini:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}',
|
|
1974
|
+
'.ez-add-area{display:flex;flex:none;align-items:center;flex-wrap:wrap;gap:6px;margin-top:6px}',
|
|
1975
|
+
'.ez-date-field{box-sizing:border-box;flex:none;display:inline-flex;align-items:center;justify-content:center;gap:5px;height:30px;margin:0;padding:0 8px;border:.5px solid var(--dsw-alias-border-l2);border-radius:7px;background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-secondary);font:inherit;font-size:11.5px;line-height:1;cursor:pointer;appearance:none;-webkit-appearance:none}',
|
|
1976
|
+
'.ez-date-field--empty{flex:0 0 40px;width:40px;padding:0}',
|
|
1977
|
+
'.ez-date-field--set{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums}',
|
|
1978
|
+
'.ez-date-field:hover{border-color:var(--dsw-alias-border-l3);color:var(--dsw-alias-label-primary)}',
|
|
1979
|
+
'.ez-date-field:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}',
|
|
1980
|
+
'.ez-picker{position:fixed;z-index:70;box-sizing:border-box;width:252px;padding:10px;border:.5px solid var(--dsw-alias-border-l2);border-radius:12px;background:var(--dsw-alias-bg-overlay);box-shadow:0 16px 44px color-mix(in srgb,var(--dsw-alias-label-primary) 16%,transparent);user-select:none}',
|
|
1981
|
+
'.ez-picker-head{display:flex;align-items:center;justify-content:space-between;gap:4px;height:28px;margin-bottom:6px}',
|
|
1982
|
+
'.ez-picker-title{font-size:12.5px;line-height:1;font-weight:600;color:var(--dsw-alias-label-primary)}',
|
|
1983
|
+
'.ez-picker-nav{box-sizing:border-box;display:grid;place-items:center;width:24px;height:24px;margin:0;padding:0;border:0;border-radius:6px;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:15px;line-height:1;cursor:pointer;appearance:none;-webkit-appearance:none}',
|
|
1984
|
+
'.ez-picker-nav:hover{background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary)}',
|
|
1985
|
+
'.ez-picker-nav:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}',
|
|
1986
|
+
'.ez-picker-grid{display:grid;grid-template-columns:repeat(7,1fr);gap:2px}',
|
|
1987
|
+
'.ez-picker-grid--wd{margin-bottom:2px}',
|
|
1988
|
+
'.ez-picker-wd{display:grid;place-items:center;height:22px;font-size:10.5px;line-height:1;color:var(--dsw-alias-label-secondary)}',
|
|
1989
|
+
'.ez-picker-cell{display:block;height:28px}',
|
|
1990
|
+
'.ez-picker-day{box-sizing:border-box;display:grid;place-items:center;width:100%;height:28px;margin:0;padding:0;border:0;border-radius:7px;background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:11.5px;line-height:1;cursor:pointer;appearance:none;-webkit-appearance:none;font-variant-numeric:tabular-nums}',
|
|
1991
|
+
'.ez-picker-day:hover{background:var(--dsw-alias-bg-layer-2)}',
|
|
1992
|
+
'.ez-picker-day:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:-1px}',
|
|
1993
|
+
'.ez-picker-day.is-today{color:var(--dsw-alias-brand-primary);font-weight:600}',
|
|
1994
|
+
'.ez-picker-day.is-selected{background:var(--dsw-alias-brand-primary);color:var(--dsw-alias-bg-base);font-weight:600}',
|
|
1995
|
+
'.ez-picker-day.is-selected:hover{opacity:.9}',
|
|
1996
|
+
'.ez-picker-foot{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-top:8px;padding-top:8px;border-top:.5px solid var(--dsw-alias-border-l1)}',
|
|
1997
|
+
'.ez-picker-link{box-sizing:border-box;margin:0;padding:3px 5px;border:0;border-radius:5px;background:transparent;color:var(--dsw-alias-brand-primary);font:inherit;font-size:11.5px;line-height:1;cursor:pointer;appearance:none;-webkit-appearance:none}',
|
|
1998
|
+
'.ez-picker-link:hover:not(:disabled){background:var(--dsw-alias-bg-layer-2)}',
|
|
1999
|
+
'.ez-picker-link:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}',
|
|
2000
|
+
'.ez-picker-link:disabled{color:var(--dsw-alias-state-idle-primary);cursor:default}',
|
|
2001
|
+
'.ez-due{box-sizing:border-box;flex:none;display:inline-flex;align-items:center;height:22px;line-height:22px;margin:calc((var(--ez-font-size,13px) * 1.55 - 22px) / 2) 0 0 6px;padding:0 1px;border:0;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:calc(var(--ez-font-size,13px) * .82);cursor:pointer;appearance:none;-webkit-appearance:none;font-variant-numeric:tabular-nums;white-space:nowrap}',
|
|
2002
|
+
'.ez-due:hover{color:var(--dsw-alias-label-primary)}',
|
|
2003
|
+
'.ez-due:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px;border-radius:4px}',
|
|
2004
|
+
'.ez-due--today{color:var(--dsw-alias-state-warn-primary);font-weight:600}',
|
|
2005
|
+
'.ez-due--overdue{color:var(--dsw-alias-state-error-primary);font-weight:600}',
|
|
2006
|
+
'.ez-row[draggable=true]{cursor:grab}',
|
|
2007
|
+
'.ez-row[draggable=true]:active{cursor:grabbing}',
|
|
2008
|
+
'.ez-row.is-overdue .ez-title{color:var(--dsw-alias-state-error-primary)}',
|
|
2009
|
+
'.ez-row.is-dragging{opacity:.35}',
|
|
2010
|
+
'.ez-row.is-drop-before{box-shadow:inset 0 2px 0 var(--dsw-alias-brand-primary)}',
|
|
2011
|
+
'.ez-list.is-drop-end::after{content:"";display:block;flex:none;height:2px;margin:1px 2px 0;border-radius:2px;background:var(--dsw-alias-brand-primary)}',
|
|
2012
|
+
'.ez-quad.is-drop-target{outline:1px dashed var(--dsw-alias-brand-primary);outline-offset:-3px}',
|
|
2013
|
+
'.ez-toast{position:fixed;left:50%;top:50%;transform:translate(-50%,-50%);z-index:60;pointer-events:none;display:flex;align-items:center;gap:10px;max-width:min(360px,calc(100vw - 64px));padding:16px 24px;border:.5px solid var(--dsw-alias-border-l2);border-radius:14px;background:var(--dsw-alias-bg-overlay);color:var(--dsw-alias-label-primary);font-size:14.5px;line-height:1.5;box-shadow:0 16px 44px color-mix(in srgb,var(--dsw-alias-label-primary) 18%,transparent);animation:ez-toast-in .24s ease-out}',
|
|
2014
|
+
'.ez-toast-mark{display:grid;place-items:center;flex:none;width:22px;height:22px;border-radius:50%;background:var(--dsw-alias-state-success-primary);color:var(--dsw-alias-bg-overlay);font-size:12px;font-weight:700;line-height:1}',
|
|
2015
|
+
'.ez-toast--cheer{border-color:color-mix(in srgb,var(--dsw-alias-brand-primary) 42%,var(--dsw-alias-border-l2))}',
|
|
2016
|
+
'.ez-toast--cheer .ez-toast-mark{background:var(--dsw-alias-brand-primary);font-size:13px}',
|
|
2017
|
+
'@keyframes ez-toast-in{from{opacity:0;transform:translate(-50%,-50%) scale(.95)}to{opacity:1;transform:translate(-50%,-50%) scale(1)}}',
|
|
2018
|
+
'.ez-add-input::placeholder{color:var(--dsw-alias-state-idle-primary)}',
|
|
2019
|
+
'.ez-quick-add{box-sizing:border-box;display:flex;align-items:center;gap:6px;height:26px;margin:0;padding:0 6px;border:0;border-radius:6px;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:12px;line-height:1;cursor:pointer;opacity:.78;appearance:none;-webkit-appearance:none}',
|
|
2020
|
+
'.ez-quick-add:hover{opacity:1;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary)}',
|
|
2021
|
+
'.ez-quick-add:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}',
|
|
2022
|
+
'.ez-quick-plus{font-size:14px;line-height:1}',
|
|
2023
|
+
'.ez-add-input{box-sizing:border-box;flex:1 1 auto;min-width:0;width:auto;height:30px;margin:0;padding:0 9px;border:.5px solid var(--dsw-alias-brand-primary);border-radius:7px;background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);font:inherit;font-size:var(--ez-font-size,13px);outline:none}',
|
|
2024
|
+
'.ez-add-input::placeholder{color:var(--dsw-alias-state-idle-primary)}',
|
|
2025
|
+
'.ez-completed{box-sizing:border-box;display:flex;flex:1 1 auto;flex-direction:column;min-height:0;margin-top:16px;border:.5px solid var(--dsw-alias-border-l1);border-radius:10px;background:var(--dsw-alias-bg-layer-1)}',
|
|
2026
|
+
'.ez-completed-head{display:flex;flex:none;align-items:center;gap:8px;padding:12px 13px 6px}',
|
|
2027
|
+
'.ez-completed-title{margin:0;font-size:13px;line-height:1;font-weight:600}',
|
|
2028
|
+
'.ez-completed-count{font-size:11px;line-height:1;color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums}',
|
|
2029
|
+
'.ez-clear{box-sizing:border-box;margin:0 0 0 auto;padding:4px 9px;border:.5px solid var(--dsw-alias-border-l2);border-radius:7px;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:11.5px;line-height:1;cursor:pointer;appearance:none;-webkit-appearance:none}',
|
|
2030
|
+
'.ez-clear:hover{background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary)}',
|
|
2031
|
+
'.ez-clear.is-confirming{border-color:var(--dsw-alias-state-error-primary);color:var(--dsw-alias-state-error-primary)}',
|
|
2032
|
+
'.ez-clear:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}',
|
|
2033
|
+
'.ez-completed .ez-list{padding:0 11px 9px}',
|
|
2034
|
+
'.ez-completed-body{display:flex;flex:1 1 auto;min-height:0}',
|
|
2035
|
+
'.ez-blank{margin:0;padding:20px;font-size:12.5px;line-height:20px;text-align:center;color:var(--dsw-alias-label-secondary)}',
|
|
2036
|
+
'.ez-completed-body .ez-blank{margin:auto}',
|
|
2037
|
+
'@media (max-width:640px){.ez-inner{padding:16px 14px}.ez-matrix{min-height:420px;margin-top:12px}.ez-matrix--cards{gap:9px}.ez-matrix--cards .ez-quad,.ez-matrix--grid .ez-quad,.ez-matrix--cross .ez-quad{padding:10px 10px 7px}.ez-quad-hint{display:none}.ez-head-actions{width:100%;justify-content:space-between}.ez-set-label{width:100%}}',
|
|
2038
|
+
'@media (prefers-reduced-motion:reduce){.ez-actions{transition:none}}',
|
|
2039
|
+
].join('\n');
|
|
2040
|
+
|
|
2041
|
+
return {
|
|
2042
|
+
inject: ['slots', 'locale'],
|
|
2043
|
+
apply(ctx) {
|
|
2044
|
+
ctx.effect(() => ctx.locale.register(NS, { en: EN, zh: ZH }), 'matrix-todo: dictionaries');
|
|
2045
|
+
const t = ctx.locale.bind(NS);
|
|
2046
|
+
// Detached service methods lose their receiver, so the page binds
|
|
2047
|
+
// through stable wrappers instead of passing `locale.subscribe` directly.
|
|
2048
|
+
const localeSource = Object.freeze({
|
|
2049
|
+
subscribe: (listener) => ctx.locale.subscribe(listener),
|
|
2050
|
+
getSnapshot: () => ctx.locale.getSnapshot(),
|
|
2051
|
+
});
|
|
1839
2052
|
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
'.ez-head{display:flex;flex:none;align-items:flex-end;justify-content:space-between;gap:16px;flex-wrap:wrap}',
|
|
1846
|
-
'.ez-heading{display:flex;flex-direction:column;gap:4px;min-width:0}',
|
|
1847
|
-
'.ez-head-actions{display:flex;flex:none;align-items:center;gap:10px}',
|
|
1848
|
-
'.ez-page-title{margin:0;font-size:20px;line-height:28px;font-weight:600;letter-spacing:-.01em}',
|
|
1849
|
-
'.ez-sub{margin:0;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary);letter-spacing:.02em}',
|
|
1850
|
-
'.ez-seg{display:inline-flex;flex:none;gap:2px;padding:2px;border:.5px solid var(--dsw-alias-border-l2);border-radius:9px;background:var(--dsw-alias-bg-layer-1)}',
|
|
1851
|
-
'.ez-seg-btn{box-sizing:border-box;display:inline-flex;align-items:center;gap:6px;height:26px;margin:0;padding:0 11px;border:0;border-radius:7px;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:12.5px;line-height:1;cursor:pointer;appearance:none;-webkit-appearance:none}',
|
|
1852
|
-
'.ez-seg-btn:hover{color:var(--dsw-alias-label-primary)}',
|
|
1853
|
-
'.ez-seg-btn.is-active{background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary)}',
|
|
1854
|
-
'.ez-seg-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}',
|
|
1855
|
-
'.ez-seg--sm .ez-seg-btn{height:24px;padding:0 9px;font-size:11.5px}',
|
|
1856
|
-
'.ez-count{font-size:11px;line-height:1;color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums}',
|
|
1857
|
-
'.ez-icon-btn{box-sizing:border-box;display:grid;place-items:center;width:28px;height:28px;margin:0;padding:0;border:.5px solid var(--dsw-alias-border-l2);border-radius:8px;background:transparent;color:var(--dsw-alias-label-secondary);cursor:pointer;appearance:none;-webkit-appearance:none}',
|
|
1858
|
-
'.ez-icon-btn:hover{background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary)}',
|
|
1859
|
-
'.ez-icon-btn.is-on{background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary)}',
|
|
1860
|
-
'.ez-icon-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}',
|
|
1861
|
-
'.ez-settings{display:flex;flex:none;flex-direction:column;gap:10px;margin-top:14px;padding:12px 14px;border:.5px solid var(--dsw-alias-border-l1);border-radius:10px;background:var(--dsw-alias-bg-layer-1)}',
|
|
1862
|
-
'.ez-set-row{display:flex;align-items:center;gap:12px;flex-wrap:wrap}',
|
|
1863
|
-
'.ez-set-about{display:flex;align-items:center;flex-wrap:wrap;gap:6px 14px;margin-top:4px;padding-top:10px;border-top:.5px solid var(--dsw-alias-border-l1)}',
|
|
1864
|
-
'.ez-about-dev{display:inline-flex;align-items:center;gap:5px;margin-left:auto;font-size:12px;line-height:1;color:var(--dsw-alias-label-secondary)}',
|
|
1865
|
-
'.ez-about-dev-label{font-style:italic}',
|
|
1866
|
-
'.ez-about-avatar{width:16px;height:16px;flex:0 0 auto;border-radius:50%;object-fit:cover;background:var(--dsw-alias-bg-layer-2)}',
|
|
1867
|
-
'.ez-about-link{display:inline-flex;align-items:center;gap:5px;padding:1px 0;border-radius:5px;color:var(--dsw-alias-label-secondary);font-size:12px;line-height:1;text-decoration:none;cursor:pointer;transition:color .16s ease}',
|
|
1868
|
-
'.ez-about-link:hover,.ez-about-link:focus-visible{color:var(--dsw-alias-brand-primary);text-decoration:underline;text-underline-offset:3px;outline:none}',
|
|
1869
|
-
'.ez-set-label{flex:none;width:68px;font-size:12px;line-height:1;color:var(--dsw-alias-label-secondary)}',
|
|
1870
|
-
'.ez-set-slider{display:flex;flex:1 1 auto;align-items:center;gap:10px;min-width:0}',
|
|
1871
|
-
'.ez-range{flex:1 1 120px;max-width:240px;height:18px;margin:0;accent-color:var(--dsw-alias-brand-primary);background:transparent}',
|
|
1872
|
-
'.ez-set-value{flex:none;width:44px;text-align:right;font-size:11px;line-height:1;color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums}',
|
|
1873
|
-
'.ez-text-field{box-sizing:border-box;flex:0 1 260px;min-width:0;height:28px;margin:0;padding:0 9px;border:.5px solid var(--dsw-alias-border-l2);border-radius:7px;background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);font:inherit;font-size:12px;outline:none}',
|
|
1874
|
-
'.ez-text-field::placeholder{color:var(--dsw-alias-state-idle-primary)}',
|
|
1875
|
-
'.ez-text-field:focus{border-color:var(--dsw-alias-brand-primary)}',
|
|
1876
|
-
'.ez-reset--inline{margin-left:auto}',
|
|
1877
|
-
'.ez-reset{box-sizing:border-box;margin:0;padding:4px 9px;border:.5px solid var(--dsw-alias-border-l2);border-radius:7px;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:11.5px;line-height:1;cursor:pointer;appearance:none;-webkit-appearance:none}',
|
|
1878
|
-
'.ez-reset:hover{background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary)}',
|
|
1879
|
-
'.ez-reset:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}',
|
|
1880
|
-
'.ez-error{display:flex;flex:none;align-items:center;gap:10px;margin-top:10px;font-size:12px;line-height:18px;color:var(--dsw-alias-state-error-primary)}',
|
|
1881
|
-
'.ez-retry{box-sizing:border-box;margin:0;padding:0;border:0;background:transparent;color:inherit;font:inherit;font-size:12px;text-decoration:underline;text-underline-offset:2px;cursor:pointer;appearance:none;-webkit-appearance:none}',
|
|
1882
|
-
'.ez-retry:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px}',
|
|
1883
|
-
'.ez-body{display:flex;flex:1 1 auto;min-height:0}',
|
|
1884
|
-
'.ez-matrix{position:relative;display:grid;flex:1 1 auto;min-height:340px;grid-template-columns:1fr 1fr;grid-template-rows:1fr 1fr;margin-top:16px}',
|
|
1885
|
-
'.ez-matrix--cards{gap:14px}',
|
|
1886
|
-
'.ez-matrix--grid{gap:1px;border:.5px solid var(--dsw-alias-border-l1);border-radius:var(--ez-radius,10px);background:var(--dsw-alias-border-l1);overflow:hidden}',
|
|
1887
|
-
'.ez-matrix--cross{gap:0;border:0;border-radius:var(--ez-radius,10px);overflow:hidden}',
|
|
1888
|
-
'.ez-matrix--cross::before{content:"";position:absolute;top:0;bottom:0;left:calc(var(--ez-col-ratio,.5) * 100%);width:1px;margin-left:-.5px;background:var(--dsw-alias-border-l1);z-index:1;pointer-events:none}',
|
|
1889
|
-
'.ez-matrix--cross::after{content:"";position:absolute;left:0;right:0;top:calc(var(--ez-row-ratio,.5) * 100%);height:1px;margin-top:-.5px;background:var(--dsw-alias-border-l1);z-index:1;pointer-events:none}',
|
|
1890
|
-
'.ez-split{position:absolute;left:calc(var(--ez-col-ratio,.5) * 100%);top:calc(var(--ez-row-ratio,.5) * 100%);z-index:6;box-sizing:border-box;display:grid;place-items:center;width:20px;height:20px;margin:-10px 0 0 -10px;padding:0;border:.5px solid var(--dsw-alias-border-l2);border-radius:50%;background:var(--dsw-alias-bg-overlay);color:var(--dsw-alias-label-secondary);cursor:move;opacity:0;transition:opacity .12s ease,border-color .12s ease,color .12s ease;appearance:none;-webkit-appearance:none}',
|
|
1891
|
-
'.ez-split.is-visible,.ez-split:focus-visible{opacity:1}',
|
|
1892
|
-
'.ez-split-dot{display:block;width:6px;height:6px;border-radius:50%;background:currentColor}',
|
|
1893
|
-
'.ez-split:hover{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-brand-primary)}',
|
|
1894
|
-
'.ez-split:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}',
|
|
1895
|
-
'.ez-split.is-dragging{opacity:1;border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-brand-primary)}',
|
|
1896
|
-
'.ez-split.is-snap{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-brand-primary);box-shadow:0 0 0 4px color-mix(in srgb,var(--dsw-alias-brand-primary) 20%,transparent)}',
|
|
1897
|
-
'.ez-split-center{position:absolute;left:50%;top:50%;z-index:5;width:0;height:0;pointer-events:none;color:var(--dsw-alias-brand-primary);opacity:.85;transition:opacity .12s ease}',
|
|
1898
|
-
'.ez-split-center-h{position:absolute;left:-28px;top:-.5px;width:56px;height:1px;background:linear-gradient(to right,transparent,currentColor 22%,currentColor 78%,transparent);opacity:.55;transition:opacity .12s ease}',
|
|
1899
|
-
'.ez-split-center-v{position:absolute;top:-28px;left:-.5px;height:56px;width:1px;background:linear-gradient(to bottom,transparent,currentColor 22%,currentColor 78%,transparent);opacity:.55;transition:opacity .12s ease}',
|
|
1900
|
-
'.ez-split-center-dot{position:absolute;left:-3px;top:-3px;width:6px;height:6px;border-radius:50%;background:currentColor;opacity:.9;transition:transform .12s ease,box-shadow .12s ease,opacity .12s ease}',
|
|
1901
|
-
'.ez-split-center.is-active{opacity:1}',
|
|
1902
|
-
'.ez-split-center.is-active .ez-split-center-h,.ez-split-center.is-active .ez-split-center-v{opacity:.95}',
|
|
1903
|
-
'.ez-split-center.is-active .ez-split-center-dot{opacity:1;transform:scale(1.35);box-shadow:0 0 0 4px color-mix(in srgb,var(--dsw-alias-brand-primary) 22%,transparent)}',
|
|
1904
|
-
'@media (hover:none){.ez-split{opacity:1}}',
|
|
1905
|
-
'.ez-matrix--truncate .ez-title{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;overflow-wrap:normal;word-break:normal}',
|
|
1906
|
-
'.ez-quad{box-sizing:border-box;display:flex;flex-direction:column;min-width:0;min-height:0;overflow:hidden}',
|
|
1907
|
-
'.ez-matrix--cards .ez-quad{padding:12px 13px 9px;border:.5px solid var(--dsw-alias-border-l1);border-radius:var(--ez-radius,10px);background:var(--dsw-alias-bg-layer-1)}',
|
|
1908
|
-
'.ez-matrix--grid .ez-quad{padding:12px 13px 9px;border:0;border-radius:0;background:var(--dsw-alias-bg-layer-1)}',
|
|
1909
|
-
'.ez-matrix--cross .ez-quad{padding:12px 13px 9px;border:0;border-radius:0;background:transparent}',
|
|
1910
|
-
'.ez-matrix--tint .ez-quad--q1{background:var(--dsw-alias-bg-layer-1);background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 8%,var(--dsw-alias-bg-layer-1))}',
|
|
1911
|
-
'.ez-matrix--tint .ez-quad--q2{background:var(--dsw-alias-bg-layer-1);background:color-mix(in srgb,var(--dsw-alias-brand-primary) 7%,var(--dsw-alias-bg-layer-1))}',
|
|
1912
|
-
'.ez-matrix--tint .ez-quad--q3{background:var(--dsw-alias-bg-layer-1);background:color-mix(in srgb,var(--dsw-alias-state-warn-primary) 9%,var(--dsw-alias-bg-layer-1))}',
|
|
1913
|
-
'.ez-matrix--tint .ez-quad--q4{background:var(--dsw-alias-bg-layer-1);background:color-mix(in srgb,var(--dsw-alias-state-idle-primary) 9%,var(--dsw-alias-bg-layer-1))}',
|
|
1914
|
-
'.ez-quad-head{display:flex;flex:none;align-items:center;gap:7px;height:24px}',
|
|
1915
|
-
'.ez-dot{flex:none;width:6px;height:6px;border-radius:50%}',
|
|
1916
|
-
'.ez-quad--q1 .ez-dot{background:var(--dsw-alias-state-error-primary)}',
|
|
1917
|
-
'.ez-quad--q2 .ez-dot{background:var(--dsw-alias-brand-primary)}',
|
|
1918
|
-
'.ez-quad--q3 .ez-dot{background:var(--dsw-alias-state-warn-primary)}',
|
|
1919
|
-
'.ez-quad--q4 .ez-dot{background:var(--dsw-alias-state-idle-primary)}',
|
|
1920
|
-
'.ez-quad-name{margin:0;font-size:13px;line-height:1;font-weight:600;letter-spacing:.01em;white-space:nowrap}',
|
|
1921
|
-
'.ez-quad-hint{min-width:0;font-size:11px;line-height:1;color:var(--dsw-alias-label-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
|
|
1922
|
-
'.ez-quad-count{margin-left:auto;font-size:11px;line-height:1;color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums}',
|
|
1923
|
-
'.ez-list{display:flex;flex:1 1 auto;flex-direction:column;gap:1px;min-height:0;margin:6px 0 0;padding:0;list-style:none;overflow-y:auto}',
|
|
1924
|
-
'.ez-row{display:flex;flex:none;align-items:flex-start;gap:8px;min-height:30px;padding:4px 2px 4px 3px;border-radius:7px}',
|
|
1925
|
-
'.ez-row:hover{background:var(--dsw-alias-bg-layer-2)}',
|
|
1926
|
-
'.ez-check{box-sizing:border-box;flex:none;width:15px;height:15px;margin:calc((var(--ez-font-size,13px) * 1.55 - 15px) / 2) 0 0 0;padding:0;accent-color:var(--dsw-alias-brand-primary);cursor:pointer}',
|
|
1927
|
-
'.ez-check:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px}',
|
|
1928
|
-
'.ez-title{flex:1 1 auto;min-width:0;font-size:var(--ez-font-size,13px);line-height:1.55;white-space:normal;overflow-wrap:anywhere;word-break:break-word;cursor:text}',
|
|
1929
|
-
'.ez-title-input{flex:1 1 auto;min-width:0;margin:0;padding:0 0 1px;border:0;border-bottom:1px solid var(--dsw-alias-brand-primary,currentColor);border-radius:0;background:transparent;color:inherit;font:inherit;font-size:var(--ez-font-size,13px);line-height:1.55;outline:none;white-space:normal;overflow-wrap:anywhere;word-break:break-word}',
|
|
1930
|
-
'.ez-title--done{color:var(--dsw-alias-label-secondary);text-decoration:line-through;text-decoration-thickness:.5px}',
|
|
1931
|
-
'.ez-date{flex:none;margin-top:calc((var(--ez-font-size,13px) * 1.55 - 22px) / 2);font-size:calc(var(--ez-font-size,13px) * .82);line-height:22px;color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums}',
|
|
1932
|
-
'.ez-actions{display:flex;flex:none;align-items:center;justify-content:flex-end;gap:2px;width:0;overflow:hidden;margin-top:calc((var(--ez-font-size,13px) * 1.55 - 22px) / 2);opacity:0;transition:width .13s ease,opacity .13s ease}',
|
|
1933
|
-
'.ez-row:hover .ez-actions,.ez-row:focus-within .ez-actions{width:96px;opacity:1}',
|
|
1934
|
-
'@media (hover:none){.ez-actions{width:96px;opacity:1}}',
|
|
1935
|
-
'.ez-mini{box-sizing:border-box;display:grid;place-items:center;width:22px;height:22px;margin:0;padding:0;border:0;border-radius:5px;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;cursor:pointer;appearance:none;-webkit-appearance:none}',
|
|
1936
|
-
'.ez-mini:hover{background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary)}',
|
|
1937
|
-
'.ez-mini.is-on{color:var(--dsw-alias-brand-primary)}',
|
|
1938
|
-
'.ez-mini:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}',
|
|
1939
|
-
'.ez-add-area{display:flex;flex:none;align-items:center;flex-wrap:wrap;gap:6px;margin-top:6px}',
|
|
1940
|
-
'.ez-date-field{box-sizing:border-box;flex:none;display:inline-flex;align-items:center;justify-content:center;gap:5px;height:30px;margin:0;padding:0 8px;border:.5px solid var(--dsw-alias-border-l2);border-radius:7px;background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-secondary);font:inherit;font-size:11.5px;line-height:1;cursor:pointer;appearance:none;-webkit-appearance:none}',
|
|
1941
|
-
'.ez-date-field--empty{flex:0 0 40px;width:40px;padding:0}',
|
|
1942
|
-
'.ez-date-field--set{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums}',
|
|
1943
|
-
'.ez-date-field:hover{border-color:var(--dsw-alias-border-l3);color:var(--dsw-alias-label-primary)}',
|
|
1944
|
-
'.ez-date-field:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}',
|
|
1945
|
-
'.ez-picker{position:fixed;z-index:70;box-sizing:border-box;width:252px;padding:10px;border:.5px solid var(--dsw-alias-border-l2);border-radius:12px;background:var(--dsw-alias-bg-overlay);box-shadow:0 16px 44px color-mix(in srgb,var(--dsw-alias-label-primary) 16%,transparent);user-select:none}',
|
|
1946
|
-
'.ez-picker-head{display:flex;align-items:center;justify-content:space-between;gap:4px;height:28px;margin-bottom:6px}',
|
|
1947
|
-
'.ez-picker-title{font-size:12.5px;line-height:1;font-weight:600;color:var(--dsw-alias-label-primary)}',
|
|
1948
|
-
'.ez-picker-nav{box-sizing:border-box;display:grid;place-items:center;width:24px;height:24px;margin:0;padding:0;border:0;border-radius:6px;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:15px;line-height:1;cursor:pointer;appearance:none;-webkit-appearance:none}',
|
|
1949
|
-
'.ez-picker-nav:hover{background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary)}',
|
|
1950
|
-
'.ez-picker-nav:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}',
|
|
1951
|
-
'.ez-picker-grid{display:grid;grid-template-columns:repeat(7,1fr);gap:2px}',
|
|
1952
|
-
'.ez-picker-grid--wd{margin-bottom:2px}',
|
|
1953
|
-
'.ez-picker-wd{display:grid;place-items:center;height:22px;font-size:10.5px;line-height:1;color:var(--dsw-alias-label-secondary)}',
|
|
1954
|
-
'.ez-picker-cell{display:block;height:28px}',
|
|
1955
|
-
'.ez-picker-day{box-sizing:border-box;display:grid;place-items:center;width:100%;height:28px;margin:0;padding:0;border:0;border-radius:7px;background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:11.5px;line-height:1;cursor:pointer;appearance:none;-webkit-appearance:none;font-variant-numeric:tabular-nums}',
|
|
1956
|
-
'.ez-picker-day:hover{background:var(--dsw-alias-bg-layer-2)}',
|
|
1957
|
-
'.ez-picker-day:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:-1px}',
|
|
1958
|
-
'.ez-picker-day.is-today{color:var(--dsw-alias-brand-primary);font-weight:600}',
|
|
1959
|
-
'.ez-picker-day.is-selected{background:var(--dsw-alias-brand-primary);color:var(--dsw-alias-bg-base);font-weight:600}',
|
|
1960
|
-
'.ez-picker-day.is-selected:hover{opacity:.9}',
|
|
1961
|
-
'.ez-picker-foot{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-top:8px;padding-top:8px;border-top:.5px solid var(--dsw-alias-border-l1)}',
|
|
1962
|
-
'.ez-picker-link{box-sizing:border-box;margin:0;padding:3px 5px;border:0;border-radius:5px;background:transparent;color:var(--dsw-alias-brand-primary);font:inherit;font-size:11.5px;line-height:1;cursor:pointer;appearance:none;-webkit-appearance:none}',
|
|
1963
|
-
'.ez-picker-link:hover:not(:disabled){background:var(--dsw-alias-bg-layer-2)}',
|
|
1964
|
-
'.ez-picker-link:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}',
|
|
1965
|
-
'.ez-picker-link:disabled{color:var(--dsw-alias-state-idle-primary);cursor:default}',
|
|
1966
|
-
'.ez-due{box-sizing:border-box;flex:none;display:inline-flex;align-items:center;height:22px;line-height:22px;margin:calc((var(--ez-font-size,13px) * 1.55 - 22px) / 2) 0 0 6px;padding:0 1px;border:0;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:calc(var(--ez-font-size,13px) * .82);cursor:pointer;appearance:none;-webkit-appearance:none;font-variant-numeric:tabular-nums;white-space:nowrap}',
|
|
1967
|
-
'.ez-due:hover{color:var(--dsw-alias-label-primary)}',
|
|
1968
|
-
'.ez-due:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px;border-radius:4px}',
|
|
1969
|
-
'.ez-due--today{color:var(--dsw-alias-state-warn-primary);font-weight:600}',
|
|
1970
|
-
'.ez-due--overdue{color:var(--dsw-alias-state-error-primary);font-weight:600}',
|
|
1971
|
-
'.ez-row[draggable=true]{cursor:grab}',
|
|
1972
|
-
'.ez-row[draggable=true]:active{cursor:grabbing}',
|
|
1973
|
-
'.ez-row.is-overdue .ez-title{color:var(--dsw-alias-state-error-primary)}',
|
|
1974
|
-
'.ez-row.is-dragging{opacity:.35}',
|
|
1975
|
-
'.ez-row.is-drop-before{box-shadow:inset 0 2px 0 var(--dsw-alias-brand-primary)}',
|
|
1976
|
-
'.ez-list.is-drop-end::after{content:"";display:block;flex:none;height:2px;margin:1px 2px 0;border-radius:2px;background:var(--dsw-alias-brand-primary)}',
|
|
1977
|
-
'.ez-quad.is-drop-target{outline:1px dashed var(--dsw-alias-brand-primary);outline-offset:-3px}',
|
|
1978
|
-
'.ez-toast{position:fixed;left:50%;top:50%;transform:translate(-50%,-50%);z-index:60;pointer-events:none;display:flex;align-items:center;gap:10px;max-width:min(360px,calc(100vw - 64px));padding:16px 24px;border:.5px solid var(--dsw-alias-border-l2);border-radius:14px;background:var(--dsw-alias-bg-overlay);color:var(--dsw-alias-label-primary);font-size:14.5px;line-height:1.5;box-shadow:0 16px 44px color-mix(in srgb,var(--dsw-alias-label-primary) 18%,transparent);animation:ez-toast-in .24s ease-out}',
|
|
1979
|
-
'.ez-toast-mark{display:grid;place-items:center;flex:none;width:22px;height:22px;border-radius:50%;background:var(--dsw-alias-state-success-primary);color:var(--dsw-alias-bg-overlay);font-size:12px;font-weight:700;line-height:1}',
|
|
1980
|
-
'.ez-toast--cheer{border-color:color-mix(in srgb,var(--dsw-alias-brand-primary) 42%,var(--dsw-alias-border-l2))}',
|
|
1981
|
-
'.ez-toast--cheer .ez-toast-mark{background:var(--dsw-alias-brand-primary);font-size:13px}',
|
|
1982
|
-
'@keyframes ez-toast-in{from{opacity:0;transform:translate(-50%,-50%) scale(.95)}to{opacity:1;transform:translate(-50%,-50%) scale(1)}}',
|
|
1983
|
-
'.ez-add-input::placeholder{color:var(--dsw-alias-state-idle-primary)}',
|
|
1984
|
-
'.ez-quick-add{box-sizing:border-box;display:flex;align-items:center;gap:6px;height:26px;margin:0;padding:0 6px;border:0;border-radius:6px;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:12px;line-height:1;cursor:pointer;opacity:.78;appearance:none;-webkit-appearance:none}',
|
|
1985
|
-
'.ez-quick-add:hover{opacity:1;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary)}',
|
|
1986
|
-
'.ez-quick-add:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}',
|
|
1987
|
-
'.ez-quick-plus{font-size:14px;line-height:1}',
|
|
1988
|
-
'.ez-add-input{box-sizing:border-box;flex:1 1 auto;min-width:0;width:auto;height:30px;margin:0;padding:0 9px;border:.5px solid var(--dsw-alias-brand-primary);border-radius:7px;background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);font:inherit;font-size:var(--ez-font-size,13px);outline:none}',
|
|
1989
|
-
'.ez-add-input::placeholder{color:var(--dsw-alias-state-idle-primary)}',
|
|
1990
|
-
'.ez-completed{box-sizing:border-box;display:flex;flex:1 1 auto;flex-direction:column;min-height:0;margin-top:16px;border:.5px solid var(--dsw-alias-border-l1);border-radius:10px;background:var(--dsw-alias-bg-layer-1)}',
|
|
1991
|
-
'.ez-completed-head{display:flex;flex:none;align-items:center;gap:8px;padding:12px 13px 6px}',
|
|
1992
|
-
'.ez-completed-title{margin:0;font-size:13px;line-height:1;font-weight:600}',
|
|
1993
|
-
'.ez-completed-count{font-size:11px;line-height:1;color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums}',
|
|
1994
|
-
'.ez-clear{box-sizing:border-box;margin:0 0 0 auto;padding:4px 9px;border:.5px solid var(--dsw-alias-border-l2);border-radius:7px;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:11.5px;line-height:1;cursor:pointer;appearance:none;-webkit-appearance:none}',
|
|
1995
|
-
'.ez-clear:hover{background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary)}',
|
|
1996
|
-
'.ez-clear.is-confirming{border-color:var(--dsw-alias-state-error-primary);color:var(--dsw-alias-state-error-primary)}',
|
|
1997
|
-
'.ez-clear:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}',
|
|
1998
|
-
'.ez-completed .ez-list{padding:0 11px 9px}',
|
|
1999
|
-
'.ez-completed-body{display:flex;flex:1 1 auto;min-height:0}',
|
|
2000
|
-
'.ez-blank{margin:0;padding:20px;font-size:12.5px;line-height:20px;text-align:center;color:var(--dsw-alias-label-secondary)}',
|
|
2001
|
-
'.ez-completed-body .ez-blank{margin:auto}',
|
|
2002
|
-
'@media (max-width:640px){.ez-inner{padding:16px 14px}.ez-matrix{min-height:420px;margin-top:12px}.ez-matrix--cards{gap:9px}.ez-matrix--cards .ez-quad,.ez-matrix--grid .ez-quad,.ez-matrix--cross .ez-quad{padding:10px 10px 7px}.ez-quad-hint{display:none}.ez-head-actions{width:100%;justify-content:space-between}.ez-set-label{width:100%}}',
|
|
2003
|
-
'@media (prefers-reduced-motion:reduce){.ez-actions{transition:none}}',
|
|
2004
|
-
].join('\n');
|
|
2053
|
+
// The sidebar row text can be renamed from the settings panel. The slot
|
|
2054
|
+
// label is a thunk read on projection, so renaming re-registers the row
|
|
2055
|
+
// to make the sidebar show the new text immediately.
|
|
2056
|
+
let navOverride = '';
|
|
2057
|
+
let sidebarDisposer = null;
|
|
2005
2058
|
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2059
|
+
const mountSidebarRow = () => {
|
|
2060
|
+
if (sidebarDisposer !== null) {
|
|
2061
|
+
sidebarDisposer();
|
|
2062
|
+
sidebarDisposer = null;
|
|
2063
|
+
}
|
|
2064
|
+
const disposer = ctx.slots.register(
|
|
2065
|
+
{
|
|
2066
|
+
name: 'sidebar.panellist',
|
|
2067
|
+
id: PANEL_ID,
|
|
2068
|
+
order: ORDER,
|
|
2069
|
+
label: () => (navOverride !== '' ? navOverride : t('nav.label')),
|
|
2070
|
+
locale: NS,
|
|
2071
|
+
},
|
|
2072
|
+
PanelIcon,
|
|
2073
|
+
);
|
|
2074
|
+
sidebarDisposer = typeof disposer === 'function' ? disposer : null;
|
|
2075
|
+
};
|
|
2017
2076
|
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2077
|
+
const setNavLabel = (value) => {
|
|
2078
|
+
const next = typeof value === 'string' ? value.trim() : '';
|
|
2079
|
+
if (next === navOverride) return;
|
|
2080
|
+
navOverride = next;
|
|
2081
|
+
mountSidebarRow();
|
|
2082
|
+
};
|
|
2023
2083
|
|
|
2024
|
-
|
|
2084
|
+
ctx.slots.inject('sidebar.panellist', () => {
|
|
2085
|
+
mountSidebarRow();
|
|
2086
|
+
return () => {
|
|
2025
2087
|
if (sidebarDisposer !== null) {
|
|
2026
2088
|
sidebarDisposer();
|
|
2027
2089
|
sidebarDisposer = null;
|
|
2028
2090
|
}
|
|
2029
|
-
const disposer = ctx.slots.register(
|
|
2030
|
-
{
|
|
2031
|
-
name: 'sidebar.panellist',
|
|
2032
|
-
id: PANEL_ID,
|
|
2033
|
-
order: ORDER,
|
|
2034
|
-
label: () => (navOverride !== '' ? navOverride : t('nav.label')),
|
|
2035
|
-
locale: NS,
|
|
2036
|
-
},
|
|
2037
|
-
PanelIcon,
|
|
2038
|
-
);
|
|
2039
|
-
sidebarDisposer = typeof disposer === 'function' ? disposer : null;
|
|
2040
|
-
};
|
|
2041
|
-
|
|
2042
|
-
const setNavLabel = (value) => {
|
|
2043
|
-
const next = typeof value === 'string' ? value.trim() : '';
|
|
2044
|
-
if (next === navOverride) return;
|
|
2045
|
-
navOverride = next;
|
|
2046
|
-
mountSidebarRow();
|
|
2047
2091
|
};
|
|
2092
|
+
});
|
|
2048
2093
|
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
}
|
|
2056
|
-
}
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
locale: NS,
|
|
2065
|
-
inject: () => ({ t, localeSource, setNavLabel }),
|
|
2066
|
-
},
|
|
2067
|
-
TodoPage,
|
|
2068
|
-
),
|
|
2069
|
-
);
|
|
2070
|
-
},
|
|
2071
|
-
};
|
|
2072
|
-
},
|
|
2073
|
-
});
|
|
2074
|
-
}
|
|
2094
|
+
ctx.slots.inject('main', () =>
|
|
2095
|
+
ctx.slots.register(
|
|
2096
|
+
{
|
|
2097
|
+
name: 'main',
|
|
2098
|
+
key: PANEL_ID,
|
|
2099
|
+
locale: NS,
|
|
2100
|
+
inject: () => ({ t, localeSource, setNavLabel }),
|
|
2101
|
+
},
|
|
2102
|
+
TodoPage,
|
|
2103
|
+
),
|
|
2104
|
+
);
|
|
2105
|
+
},
|
|
2106
|
+
};
|
|
2107
|
+
},
|
|
2108
|
+
});
|