@svadmin/ui 0.117.0 → 0.118.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 +153 -0
- package/dist/app.theme.css +153 -0
- package/dist/components/AboutSettings.svelte +1 -1
- package/dist/components/ApprovalTimeline.svelte +170 -0
- package/dist/components/ApprovalTimeline.svelte.d.ts +26 -0
- package/dist/components/ExcelExportButton.svelte +142 -0
- package/dist/components/ExcelExportButton.svelte.d.ts +21 -0
- package/dist/components/ExcelImportWizard.svelte +571 -0
- package/dist/components/ExcelImportWizard.svelte.d.ts +26 -0
- package/dist/components/FloatButtonGroup.svelte +162 -0
- package/dist/components/FloatButtonGroup.svelte.d.ts +34 -0
- package/dist/components/OrgTreePicker.svelte +325 -0
- package/dist/components/OrgTreePicker.svelte.d.ts +32 -0
- package/dist/components/PivotDrilldownModal.svelte +228 -0
- package/dist/components/PivotDrilldownModal.svelte.d.ts +22 -0
- package/dist/components/ProSkeleton.svelte +186 -0
- package/dist/components/ProSkeleton.svelte.d.ts +20 -0
- package/dist/components/Ribbon.svelte +97 -0
- package/dist/components/Ribbon.svelte.d.ts +19 -0
- package/dist/components/TreeTransfer.svelte +288 -0
- package/dist/components/TreeTransfer.svelte.d.ts +25 -0
- package/dist/components/WorkflowProcessCard.svelte +93 -0
- package/dist/components/WorkflowProcessCard.svelte.d.ts +21 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +13 -0
- package/package.json +4 -4
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount, type Snippet } from 'svelte';
|
|
3
|
+
import { Plus, X } from '@lucide/svelte';
|
|
4
|
+
import { cn } from '../utils.js';
|
|
5
|
+
|
|
6
|
+
export type FloatButtonPosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
7
|
+
export type FloatButtonShape = 'circle' | 'square';
|
|
8
|
+
|
|
9
|
+
export interface FloatButtonGroupProps {
|
|
10
|
+
/** Trigger mode to open the button group */
|
|
11
|
+
trigger?: 'click' | 'hover';
|
|
12
|
+
/** Two-way bindable open state */
|
|
13
|
+
open?: boolean;
|
|
14
|
+
/** Default open state */
|
|
15
|
+
defaultOpen?: boolean;
|
|
16
|
+
/** Shape of the main button */
|
|
17
|
+
shape?: FloatButtonShape;
|
|
18
|
+
/** Screen corner position */
|
|
19
|
+
position?: FloatButtonPosition;
|
|
20
|
+
/** Primary button style */
|
|
21
|
+
type?: 'default' | 'primary';
|
|
22
|
+
/** Custom main icon snippet */
|
|
23
|
+
icon?: Snippet;
|
|
24
|
+
/** Custom close icon snippet */
|
|
25
|
+
closeIcon?: Snippet;
|
|
26
|
+
/** Tooltip hint */
|
|
27
|
+
tooltip?: string;
|
|
28
|
+
/** Accessible label */
|
|
29
|
+
ariaLabel?: string;
|
|
30
|
+
/** Additional CSS classes */
|
|
31
|
+
class?: string;
|
|
32
|
+
/** Child buttons slot */
|
|
33
|
+
children?: Snippet;
|
|
34
|
+
/** Callback when open state changes */
|
|
35
|
+
onopenchange?: (open: boolean) => void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let {
|
|
39
|
+
trigger = 'click',
|
|
40
|
+
defaultOpen = false,
|
|
41
|
+
open = $bindable(defaultOpen),
|
|
42
|
+
shape = 'circle',
|
|
43
|
+
position = 'bottom-right',
|
|
44
|
+
type = 'primary',
|
|
45
|
+
icon,
|
|
46
|
+
closeIcon,
|
|
47
|
+
tooltip,
|
|
48
|
+
ariaLabel = 'Floating Action Menu',
|
|
49
|
+
class: className = '',
|
|
50
|
+
children,
|
|
51
|
+
onopenchange,
|
|
52
|
+
}: FloatButtonGroupProps = $props();
|
|
53
|
+
|
|
54
|
+
let containerEl: HTMLElement | null = $state(null);
|
|
55
|
+
|
|
56
|
+
function setOpen(next: boolean) {
|
|
57
|
+
if (open === next) return;
|
|
58
|
+
open = next;
|
|
59
|
+
onopenchange?.(next);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function toggle() {
|
|
63
|
+
setOpen(!open);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function handleMouseEnter() {
|
|
67
|
+
if (trigger === 'hover') {
|
|
68
|
+
setOpen(true);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function handleMouseLeave() {
|
|
73
|
+
if (trigger === 'hover') {
|
|
74
|
+
setOpen(false);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
onMount(() => {
|
|
79
|
+
function handleClickOutside(event: MouseEvent) {
|
|
80
|
+
if (trigger === 'click' && open && containerEl && !containerEl.contains(event.target as Node)) {
|
|
81
|
+
setOpen(false);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
86
|
+
return () => {
|
|
87
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const positionClasses: Record<FloatButtonPosition, string> = {
|
|
92
|
+
'bottom-right': 'bottom-6 right-6 flex-col-reverse',
|
|
93
|
+
'bottom-left': 'bottom-6 left-6 flex-col-reverse',
|
|
94
|
+
'top-right': 'top-6 right-6 flex-col',
|
|
95
|
+
'top-left': 'top-6 left-6 flex-col',
|
|
96
|
+
};
|
|
97
|
+
</script>
|
|
98
|
+
|
|
99
|
+
<div
|
|
100
|
+
bind:this={containerEl}
|
|
101
|
+
data-svadmin-component="FloatButtonGroup"
|
|
102
|
+
data-position={position}
|
|
103
|
+
data-open={open}
|
|
104
|
+
class={cn(
|
|
105
|
+
'fixed z-60 inline-flex items-center gap-2.5 transition-all select-none',
|
|
106
|
+
positionClasses[position],
|
|
107
|
+
className,
|
|
108
|
+
)}
|
|
109
|
+
onmouseenter={handleMouseEnter}
|
|
110
|
+
onmouseleave={handleMouseLeave}
|
|
111
|
+
role="region"
|
|
112
|
+
aria-label={ariaLabel}
|
|
113
|
+
>
|
|
114
|
+
<!-- Main Trigger Button -->
|
|
115
|
+
<button
|
|
116
|
+
type="button"
|
|
117
|
+
onclick={trigger === 'click' ? toggle : undefined}
|
|
118
|
+
aria-expanded={open}
|
|
119
|
+
aria-label={ariaLabel}
|
|
120
|
+
title={tooltip}
|
|
121
|
+
class={cn(
|
|
122
|
+
'relative flex h-11 w-11 items-center justify-center border shadow-md transition-all duration-200 outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
|
|
123
|
+
shape === 'circle' ? 'rounded-full' : 'rounded-lg',
|
|
124
|
+
type === 'primary'
|
|
125
|
+
? 'border-primary bg-primary text-primary-foreground hover:bg-primary/90'
|
|
126
|
+
: 'border-border bg-card text-foreground hover:bg-accent hover:text-accent-foreground',
|
|
127
|
+
)}
|
|
128
|
+
>
|
|
129
|
+
<div
|
|
130
|
+
class={cn(
|
|
131
|
+
'flex items-center justify-center transition-transform duration-200',
|
|
132
|
+
open && 'rotate-90',
|
|
133
|
+
)}
|
|
134
|
+
>
|
|
135
|
+
{#if open}
|
|
136
|
+
{#if closeIcon}
|
|
137
|
+
{@render closeIcon()}
|
|
138
|
+
{:else}
|
|
139
|
+
<X size={20} />
|
|
140
|
+
{/if}
|
|
141
|
+
{:else}
|
|
142
|
+
{#if icon}
|
|
143
|
+
{@render icon()}
|
|
144
|
+
{:else}
|
|
145
|
+
<Plus size={20} />
|
|
146
|
+
{/if}
|
|
147
|
+
{/if}
|
|
148
|
+
</div>
|
|
149
|
+
</button>
|
|
150
|
+
|
|
151
|
+
<!-- Child Buttons List -->
|
|
152
|
+
{#if open && children}
|
|
153
|
+
<div
|
|
154
|
+
class={cn(
|
|
155
|
+
'flex items-center gap-2 transition-all animate-in fade-in-0 zoom-in-95 duration-150',
|
|
156
|
+
position.startsWith('bottom') ? 'flex-col-reverse' : 'flex-col',
|
|
157
|
+
)}
|
|
158
|
+
>
|
|
159
|
+
{@render children()}
|
|
160
|
+
</div>
|
|
161
|
+
{/if}
|
|
162
|
+
</div>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type Snippet } from 'svelte';
|
|
2
|
+
export type FloatButtonPosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
3
|
+
export type FloatButtonShape = 'circle' | 'square';
|
|
4
|
+
export interface FloatButtonGroupProps {
|
|
5
|
+
/** Trigger mode to open the button group */
|
|
6
|
+
trigger?: 'click' | 'hover';
|
|
7
|
+
/** Two-way bindable open state */
|
|
8
|
+
open?: boolean;
|
|
9
|
+
/** Default open state */
|
|
10
|
+
defaultOpen?: boolean;
|
|
11
|
+
/** Shape of the main button */
|
|
12
|
+
shape?: FloatButtonShape;
|
|
13
|
+
/** Screen corner position */
|
|
14
|
+
position?: FloatButtonPosition;
|
|
15
|
+
/** Primary button style */
|
|
16
|
+
type?: 'default' | 'primary';
|
|
17
|
+
/** Custom main icon snippet */
|
|
18
|
+
icon?: Snippet;
|
|
19
|
+
/** Custom close icon snippet */
|
|
20
|
+
closeIcon?: Snippet;
|
|
21
|
+
/** Tooltip hint */
|
|
22
|
+
tooltip?: string;
|
|
23
|
+
/** Accessible label */
|
|
24
|
+
ariaLabel?: string;
|
|
25
|
+
/** Additional CSS classes */
|
|
26
|
+
class?: string;
|
|
27
|
+
/** Child buttons slot */
|
|
28
|
+
children?: Snippet;
|
|
29
|
+
/** Callback when open state changes */
|
|
30
|
+
onopenchange?: (open: boolean) => void;
|
|
31
|
+
}
|
|
32
|
+
declare const FloatButtonGroup: import("svelte").Component<FloatButtonGroupProps, {}, "open">;
|
|
33
|
+
type FloatButtonGroup = ReturnType<typeof FloatButtonGroup>;
|
|
34
|
+
export default FloatButtonGroup;
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Search, Users, Building, Check, X, ChevronRight, ChevronDown } from '@lucide/svelte';
|
|
3
|
+
import { cn } from '../utils.js';
|
|
4
|
+
import { useTranslation } from '@svadmin/core';
|
|
5
|
+
import MediaThumbnail from './content/MediaThumbnail.svelte';
|
|
6
|
+
|
|
7
|
+
export interface OrgDepartment {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
children?: OrgDepartment[] | undefined;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface OrgMember {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
avatar?: string | undefined;
|
|
17
|
+
departmentId: string;
|
|
18
|
+
jobTitle?: string | undefined;
|
|
19
|
+
email?: string | undefined;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface OrgTreePickerProps {
|
|
23
|
+
/** Departments hierarchy tree */
|
|
24
|
+
departments: OrgDepartment[];
|
|
25
|
+
/** Flat list of organization members */
|
|
26
|
+
members: OrgMember[];
|
|
27
|
+
/** Bound list of selected user IDs */
|
|
28
|
+
selectedUserIds?: string[] | undefined;
|
|
29
|
+
/** Whether multiple users can be selected (default: true) */
|
|
30
|
+
multiple?: boolean | undefined;
|
|
31
|
+
/** Maximum allowed selections */
|
|
32
|
+
maxCount?: number | undefined;
|
|
33
|
+
/** Additional CSS classes */
|
|
34
|
+
class?: string | undefined;
|
|
35
|
+
/** Callback when selection changes */
|
|
36
|
+
onchange?: ((selectedIds: string[], selectedMembers: OrgMember[]) => void) | undefined;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
let {
|
|
40
|
+
departments = [],
|
|
41
|
+
members = [],
|
|
42
|
+
selectedUserIds = $bindable([]),
|
|
43
|
+
multiple = true,
|
|
44
|
+
maxCount,
|
|
45
|
+
class: className = '',
|
|
46
|
+
onchange,
|
|
47
|
+
}: OrgTreePickerProps = $props();
|
|
48
|
+
|
|
49
|
+
const i18n = useTranslation();
|
|
50
|
+
let activeDeptId = $state<string>('');
|
|
51
|
+
let searchQuery = $state('');
|
|
52
|
+
let expandedDepts = $state<Record<string, boolean>>({});
|
|
53
|
+
|
|
54
|
+
$effect(() => {
|
|
55
|
+
if (!activeDeptId && departments.length > 0 && departments[0]) {
|
|
56
|
+
activeDeptId = departments[0].id;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const memberMap = $derived(new Map(members.map((m) => [m.id, m])));
|
|
61
|
+
|
|
62
|
+
const displayedMembers = $derived.by(() => {
|
|
63
|
+
if (searchQuery.trim()) {
|
|
64
|
+
const q = searchQuery.toLowerCase();
|
|
65
|
+
return members.filter(
|
|
66
|
+
(m) =>
|
|
67
|
+
m.name.toLowerCase().includes(q) ||
|
|
68
|
+
m.email?.toLowerCase().includes(q) ||
|
|
69
|
+
m.jobTitle?.toLowerCase().includes(q),
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
return members.filter((m) => m.departmentId === activeDeptId);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const selectedMembers = $derived(
|
|
76
|
+
selectedUserIds.map((id) => memberMap.get(id)).filter((m): m is OrgMember => m !== undefined),
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
const isCurrentDeptAllSelected = $derived.by(() => {
|
|
80
|
+
if (displayedMembers.length === 0) return false;
|
|
81
|
+
return displayedMembers.every((m) => selectedUserIds.includes(m.id));
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
function toggleMember(member: OrgMember) {
|
|
85
|
+
let next: string[];
|
|
86
|
+
if (selectedUserIds.includes(member.id)) {
|
|
87
|
+
next = selectedUserIds.filter((id) => id !== member.id);
|
|
88
|
+
} else {
|
|
89
|
+
if (!multiple) {
|
|
90
|
+
next = [member.id];
|
|
91
|
+
} else {
|
|
92
|
+
if (maxCount && selectedUserIds.length >= maxCount) return;
|
|
93
|
+
next = [...selectedUserIds, member.id];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
selectedUserIds = next;
|
|
97
|
+
onchange?.(next, next.map((id) => memberMap.get(id)).filter((m): m is OrgMember => m !== undefined));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function toggleSelectAllDept() {
|
|
101
|
+
if (!multiple) return;
|
|
102
|
+
const currentIds = displayedMembers.map((m) => m.id);
|
|
103
|
+
let next: string[];
|
|
104
|
+
if (isCurrentDeptAllSelected) {
|
|
105
|
+
next = selectedUserIds.filter((id) => !currentIds.includes(id));
|
|
106
|
+
} else {
|
|
107
|
+
next = Array.from(new Set([...selectedUserIds, ...currentIds]));
|
|
108
|
+
if (maxCount && next.length > maxCount) {
|
|
109
|
+
next = next.slice(0, maxCount);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
selectedUserIds = next;
|
|
113
|
+
onchange?.(next, next.map((id) => memberMap.get(id)).filter((m): m is OrgMember => m !== undefined));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function removeSelected(id: string) {
|
|
117
|
+
const next = selectedUserIds.filter((item) => item !== id);
|
|
118
|
+
selectedUserIds = next;
|
|
119
|
+
onchange?.(next, next.map((i) => memberMap.get(i)).filter((m): m is OrgMember => m !== undefined));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function clearAll() {
|
|
123
|
+
selectedUserIds = [];
|
|
124
|
+
onchange?.([], []);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function toggleExpandDept(deptId: string, e?: MouseEvent) {
|
|
128
|
+
e?.stopPropagation();
|
|
129
|
+
expandedDepts[deptId] = !expandedDepts[deptId];
|
|
130
|
+
}
|
|
131
|
+
</script>
|
|
132
|
+
|
|
133
|
+
<div
|
|
134
|
+
data-svadmin-component="OrgTreePicker"
|
|
135
|
+
class={cn(
|
|
136
|
+
'flex flex-col lg:flex-row items-stretch border border-border rounded-xl bg-card text-card-foreground shadow-xs overflow-hidden h-[540px]',
|
|
137
|
+
className,
|
|
138
|
+
)}
|
|
139
|
+
>
|
|
140
|
+
<!-- 第 1 列:部门组织树 -->
|
|
141
|
+
<div class="w-full lg:w-64 border-b lg:border-b-0 lg:border-r border-border flex flex-col bg-muted/20">
|
|
142
|
+
<div class="p-3 border-b border-border font-semibold text-xs text-muted-foreground flex items-center gap-1.5">
|
|
143
|
+
<Building size={14} class="text-primary" />
|
|
144
|
+
<span>{i18n.t('org.selectDepartment')}</span>
|
|
145
|
+
</div>
|
|
146
|
+
<div class="flex-1 overflow-y-auto p-2 space-y-0.5">
|
|
147
|
+
{#snippet renderDept(dept: OrgDepartment, level = 0)}
|
|
148
|
+
{@const hasChildren = dept.children && dept.children.length > 0}
|
|
149
|
+
{@const expanded = expandedDepts[dept.id] ?? true}
|
|
150
|
+
{@const isActive = activeDeptId === dept.id}
|
|
151
|
+
|
|
152
|
+
<div class="select-none">
|
|
153
|
+
<div
|
|
154
|
+
class={cn(
|
|
155
|
+
'flex items-center justify-between rounded-lg px-2.5 py-1.5 text-xs cursor-pointer transition-colors hover:bg-accent/60',
|
|
156
|
+
isActive && 'bg-primary/10 text-primary font-medium',
|
|
157
|
+
)}
|
|
158
|
+
style={`padding-left: ${level * 16 + 8}px`}
|
|
159
|
+
onclick={() => { activeDeptId = dept.id; searchQuery = ''; }}
|
|
160
|
+
role="button"
|
|
161
|
+
tabindex="0"
|
|
162
|
+
onkeydown={(e) => e.key === 'Enter' && (activeDeptId = dept.id)}
|
|
163
|
+
>
|
|
164
|
+
<div class="flex items-center gap-1.5 truncate">
|
|
165
|
+
{#if hasChildren}
|
|
166
|
+
<button
|
|
167
|
+
type="button"
|
|
168
|
+
class="p-0.5 rounded text-muted-foreground hover:text-foreground cursor-pointer"
|
|
169
|
+
onclick={(e) => toggleExpandDept(dept.id, e)}
|
|
170
|
+
aria-label="Toggle department"
|
|
171
|
+
>
|
|
172
|
+
{#if expanded}
|
|
173
|
+
<ChevronDown size={13} />
|
|
174
|
+
{:else}
|
|
175
|
+
<ChevronRight size={13} />
|
|
176
|
+
{/if}
|
|
177
|
+
</button>
|
|
178
|
+
{:else}
|
|
179
|
+
<span class="w-4 inline-block"></span>
|
|
180
|
+
{/if}
|
|
181
|
+
<span class="truncate">{dept.name}</span>
|
|
182
|
+
</div>
|
|
183
|
+
</div>
|
|
184
|
+
|
|
185
|
+
{#if hasChildren && expanded && dept.children}
|
|
186
|
+
<div class="mt-0.5">
|
|
187
|
+
{#each dept.children as child (child.id)}
|
|
188
|
+
{@render renderDept(child, level + 1)}
|
|
189
|
+
{/each}
|
|
190
|
+
</div>
|
|
191
|
+
{/if}
|
|
192
|
+
</div>
|
|
193
|
+
{/snippet}
|
|
194
|
+
|
|
195
|
+
{#each departments as rootDept (rootDept.id)}
|
|
196
|
+
{@render renderDept(rootDept)}
|
|
197
|
+
{/each}
|
|
198
|
+
</div>
|
|
199
|
+
</div>
|
|
200
|
+
|
|
201
|
+
<!-- 第 2 列:成员勾选列表 -->
|
|
202
|
+
<div class="flex-1 flex flex-col border-b lg:border-b-0 lg:border-r border-border bg-background">
|
|
203
|
+
<div class="p-3 border-b border-border flex items-center justify-between gap-3">
|
|
204
|
+
<div class="relative flex-1">
|
|
205
|
+
<Search size={14} class="absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground" />
|
|
206
|
+
<input
|
|
207
|
+
type="text"
|
|
208
|
+
bind:value={searchQuery}
|
|
209
|
+
placeholder={i18n.t('org.searchMember')}
|
|
210
|
+
class="h-8 w-full rounded-md border border-input bg-background pl-8 pr-3 text-xs placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring"
|
|
211
|
+
/>
|
|
212
|
+
</div>
|
|
213
|
+
|
|
214
|
+
{#if multiple && !searchQuery.trim()}
|
|
215
|
+
<button
|
|
216
|
+
type="button"
|
|
217
|
+
class="text-xs text-primary hover:underline font-medium shrink-0 cursor-pointer"
|
|
218
|
+
onclick={toggleSelectAllDept}
|
|
219
|
+
>
|
|
220
|
+
{isCurrentDeptAllSelected ? (i18n.locale === 'zh-CN' ? '取消全选' : 'Deselect All') : i18n.t('org.selectAll')}
|
|
221
|
+
</button>
|
|
222
|
+
{/if}
|
|
223
|
+
</div>
|
|
224
|
+
|
|
225
|
+
<!-- 成员卡片列表 -->
|
|
226
|
+
<div class="flex-1 overflow-y-auto p-3 space-y-1.5">
|
|
227
|
+
{#each displayedMembers as member (member.id)}
|
|
228
|
+
{@const selected = selectedUserIds.includes(member.id)}
|
|
229
|
+
<div
|
|
230
|
+
class={cn(
|
|
231
|
+
'flex items-center justify-between rounded-lg p-2.5 text-xs border border-transparent transition-all cursor-pointer hover:bg-muted/50',
|
|
232
|
+
selected && 'bg-primary/5 border-primary/20',
|
|
233
|
+
)}
|
|
234
|
+
onclick={() => toggleMember(member)}
|
|
235
|
+
role="checkbox"
|
|
236
|
+
aria-checked={selected}
|
|
237
|
+
tabindex="0"
|
|
238
|
+
onkeydown={(e) => e.key === 'Enter' && toggleMember(member)}
|
|
239
|
+
>
|
|
240
|
+
<div class="flex items-center gap-2.5 min-w-0">
|
|
241
|
+
<div class="relative flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-muted border border-border text-[11px] font-semibold text-foreground overflow-hidden">
|
|
242
|
+
{#if member.avatar}
|
|
243
|
+
<MediaThumbnail
|
|
244
|
+
src={member.avatar}
|
|
245
|
+
alt={member.name}
|
|
246
|
+
size="full"
|
|
247
|
+
fit="cover"
|
|
248
|
+
showOverlay={false}
|
|
249
|
+
class="h-full w-full rounded-full border-0"
|
|
250
|
+
/>
|
|
251
|
+
{:else}
|
|
252
|
+
{member.name.slice(0, 1).toUpperCase()}
|
|
253
|
+
{/if}
|
|
254
|
+
</div>
|
|
255
|
+
<div class="flex flex-col min-w-0">
|
|
256
|
+
<span class="font-medium text-foreground truncate">{member.name}</span>
|
|
257
|
+
{#if member.jobTitle || member.email}
|
|
258
|
+
<span class="text-[11px] text-muted-foreground truncate">{member.jobTitle || member.email}</span>
|
|
259
|
+
{/if}
|
|
260
|
+
</div>
|
|
261
|
+
</div>
|
|
262
|
+
|
|
263
|
+
<div
|
|
264
|
+
class={cn(
|
|
265
|
+
'flex h-4.5 w-4.5 shrink-0 items-center justify-center rounded-sm border border-input transition-colors',
|
|
266
|
+
selected && 'bg-primary border-primary text-primary-foreground',
|
|
267
|
+
)}
|
|
268
|
+
>
|
|
269
|
+
{#if selected}
|
|
270
|
+
<Check size={12} strokeWidth={3} />
|
|
271
|
+
{/if}
|
|
272
|
+
</div>
|
|
273
|
+
</div>
|
|
274
|
+
{/each}
|
|
275
|
+
|
|
276
|
+
{#if displayedMembers.length === 0}
|
|
277
|
+
<div class="py-16 text-center text-xs text-muted-foreground">{i18n.t('org.noMembers')}</div>
|
|
278
|
+
{/if}
|
|
279
|
+
</div>
|
|
280
|
+
</div>
|
|
281
|
+
|
|
282
|
+
<!-- 第 3 列:已选成员列表 -->
|
|
283
|
+
<div class="w-full lg:w-64 flex flex-col bg-muted/10">
|
|
284
|
+
<div class="p-3 border-b border-border flex items-center justify-between font-semibold text-xs text-muted-foreground">
|
|
285
|
+
<div class="flex items-center gap-1.5">
|
|
286
|
+
<Users size={14} class="text-primary" />
|
|
287
|
+
<span>{i18n.t('org.selectedMembers')} ({selectedUserIds.length})</span>
|
|
288
|
+
</div>
|
|
289
|
+
{#if selectedUserIds.length > 0}
|
|
290
|
+
<button
|
|
291
|
+
type="button"
|
|
292
|
+
class="text-destructive hover:underline text-[11px] font-normal cursor-pointer"
|
|
293
|
+
onclick={clearAll}
|
|
294
|
+
>
|
|
295
|
+
{i18n.t('org.clearAll')}
|
|
296
|
+
</button>
|
|
297
|
+
{/if}
|
|
298
|
+
</div>
|
|
299
|
+
|
|
300
|
+
<div class="flex-1 overflow-y-auto p-2 space-y-1">
|
|
301
|
+
{#each selectedMembers as item (item.id)}
|
|
302
|
+
<div class="flex items-center justify-between rounded-lg px-2.5 py-1.5 text-xs bg-background border border-border shadow-2xs group">
|
|
303
|
+
<div class="flex items-center gap-2 truncate">
|
|
304
|
+
<span class="font-medium text-foreground truncate">{item.name}</span>
|
|
305
|
+
{#if item.jobTitle}
|
|
306
|
+
<span class="text-[10px] text-muted-foreground truncate">({item.jobTitle})</span>
|
|
307
|
+
{/if}
|
|
308
|
+
</div>
|
|
309
|
+
<button
|
|
310
|
+
type="button"
|
|
311
|
+
class="text-muted-foreground hover:text-destructive p-0.5 rounded transition-colors cursor-pointer"
|
|
312
|
+
onclick={() => removeSelected(item.id)}
|
|
313
|
+
aria-label={`Remove ${item.name}`}
|
|
314
|
+
>
|
|
315
|
+
<X size={12} />
|
|
316
|
+
</button>
|
|
317
|
+
</div>
|
|
318
|
+
{/each}
|
|
319
|
+
|
|
320
|
+
{#if selectedUserIds.length === 0}
|
|
321
|
+
<div class="py-16 text-center text-xs text-muted-foreground">{i18n.t('org.empty')}</div>
|
|
322
|
+
{/if}
|
|
323
|
+
</div>
|
|
324
|
+
</div>
|
|
325
|
+
</div>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface OrgDepartment {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
children?: OrgDepartment[] | undefined;
|
|
5
|
+
}
|
|
6
|
+
export interface OrgMember {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
avatar?: string | undefined;
|
|
10
|
+
departmentId: string;
|
|
11
|
+
jobTitle?: string | undefined;
|
|
12
|
+
email?: string | undefined;
|
|
13
|
+
}
|
|
14
|
+
export interface OrgTreePickerProps {
|
|
15
|
+
/** Departments hierarchy tree */
|
|
16
|
+
departments: OrgDepartment[];
|
|
17
|
+
/** Flat list of organization members */
|
|
18
|
+
members: OrgMember[];
|
|
19
|
+
/** Bound list of selected user IDs */
|
|
20
|
+
selectedUserIds?: string[] | undefined;
|
|
21
|
+
/** Whether multiple users can be selected (default: true) */
|
|
22
|
+
multiple?: boolean | undefined;
|
|
23
|
+
/** Maximum allowed selections */
|
|
24
|
+
maxCount?: number | undefined;
|
|
25
|
+
/** Additional CSS classes */
|
|
26
|
+
class?: string | undefined;
|
|
27
|
+
/** Callback when selection changes */
|
|
28
|
+
onchange?: ((selectedIds: string[], selectedMembers: OrgMember[]) => void) | undefined;
|
|
29
|
+
}
|
|
30
|
+
declare const OrgTreePicker: import("svelte").Component<OrgTreePickerProps, {}, "selectedUserIds">;
|
|
31
|
+
type OrgTreePicker = ReturnType<typeof OrgTreePicker>;
|
|
32
|
+
export default OrgTreePicker;
|