@nbtca/prompt 1.5.2 → 1.5.3
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/dist/features/calendar.js +30 -9
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ import { c, type, space, glyph } from '../core/theme.js';
|
|
|
4
4
|
import { pickIcon } from '../core/icons.js';
|
|
5
5
|
import { padEndV, sanitizeTerminalLine, sanitizeTerminalText, truncate, visualWidth, wrapAnsiWithIndent, wrapAnsiToVisualWidth, } from '../core/text.js';
|
|
6
6
|
import { t } from '../i18n/index.js';
|
|
7
|
-
import { addLocalDays } from '../core/calendar-day.js';
|
|
7
|
+
import { addLocalDays, localDayDifference } from '../core/calendar-day.js';
|
|
8
8
|
import { countdownParts, isCountdownUrgent, buildExportFilename } from './calendar-query.js';
|
|
9
9
|
import { loadFeedCache, saveFeedCache } from './calendar-store.js';
|
|
10
10
|
import { writeFileSync, existsSync } from 'fs';
|
|
@@ -146,17 +146,38 @@ export function renderEventsTable(events, options) {
|
|
|
146
146
|
}
|
|
147
147
|
return lines.join('\n');
|
|
148
148
|
}
|
|
149
|
+
export function eventProximity(startDate, now) {
|
|
150
|
+
const days = localDayDifference(now, startDate);
|
|
151
|
+
if (days <= 0)
|
|
152
|
+
return 'today';
|
|
153
|
+
if (days === 1)
|
|
154
|
+
return 'tomorrow';
|
|
155
|
+
if (days <= 7)
|
|
156
|
+
return 'week';
|
|
157
|
+
return 'later';
|
|
158
|
+
}
|
|
159
|
+
const SOURCE_TAG = /^(\[[^\]]{1,16}\])(\s+)(?=\S)/;
|
|
160
|
+
function styleTitle(title, style) {
|
|
161
|
+
const match = SOURCE_TAG.exec(title);
|
|
162
|
+
if (!match?.[1] || !match[2])
|
|
163
|
+
return style(title);
|
|
164
|
+
return `${type.hint(match[1])}${match[2]}${style(title.slice(match[0].length))}`;
|
|
165
|
+
}
|
|
149
166
|
export function renderEventBrief(e, now) {
|
|
150
167
|
const dot = pickIcon('·', '-');
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
168
|
+
const proximity = eventProximity(e.startDate, now);
|
|
169
|
+
const dateStyle = proximity === 'today'
|
|
170
|
+
? type.active
|
|
171
|
+
: proximity === 'tomorrow'
|
|
172
|
+
? c.brand
|
|
173
|
+
: proximity === 'week'
|
|
174
|
+
? type.body
|
|
175
|
+
: type.hint;
|
|
154
176
|
const dateTime = `${e.date}${e.time ? ' ' + e.time : ''}`;
|
|
155
|
-
const marker =
|
|
156
|
-
const
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
return `${space.indent}${marker} ${dateStyled} ${dot} ${titleStyled}${recurringMark}`;
|
|
177
|
+
const marker = proximity === 'today' ? type.active(pickIcon('●', '*')) : dateStyle(pickIcon('·', '-'));
|
|
178
|
+
const titleStyled = styleTitle(e.title, proximity === 'today' ? type.active : type.body);
|
|
179
|
+
const recurringMark = e.recurring ? ` ${type.hint(pickIcon('↻', '~'))}` : '';
|
|
180
|
+
return `${space.indent}${marker} ${dateStyle(dateTime)} ${type.hint(dot)} ${titleStyled}${recurringMark}`;
|
|
160
181
|
}
|
|
161
182
|
export function renderCountdownBanner(event, now, cols = Number.POSITIVE_INFINITY) {
|
|
162
183
|
if (!event)
|