@svadmin/ui 0.111.0 → 0.113.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 +216 -0
- package/dist/app.theme.css +216 -0
- package/dist/components/AboutSettings.svelte +1 -1
- package/dist/components/AutoForm.svelte +24 -35
- package/dist/components/FormDependency.svelte +36 -0
- package/dist/components/FormDependency.svelte.d.ts +12 -0
- package/dist/components/Icon.svelte +57 -0
- package/dist/components/Icon.svelte.d.ts +10 -0
- package/dist/components/JsonSchemaForm.svelte +68 -10
- package/dist/components/PageContainer.svelte +263 -0
- package/dist/components/PageContainer.svelte.d.ts +53 -0
- package/dist/components/ProDescriptions.svelte +278 -0
- package/dist/components/ProDescriptions.svelte.d.ts +37 -0
- package/dist/components/QueryFilter.svelte +194 -0
- package/dist/components/QueryFilter.svelte.d.ts +34 -0
- package/dist/components/RealtimeMonitorView.svelte +245 -0
- package/dist/components/RealtimeMonitorView.svelte.d.ts +40 -0
- package/dist/components/RoleSwitcher.svelte +267 -0
- package/dist/components/RoleSwitcher.svelte.d.ts +40 -0
- package/dist/components/WorkflowDesigner.svelte +244 -0
- package/dist/components/WorkflowDesigner.svelte.d.ts +29 -0
- package/dist/components/auto-form-layout.d.ts +28 -0
- package/dist/components/auto-form-layout.js +70 -0
- package/dist/components/fields/UploadField.svelte +222 -0
- package/dist/components/fields/UploadField.svelte.d.ts +14 -0
- package/dist/components/icons/IconApprove.svelte +35 -0
- package/dist/components/icons/IconApprove.svelte.d.ts +4 -0
- package/dist/components/icons/IconAudit.svelte +38 -0
- package/dist/components/icons/IconAudit.svelte.d.ts +4 -0
- package/dist/components/icons/IconBilling.svelte +37 -0
- package/dist/components/icons/IconBilling.svelte.d.ts +4 -0
- package/dist/components/icons/IconCluster.svelte +41 -0
- package/dist/components/icons/IconCluster.svelte.d.ts +4 -0
- package/dist/components/icons/IconMonitor.svelte +37 -0
- package/dist/components/icons/IconMonitor.svelte.d.ts +4 -0
- package/dist/components/icons/IconReject.svelte +36 -0
- package/dist/components/icons/IconReject.svelte.d.ts +4 -0
- package/dist/components/icons/IconSeal.svelte +36 -0
- package/dist/components/icons/IconSeal.svelte.d.ts +4 -0
- package/dist/components/icons/IconSecurity.svelte +35 -0
- package/dist/components/icons/IconSecurity.svelte.d.ts +4 -0
- package/dist/components/icons/IconTenant.svelte +39 -0
- package/dist/components/icons/IconTenant.svelte.d.ts +4 -0
- package/dist/components/icons/IconWorkflow.svelte +38 -0
- package/dist/components/icons/IconWorkflow.svelte.d.ts +4 -0
- package/dist/components/icons/index.d.ts +11 -0
- package/dist/components/icons/index.js +10 -0
- package/dist/components/icons/types.d.ts +15 -0
- package/dist/components/icons/types.js +1 -0
- package/dist/components/json-schema-form-state.d.ts +3 -1
- package/dist/icon-registry.d.ts +27 -0
- package/dist/icon-registry.js +52 -0
- package/dist/icons.d.ts +5 -1
- package/dist/icons.js +4 -0
- package/dist/index.d.ts +27 -7
- package/dist/index.js +19 -6
- package/dist/intent-preload.d.ts +28 -0
- package/dist/intent-preload.js +76 -0
- package/package.json +5 -5
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import { cn } from '../utils';
|
|
4
|
+
|
|
5
|
+
export interface ProDescriptionItem {
|
|
6
|
+
key: string;
|
|
7
|
+
label: string;
|
|
8
|
+
value?: unknown;
|
|
9
|
+
span?: number;
|
|
10
|
+
editable?: boolean;
|
|
11
|
+
type?: 'text' | 'number' | 'tag' | 'badge';
|
|
12
|
+
tone?: 'primary' | 'success' | 'warning' | 'danger' | 'neutral';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ProDescriptionsProps {
|
|
16
|
+
/** Title of the descriptions card */
|
|
17
|
+
title?: string;
|
|
18
|
+
/** Whether to display a border around the container and between cells (default: true) */
|
|
19
|
+
bordered?: boolean;
|
|
20
|
+
/** Number of columns in a row (1, 2, 3, or 4, default: 3) */
|
|
21
|
+
columns?: 1 | 2 | 3 | 4;
|
|
22
|
+
/** Density / size of the cells: 'small' | 'default' | 'large' (default: 'default') */
|
|
23
|
+
size?: 'small' | 'default' | 'large';
|
|
24
|
+
/** Layout direction of label and value: 'horizontal' | 'vertical' (default: 'horizontal') */
|
|
25
|
+
layout?: 'horizontal' | 'vertical';
|
|
26
|
+
/** List of description items to render */
|
|
27
|
+
items?: ProDescriptionItem[];
|
|
28
|
+
/** Whether inline editing is enabled globally */
|
|
29
|
+
editable?: boolean;
|
|
30
|
+
/** Callback triggered when a field value is saved */
|
|
31
|
+
onedit?: (key: string, value: unknown) => void | Promise<void>;
|
|
32
|
+
/** Extra actions slot on the top right */
|
|
33
|
+
extra?: Snippet;
|
|
34
|
+
/** Children slot */
|
|
35
|
+
children?: Snippet;
|
|
36
|
+
/** Additional CSS classes */
|
|
37
|
+
class?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let {
|
|
41
|
+
title,
|
|
42
|
+
bordered = true,
|
|
43
|
+
columns = 3,
|
|
44
|
+
size = 'default',
|
|
45
|
+
layout = 'horizontal',
|
|
46
|
+
items = [],
|
|
47
|
+
editable = false,
|
|
48
|
+
onedit,
|
|
49
|
+
extra,
|
|
50
|
+
children,
|
|
51
|
+
class: className = '',
|
|
52
|
+
}: ProDescriptionsProps = $props();
|
|
53
|
+
|
|
54
|
+
let editingKey = $state<string | null>(null);
|
|
55
|
+
let editValue = $state<unknown>('');
|
|
56
|
+
let isSaving = $state(false);
|
|
57
|
+
|
|
58
|
+
function startEdit(item: ProDescriptionItem) {
|
|
59
|
+
editingKey = item.key;
|
|
60
|
+
editValue = item.value ?? '';
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function cancelEdit() {
|
|
64
|
+
editingKey = null;
|
|
65
|
+
editValue = '';
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async function saveEdit(key: string) {
|
|
69
|
+
if (!onedit) {
|
|
70
|
+
editingKey = null;
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
isSaving = true;
|
|
74
|
+
try {
|
|
75
|
+
await onedit(key, editValue);
|
|
76
|
+
editingKey = null;
|
|
77
|
+
} finally {
|
|
78
|
+
isSaving = false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function getPaddingClass(size: 'small' | 'default' | 'large'): string {
|
|
83
|
+
switch (size) {
|
|
84
|
+
case 'small':
|
|
85
|
+
return 'px-3 py-1.5 text-xs';
|
|
86
|
+
case 'large':
|
|
87
|
+
return 'px-5 py-3.5 text-sm';
|
|
88
|
+
case 'default':
|
|
89
|
+
default:
|
|
90
|
+
return 'px-4 py-2.5 text-xs';
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function getTagToneClasses(tone?: ProDescriptionItem['tone']): string {
|
|
95
|
+
switch (tone) {
|
|
96
|
+
case 'success':
|
|
97
|
+
return 'bg-success/10 text-success border-success/30';
|
|
98
|
+
case 'warning':
|
|
99
|
+
return 'bg-warning/10 text-warning border-warning/30';
|
|
100
|
+
case 'danger':
|
|
101
|
+
return 'bg-destructive/10 text-destructive border-destructive/30';
|
|
102
|
+
case 'primary':
|
|
103
|
+
return 'bg-primary/10 text-primary border-primary/30';
|
|
104
|
+
case 'neutral':
|
|
105
|
+
default:
|
|
106
|
+
return 'bg-muted text-muted-foreground border-border';
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
let gridColsClass = $derived.by(() => {
|
|
111
|
+
switch (columns) {
|
|
112
|
+
case 1:
|
|
113
|
+
return 'grid-cols-1';
|
|
114
|
+
case 2:
|
|
115
|
+
return 'grid-cols-1 md:grid-cols-2';
|
|
116
|
+
case 4:
|
|
117
|
+
return 'grid-cols-1 sm:grid-cols-2 md:grid-cols-4';
|
|
118
|
+
case 3:
|
|
119
|
+
default:
|
|
120
|
+
return 'grid-cols-1 sm:grid-cols-2 md:grid-cols-3';
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
</script>
|
|
124
|
+
|
|
125
|
+
<div
|
|
126
|
+
data-svadmin-component="ProDescriptions"
|
|
127
|
+
class={cn(
|
|
128
|
+
'svadmin-pro-descriptions rounded-[4px] bg-card text-card-foreground',
|
|
129
|
+
className
|
|
130
|
+
)}
|
|
131
|
+
>
|
|
132
|
+
{#if title || extra}
|
|
133
|
+
<div class="mb-3 flex items-center justify-between gap-3">
|
|
134
|
+
{#if title}
|
|
135
|
+
<h3 class="text-sm font-semibold tracking-tight text-foreground">
|
|
136
|
+
{title}
|
|
137
|
+
</h3>
|
|
138
|
+
{/if}
|
|
139
|
+
{#if extra}
|
|
140
|
+
<div class="flex items-center gap-2">
|
|
141
|
+
{@render extra()}
|
|
142
|
+
</div>
|
|
143
|
+
{/if}
|
|
144
|
+
</div>
|
|
145
|
+
{/if}
|
|
146
|
+
|
|
147
|
+
{#if items && items.length > 0}
|
|
148
|
+
<div
|
|
149
|
+
class={cn(
|
|
150
|
+
'grid overflow-hidden rounded-[4px]',
|
|
151
|
+
bordered && 'border border-border',
|
|
152
|
+
gridColsClass
|
|
153
|
+
)}
|
|
154
|
+
>
|
|
155
|
+
{#each items as item (item.key)}
|
|
156
|
+
{@const span = Math.min(item.span || 1, columns)}
|
|
157
|
+
{@const isItemEditable = editable || item.editable}
|
|
158
|
+
<div
|
|
159
|
+
class={cn(
|
|
160
|
+
'flex flex-col border-border',
|
|
161
|
+
bordered && 'border-b border-r last:border-b-0',
|
|
162
|
+
span === 2 && 'sm:col-span-2',
|
|
163
|
+
span === 3 && 'sm:col-span-2 md:col-span-3',
|
|
164
|
+
span === 4 && 'sm:col-span-2 md:col-span-4',
|
|
165
|
+
layout === 'horizontal' ? 'sm:flex-row' : 'flex-col'
|
|
166
|
+
)}
|
|
167
|
+
>
|
|
168
|
+
<!-- Label -->
|
|
169
|
+
<div
|
|
170
|
+
class={cn(
|
|
171
|
+
'font-medium text-muted-foreground select-none',
|
|
172
|
+
getPaddingClass(size),
|
|
173
|
+
bordered
|
|
174
|
+
? 'bg-muted/40 border-border'
|
|
175
|
+
: 'bg-transparent text-muted-foreground',
|
|
176
|
+
layout === 'horizontal' ? 'sm:w-36 shrink-0 sm:border-r' : 'border-b'
|
|
177
|
+
)}
|
|
178
|
+
>
|
|
179
|
+
{item.label}
|
|
180
|
+
</div>
|
|
181
|
+
|
|
182
|
+
<!-- Value -->
|
|
183
|
+
<div
|
|
184
|
+
class={cn(
|
|
185
|
+
'group/cell relative flex flex-1 items-center justify-between gap-2 text-foreground',
|
|
186
|
+
getPaddingClass(size),
|
|
187
|
+
bordered ? 'bg-card' : 'bg-transparent'
|
|
188
|
+
)}
|
|
189
|
+
>
|
|
190
|
+
{#if editingKey === item.key}
|
|
191
|
+
<!-- Inline edit mode -->
|
|
192
|
+
<div class="flex w-full items-center gap-2">
|
|
193
|
+
<input
|
|
194
|
+
type={item.type === 'number' ? 'number' : 'text'}
|
|
195
|
+
bind:value={editValue}
|
|
196
|
+
class="h-7 w-full rounded-[2px] border border-primary bg-background px-2 text-xs focus:outline-none"
|
|
197
|
+
disabled={isSaving}
|
|
198
|
+
onkeydown={(e) => {
|
|
199
|
+
if (e.key === 'Enter') saveEdit(item.key);
|
|
200
|
+
if (e.key === 'Escape') cancelEdit();
|
|
201
|
+
}}
|
|
202
|
+
/>
|
|
203
|
+
<button
|
|
204
|
+
type="button"
|
|
205
|
+
aria-label="保存"
|
|
206
|
+
class="inline-flex h-6 w-6 items-center justify-center rounded-[2px] bg-primary text-primary-foreground hover:bg-primary/90"
|
|
207
|
+
onclick={() => saveEdit(item.key)}
|
|
208
|
+
>
|
|
209
|
+
<svg class="h-3.5 w-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
|
|
210
|
+
<polyline points="20 6 9 17 4 12" />
|
|
211
|
+
</svg>
|
|
212
|
+
</button>
|
|
213
|
+
<button
|
|
214
|
+
type="button"
|
|
215
|
+
aria-label="取消"
|
|
216
|
+
class="inline-flex h-6 w-6 items-center justify-center rounded-[2px] border border-border text-muted-foreground hover:bg-muted"
|
|
217
|
+
onclick={cancelEdit}
|
|
218
|
+
>
|
|
219
|
+
<svg class="h-3.5 w-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
|
|
220
|
+
<line x1="18" y1="6" x2="6" y2="18" />
|
|
221
|
+
<line x1="6" y1="6" x2="18" y2="18" />
|
|
222
|
+
</svg>
|
|
223
|
+
</button>
|
|
224
|
+
</div>
|
|
225
|
+
{:else}
|
|
226
|
+
<!-- Display mode -->
|
|
227
|
+
<div class="flex items-center gap-2">
|
|
228
|
+
{#if item.type === 'tag'}
|
|
229
|
+
<span
|
|
230
|
+
class={cn(
|
|
231
|
+
'inline-flex items-center rounded-[2px] border px-2 py-0.5 text-[11px] font-medium leading-none',
|
|
232
|
+
getTagToneClasses(item.tone)
|
|
233
|
+
)}
|
|
234
|
+
>
|
|
235
|
+
{item.value ?? '-'}
|
|
236
|
+
</span>
|
|
237
|
+
{:else if item.type === 'badge'}
|
|
238
|
+
<span class="inline-flex items-center gap-1.5">
|
|
239
|
+
<span
|
|
240
|
+
class={cn(
|
|
241
|
+
'h-1.5 w-1.5 rounded-full',
|
|
242
|
+
item.tone === 'success' && 'bg-success',
|
|
243
|
+
item.tone === 'warning' && 'bg-warning',
|
|
244
|
+
item.tone === 'danger' && 'bg-destructive',
|
|
245
|
+
(!item.tone || item.tone === 'primary') && 'bg-primary'
|
|
246
|
+
)}
|
|
247
|
+
></span>
|
|
248
|
+
<span>{item.value ?? '-'}</span>
|
|
249
|
+
</span>
|
|
250
|
+
{:else}
|
|
251
|
+
<span>{item.value !== undefined && item.value !== null && item.value !== '' ? item.value : '-'}</span>
|
|
252
|
+
{/if}
|
|
253
|
+
</div>
|
|
254
|
+
|
|
255
|
+
{#if isItemEditable}
|
|
256
|
+
<button
|
|
257
|
+
type="button"
|
|
258
|
+
aria-label={`编辑 ${item.label}`}
|
|
259
|
+
class="opacity-0 transition-opacity group-hover/cell:opacity-100 p-1 text-muted-foreground hover:text-primary"
|
|
260
|
+
onclick={() => startEdit(item)}
|
|
261
|
+
>
|
|
262
|
+
<svg class="h-3.5 w-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
263
|
+
<path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z" />
|
|
264
|
+
<path d="m15 5 4 4" />
|
|
265
|
+
</svg>
|
|
266
|
+
</button>
|
|
267
|
+
{/if}
|
|
268
|
+
{/if}
|
|
269
|
+
</div>
|
|
270
|
+
</div>
|
|
271
|
+
{/each}
|
|
272
|
+
</div>
|
|
273
|
+
{/if}
|
|
274
|
+
|
|
275
|
+
{#if children}
|
|
276
|
+
{@render children()}
|
|
277
|
+
{/if}
|
|
278
|
+
</div>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export interface ProDescriptionItem {
|
|
3
|
+
key: string;
|
|
4
|
+
label: string;
|
|
5
|
+
value?: unknown;
|
|
6
|
+
span?: number;
|
|
7
|
+
editable?: boolean;
|
|
8
|
+
type?: 'text' | 'number' | 'tag' | 'badge';
|
|
9
|
+
tone?: 'primary' | 'success' | 'warning' | 'danger' | 'neutral';
|
|
10
|
+
}
|
|
11
|
+
export interface ProDescriptionsProps {
|
|
12
|
+
/** Title of the descriptions card */
|
|
13
|
+
title?: string;
|
|
14
|
+
/** Whether to display a border around the container and between cells (default: true) */
|
|
15
|
+
bordered?: boolean;
|
|
16
|
+
/** Number of columns in a row (1, 2, 3, or 4, default: 3) */
|
|
17
|
+
columns?: 1 | 2 | 3 | 4;
|
|
18
|
+
/** Density / size of the cells: 'small' | 'default' | 'large' (default: 'default') */
|
|
19
|
+
size?: 'small' | 'default' | 'large';
|
|
20
|
+
/** Layout direction of label and value: 'horizontal' | 'vertical' (default: 'horizontal') */
|
|
21
|
+
layout?: 'horizontal' | 'vertical';
|
|
22
|
+
/** List of description items to render */
|
|
23
|
+
items?: ProDescriptionItem[];
|
|
24
|
+
/** Whether inline editing is enabled globally */
|
|
25
|
+
editable?: boolean;
|
|
26
|
+
/** Callback triggered when a field value is saved */
|
|
27
|
+
onedit?: (key: string, value: unknown) => void | Promise<void>;
|
|
28
|
+
/** Extra actions slot on the top right */
|
|
29
|
+
extra?: Snippet;
|
|
30
|
+
/** Children slot */
|
|
31
|
+
children?: Snippet;
|
|
32
|
+
/** Additional CSS classes */
|
|
33
|
+
class?: string;
|
|
34
|
+
}
|
|
35
|
+
declare const ProDescriptions: import("svelte").Component<ProDescriptionsProps, {}, "">;
|
|
36
|
+
type ProDescriptions = ReturnType<typeof ProDescriptions>;
|
|
37
|
+
export default ProDescriptions;
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import { cn } from '../utils';
|
|
4
|
+
|
|
5
|
+
export interface QueryFilterProps {
|
|
6
|
+
/** Number of columns in the grid layout (1 - 4, default: 3) */
|
|
7
|
+
cols?: 1 | 2 | 3 | 4;
|
|
8
|
+
/** Initial collapsed state when uncontrolled */
|
|
9
|
+
defaultCollapsed?: boolean;
|
|
10
|
+
/** Controlled collapsed state */
|
|
11
|
+
collapsed?: boolean;
|
|
12
|
+
/** Callback triggered when collapsed state changes */
|
|
13
|
+
oncollapse?: (collapsed: boolean) => void;
|
|
14
|
+
/** Callback triggered when search/filter form is submitted */
|
|
15
|
+
onsubmit?: (event?: SubmitEvent) => void;
|
|
16
|
+
/** Callback triggered when reset button is clicked */
|
|
17
|
+
onreset?: () => void;
|
|
18
|
+
/** Label text for search button (default: '查询') */
|
|
19
|
+
searchBtnText?: string;
|
|
20
|
+
/** Label text for reset button (default: '重置') */
|
|
21
|
+
resetBtnText?: string;
|
|
22
|
+
/** Whether to show the expand/collapse toggle button (default: true) */
|
|
23
|
+
showCollapseButton?: boolean;
|
|
24
|
+
/** Whether to show the reset button (default: true) */
|
|
25
|
+
showResetButton?: boolean;
|
|
26
|
+
/** Label layout mode: horizontal, vertical, or inline (default: 'horizontal') */
|
|
27
|
+
layout?: 'horizontal' | 'vertical' | 'inline';
|
|
28
|
+
/** Content slot containing form filter items */
|
|
29
|
+
children?: Snippet;
|
|
30
|
+
/** Custom extra action buttons slot next to search/reset */
|
|
31
|
+
extra?: Snippet;
|
|
32
|
+
/** Custom class for the wrapper container */
|
|
33
|
+
class?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let {
|
|
37
|
+
cols = 3,
|
|
38
|
+
defaultCollapsed = true,
|
|
39
|
+
collapsed = $bindable(),
|
|
40
|
+
oncollapse,
|
|
41
|
+
onsubmit,
|
|
42
|
+
onreset,
|
|
43
|
+
searchBtnText = '查询',
|
|
44
|
+
resetBtnText = '重置',
|
|
45
|
+
showCollapseButton = true,
|
|
46
|
+
showResetButton = true,
|
|
47
|
+
layout = 'horizontal',
|
|
48
|
+
children,
|
|
49
|
+
extra,
|
|
50
|
+
class: className = '',
|
|
51
|
+
}: QueryFilterProps = $props();
|
|
52
|
+
|
|
53
|
+
// Internal collapsed state if not externally controlled
|
|
54
|
+
let internalCollapsed = $derived(collapsed ?? defaultCollapsed);
|
|
55
|
+
|
|
56
|
+
function toggleCollapse() {
|
|
57
|
+
const next = !internalCollapsed;
|
|
58
|
+
internalCollapsed = next;
|
|
59
|
+
collapsed = next;
|
|
60
|
+
oncollapse?.(next);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function handleSubmit(event: SubmitEvent) {
|
|
64
|
+
event.preventDefault();
|
|
65
|
+
onsubmit?.(event);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function handleReset() {
|
|
69
|
+
onreset?.();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
let gridColsClass = $derived.by(() => {
|
|
73
|
+
switch (cols) {
|
|
74
|
+
case 1:
|
|
75
|
+
return 'grid-cols-1';
|
|
76
|
+
case 2:
|
|
77
|
+
return 'grid-cols-1 md:grid-cols-2';
|
|
78
|
+
case 4:
|
|
79
|
+
return 'grid-cols-1 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4';
|
|
80
|
+
case 3:
|
|
81
|
+
default:
|
|
82
|
+
return 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-3';
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
</script>
|
|
86
|
+
|
|
87
|
+
<form
|
|
88
|
+
role="search"
|
|
89
|
+
aria-label="Query filter form"
|
|
90
|
+
data-svadmin-component="QueryFilter"
|
|
91
|
+
class={cn(
|
|
92
|
+
'svadmin-query-filter group/qf relative rounded-[4px] border border-border bg-card p-4 text-card-foreground shadow-xs transition-all duration-200',
|
|
93
|
+
className
|
|
94
|
+
)}
|
|
95
|
+
onsubmit={handleSubmit}
|
|
96
|
+
>
|
|
97
|
+
<div
|
|
98
|
+
class={cn(
|
|
99
|
+
'svadmin-query-filter-grid grid gap-x-4 gap-y-3.5',
|
|
100
|
+
gridColsClass,
|
|
101
|
+
layout === 'vertical' && 'items-start',
|
|
102
|
+
layout === 'horizontal' && 'items-center',
|
|
103
|
+
layout === 'inline' && 'flex flex-wrap items-center'
|
|
104
|
+
)}
|
|
105
|
+
>
|
|
106
|
+
{#if !internalCollapsed && children}
|
|
107
|
+
{@render children()}
|
|
108
|
+
{/if}
|
|
109
|
+
|
|
110
|
+
<!-- Actions area -->
|
|
111
|
+
<div
|
|
112
|
+
class={cn(
|
|
113
|
+
'svadmin-query-filter-actions flex items-center justify-end gap-2.5 pt-1 sm:pt-0',
|
|
114
|
+
cols === 1 ? 'col-span-1' : '',
|
|
115
|
+
cols === 2 ? 'col-span-1 md:col-span-2' : '',
|
|
116
|
+
cols === 3 ? 'col-span-1 sm:col-span-2 lg:col-span-3' : '',
|
|
117
|
+
cols === 4 ? 'col-span-1 sm:col-span-2 md:col-span-3 xl:col-span-4' : ''
|
|
118
|
+
)}
|
|
119
|
+
>
|
|
120
|
+
{#if showResetButton}
|
|
121
|
+
<button
|
|
122
|
+
type="button"
|
|
123
|
+
aria-label={resetBtnText}
|
|
124
|
+
class="svadmin-btn-reset inline-flex h-8 items-center justify-center rounded-[4px] border border-border bg-transparent px-3 text-xs font-normal text-muted-foreground transition-colors hover:bg-muted active:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/20"
|
|
125
|
+
onclick={handleReset}
|
|
126
|
+
>
|
|
127
|
+
<svg
|
|
128
|
+
class="mr-1.5 h-3.5 w-3.5"
|
|
129
|
+
viewBox="0 0 24 24"
|
|
130
|
+
fill="none"
|
|
131
|
+
stroke="currentColor"
|
|
132
|
+
stroke-width="2"
|
|
133
|
+
stroke-linecap="round"
|
|
134
|
+
stroke-linejoin="round"
|
|
135
|
+
>
|
|
136
|
+
<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" />
|
|
137
|
+
<path d="M3 3v5h5" />
|
|
138
|
+
</svg>
|
|
139
|
+
{resetBtnText}
|
|
140
|
+
</button>
|
|
141
|
+
{/if}
|
|
142
|
+
|
|
143
|
+
<button
|
|
144
|
+
type="submit"
|
|
145
|
+
aria-label={searchBtnText}
|
|
146
|
+
class="svadmin-btn-search inline-flex h-8 items-center justify-center rounded-[4px] bg-primary px-3.5 text-xs font-medium text-primary-foreground shadow-xs transition-colors hover:bg-primary/90 active:bg-primary/80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40"
|
|
147
|
+
>
|
|
148
|
+
<svg
|
|
149
|
+
class="mr-1.5 h-3.5 w-3.5"
|
|
150
|
+
viewBox="0 0 24 24"
|
|
151
|
+
fill="none"
|
|
152
|
+
stroke="currentColor"
|
|
153
|
+
stroke-width="2"
|
|
154
|
+
stroke-linecap="round"
|
|
155
|
+
stroke-linejoin="round"
|
|
156
|
+
>
|
|
157
|
+
<circle cx="11" cy="11" r="8" />
|
|
158
|
+
<path d="m21 21-4.3-4.3" />
|
|
159
|
+
</svg>
|
|
160
|
+
{searchBtnText}
|
|
161
|
+
</button>
|
|
162
|
+
|
|
163
|
+
{#if extra}
|
|
164
|
+
{@render extra()}
|
|
165
|
+
{/if}
|
|
166
|
+
|
|
167
|
+
{#if showCollapseButton}
|
|
168
|
+
<button
|
|
169
|
+
type="button"
|
|
170
|
+
aria-expanded={!internalCollapsed}
|
|
171
|
+
aria-label={internalCollapsed ? '展开筛选' : '收起筛选'}
|
|
172
|
+
class="svadmin-btn-collapse ml-1 inline-flex items-center text-xs font-normal text-primary transition-colors hover:text-primary/80 focus-visible:outline-none"
|
|
173
|
+
onclick={toggleCollapse}
|
|
174
|
+
>
|
|
175
|
+
<span>{internalCollapsed ? '展开' : '收起'}</span>
|
|
176
|
+
<svg
|
|
177
|
+
class={cn(
|
|
178
|
+
'ml-1 h-3.5 w-3.5 transition-transform duration-200',
|
|
179
|
+
!internalCollapsed ? 'rotate-180' : ''
|
|
180
|
+
)}
|
|
181
|
+
viewBox="0 0 24 24"
|
|
182
|
+
fill="none"
|
|
183
|
+
stroke="currentColor"
|
|
184
|
+
stroke-width="2"
|
|
185
|
+
stroke-linecap="round"
|
|
186
|
+
stroke-linejoin="round"
|
|
187
|
+
>
|
|
188
|
+
<path d="m6 9 6 6 6-6" />
|
|
189
|
+
</svg>
|
|
190
|
+
</button>
|
|
191
|
+
{/if}
|
|
192
|
+
</div>
|
|
193
|
+
</div>
|
|
194
|
+
</form>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export interface QueryFilterProps {
|
|
3
|
+
/** Number of columns in the grid layout (1 - 4, default: 3) */
|
|
4
|
+
cols?: 1 | 2 | 3 | 4;
|
|
5
|
+
/** Initial collapsed state when uncontrolled */
|
|
6
|
+
defaultCollapsed?: boolean;
|
|
7
|
+
/** Controlled collapsed state */
|
|
8
|
+
collapsed?: boolean;
|
|
9
|
+
/** Callback triggered when collapsed state changes */
|
|
10
|
+
oncollapse?: (collapsed: boolean) => void;
|
|
11
|
+
/** Callback triggered when search/filter form is submitted */
|
|
12
|
+
onsubmit?: (event?: SubmitEvent) => void;
|
|
13
|
+
/** Callback triggered when reset button is clicked */
|
|
14
|
+
onreset?: () => void;
|
|
15
|
+
/** Label text for search button (default: '查询') */
|
|
16
|
+
searchBtnText?: string;
|
|
17
|
+
/** Label text for reset button (default: '重置') */
|
|
18
|
+
resetBtnText?: string;
|
|
19
|
+
/** Whether to show the expand/collapse toggle button (default: true) */
|
|
20
|
+
showCollapseButton?: boolean;
|
|
21
|
+
/** Whether to show the reset button (default: true) */
|
|
22
|
+
showResetButton?: boolean;
|
|
23
|
+
/** Label layout mode: horizontal, vertical, or inline (default: 'horizontal') */
|
|
24
|
+
layout?: 'horizontal' | 'vertical' | 'inline';
|
|
25
|
+
/** Content slot containing form filter items */
|
|
26
|
+
children?: Snippet;
|
|
27
|
+
/** Custom extra action buttons slot next to search/reset */
|
|
28
|
+
extra?: Snippet;
|
|
29
|
+
/** Custom class for the wrapper container */
|
|
30
|
+
class?: string;
|
|
31
|
+
}
|
|
32
|
+
declare const QueryFilter: import("svelte").Component<QueryFilterProps, {}, "collapsed">;
|
|
33
|
+
type QueryFilter = ReturnType<typeof QueryFilter>;
|
|
34
|
+
export default QueryFilter;
|