@svadmin/lite 0.31.1 → 0.32.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/LiteActivityFeed.svelte +1 -1
- package/dist/components/LiteApprovalActionCard.svelte +1 -1
- package/dist/components/LiteAuditLog.svelte +2 -1
- package/dist/components/LiteChatDialog.svelte +3 -2
- package/dist/components/LiteChatDialog.svelte.d.ts +0 -5
- package/dist/components/LiteKpiCard.svelte +2 -1
- package/dist/components/LiteMentionsInput.svelte +1 -1
- package/dist/components/LiteSearch.svelte +1 -1
- package/dist/components/LiteShowField.svelte +6 -2
- package/dist/components/LiteShowField.svelte.d.ts +1 -5
- package/dist/components/LiteStatistic.svelte +2 -1
- package/dist/components/LiteTable.svelte +3 -2
- package/dist/components/LiteTable.svelte.d.ts +1 -5
- package/dist/components/LiteTenantQuotasMatrix.svelte +2 -1
- package/dist/components/LiteThreadedCommentDrawer.svelte +1 -1
- package/dist/components/fields/LiteCopyField.svelte +1 -1
- package/dist/components/fields/LiteCurrencyField.svelte +14 -15
- package/dist/components/fields/LiteDateField.svelte +2 -1
- package/dist/components/fields/LiteDateRangeField.svelte +7 -13
- package/dist/components/fields/LiteMarkdownField.svelte +1 -1
- package/dist/components/fields/LiteNumberField.svelte +2 -1
- package/dist/components/pages/LiteListPage.svelte +1 -1
- package/package.json +2 -2
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
<form {action} {method} class="lite-activity-form">
|
|
68
68
|
<div style="margin-bottom: 8px;">
|
|
69
69
|
<label for="lite_act_comment" class="lite-label">Add Note / Comment:</label>
|
|
70
|
-
<textarea id="lite_act_comment" name="comment" class="lite-textarea" style="height: 50px;" placeholder="Write a comment
|
|
70
|
+
<textarea id="lite_act_comment" name="comment" class="lite-textarea" style="height: 50px;" placeholder="Write a comment…"></textarea>
|
|
71
71
|
</div>
|
|
72
72
|
<div style="text-align: right;">
|
|
73
73
|
<button type="submit" class="lite-btn lite-btn-primary lite-btn-sm">
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
<form {action} method="POST" class="lite-approval-form">
|
|
36
36
|
<div class="lite-approval-field">
|
|
37
37
|
<label for="approval_comment" class="lite-label">Approval / Rejection Comment:</label>
|
|
38
|
-
<textarea id="approval_comment" name="comment" class="lite-textarea" style="height: 60px;" placeholder="Optional comment or rejection reason
|
|
38
|
+
<textarea id="approval_comment" name="comment" class="lite-textarea" style="height: 60px;" placeholder="Optional comment or rejection reason…"></textarea>
|
|
39
39
|
</div>
|
|
40
40
|
<div class="lite-approval-actions">
|
|
41
41
|
<button type="submit" name="_action" value="approve" class="lite-btn lite-btn-sm lite-btn-success">
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { formatAdminTime } from '@svadmin/core/copy-format';
|
|
2
3
|
/**
|
|
3
4
|
* LiteAuditLog — SSR-compatible audit log viewer.
|
|
4
5
|
* Accepts both the legacy AuthProvider AuditLog shape and the current
|
|
@@ -78,7 +79,7 @@
|
|
|
78
79
|
const totalPages = $derived(Math.max(1, Math.ceil(effectiveTotal / Math.max(1, pageSize))));
|
|
79
80
|
|
|
80
81
|
function formatDate(value: string | Date) {
|
|
81
|
-
return
|
|
82
|
+
return formatAdminTime(value, { dateStyle: 'medium' });
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
function actionClass(action: string): string {
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Relies on standard <form> POST without polling or WebSockets.
|
|
5
5
|
* No client-side JS required.
|
|
6
6
|
*/
|
|
7
|
+
import { formatAdminTime } from '@svadmin/core/copy-format';
|
|
7
8
|
import type { ChatMessage } from '@svadmin/core';
|
|
8
9
|
|
|
9
10
|
interface Props {
|
|
@@ -23,13 +24,13 @@
|
|
|
23
24
|
actionRoute,
|
|
24
25
|
isLoading = false,
|
|
25
26
|
title = 'AI Assistant',
|
|
26
|
-
placeholder = 'Type your message
|
|
27
|
+
placeholder = 'Type your message…',
|
|
27
28
|
submitLabel = 'Send'
|
|
28
29
|
}: Props = $props();
|
|
29
30
|
|
|
30
31
|
function formatDate(ts: number) {
|
|
31
32
|
if (!ts) return '';
|
|
32
|
-
return
|
|
33
|
+
return formatAdminTime(ts, { seconds: false });
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
function messageText(message: ChatMessage): string {
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LiteChatDialog — SSR-compatible AI Chat Dialog fallback.
|
|
3
|
-
* Relies on standard <form> POST without polling or WebSockets.
|
|
4
|
-
* No client-side JS required.
|
|
5
|
-
*/
|
|
6
1
|
import type { ChatMessage } from '@svadmin/core';
|
|
7
2
|
interface Props {
|
|
8
3
|
/** History of messages */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { formatAdminNumber } from '@svadmin/core/copy-format';
|
|
2
3
|
import type { Snippet } from 'svelte';
|
|
3
4
|
|
|
4
5
|
interface TargetProgress {
|
|
@@ -42,7 +43,7 @@
|
|
|
42
43
|
}: Props = $props();
|
|
43
44
|
|
|
44
45
|
const formattedValue = $derived(
|
|
45
|
-
typeof value === 'number' ? value
|
|
46
|
+
typeof value === 'number' ? formatAdminNumber(value, 'en-US') : String(value)
|
|
46
47
|
);
|
|
47
48
|
|
|
48
49
|
const progressPercent = $derived.by(() => {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
name="q"
|
|
29
29
|
value={value}
|
|
30
30
|
class="lite-input"
|
|
31
|
-
placeholder={placeholder || t('common.search') || 'Search
|
|
31
|
+
placeholder={placeholder || t('common.search') || 'Search…'}
|
|
32
32
|
/>
|
|
33
33
|
<button type="submit" class="lite-btn lite-btn-primary">
|
|
34
34
|
{t('common.search') || 'Search'}
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* LiteShowField — SSR-compatible field renderer for detail views.
|
|
6
6
|
* Renders a single field value based on its type definition.
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
8
|
+
import { formatAdminTime } from '@svadmin/core/copy-format';
|
|
9
|
+
import type { FieldDefinition } from '@svadmin/core';
|
|
9
10
|
import { toSafeHref, toSafeText } from "../security";
|
|
10
11
|
import { isExplicitBooleanTrue, getStatusBadgeClass } from "../value-normalization";
|
|
11
12
|
import LiteMediaThumbnail from "./LiteMediaThumbnail.svelte";
|
|
@@ -26,7 +27,10 @@
|
|
|
26
27
|
function formatValue(v: unknown, f: FieldDefinition): string {
|
|
27
28
|
if (v == null) return "—";
|
|
28
29
|
if (f.type === "date") {
|
|
29
|
-
try {
|
|
30
|
+
try {
|
|
31
|
+
const formatted = formatAdminTime(v as string, { dateStyle: 'medium' });
|
|
32
|
+
return formatted || String(v);
|
|
33
|
+
} catch { return String(v); }
|
|
30
34
|
}
|
|
31
35
|
if (f.type === "select" && f.options) {
|
|
32
36
|
const opt = f.options.find(o => String(o.value) === String(v));
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* LiteShowField — SSR-compatible field renderer for detail views.
|
|
3
|
-
* Renders a single field value based on its type definition.
|
|
4
|
-
*/
|
|
5
|
-
import type { FieldDefinition } from "@svadmin/core";
|
|
1
|
+
import type { FieldDefinition } from '@svadmin/core';
|
|
6
2
|
interface Props {
|
|
7
3
|
field: FieldDefinition;
|
|
8
4
|
value: unknown;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { formatAdminNumber } from '@svadmin/core/copy-format';
|
|
2
3
|
interface Props {
|
|
3
4
|
title?: string;
|
|
4
5
|
value: number | string;
|
|
@@ -26,7 +27,7 @@
|
|
|
26
27
|
|
|
27
28
|
const display = $derived(
|
|
28
29
|
typeof value === 'number'
|
|
29
|
-
?
|
|
30
|
+
? formatAdminNumber(value, { locale: null, minimumFractionDigits: precision, maximumFractionDigits: precision })
|
|
30
31
|
: value,
|
|
31
32
|
);
|
|
32
33
|
</script>
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* LiteTable — Pure HTML table with <a> sort links.
|
|
4
4
|
* No JavaScript required — sorting and pagination are URL-driven.
|
|
5
5
|
*/
|
|
6
|
-
import
|
|
6
|
+
import { formatAdminDate } from '@svadmin/core/copy-format';
|
|
7
|
+
import type { ResourceDefinition, FieldDefinition } from '@svadmin/core';
|
|
7
8
|
import { t } from "@svadmin/core/i18n";
|
|
8
9
|
import { isExplicitBooleanTrue, getStatusBadgeClass } from "../value-normalization";
|
|
9
10
|
import { liteFragmentId } from "../fragment-id";
|
|
@@ -83,7 +84,7 @@
|
|
|
83
84
|
if (value == null) return "—";
|
|
84
85
|
if (field.type === "boolean") return "";
|
|
85
86
|
if (field.type === "date") {
|
|
86
|
-
try { return
|
|
87
|
+
try { return formatAdminDate(value as string) || String(value); } catch { return String(value); }
|
|
87
88
|
}
|
|
88
89
|
if (field.type === "select" && field.options) {
|
|
89
90
|
const opt = field.options.find(o => String(o.value) === String(value));
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* LiteTable — Pure HTML table with <a> sort links.
|
|
3
|
-
* No JavaScript required — sorting and pagination are URL-driven.
|
|
4
|
-
*/
|
|
5
|
-
import type { ResourceDefinition } from "@svadmin/core";
|
|
1
|
+
import type { ResourceDefinition } from '@svadmin/core';
|
|
6
2
|
interface Props {
|
|
7
3
|
records: Record<string, unknown>[];
|
|
8
4
|
resource: ResourceDefinition;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { formatAdminNumber } from '@svadmin/core/copy-format';
|
|
2
3
|
interface QuotaItem {
|
|
3
4
|
id: string;
|
|
4
5
|
resourceName: string;
|
|
@@ -52,7 +53,7 @@
|
|
|
52
53
|
<div class="lite-quota-card">
|
|
53
54
|
<div class="lite-card-top">
|
|
54
55
|
<span class="lite-card-name">{q.resourceName}</span>
|
|
55
|
-
<span class="lite-card-usage">{q.used
|
|
56
|
+
<span class="lite-card-usage">{formatAdminNumber(q.used, { locale: null })} / {formatAdminNumber(q.limit, { locale: null })} {q.unit}</span>
|
|
56
57
|
</div>
|
|
57
58
|
<div class="lite-card-track">
|
|
58
59
|
<div
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
</ul>
|
|
40
40
|
|
|
41
41
|
<form {action} method="POST" class="lite-comment-form">
|
|
42
|
-
<textarea name="content" required placeholder="Leave a reply
|
|
42
|
+
<textarea name="content" required placeholder="Leave a reply…" class="lite-comment-input"></textarea>
|
|
43
43
|
<button type="submit" class="lite-comment-btn">Submit Reply</button>
|
|
44
44
|
</form>
|
|
45
45
|
</div>
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
|
|
31
31
|
function maskText(str: string): string {
|
|
32
32
|
if (str.length <= 8) return '****';
|
|
33
|
-
return `${str.slice(0, 4)}
|
|
33
|
+
return `${str.slice(0, 4)}…${str.slice(-4)}`;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
const rawString = $derived(value != null && value !== '' ? String(value) : '');
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
</script>
|
|
4
4
|
|
|
5
5
|
<script lang="ts">
|
|
6
|
+
import { formatAdminCurrency, formatAdminNumber } from '@svadmin/core/copy-format';
|
|
6
7
|
import type { FieldDefinition } from '@svadmin/core';
|
|
7
8
|
|
|
8
9
|
interface Props {
|
|
@@ -53,24 +54,22 @@
|
|
|
53
54
|
const formatted = $derived.by(() => {
|
|
54
55
|
if (numericValue === null) return nullLabel;
|
|
55
56
|
|
|
56
|
-
const opts: Intl.NumberFormatOptions = {
|
|
57
|
-
style: symbol ? 'decimal' : 'currency',
|
|
58
|
-
currency: symbol ? undefined : currency,
|
|
59
|
-
minimumFractionDigits: normalizedPrecision,
|
|
60
|
-
maximumFractionDigits: normalizedPrecision,
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
if (compact) {
|
|
64
|
-
opts.notation = 'compact';
|
|
65
|
-
opts.compactDisplay = 'short';
|
|
66
|
-
}
|
|
67
|
-
|
|
68
57
|
try {
|
|
69
|
-
let res = new Intl.NumberFormat(locale, opts).format(numericValue);
|
|
70
58
|
if (symbol) {
|
|
71
|
-
|
|
59
|
+
const amount = formatAdminNumber(numericValue, {
|
|
60
|
+
locale,
|
|
61
|
+
minimumFractionDigits: normalizedPrecision,
|
|
62
|
+
maximumFractionDigits: normalizedPrecision,
|
|
63
|
+
});
|
|
64
|
+
return `${symbol}${amount}`;
|
|
72
65
|
}
|
|
73
|
-
return
|
|
66
|
+
return formatAdminCurrency(numericValue, {
|
|
67
|
+
locale,
|
|
68
|
+
currency,
|
|
69
|
+
minimumFractionDigits: normalizedPrecision,
|
|
70
|
+
maximumFractionDigits: normalizedPrecision,
|
|
71
|
+
...(compact ? { notation: 'compact' as const } : {}),
|
|
72
|
+
});
|
|
74
73
|
} catch {
|
|
75
74
|
return String(numericValue);
|
|
76
75
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { formatAdminDate } from '@svadmin/core/copy-format';
|
|
2
3
|
import type { FieldDefinition } from '@svadmin/core';
|
|
3
4
|
import { useTranslation } from '@svadmin/core/i18n';
|
|
4
5
|
|
|
@@ -54,7 +55,7 @@
|
|
|
54
55
|
function displayDate(v: unknown): string {
|
|
55
56
|
if (!v) return '—';
|
|
56
57
|
try {
|
|
57
|
-
return
|
|
58
|
+
return formatAdminDate(v as string) || String(v);
|
|
58
59
|
} catch {
|
|
59
60
|
return String(v);
|
|
60
61
|
}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
</script>
|
|
9
9
|
|
|
10
10
|
<script lang="ts">
|
|
11
|
+
import { formatAdminDate, formatAdminTime } from '@svadmin/core/copy-format';
|
|
11
12
|
import type { FieldDefinition } from '@svadmin/core';
|
|
12
13
|
import { useTranslation } from '@svadmin/core/i18n';
|
|
13
14
|
|
|
@@ -70,20 +71,13 @@
|
|
|
70
71
|
if (isNaN(d.getTime())) return null;
|
|
71
72
|
|
|
72
73
|
if (format === 'iso') return d.toISOString();
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
(format === 'datetime'
|
|
77
|
-
? { dateStyle: 'medium', timeStyle: 'short' }
|
|
78
|
-
: format === 'time'
|
|
79
|
-
? { timeStyle: 'medium' }
|
|
80
|
-
: { dateStyle: 'medium' });
|
|
81
|
-
|
|
82
|
-
try {
|
|
83
|
-
return new Intl.DateTimeFormat(locale, defaultOptions).format(d);
|
|
84
|
-
} catch {
|
|
85
|
-
return d.toLocaleDateString();
|
|
74
|
+
if (options) {
|
|
75
|
+
try { return new Intl.DateTimeFormat(locale, options).format(d); }
|
|
76
|
+
catch { return formatAdminDate(d, { locale }); }
|
|
86
77
|
}
|
|
78
|
+
if (format === 'datetime') return formatAdminTime(d, { locale, dateStyle: 'medium', seconds: false });
|
|
79
|
+
if (format === 'time') return formatAdminTime(d, { locale });
|
|
80
|
+
return formatAdminDate(d, { locale, dateStyle: 'medium' });
|
|
87
81
|
}
|
|
88
82
|
|
|
89
83
|
function toIsoDateInput(val: string | number | Date | null | undefined): string {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
id={field.key}
|
|
35
35
|
class="lite-input {hasError ? 'lite-input-error' : ''}"
|
|
36
36
|
style="min-height: 200px; font-family: monospace;"
|
|
37
|
-
placeholder="Enter markdown
|
|
37
|
+
placeholder="Enter markdown…"
|
|
38
38
|
{...field.required ? { required: true } : {}}
|
|
39
39
|
>{String(value ?? '')}</textarea>
|
|
40
40
|
{#if hasError}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { formatAdminNumber } from '@svadmin/core/copy-format';
|
|
2
3
|
import type { FieldDefinition } from '@svadmin/core';
|
|
3
4
|
|
|
4
5
|
interface Props {
|
|
@@ -15,7 +16,7 @@
|
|
|
15
16
|
</script>
|
|
16
17
|
|
|
17
18
|
{#if mode === 'show'}
|
|
18
|
-
<span class="lite-field-value {className}">{value == null ? '—' : Number(value)
|
|
19
|
+
<span class="lite-field-value {className}">{value == null || !Number.isFinite(Number(value)) ? '—' : formatAdminNumber(Number(value), { locale: null })}</span>
|
|
19
20
|
{:else}
|
|
20
21
|
<div class="lite-field-edit {className}">
|
|
21
22
|
<input
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@svadmin/lite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.1",
|
|
4
4
|
"description": "SSR-first lightweight admin UI for @svadmin with optional progressive enhancement",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"svelte": "^5.57.1",
|
|
59
|
-
"@svadmin/core": ">=0.34.2 <0.
|
|
59
|
+
"@svadmin/core": ">=0.34.2 <0.84.0",
|
|
60
60
|
"@sveltejs/kit": "^3.0.0",
|
|
61
61
|
"qrcode": "^1.5.4"
|
|
62
62
|
},
|