@svadmin/ui 0.126.1 → 0.128.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/dist/app.css +660 -81
- package/dist/app.theme.css +660 -81
- package/dist/components/AbacPolicyMatrix.svelte +1 -1
- package/dist/components/AboutSettings.svelte +1 -1
- package/dist/components/ActionPalette.svelte +2 -2
- package/dist/components/ActivityFeed.svelte +1 -1
- package/dist/components/AdminApp.svelte +2 -2
- package/dist/components/AdminCopilotWidget.svelte +4 -4
- package/dist/components/AnimatedCounter.svelte +2 -1
- package/dist/components/ApiPlayground.svelte +2 -2
- package/dist/components/ApiSettings.svelte +3 -3
- package/dist/components/ApprovalActionCard.svelte +1 -1
- package/dist/components/AsyncExportModal.svelte +6 -6
- package/dist/components/AuditLogDrawer.svelte +1 -1
- package/dist/components/AuditLogViewer.svelte +3 -3
- package/dist/components/AuditTrailInspector.svelte +1 -1
- package/dist/components/AutoTable.svelte +2 -1
- package/dist/components/BatchEditModal.svelte +2 -2
- package/dist/components/BillingInvoiceDrawer.svelte +4 -3
- package/dist/components/CanvasAnnotation.svelte +1 -1
- package/dist/components/Cascader.svelte +3 -3
- package/dist/components/ColumnSettings.svelte +1 -1
- package/dist/components/ColumnVisibilityDrawer.svelte +2 -2
- package/dist/components/ComboboxField.svelte +15 -8
- package/dist/components/CommandPalette.svelte +16 -5
- package/dist/components/CommentThread.svelte +2 -1
- package/dist/components/ConcurrentConflictModal.svelte +3 -3
- package/dist/components/ConfirmDialog.svelte +2 -2
- package/dist/components/DashboardLayoutStorage.svelte +2 -2
- package/dist/components/DataFreshnessIndicator.svelte +1 -1
- package/dist/components/DataImportDropzone.svelte +1 -1
- package/dist/components/DrawerForm.svelte +1 -1
- package/dist/components/DualApprovalGate.svelte +2 -2
- package/dist/components/ExcelExportButton.svelte +1 -1
- package/dist/components/ExcelImportWizard.svelte +1 -1
- package/dist/components/FieldRenderer.svelte +6 -6
- package/dist/components/FileUpload.svelte +11 -2
- package/dist/components/FileUpload.svelte.d.ts +2 -0
- package/dist/components/FilterDropdown.svelte +2 -2
- package/dist/components/FilterTagBar.svelte +1 -1
- package/dist/components/GlobalShortcuts.svelte +1 -1
- package/dist/components/HmacSignatureCalculator.svelte +2 -2
- package/dist/components/I18nLanguagePackEditor.svelte +1 -1
- package/dist/components/ImportPreviewValidator.svelte +1 -1
- package/dist/components/ImportWizard.svelte +2 -2
- package/dist/components/IncidentWarRoomDrawer.svelte +1 -1
- package/dist/components/InlineEdit.svelte +1 -1
- package/dist/components/JsonViewer.svelte +1 -1
- package/dist/components/KeyboardShortcutsModal.svelte +1 -1
- package/dist/components/KpiCard.svelte +2 -1
- package/dist/components/LazyPage.svelte +1 -1
- package/dist/components/LiveIndicator.svelte +1 -1
- package/dist/components/LiveStreamLogViewer.svelte +1 -1
- package/dist/components/LockScreen.svelte +4 -4
- package/dist/components/MasterDetailView.svelte +1 -1
- package/dist/components/MasterSubTableDrawer.svelte +1 -1
- package/dist/components/MentionsInput.svelte +1 -1
- package/dist/components/MicroAppFrame.svelte +1 -1
- package/dist/components/MicroAppSandbox.svelte +1 -1
- package/dist/components/MockDataInterceptor.svelte +1 -1
- package/dist/components/ModalForm.svelte +9 -9
- package/dist/components/NavigateToResource.svelte +1 -1
- package/dist/components/NotificationCenter.svelte +2 -1
- package/dist/components/OfflineSyncBanner.svelte +1 -1
- package/dist/components/OmnibarCommandPalette.svelte +1 -1
- package/dist/components/PivotDrilldownModal.svelte +1 -1
- package/dist/components/Popconfirm.svelte +62 -21
- package/dist/components/Popconfirm.svelte.d.ts +5 -0
- package/dist/components/QueryBuilder.svelte +1 -1
- package/dist/components/QuotaProgressBar.svelte +2 -1
- package/dist/components/RadioGroup.svelte +1 -1
- package/dist/components/RecordCompareModal.svelte +1 -1
- package/dist/components/RuleExpressionBuilder.svelte +1 -1
- package/dist/components/SafeDeleteConfirm.svelte +1 -1
- package/dist/components/ScheduledJobManager.svelte +1 -1
- package/dist/components/SchemaVisualModeler.svelte +1 -1
- package/dist/components/SecureDataExporter.svelte +1 -1
- package/dist/components/SecuritySettings.svelte +3 -3
- package/dist/components/SessionTimeoutGuard.svelte +1 -1
- package/dist/components/Space.svelte +19 -3
- package/dist/components/Space.svelte.d.ts +6 -1
- package/dist/components/Statistic.svelte +2 -1
- package/dist/components/StepWizard.svelte +1 -1
- package/dist/components/SvarDataGrid.svelte +1 -1
- package/dist/components/SystemHealthCheckDashboard.svelte +2 -2
- package/dist/components/TableAggregationFooter.svelte +3 -1
- package/dist/components/TaskCenter.svelte +3 -2
- package/dist/components/TenantContextSwitcher.svelte +1 -1
- package/dist/components/ThreadedCommentDrawer.svelte +1 -1
- package/dist/components/Toast.svelte +7 -1
- package/dist/components/Toast.svelte.d.ts +4 -1
- package/dist/components/Transfer.svelte +2 -2
- package/dist/components/TreeSelect.svelte +2 -2
- package/dist/components/TreeTransferSelect.svelte +2 -2
- package/dist/components/VirtualTreeSelect.svelte +2 -2
- package/dist/components/WebhookSimulator.svelte +1 -1
- package/dist/components/WidgetContainer.svelte +2 -1
- package/dist/components/account/SettingsEnterprisePage.svelte +5 -4
- package/dist/components/charts/FunnelChart.svelte +2 -2
- package/dist/components/content/AuditTimeline.svelte +2 -1
- package/dist/components/content/ContentPageHeader.svelte +2 -2
- package/dist/components/fields/CopyField.svelte +1 -1
- package/dist/components/fields/DateRangeField.svelte +7 -13
- package/dist/components/svar-grid-interactions.js +9 -5
- package/dist/components/ui/alert/alert.svelte +1 -0
- package/dist/components/ui/breadcrumb/breadcrumb-separator.svelte +10 -2
- package/dist/components/ui/breadcrumb/breadcrumb-separator.svelte.d.ts +1 -0
- package/dist/components/ui/command/command-list.svelte +2 -0
- package/dist/components/ui/command/command-loading.svelte +13 -7
- package/dist/components/ui/dialog/dialog-content.svelte +15 -1
- package/dist/components/ui/dialog/dialog-content.svelte.d.ts +6 -0
- package/dist/components/ui/input/input.svelte +82 -7
- package/dist/components/ui/input/input.svelte.d.ts +7 -2
- package/dist/components/ui/select/select.svelte +6 -1
- package/dist/components/ui/select/select.svelte.d.ts +4 -1
- package/dist/components/ui/switch/switch.svelte +11 -2
- package/dist/components/ui/switch/switch.svelte.d.ts +2 -0
- package/dist/components/ui/textarea/textarea.svelte +61 -1
- package/dist/components/ui/textarea/textarea.svelte.d.ts +7 -1
- package/dist/components/ui/tooltip/tooltip-content.svelte +5 -1
- package/dist/components/ui/tooltip/tooltip-content.svelte.d.ts +1 -0
- package/dist/components/ui/tooltip/tooltip-context.svelte.js +1 -1
- package/dist/copy-format.d.ts +2 -0
- package/dist/copy-format.js +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/notifications.svelte.js +1 -1
- package/dist/page-chrome.css +5 -0
- package/package.json +4 -4
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { formatAdminCurrency, formatAdminDate, formatAdminNumber, formatAdminPercent, formatAdminTime } from '@svadmin/core/copy-format';
|
|
1
2
|
import { checkedSvarColumns, buildSvarColumns, svarColumnId, nextSvarSort, nextSvarFilter, SVAR_BLOCKED_ACTIONS } from './svar-grid-contract.js';
|
|
2
3
|
import { svarRecordIndex, svarRecordKey } from './svar-grid-operations.js';
|
|
3
4
|
export function checkedSvarInteractiveColumns(columns) {
|
|
@@ -29,10 +30,11 @@ export function formatSvarValue(value, column, locale) {
|
|
|
29
30
|
if (format === 'number' || format === 'currency' || format === 'percent') {
|
|
30
31
|
if (typeof value !== 'number' || !Number.isFinite(value))
|
|
31
32
|
return '—';
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
if (format === 'currency')
|
|
34
|
+
return formatAdminCurrency(value, { locale, currency: column.currency ?? 'USD' });
|
|
35
|
+
if (format === 'percent')
|
|
36
|
+
return formatAdminPercent(value, { locale, maximumFractionDigits: 2 });
|
|
37
|
+
return formatAdminNumber(value, { locale });
|
|
36
38
|
}
|
|
37
39
|
if (format === 'date' || format === 'datetime') {
|
|
38
40
|
if (typeof value !== 'string' && typeof value !== 'number')
|
|
@@ -40,7 +42,9 @@ export function formatSvarValue(value, column, locale) {
|
|
|
40
42
|
const date = new Date(value);
|
|
41
43
|
if (!Number.isFinite(date.getTime()))
|
|
42
44
|
return '—';
|
|
43
|
-
return
|
|
45
|
+
return format === 'date'
|
|
46
|
+
? formatAdminDate(date, { locale, dateStyle: 'medium', timeZone: 'UTC' })
|
|
47
|
+
: formatAdminTime(date, { locale, dateStyle: 'medium', seconds: false, timeZone: 'UTC' });
|
|
44
48
|
}
|
|
45
49
|
return typeof value === 'string' || typeof value === 'boolean' || (typeof value === 'number' && Number.isFinite(value)) ? String(value) : '—';
|
|
46
50
|
}
|
|
@@ -4,19 +4,27 @@
|
|
|
4
4
|
import type { HTMLLiAttributes } from 'svelte/elements';
|
|
5
5
|
import { ChevronRight } from '@lucide/svelte';
|
|
6
6
|
|
|
7
|
-
let {
|
|
7
|
+
let {
|
|
8
|
+
class: className,
|
|
9
|
+
children,
|
|
10
|
+
separator = 'slash',
|
|
11
|
+
...restProps
|
|
12
|
+
}: HTMLLiAttributes & { children?: Snippet; separator?: 'slash' | 'arrow' } = $props();
|
|
8
13
|
</script>
|
|
9
14
|
|
|
10
15
|
<li
|
|
11
16
|
role="presentation"
|
|
12
17
|
aria-hidden="true"
|
|
13
18
|
data-slot="breadcrumb-separator"
|
|
19
|
+
data-separator={separator}
|
|
14
20
|
class={cn("svadmin-breadcrumb-separator", className)}
|
|
15
21
|
{...restProps}
|
|
16
22
|
>
|
|
17
23
|
{#if children}
|
|
18
24
|
{@render children()}
|
|
19
|
-
{:else}
|
|
25
|
+
{:else if separator === 'arrow'}
|
|
20
26
|
<ChevronRight class="svadmin-breadcrumb-icon" />
|
|
27
|
+
{:else}
|
|
28
|
+
<span class="svadmin-breadcrumb-slash">/</span>
|
|
21
29
|
{/if}
|
|
22
30
|
</li>
|
|
@@ -2,6 +2,7 @@ import type { Snippet } from 'svelte';
|
|
|
2
2
|
import type { HTMLLiAttributes } from 'svelte/elements';
|
|
3
3
|
type $$ComponentProps = HTMLLiAttributes & {
|
|
4
4
|
children?: Snippet;
|
|
5
|
+
separator?: 'slash' | 'arrow';
|
|
5
6
|
};
|
|
6
7
|
declare const BreadcrumbSeparator: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
8
|
type BreadcrumbSeparator = ReturnType<typeof BreadcrumbSeparator>;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
let {
|
|
6
6
|
ref = $bindable(null),
|
|
7
7
|
class: className,
|
|
8
|
+
"aria-label": ariaLabel = "Suggestions…",
|
|
8
9
|
...restProps
|
|
9
10
|
}: CommandPrimitive.ListProps = $props();
|
|
10
11
|
</script>
|
|
@@ -14,5 +15,6 @@
|
|
|
14
15
|
data-slot="command-list"
|
|
15
16
|
data-cmdk-list=""
|
|
16
17
|
class={cn("svadmin-command-list", className)}
|
|
18
|
+
aria-label={ariaLabel}
|
|
17
19
|
{...restProps}
|
|
18
20
|
/>
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { Command as CommandPrimitive } from "bits-ui";
|
|
3
3
|
|
|
4
|
-
let {
|
|
4
|
+
let {
|
|
5
|
+
ref = $bindable(null),
|
|
6
|
+
children,
|
|
7
|
+
"aria-label": ariaLabel = "Loading…",
|
|
8
|
+
...restProps
|
|
9
|
+
}: CommandPrimitive.LoadingProps = $props();
|
|
5
10
|
</script>
|
|
6
11
|
|
|
7
|
-
<CommandPrimitive.Loading
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
<CommandPrimitive.Loading bind:ref {...restProps}>
|
|
13
|
+
{#snippet child({ props })}
|
|
14
|
+
<div {...props} data-slot="command-loading" data-cmdk-loading="" aria-label={ariaLabel}>
|
|
15
|
+
{@render children?.()}
|
|
16
|
+
</div>
|
|
17
|
+
{/snippet}
|
|
18
|
+
</CommandPrimitive.Loading>
|
|
@@ -14,11 +14,20 @@
|
|
|
14
14
|
portalProps,
|
|
15
15
|
children,
|
|
16
16
|
showCloseButton = true,
|
|
17
|
+
closeOnOverlayClick = true,
|
|
18
|
+
size,
|
|
19
|
+
loading = false,
|
|
17
20
|
...restProps
|
|
18
21
|
}: WithoutChildrenOrChild<DialogPrimitive.ContentProps> & {
|
|
19
22
|
portalProps?: WithoutChildrenOrChild<ComponentProps<typeof DialogPortal>>;
|
|
20
23
|
children: Snippet;
|
|
21
24
|
showCloseButton?: boolean;
|
|
25
|
+
/** 信息展示可点遮罩关闭。录入表单应传 false。 */
|
|
26
|
+
closeOnOverlayClick?: boolean;
|
|
27
|
+
/** Arco 建议宽度:400 / 520 / 720。不传则保持现有默认宽度。 */
|
|
28
|
+
size?: 'sm' | 'md' | 'lg';
|
|
29
|
+
/** 加载中时正文区保持最小高度,避免标题和按钮跳动。 */
|
|
30
|
+
loading?: boolean;
|
|
22
31
|
} = $props();
|
|
23
32
|
</script>
|
|
24
33
|
|
|
@@ -27,6 +36,11 @@
|
|
|
27
36
|
<DialogPrimitive.Content
|
|
28
37
|
bind:ref
|
|
29
38
|
data-slot="dialog-content"
|
|
39
|
+
data-dialog-size={size}
|
|
40
|
+
data-close-on-overlay={closeOnOverlayClick ? 'true' : 'false'}
|
|
41
|
+
data-loading={loading ? 'true' : undefined}
|
|
42
|
+
aria-busy={loading ? 'true' : undefined}
|
|
43
|
+
interactOutsideBehavior={closeOnOverlayClick ? 'close' : 'ignore'}
|
|
30
44
|
class={cn(
|
|
31
45
|
"svadmin-dialog-content",
|
|
32
46
|
className
|
|
@@ -37,7 +51,7 @@
|
|
|
37
51
|
{#if showCloseButton}
|
|
38
52
|
<DialogPrimitive.Close data-slot="dialog-close">
|
|
39
53
|
{#snippet child({ props })}
|
|
40
|
-
<Button variant="ghost" class="absolute top-2 right-2" size="icon-sm" {...props}>
|
|
54
|
+
<Button variant="ghost" class="svadmin-dialog-dismiss absolute top-2 right-2" size="icon-sm" {...props}>
|
|
41
55
|
<XIcon />
|
|
42
56
|
<span class="svadmin-sr-only">Close</span>
|
|
43
57
|
</Button>
|
|
@@ -7,6 +7,12 @@ type $$ComponentProps = WithoutChildrenOrChild<DialogPrimitive.ContentProps> & {
|
|
|
7
7
|
portalProps?: WithoutChildrenOrChild<ComponentProps<typeof DialogPortal>>;
|
|
8
8
|
children: Snippet;
|
|
9
9
|
showCloseButton?: boolean;
|
|
10
|
+
/** 信息展示可点遮罩关闭。录入表单应传 false。 */
|
|
11
|
+
closeOnOverlayClick?: boolean;
|
|
12
|
+
/** Arco 建议宽度:400 / 520 / 720。不传则保持现有默认宽度。 */
|
|
13
|
+
size?: 'sm' | 'md' | 'lg';
|
|
14
|
+
/** 加载中时正文区保持最小高度,避免标题和按钮跳动。 */
|
|
15
|
+
loading?: boolean;
|
|
10
16
|
};
|
|
11
17
|
declare const DialogContent: import("svelte").Component<$$ComponentProps, {}, "ref">;
|
|
12
18
|
type DialogContent = ReturnType<typeof DialogContent>;
|
|
@@ -12,8 +12,19 @@
|
|
|
12
12
|
? number | null | undefined
|
|
13
13
|
: string | null | undefined;
|
|
14
14
|
|
|
15
|
-
type
|
|
16
|
-
|
|
15
|
+
type InputStatus = "success" | "error" | "loading";
|
|
16
|
+
type InputSize = "mini" | "compact" | "sm" | "default" | "lg";
|
|
17
|
+
type InputState = "default" | "focus" | "selected" | "complete" | "disabled" | "loading" | "success" | "error";
|
|
18
|
+
|
|
19
|
+
type InputHandlers = {
|
|
20
|
+
onfocus?: HTMLInputAttributes["onfocus"];
|
|
21
|
+
onblur?: HTMLInputAttributes["onblur"];
|
|
22
|
+
onselect?: HTMLInputAttributes["onselect"];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type Props = WithElementRef<Omit<HTMLInputAttributes, "type" | "value" | "size" | "onfocus" | "onblur" | "onselect">> &
|
|
26
|
+
{ size?: InputSize; nativeSize?: number; status?: InputStatus | undefined } &
|
|
27
|
+
InputHandlers &
|
|
17
28
|
(Type extends "file"
|
|
18
29
|
? { type: "file"; files?: FileList | undefined; value?: never }
|
|
19
30
|
: { type?: Type; files?: undefined; value?: InputValue });
|
|
@@ -26,13 +37,21 @@
|
|
|
26
37
|
disabled,
|
|
27
38
|
size: sizeProp,
|
|
28
39
|
nativeSize,
|
|
40
|
+
status,
|
|
29
41
|
class: className,
|
|
30
42
|
"data-slot": dataSlot = "input",
|
|
43
|
+
"aria-invalid": ariaInvalid,
|
|
44
|
+
onfocus,
|
|
45
|
+
onblur,
|
|
46
|
+
onselect,
|
|
31
47
|
...restProps
|
|
32
48
|
}: Props = $props();
|
|
33
49
|
|
|
34
50
|
const config = useComponentConfig();
|
|
35
|
-
const size = $derived(
|
|
51
|
+
const size = $derived.by(() => {
|
|
52
|
+
const requested = sizeProp ?? (config.density === "compact" || config.componentSize === "sm" ? "compact" : "default");
|
|
53
|
+
return requested === "sm" ? "compact" : requested;
|
|
54
|
+
});
|
|
36
55
|
|
|
37
56
|
const i18n = useTranslation();
|
|
38
57
|
const isFileInput = $derived(type?.toLowerCase() === "file");
|
|
@@ -45,22 +64,72 @@
|
|
|
45
64
|
if (selectedFiles.length === 1) return firstFile.name;
|
|
46
65
|
return i18n.t("common.filesSelected", { count: selectedFiles.length });
|
|
47
66
|
});
|
|
67
|
+
|
|
68
|
+
let focused = $state(false);
|
|
69
|
+
let textSelected = $state(false);
|
|
70
|
+
|
|
71
|
+
function readSelected(node: EventTarget | null): boolean {
|
|
72
|
+
if (!(node instanceof HTMLInputElement) && !(node instanceof HTMLTextAreaElement)) return false;
|
|
73
|
+
if (node.selectionStart == null || node.selectionEnd == null) return false;
|
|
74
|
+
return node.selectionStart !== node.selectionEnd;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const filled = $derived.by(() => {
|
|
78
|
+
if (isFileInput) return selectedFiles.length > 0;
|
|
79
|
+
if (value == null) return false;
|
|
80
|
+
return String(value).length > 0;
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const inputState = $derived.by((): InputState => {
|
|
84
|
+
if (disabled) return "disabled";
|
|
85
|
+
if (status === "loading") return "loading";
|
|
86
|
+
if (status === "error" || ariaInvalid === true || ariaInvalid === "true") return "error";
|
|
87
|
+
if (status === "success") return "success";
|
|
88
|
+
if (focused && textSelected) return "selected";
|
|
89
|
+
if (focused) return "focus";
|
|
90
|
+
if (filled) return "complete";
|
|
91
|
+
return "default";
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
function handleFocus(event: FocusEvent & { currentTarget: EventTarget & HTMLInputElement }) {
|
|
95
|
+
focused = true;
|
|
96
|
+
textSelected = readSelected(event.currentTarget);
|
|
97
|
+
onfocus?.(event);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function handleBlur(event: FocusEvent & { currentTarget: EventTarget & HTMLInputElement }) {
|
|
101
|
+
focused = false;
|
|
102
|
+
textSelected = false;
|
|
103
|
+
onblur?.(event);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function handleSelect(event: Event & { currentTarget: EventTarget & HTMLInputElement }) {
|
|
107
|
+
textSelected = readSelected(event.currentTarget);
|
|
108
|
+
onselect?.(event);
|
|
109
|
+
}
|
|
48
110
|
</script>
|
|
49
111
|
|
|
50
112
|
{#if isFileInput}
|
|
51
113
|
<div
|
|
52
114
|
class={cn("svadmin-file-input", className)}
|
|
53
115
|
data-disabled={disabled ? "true" : undefined}
|
|
116
|
+
data-input-state={inputState}
|
|
54
117
|
>
|
|
55
118
|
<input
|
|
56
119
|
bind:this={ref}
|
|
57
120
|
data-slot={dataSlot}
|
|
58
121
|
data-size={size}
|
|
59
122
|
data-input-type="file"
|
|
123
|
+
data-input-state={inputState}
|
|
124
|
+
aria-invalid={ariaInvalid}
|
|
125
|
+
aria-busy={inputState === "loading" ? "true" : undefined}
|
|
60
126
|
class={cn("svadmin-input", className)}
|
|
61
127
|
type="file"
|
|
62
128
|
bind:files
|
|
63
129
|
{...attributes}
|
|
130
|
+
onfocus={handleFocus}
|
|
131
|
+
onblur={handleBlur}
|
|
132
|
+
onselect={handleSelect}
|
|
64
133
|
/>
|
|
65
134
|
<span class="svadmin-file-input__visual" aria-hidden="true">
|
|
66
135
|
<span class="svadmin-file-input__button">{i18n.t("common.chooseFile")}</span>
|
|
@@ -72,10 +141,16 @@
|
|
|
72
141
|
bind:this={ref}
|
|
73
142
|
data-slot={dataSlot}
|
|
74
143
|
data-size={size}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
144
|
+
data-input-state={inputState}
|
|
145
|
+
aria-invalid={ariaInvalid}
|
|
146
|
+
aria-busy={inputState === "loading" ? "true" : undefined}
|
|
147
|
+
class={cn("svadmin-input", className)}
|
|
148
|
+
{type}
|
|
149
|
+
lang={isDateInput ? i18n.locale : undefined}
|
|
150
|
+
bind:value
|
|
79
151
|
{...attributes}
|
|
152
|
+
onfocus={handleFocus}
|
|
153
|
+
onblur={handleBlur}
|
|
154
|
+
onselect={handleSelect}
|
|
80
155
|
/>
|
|
81
156
|
{/if}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import type { HTMLInputAttributes, HTMLInputTypeAttribute } from "svelte/elements";
|
|
2
2
|
declare function $$render<Type extends HTMLInputTypeAttribute | undefined = undefined>(): {
|
|
3
|
-
props: Omit<HTMLInputAttributes, "type" | "value" | "size"> & {
|
|
3
|
+
props: Omit<HTMLInputAttributes, "type" | "value" | "size" | "onfocus" | "onblur" | "onselect"> & {
|
|
4
4
|
ref?: HTMLElement | null;
|
|
5
5
|
} & {
|
|
6
|
-
size?: "default" | "compact";
|
|
6
|
+
size?: "default" | "sm" | "lg" | "compact" | "mini";
|
|
7
7
|
nativeSize?: number;
|
|
8
|
+
status?: ("error" | "success" | "loading") | undefined;
|
|
9
|
+
} & {
|
|
10
|
+
onfocus?: HTMLInputAttributes["onfocus"];
|
|
11
|
+
onblur?: HTMLInputAttributes["onblur"];
|
|
12
|
+
onselect?: HTMLInputAttributes["onselect"];
|
|
8
13
|
} & (Type extends "file" ? {
|
|
9
14
|
type: "file";
|
|
10
15
|
files?: FileList | undefined;
|
|
@@ -5,9 +5,12 @@
|
|
|
5
5
|
|
|
6
6
|
// Use HTMLElement instead of HTMLSelectElement to avoid TS error:
|
|
7
7
|
// HTMLSelectElement.remove() returns void, incompatible with HTMLElement's Element return
|
|
8
|
+
type SelectSize = "mini" | "small" | "default" | "large" | "compact";
|
|
8
9
|
type Props = Omit<WithElementRef<HTMLSelectAttributes, HTMLElement>, "size"> & {
|
|
9
10
|
placeholder?: string;
|
|
10
|
-
size?:
|
|
11
|
+
size?: SelectSize;
|
|
12
|
+
/** 无边框选择。和高度尺寸分开。 */
|
|
13
|
+
borderless?: boolean;
|
|
11
14
|
};
|
|
12
15
|
|
|
13
16
|
let {
|
|
@@ -16,6 +19,7 @@
|
|
|
16
19
|
class: className,
|
|
17
20
|
placeholder,
|
|
18
21
|
size: sizeProp,
|
|
22
|
+
borderless = false,
|
|
19
23
|
children,
|
|
20
24
|
...restProps
|
|
21
25
|
}: Props = $props();
|
|
@@ -28,6 +32,7 @@
|
|
|
28
32
|
bind:this={ref}
|
|
29
33
|
data-slot="select"
|
|
30
34
|
data-size={size}
|
|
35
|
+
data-select-type={borderless ? "borderless" : "default"}
|
|
31
36
|
class={cn(
|
|
32
37
|
"svadmin-select",
|
|
33
38
|
className
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { type WithElementRef } from "../../../utils.js";
|
|
2
2
|
import type { HTMLSelectAttributes } from "svelte/elements";
|
|
3
|
+
type SelectSize = "mini" | "small" | "default" | "large" | "compact";
|
|
3
4
|
type Props = Omit<WithElementRef<HTMLSelectAttributes, HTMLElement>, "size"> & {
|
|
4
5
|
placeholder?: string;
|
|
5
|
-
size?:
|
|
6
|
+
size?: SelectSize;
|
|
7
|
+
/** 无边框选择。和高度尺寸分开。 */
|
|
8
|
+
borderless?: boolean;
|
|
6
9
|
};
|
|
7
10
|
declare const Select: import("svelte").Component<Props, {}, "value" | "ref">;
|
|
8
11
|
type Select = ReturnType<typeof Select>;
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
type Props = WithElementRef<HTMLButtonAttributes, HTMLButtonElement> & {
|
|
6
6
|
checked?: boolean;
|
|
7
7
|
disabled?: boolean;
|
|
8
|
+
loading?: boolean;
|
|
9
|
+
size?: "default" | "small";
|
|
8
10
|
onCheckedChange?: (checked: boolean) => void;
|
|
9
11
|
};
|
|
10
12
|
|
|
@@ -12,13 +14,17 @@
|
|
|
12
14
|
ref = $bindable(null),
|
|
13
15
|
checked = $bindable(false),
|
|
14
16
|
disabled = false,
|
|
17
|
+
loading = false,
|
|
18
|
+
size = "default",
|
|
15
19
|
onCheckedChange,
|
|
16
20
|
class: className,
|
|
17
21
|
...restProps
|
|
18
22
|
}: Props = $props();
|
|
19
23
|
|
|
24
|
+
const inactive = $derived(disabled || loading);
|
|
25
|
+
|
|
20
26
|
function toggle() {
|
|
21
|
-
if (
|
|
27
|
+
if (inactive) return;
|
|
22
28
|
checked = !checked;
|
|
23
29
|
onCheckedChange?.(checked);
|
|
24
30
|
}
|
|
@@ -29,9 +35,12 @@
|
|
|
29
35
|
type="button"
|
|
30
36
|
role="switch"
|
|
31
37
|
aria-checked={checked}
|
|
38
|
+
aria-busy={loading ? "true" : undefined}
|
|
32
39
|
data-state={checked ? "checked" : "unchecked"}
|
|
33
40
|
data-slot="switch"
|
|
34
|
-
{
|
|
41
|
+
data-size={size}
|
|
42
|
+
data-loading={loading ? "true" : undefined}
|
|
43
|
+
disabled={inactive}
|
|
35
44
|
class={cn("svadmin-switch", className)}
|
|
36
45
|
onclick={toggle}
|
|
37
46
|
{...restProps}
|
|
@@ -3,6 +3,8 @@ import type { HTMLButtonAttributes } from "svelte/elements";
|
|
|
3
3
|
type Props = WithElementRef<HTMLButtonAttributes, HTMLButtonElement> & {
|
|
4
4
|
checked?: boolean;
|
|
5
5
|
disabled?: boolean;
|
|
6
|
+
loading?: boolean;
|
|
7
|
+
size?: "default" | "small";
|
|
6
8
|
onCheckedChange?: (checked: boolean) => void;
|
|
7
9
|
};
|
|
8
10
|
declare const Switch: import("svelte").Component<Props, {}, "ref" | "checked">;
|
|
@@ -3,20 +3,80 @@
|
|
|
3
3
|
import { cn, type WithElementRef } from "../../../utils.js";
|
|
4
4
|
import { textareaRecipe as uiTextarea } from "../../../recipes.js";
|
|
5
5
|
|
|
6
|
-
type
|
|
6
|
+
type TextareaStatus = "success" | "error" | "loading";
|
|
7
|
+
type TextareaState = "default" | "focus" | "selected" | "complete" | "disabled" | "loading" | "success" | "error";
|
|
8
|
+
|
|
9
|
+
type Props = WithElementRef<Omit<HTMLTextareaAttributes, "onfocus" | "onblur" | "onselect">> & {
|
|
10
|
+
status?: TextareaStatus | undefined;
|
|
11
|
+
onfocus?: HTMLTextareaAttributes["onfocus"];
|
|
12
|
+
onblur?: HTMLTextareaAttributes["onblur"];
|
|
13
|
+
onselect?: HTMLTextareaAttributes["onselect"];
|
|
14
|
+
};
|
|
7
15
|
|
|
8
16
|
let {
|
|
9
17
|
ref = $bindable(null),
|
|
10
18
|
value = $bindable(),
|
|
19
|
+
disabled,
|
|
20
|
+
status,
|
|
11
21
|
class: className,
|
|
22
|
+
"aria-invalid": ariaInvalid,
|
|
23
|
+
onfocus,
|
|
24
|
+
onblur,
|
|
25
|
+
onselect,
|
|
12
26
|
...restProps
|
|
13
27
|
}: Props = $props();
|
|
28
|
+
|
|
29
|
+
let focused = $state(false);
|
|
30
|
+
let textSelected = $state(false);
|
|
31
|
+
|
|
32
|
+
function readSelected(node: EventTarget | null): boolean {
|
|
33
|
+
if (!(node instanceof HTMLTextAreaElement)) return false;
|
|
34
|
+
if (node.selectionStart == null || node.selectionEnd == null) return false;
|
|
35
|
+
return node.selectionStart !== node.selectionEnd;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const filled = $derived(value != null && String(value).length > 0);
|
|
39
|
+
|
|
40
|
+
const inputState = $derived.by((): TextareaState => {
|
|
41
|
+
if (disabled) return "disabled";
|
|
42
|
+
if (status === "loading") return "loading";
|
|
43
|
+
if (status === "error" || ariaInvalid === true || ariaInvalid === "true") return "error";
|
|
44
|
+
if (status === "success") return "success";
|
|
45
|
+
if (focused && textSelected) return "selected";
|
|
46
|
+
if (focused) return "focus";
|
|
47
|
+
if (filled) return "complete";
|
|
48
|
+
return "default";
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
function handleFocus(event: FocusEvent & { currentTarget: EventTarget & HTMLTextAreaElement }) {
|
|
52
|
+
focused = true;
|
|
53
|
+
textSelected = readSelected(event.currentTarget);
|
|
54
|
+
onfocus?.(event);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function handleBlur(event: FocusEvent & { currentTarget: EventTarget & HTMLTextAreaElement }) {
|
|
58
|
+
focused = false;
|
|
59
|
+
textSelected = false;
|
|
60
|
+
onblur?.(event);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function handleSelect(event: Event & { currentTarget: EventTarget & HTMLTextAreaElement }) {
|
|
64
|
+
textSelected = readSelected(event.currentTarget);
|
|
65
|
+
onselect?.(event);
|
|
66
|
+
}
|
|
14
67
|
</script>
|
|
15
68
|
|
|
16
69
|
<textarea
|
|
17
70
|
bind:this={ref}
|
|
18
71
|
data-slot="textarea"
|
|
72
|
+
data-input-state={inputState}
|
|
73
|
+
aria-invalid={ariaInvalid}
|
|
74
|
+
aria-busy={inputState === "loading" ? "true" : undefined}
|
|
19
75
|
class={cn(uiTextarea().root, className)}
|
|
76
|
+
{disabled}
|
|
20
77
|
bind:value
|
|
21
78
|
{...restProps}
|
|
79
|
+
onfocus={handleFocus}
|
|
80
|
+
onblur={handleBlur}
|
|
81
|
+
onselect={handleSelect}
|
|
22
82
|
></textarea>
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { HTMLTextareaAttributes } from "svelte/elements";
|
|
2
2
|
import { type WithElementRef } from "../../../utils.js";
|
|
3
|
-
type
|
|
3
|
+
type TextareaStatus = "success" | "error" | "loading";
|
|
4
|
+
type Props = WithElementRef<Omit<HTMLTextareaAttributes, "onfocus" | "onblur" | "onselect">> & {
|
|
5
|
+
status?: TextareaStatus | undefined;
|
|
6
|
+
onfocus?: HTMLTextareaAttributes["onfocus"];
|
|
7
|
+
onblur?: HTMLTextareaAttributes["onblur"];
|
|
8
|
+
onselect?: HTMLTextareaAttributes["onselect"];
|
|
9
|
+
};
|
|
4
10
|
declare const Textarea: import("svelte").Component<Props, {}, "value" | "ref">;
|
|
5
11
|
type Textarea = ReturnType<typeof Textarea>;
|
|
6
12
|
export default Textarea;
|
|
@@ -71,6 +71,7 @@
|
|
|
71
71
|
child?: Snippet<[TooltipContentChildProps]>;
|
|
72
72
|
arrowClasses?: string;
|
|
73
73
|
portalProps?: WithoutChildrenOrChild<ComponentProps<typeof TooltipPortal>>;
|
|
74
|
+
size?: "default" | "mini";
|
|
74
75
|
};
|
|
75
76
|
|
|
76
77
|
let {
|
|
@@ -105,6 +106,7 @@
|
|
|
105
106
|
child,
|
|
106
107
|
arrowClasses,
|
|
107
108
|
portalProps,
|
|
109
|
+
size = "default",
|
|
108
110
|
...domProps
|
|
109
111
|
}: TooltipContentProps = $props();
|
|
110
112
|
|
|
@@ -136,7 +138,8 @@
|
|
|
136
138
|
);
|
|
137
139
|
const contentClass = $derived(
|
|
138
140
|
cn(
|
|
139
|
-
"animate-in fade-in-0 zoom-in-95 inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-
|
|
141
|
+
"animate-in fade-in-0 zoom-in-95 inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-sm has-data-[slot=kbd]:pr-1.5 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm bg-foreground text-background shadow-md dark:bg-card dark:text-foreground dark:border dark:border-border z-50 w-fit max-w-xs",
|
|
142
|
+
size === "mini" ? "min-h-[30px]" : "min-h-[38px]",
|
|
140
143
|
className
|
|
141
144
|
)
|
|
142
145
|
);
|
|
@@ -183,6 +186,7 @@
|
|
|
183
186
|
id: contentId,
|
|
184
187
|
role: "tooltip",
|
|
185
188
|
"data-slot": "tooltip-content",
|
|
189
|
+
"data-size": size,
|
|
186
190
|
"data-state": tooltip.open ? "instant-open" : "closed",
|
|
187
191
|
"data-starting-style": tooltip.presenceStatus === "starting" ? "" : undefined,
|
|
188
192
|
"data-ending-style": tooltip.presenceStatus === "ending" ? "" : undefined,
|
|
@@ -44,6 +44,7 @@ type TooltipContentProps = Omit<HTMLAttributes<HTMLDivElement>, "children" | "cl
|
|
|
44
44
|
child?: Snippet<[TooltipContentChildProps]>;
|
|
45
45
|
arrowClasses?: string;
|
|
46
46
|
portalProps?: WithoutChildrenOrChild<ComponentProps<typeof TooltipPortal>>;
|
|
47
|
+
size?: "default" | "mini";
|
|
47
48
|
};
|
|
48
49
|
declare const TooltipContent: import("svelte").Component<TooltipContentProps, {}, "ref">;
|
|
49
50
|
type TooltipContent = ReturnType<typeof TooltipContent>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { formatAdminCopy, formatAdminCurrency, formatAdminDate, formatAdminEllipsis, formatAdminEmDash, formatAdminEnglishPunctuation, formatAdminLessThanOrEqual, formatAdminNumber, formatAdminNumericRange, formatAdminPercent, formatAdminTime, spaceCjkLatin, } from '@svadmin/core/copy-format';
|
|
2
|
+
export type { AdminCurrencyOptions, AdminDateOptions, AdminNumberOptions, AdminPercentOptions, AdminTimeOptions, } from '@svadmin/core/copy-format';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { formatAdminCopy, formatAdminCurrency, formatAdminDate, formatAdminEllipsis, formatAdminEmDash, formatAdminEnglishPunctuation, formatAdminLessThanOrEqual, formatAdminNumber, formatAdminNumericRange, formatAdminPercent, formatAdminTime, spaceCjkLatin, } from '@svadmin/core/copy-format';
|
package/dist/index.d.ts
CHANGED
|
@@ -191,6 +191,8 @@ export { default as NumberInput } from './components/NumberInput.svelte';
|
|
|
191
191
|
export { default as InputNumber } from './components/NumberInput.svelte';
|
|
192
192
|
export { NUMERIC_INPUT_LOCALES, isNumericInputLocale } from './components/numeric-format.js';
|
|
193
193
|
export type { NumericInputLocale, NumericParseResult } from './components/numeric-format.js';
|
|
194
|
+
export { formatAdminCopy, formatAdminCurrency, formatAdminDate, formatAdminEllipsis, formatAdminEmDash, formatAdminEnglishPunctuation, formatAdminLessThanOrEqual, formatAdminNumber, formatAdminNumericRange, formatAdminPercent, formatAdminTime, spaceCjkLatin } from './copy-format.js';
|
|
195
|
+
export type { AdminCurrencyOptions, AdminDateOptions, AdminNumberOptions, AdminPercentOptions, AdminTimeOptions } from './copy-format.js';
|
|
194
196
|
export { default as MoneyInput } from './components/MoneyInput.svelte';
|
|
195
197
|
export { default as PercentInput } from './components/PercentInput.svelte';
|
|
196
198
|
export { default as DateTimeInput } from './components/DateTimeInput.svelte';
|
|
@@ -264,6 +266,7 @@ export { default as CurrencyField } from './components/fields/CurrencyField.svel
|
|
|
264
266
|
export { default as PhoneField } from './components/fields/PhoneField.svelte';
|
|
265
267
|
export { CreateButton, EditButton, DeleteButton, ShowButton, ListButton, RefreshButton, ExportButton, ImportButton, SaveButton, CloneButton, } from './components/buttons/index.js';
|
|
266
268
|
export { Button, buttonVariants } from './components/ui/button/index.js';
|
|
269
|
+
export { default as TooltipButton } from './components/TooltipButton.svelte';
|
|
267
270
|
export { Input } from './components/ui/input/index.js';
|
|
268
271
|
export { default as InputGroup } from './components/InputGroup.svelte';
|
|
269
272
|
export type { InputGroupProps } from './components/InputGroup.svelte';
|
package/dist/index.js
CHANGED
|
@@ -141,6 +141,7 @@ export { default as NumericInput } from './components/NumericInput.svelte';
|
|
|
141
141
|
export { default as NumberInput } from './components/NumberInput.svelte';
|
|
142
142
|
export { default as InputNumber } from './components/NumberInput.svelte';
|
|
143
143
|
export { NUMERIC_INPUT_LOCALES, isNumericInputLocale } from './components/numeric-format.js';
|
|
144
|
+
export { formatAdminCopy, formatAdminCurrency, formatAdminDate, formatAdminEllipsis, formatAdminEmDash, formatAdminEnglishPunctuation, formatAdminLessThanOrEqual, formatAdminNumber, formatAdminNumericRange, formatAdminPercent, formatAdminTime, spaceCjkLatin } from './copy-format.js';
|
|
144
145
|
export { default as MoneyInput } from './components/MoneyInput.svelte';
|
|
145
146
|
export { default as PercentInput } from './components/PercentInput.svelte';
|
|
146
147
|
export { default as DateTimeInput } from './components/DateTimeInput.svelte';
|
|
@@ -210,6 +211,7 @@ export { default as PhoneField } from './components/fields/PhoneField.svelte';
|
|
|
210
211
|
export { CreateButton, EditButton, DeleteButton, ShowButton, ListButton, RefreshButton, ExportButton, ImportButton, SaveButton, CloneButton, } from './components/buttons/index.js';
|
|
211
212
|
// Base UI components (shadcn-svelte)
|
|
212
213
|
export { Button, buttonVariants } from './components/ui/button/index.js';
|
|
214
|
+
export { default as TooltipButton } from './components/TooltipButton.svelte';
|
|
213
215
|
export { Input } from './components/ui/input/index.js';
|
|
214
216
|
export { default as InputGroup } from './components/InputGroup.svelte';
|
|
215
217
|
export { Textarea } from './components/ui/textarea/index.js';
|
|
@@ -28,7 +28,7 @@ export function createNotificationController() {
|
|
|
28
28
|
id: nextId++,
|
|
29
29
|
tone: options.tone ?? 'info',
|
|
30
30
|
placement: options.placement ?? 'top-right',
|
|
31
|
-
duration: options.duration ??
|
|
31
|
+
duration: options.duration ?? 3000,
|
|
32
32
|
};
|
|
33
33
|
items = [...items, item];
|
|
34
34
|
if (item.duration > 0) {
|
package/dist/page-chrome.css
CHANGED
|
@@ -19,6 +19,11 @@
|
|
|
19
19
|
}
|
|
20
20
|
.svadmin-page-header__breadcrumbs {
|
|
21
21
|
margin-bottom: var(--svadmin-space-4);
|
|
22
|
+
line-height: 1.5;
|
|
23
|
+
}
|
|
24
|
+
/* 说明文字保持 1.5,正文才是 1.4。历史内容基线把 eyebrow 钉在 1.5。 */
|
|
25
|
+
.svadmin-page-header__eyebrow {
|
|
26
|
+
line-height: 1.5;
|
|
22
27
|
}
|
|
23
28
|
.svadmin-page-header__row, .svadmin-filter-toolbar__row {
|
|
24
29
|
display: flex;
|