@streamscloud/kit 0.93.6 → 0.93.7
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/core/utils/date-helper.d.ts +2 -0
- package/dist/core/utils/date-helper.js +21 -0
- package/dist/ui/table/table-cells/table-by-cell.svelte +2 -18
- package/dist/ui/table/types.d.ts +1 -1
- package/dist/ui/time-ago/cmp.time-ago.svelte +5 -1
- package/dist/ui/time-ago/cmp.time-ago.svelte.d.ts +2 -0
- package/dist/ui/time-ago/time-ago-localization.js +4 -4
- package/package.json +1 -1
|
@@ -16,6 +16,8 @@ export declare class DateHelper {
|
|
|
16
16
|
static formatDateRange(startDate: LikeDate, endDate: LikeDate, locale: string): string;
|
|
17
17
|
static dateRangeDescriptionString(startDate: LikeDate, endDate: LikeDate | null | undefined, locale: string): string;
|
|
18
18
|
static toDefaultDateTimeRepresentation: (val: LikeDate, locale: string, alwaysIncludeYear?: boolean) => string;
|
|
19
|
+
/** `01.dec · 11:30`, with a two-digit year for past years: `01.dec.25 · 11:30`. */
|
|
20
|
+
static toCompactDateTimeRepresentation: (val: LikeDate, locale: string, showTime?: boolean) => string;
|
|
19
21
|
static addYears(dateToModify: LikeDate, yearsToAdd: number, resetTime?: boolean): Date;
|
|
20
22
|
static startOfLastWeek(): string;
|
|
21
23
|
static endOfLastWeek(): string;
|
|
@@ -151,6 +151,27 @@ export class DateHelper {
|
|
|
151
151
|
const time = `${formatNumber(dateTime.getHours())}:${formatNumber(dateTime.getMinutes())}`;
|
|
152
152
|
return `${date}. ${monthName}${year} - ${time}`;
|
|
153
153
|
};
|
|
154
|
+
/** `01.dec · 11:30`, with a two-digit year for past years: `01.dec.25 · 11:30`. */
|
|
155
|
+
static toCompactDateTimeRepresentation = (val, locale, showTime = true) => {
|
|
156
|
+
const dateTime = DateHelper.toDate(val);
|
|
157
|
+
const parts = new Intl.DateTimeFormat(locale, {
|
|
158
|
+
day: '2-digit',
|
|
159
|
+
month: 'short',
|
|
160
|
+
year: '2-digit',
|
|
161
|
+
hour: '2-digit',
|
|
162
|
+
minute: '2-digit',
|
|
163
|
+
hourCycle: 'h23'
|
|
164
|
+
}).formatToParts(dateTime);
|
|
165
|
+
const getPart = (type) => parts.find((part) => part.type === type)?.value ?? '';
|
|
166
|
+
// Norwegian short months carry their own trailing dot ("nov."), which would double the separator.
|
|
167
|
+
const month = getPart('month').replace(/\.$/, '').toLocaleLowerCase(locale);
|
|
168
|
+
const dateSegments = [getPart('day'), month];
|
|
169
|
+
if (dateTime.getFullYear() !== new Date().getFullYear()) {
|
|
170
|
+
dateSegments.push(getPart('year'));
|
|
171
|
+
}
|
|
172
|
+
const date = dateSegments.join('.');
|
|
173
|
+
return showTime ? `${date} · ${getPart('hour')}:${getPart('minute')}` : date;
|
|
174
|
+
};
|
|
154
175
|
static addYears(dateToModify, yearsToAdd, resetTime = true) {
|
|
155
176
|
const date = new Date(dateToModify);
|
|
156
177
|
date.setFullYear(date.getFullYear() + yearsToAdd);
|
|
@@ -4,11 +4,6 @@ import { ImageRound } from '../../image';
|
|
|
4
4
|
import { TimeAgo } from '../../time-ago';
|
|
5
5
|
import { Tooltip } from '../../tooltip';
|
|
6
6
|
let { item, column } = $props();
|
|
7
|
-
const fmt = (d, options) => new Intl.DateTimeFormat(column.locale ?? AppLocale.current, options).format(d);
|
|
8
|
-
const timeFormat = { hour: '2-digit', minute: '2-digit', hour12: false };
|
|
9
|
-
const dateFormat = { day: '2-digit' };
|
|
10
|
-
const monthFormat = { month: 'short' };
|
|
11
|
-
const yearFormat = { year: '2-digit' };
|
|
12
7
|
const getValueForColumn = (column, item) => (column.valueFactory ? column.valueFactory(item) : item[column.id])?.toString();
|
|
13
8
|
const getDateValueForColumn = (column, item) => {
|
|
14
9
|
const value = getValueForColumn(column, item);
|
|
@@ -50,17 +45,9 @@ const navigateToUser = (event, by) => {
|
|
|
50
45
|
{/if}
|
|
51
46
|
<span class="table-by-cell__date">
|
|
52
47
|
{#if column.dateDisplay === 'absolute'}
|
|
53
|
-
{
|
|
54
|
-
<span class="table-by-cell__month">{fmt(dateTime, monthFormat)}</span>
|
|
55
|
-
{#if dateTime.getFullYear() !== new Date().getFullYear()}
|
|
56
|
-
.{fmt(dateTime, yearFormat)}
|
|
57
|
-
{/if}
|
|
58
|
-
{#if showTime}
|
|
59
|
-
<span> · </span>
|
|
60
|
-
{fmt(dateTime, timeFormat)}
|
|
61
|
-
{/if}
|
|
48
|
+
{DateHelper.toCompactDateTimeRepresentation(dateTime, column.locale ?? AppLocale.current, showTime)}
|
|
62
49
|
{:else}
|
|
63
|
-
<TimeAgo date={dateTime} autoUpdate={column.autoUpdate ?? false} showTime={showTime} locale={column.locale} />
|
|
50
|
+
<TimeAgo date={dateTime} autoUpdate={column.autoUpdate ?? false} showTime={showTime} locale={column.locale} absoluteFormat="compact" />
|
|
64
51
|
{/if}
|
|
65
52
|
</span>
|
|
66
53
|
{:else if by}
|
|
@@ -108,9 +95,6 @@ const navigateToUser = (event, by) => {
|
|
|
108
95
|
justify-content: center;
|
|
109
96
|
height: 100%;
|
|
110
97
|
}
|
|
111
|
-
.table-by-cell__month {
|
|
112
|
-
text-transform: lowercase;
|
|
113
|
-
}
|
|
114
98
|
.table-by-cell__by {
|
|
115
99
|
display: flex;
|
|
116
100
|
align-items: center;
|
package/dist/ui/table/types.d.ts
CHANGED
|
@@ -78,7 +78,7 @@ export interface ITableByColumn<T> extends ITableColumn<T> {
|
|
|
78
78
|
}) => void) | null;
|
|
79
79
|
/** When the person-name link shows its underline: only on hover, permanently, or not at all. @default 'hover' */
|
|
80
80
|
underline?: 'hover' | 'always' | 'never';
|
|
81
|
-
/** Relative "5 minutes ago" text, or the absolute "04.
|
|
81
|
+
/** Relative "5 minutes ago" text, or the absolute "04.nov · 14:32" form. @default 'relative' */
|
|
82
82
|
dateDisplay?: 'relative' | 'absolute';
|
|
83
83
|
/** Re-render the relative text on a timer as time passes. Relative display only. */
|
|
84
84
|
autoUpdate?: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">import { DateFormatOptions, DateHelper } from '../../core/utils/date-helper';
|
|
2
2
|
import { TimeAgoLocalization } from './time-ago-localization';
|
|
3
|
-
let { date = null, thresholdMinutes = 60 * 24 * 2 /* 2 days */, autoUpdate = true, showTime = true, locale = null } = $props();
|
|
3
|
+
let { date = null, thresholdMinutes = 60 * 24 * 2 /* 2 days */, autoUpdate = true, showTime = true, locale = null, absoluteFormat = 'phrase' } = $props();
|
|
4
4
|
const localization = new TimeAgoLocalization(() => locale);
|
|
5
5
|
let timeSpan = $state.raw(null);
|
|
6
6
|
let timeoutId;
|
|
@@ -9,6 +9,10 @@ const setRelativeTime = (d) => {
|
|
|
9
9
|
const dateVal = d ? DateHelper.toDate(d) : new Date();
|
|
10
10
|
const formatTime = () => dateVal.toLocaleString(localization.locale, DateFormatOptions.timeFormat);
|
|
11
11
|
const setupAbsDate = () => {
|
|
12
|
+
if (absoluteFormat === 'compact') {
|
|
13
|
+
timeSpan = DateHelper.toCompactDateTimeRepresentation(dateVal, localization.locale, showTime);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
12
16
|
const formattedDate = dateVal.toLocaleString(localization.locale, dateVal.getFullYear() === new Date().getFullYear() ? DateFormatOptions.dateFormatWithoutYear : DateFormatOptions.dateFormat);
|
|
13
17
|
timeSpan = showTime ? localization.at(formattedDate, formatTime()) : formattedDate;
|
|
14
18
|
};
|
|
@@ -10,6 +10,8 @@ type Props = {
|
|
|
10
10
|
showTime?: boolean;
|
|
11
11
|
/** Falls back to the global `AppLocale` when not set. */
|
|
12
12
|
locale?: AppLocaleValue | null;
|
|
13
|
+
/** Form of the date past `thresholdMinutes`: `'phrase'` — "Dec 01 at 11:30", `'compact'` — "01.dec · 11:30", the table `by` column's form. @default 'phrase' */
|
|
14
|
+
absoluteFormat?: 'phrase' | 'compact';
|
|
13
15
|
};
|
|
14
16
|
/**
|
|
15
17
|
* Displays a human-readable relative time string (e.g. "5 minutes ago") that can auto-update on a self-scheduled
|
|
@@ -53,8 +53,8 @@ const loc = {
|
|
|
53
53
|
no: 'nettopp nå'
|
|
54
54
|
},
|
|
55
55
|
yesterday: {
|
|
56
|
-
en: '
|
|
57
|
-
no: '
|
|
56
|
+
en: 'yesterday',
|
|
57
|
+
no: 'i går'
|
|
58
58
|
},
|
|
59
59
|
at: {
|
|
60
60
|
en: (date, time) => `${date} at ${time}`,
|
|
@@ -69,7 +69,7 @@ const loc = {
|
|
|
69
69
|
no: (minutes) => `${minutes} minutter siden`
|
|
70
70
|
},
|
|
71
71
|
yesterdayAt: {
|
|
72
|
-
en: (time) => `
|
|
73
|
-
no: (time) => `
|
|
72
|
+
en: (time) => `yesterday at ${time}`,
|
|
73
|
+
no: (time) => `i går kl. ${time}`
|
|
74
74
|
}
|
|
75
75
|
};
|