@h-ai/ui 0.1.0-alpha.73 → 0.1.0-alpha.75
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/README.en.md +70 -7
- package/README.ja.md +71 -8
- package/README.md +72 -9
- package/auto-import.d.ts +4 -0
- package/auto-import.js +4 -0
- package/dist/components/compounds/Confirm.svelte +12 -2
- package/dist/components/compounds/Drawer.svelte +32 -14
- package/dist/components/compounds/FilterBar.svelte +77 -0
- package/dist/components/compounds/FilterBar.svelte.d.ts +39 -0
- package/dist/components/compounds/Modal.svelte +4 -37
- package/dist/components/compounds/PageHeader.svelte +18 -11
- package/dist/components/compounds/TableToolbar.svelte +1 -1
- package/dist/components/compounds/index.d.ts +1 -0
- package/dist/components/compounds/index.js +1 -0
- package/dist/components/primitives/Button.svelte +7 -0
- package/dist/components/primitives/Input.svelte +1 -1
- package/dist/components/primitives/Textarea.svelte +1 -1
- package/dist/components/scenes/app/FeedbackDetail.svelte +13 -3
- package/dist/components/scenes/app/FeedbackDetail.svelte.d.ts +6 -0
- package/dist/components/scenes/app/FeedbackForm.svelte +1 -1
- package/dist/components/scenes/app/FeedbackList.svelte +4 -4
- package/dist/components/scenes/app/SettingsLayout.svelte +4 -15
- package/dist/components/scenes/app/ThemeSelector.svelte +56 -16
- package/dist/components/scenes/app/WorkspaceLayout.svelte +64 -0
- package/dist/components/scenes/app/WorkspaceLayout.svelte.d.ts +36 -0
- package/dist/components/scenes/app/feedback-functions.d.ts +16 -0
- package/dist/components/scenes/app/feedback-functions.js +31 -0
- package/dist/components/scenes/app/index.d.ts +1 -0
- package/dist/components/scenes/app/index.js +1 -0
- package/dist/components/scenes/crud/CrudEditPanel.svelte +18 -9
- package/dist/components/scenes/crud/CrudFilterBar.svelte +39 -30
- package/dist/components/scenes/crud/CrudFilterBar.svelte.d.ts +4 -1
- package/dist/components/scenes/crud/CrudPage.svelte +27 -7
- package/dist/components/scenes/crud/CrudPage.svelte.d.ts +1 -1
- package/dist/components/scenes/crud/crud-types.d.ts +1 -1
- package/dist/components/scenes/guide/GuideHost.svelte +22 -102
- package/dist/components/scenes/guide/GuideHost.svelte.d.ts +5 -13
- package/dist/components/scenes/guide/GuideHostContent.svelte +143 -0
- package/dist/components/scenes/guide/GuideHostContent.svelte.d.ts +43 -0
- package/dist/components/scenes/guide/HelpCenter.svelte +22 -9
- package/dist/components/scenes/iam/AuthPanel.svelte +7 -7
- package/dist/components/scenes/iam/AuthShell.svelte +6 -1
- package/dist/components/scenes/iam/AuthShell.svelte.d.ts +2 -0
- package/dist/components/scenes/iam/ChangePasswordForm.svelte +1 -1
- package/dist/components/scenes/iam/ForgotPasswordForm.svelte +1 -1
- package/dist/components/scenes/iam/LoginForm.svelte +29 -3
- package/dist/components/scenes/iam/PasswordInput.svelte +1 -1
- package/dist/components/scenes/iam/RegisterForm.svelte +1 -1
- package/dist/components/scenes/iam/SensitiveOperationsForm.svelte +70 -0
- package/dist/components/scenes/iam/SensitiveOperationsForm.svelte.d.ts +21 -0
- package/dist/components/scenes/iam/SessionRecoveryDialog.svelte +64 -0
- package/dist/components/scenes/iam/SessionRecoveryDialog.svelte.d.ts +22 -0
- package/dist/components/scenes/iam/index.d.ts +6 -0
- package/dist/components/scenes/iam/index.js +4 -0
- package/dist/components/scenes/iam/sensitive-actions.svelte.d.ts +68 -0
- package/dist/components/scenes/iam/sensitive-actions.svelte.js +100 -0
- package/dist/components/scenes/iam/session-recovery.svelte.d.ts +44 -0
- package/dist/components/scenes/iam/session-recovery.svelte.js +57 -0
- package/dist/components/scenes/types.d.ts +9 -0
- package/dist/guide.svelte.js +61 -26
- package/dist/internal/dialog-focus.d.ts +21 -0
- package/dist/internal/dialog-focus.js +77 -0
- package/dist/internal/form-validation.svelte.d.ts +2 -1
- package/dist/internal/form-validation.svelte.js +9 -1
- package/dist/messages/en-US.json +21 -4
- package/dist/messages/ja-JP.json +21 -4
- package/dist/messages/zh-CN.json +21 -4
- package/dist/styles/formal.css +55 -0
- package/dist/styles/high-contrast.css +64 -0
- package/dist/styles/theme.css +2 -0
- package/dist/theme-config.d.ts +2 -2
- package/dist/theme-config.js +5 -2
- package/dist/types.d.ts +4 -0
- package/dist/workspace-context.d.ts +20 -0
- package/dist/workspace-context.js +9 -0
- package/package.json +2 -2
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
import type { DataAttributes, DrawerProps } from '../../types.js'
|
|
24
24
|
import { onDestroy, onMount, setContext } from 'svelte'
|
|
25
25
|
import { readStoredValue, writeStoredValue } from '../../internal/browser-safety.js'
|
|
26
|
+
import { focusDialog, handleDialogKeydown } from '../../internal/dialog-focus.js'
|
|
26
27
|
import { FORM_VISIBILITY_CONTEXT } from '../../internal/form-context.js'
|
|
27
28
|
import { uiM } from '../../messages.js'
|
|
28
|
-
import { cn,
|
|
29
|
+
import { cn, getDataAttributes } from '../../utils.js'
|
|
29
30
|
import IconButton from '../primitives/IconButton.svelte'
|
|
30
|
-
import ToggleCheckbox from '../primitives/ToggleCheckbox.svelte'
|
|
31
31
|
|
|
32
32
|
let {
|
|
33
33
|
open = $bindable(false),
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
resizable = false,
|
|
39
39
|
widthStorageKey,
|
|
40
40
|
closeOnBackdrop = true,
|
|
41
|
+
closeOnEscape = true,
|
|
41
42
|
showClose = true,
|
|
42
43
|
class: className = '',
|
|
43
44
|
onclose,
|
|
@@ -49,7 +50,19 @@
|
|
|
49
50
|
setContext(FORM_VISIBILITY_CONTEXT, {
|
|
50
51
|
get open() { return open },
|
|
51
52
|
})
|
|
52
|
-
const id =
|
|
53
|
+
const id = $props.id()
|
|
54
|
+
const titleId = `${id}-title`
|
|
55
|
+
let panel = $state<HTMLDivElement>()
|
|
56
|
+
let resizing = false
|
|
57
|
+
$effect(() => {
|
|
58
|
+
if (!open || !panel)
|
|
59
|
+
return
|
|
60
|
+
const restore = focusDialog(panel)
|
|
61
|
+
return () => {
|
|
62
|
+
finishResize()
|
|
63
|
+
restore()
|
|
64
|
+
}
|
|
65
|
+
})
|
|
53
66
|
/** 用户拖动后的像素宽度;优先于 width 与 size。 */
|
|
54
67
|
let resizedWidth = $state<number | null>(null)
|
|
55
68
|
/** 与响应式渲染解耦的同步宽度,确保 mouseup 时持久化最后一次 mousemove 的值。 */
|
|
@@ -106,6 +119,7 @@
|
|
|
106
119
|
)
|
|
107
120
|
|
|
108
121
|
function handleClose() {
|
|
122
|
+
finishResize()
|
|
109
123
|
open = false
|
|
110
124
|
onclose?.()
|
|
111
125
|
}
|
|
@@ -135,8 +149,9 @@
|
|
|
135
149
|
|
|
136
150
|
/** 结束拖动并在配置了 key 时记忆最终宽度。 */
|
|
137
151
|
function finishResize() {
|
|
138
|
-
if (typeof document === 'undefined')
|
|
152
|
+
if (typeof document === 'undefined' || !resizing)
|
|
139
153
|
return
|
|
154
|
+
resizing = false
|
|
140
155
|
|
|
141
156
|
globalThis.removeEventListener('mousemove', handleResizeMove)
|
|
142
157
|
globalThis.removeEventListener('mouseup', finishResize)
|
|
@@ -162,6 +177,7 @@
|
|
|
162
177
|
resizeStartWidth = drawer.getBoundingClientRect().width
|
|
163
178
|
resizeWidthForStorage = resizeStartWidth
|
|
164
179
|
previousUserSelect = document.documentElement.style.userSelect
|
|
180
|
+
resizing = true
|
|
165
181
|
document.documentElement.style.userSelect = 'none'
|
|
166
182
|
globalThis.addEventListener('mousemove', handleResizeMove)
|
|
167
183
|
globalThis.addEventListener('mouseup', finishResize, { once: true })
|
|
@@ -203,20 +219,22 @@
|
|
|
203
219
|
onDestroy(finishResize)
|
|
204
220
|
</script>
|
|
205
221
|
|
|
206
|
-
<div {...dataAttributes} class={drawerClass}
|
|
207
|
-
|
|
222
|
+
<div {...dataAttributes} class={drawerClass} role='presentation' onkeydown={(event) => {
|
|
223
|
+
if (open && panel)
|
|
224
|
+
handleDialogKeydown(event, panel, closeOnEscape ? handleClose : undefined)
|
|
225
|
+
}}>
|
|
226
|
+
<input {id} type='checkbox' class='drawer-toggle' tabindex='-1' aria-hidden='true' bind:checked={open} />
|
|
208
227
|
|
|
209
|
-
<div class={sideClass}>
|
|
210
|
-
<
|
|
211
|
-
|
|
212
|
-
tabindex='
|
|
228
|
+
<div class={sideClass} inert={!open}>
|
|
229
|
+
<button
|
|
230
|
+
type='button'
|
|
231
|
+
tabindex='-1'
|
|
213
232
|
aria-label={uiM('drawer_close')}
|
|
214
233
|
class='drawer-overlay'
|
|
215
234
|
onclick={handleBackdropClick}
|
|
216
|
-
|
|
217
|
-
></div>
|
|
235
|
+
></button>
|
|
218
236
|
|
|
219
|
-
<div class={contentClass} style={widthStyle}>
|
|
237
|
+
<div bind:this={panel} class={contentClass} style={widthStyle} role='dialog' aria-modal={open ? 'true' : undefined} aria-labelledby={title ? titleId : undefined} aria-label={title ? undefined : uiM('common_dialog')} tabindex='-1'>
|
|
220
238
|
{#if canResize}
|
|
221
239
|
<button
|
|
222
240
|
type='button'
|
|
@@ -230,7 +248,7 @@
|
|
|
230
248
|
|
|
231
249
|
<div class='flex items-center justify-between mb-4'>
|
|
232
250
|
{#if title}
|
|
233
|
-
<h3 class='text-lg font-bold'>{title}</h3>
|
|
251
|
+
<h3 id={titleId} class='text-lg font-bold'>{title}</h3>
|
|
234
252
|
{:else}
|
|
235
253
|
<div></div>
|
|
236
254
|
{/if}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component FilterBar
|
|
3
|
+
常用搜索与操作保持可见,更多筛选可展开收起;收起不卸载控件或清除值。
|
|
4
|
+
@example
|
|
5
|
+
```ts
|
|
6
|
+
import type { ComponentProps } from 'svelte'
|
|
7
|
+
import { FilterBar } from '@h-ai/ui/components/compounds/index'
|
|
8
|
+
const props: Pick<ComponentProps<typeof FilterBar>, 'expanded' | 'activeCount'> = { expanded: false, activeCount: 2 }
|
|
9
|
+
```
|
|
10
|
+
-->
|
|
11
|
+
<script lang='ts'>
|
|
12
|
+
import type { Snippet } from 'svelte'
|
|
13
|
+
import type { DataAttributes } from '../../types.js'
|
|
14
|
+
import { uiM } from '../../messages.js'
|
|
15
|
+
import { cn, getDataAttributes } from '../../utils.js'
|
|
16
|
+
import Button from '../primitives/Button.svelte'
|
|
17
|
+
|
|
18
|
+
/** FilterBar 组件的属性契约。
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import type { ComponentProps } from 'svelte'
|
|
22
|
+
* import { FilterBar } from '@h-ai/ui'
|
|
23
|
+
* const props: Partial<ComponentProps<typeof FilterBar>> = {}
|
|
24
|
+
* void props
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
interface Props extends DataAttributes {
|
|
28
|
+
/** 常驻搜索或主要条件。 */
|
|
29
|
+
leading?: Snippet
|
|
30
|
+
/** 查询、重置和业务操作。 */
|
|
31
|
+
actions?: Snippet
|
|
32
|
+
/** 可收起的筛选字段。 */
|
|
33
|
+
children?: Snippet
|
|
34
|
+
/** 是否展开;默认收起,可 bind:expanded。 */
|
|
35
|
+
expanded?: boolean
|
|
36
|
+
/** 已启用条件数量,收起时仍提示。 */
|
|
37
|
+
activeCount?: number
|
|
38
|
+
/** 清空查询与全部筛选;按钮文案由 UI 提供。 */
|
|
39
|
+
onreset?: () => void
|
|
40
|
+
class?: string
|
|
41
|
+
}
|
|
42
|
+
let { leading, actions, children, expanded = $bindable(false), activeCount = 0, onreset, class: className = '', ...restProps }: Props = $props()
|
|
43
|
+
const dataAttributes = $derived(getDataAttributes(restProps))
|
|
44
|
+
const panelId = $props.id()
|
|
45
|
+
const toggleLabel = $derived(uiM(expanded ? 'filter_bar_collapse' : 'filter_bar_expand'))
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<div {...dataAttributes} class={cn('hai-filter-bar min-w-0 space-y-2 [&_.fieldset]:m-0 [&_.fieldset]:min-w-0', className)}>
|
|
49
|
+
<div class='flex min-w-0 flex-wrap items-center gap-2'>
|
|
50
|
+
{#if leading}<div class='flex min-w-0 max-w-full flex-[1_1_14rem] flex-wrap items-center gap-2'>{@render leading()}</div>{/if}
|
|
51
|
+
<div class='ml-auto flex max-w-full shrink-0 flex-wrap items-center gap-2'>
|
|
52
|
+
{#if actions}{@render actions()}{/if}
|
|
53
|
+
{#if onreset}<Button type='button' variant='ghost' size='sm' onclick={onreset}>{uiM('crud_reset')}</Button>{/if}
|
|
54
|
+
{#if children}
|
|
55
|
+
<button type='button' class='hai-filter-bar__toggle inline-flex h-8 items-center gap-1.5 whitespace-nowrap rounded-md px-2 text-sm text-base-content/65 hover:bg-base-content/5 hover:text-base-content' aria-expanded={expanded} aria-controls={panelId} onclick={() => { expanded = !expanded }}>
|
|
56
|
+
<span>{toggleLabel}</span>
|
|
57
|
+
{#if activeCount > 0}<span class='rounded bg-primary/10 px-1.5 text-xs text-primary' aria-label={uiM('filter_bar_active').replace('{count}', String(activeCount))}>{activeCount}</span>{/if}
|
|
58
|
+
<span class='icon-[tabler--chevron-down] size-4 transition-transform' class:rotate-180={expanded} aria-hidden='true'></span>
|
|
59
|
+
</button>
|
|
60
|
+
{/if}
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
{#if children}
|
|
64
|
+
<div id={panelId} hidden={!expanded} class={expanded ? 'flex min-w-0 flex-wrap items-end gap-2 border-t border-base-content/8 pt-2' : 'hidden'}>
|
|
65
|
+
{@render children()}
|
|
66
|
+
</div>
|
|
67
|
+
{/if}
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
<style>
|
|
71
|
+
@media (pointer: coarse) {
|
|
72
|
+
.hai-filter-bar__toggle {
|
|
73
|
+
min-height: var(--hai-touch-target-min, 44px);
|
|
74
|
+
min-width: var(--hai-touch-target-min, 44px);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
</style>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { DataAttributes } from '../../types.js';
|
|
3
|
+
/** FilterBar 组件的属性契约。
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import type { ComponentProps } from 'svelte'
|
|
7
|
+
* import { FilterBar } from '@h-ai/ui'
|
|
8
|
+
* const props: Partial<ComponentProps<typeof FilterBar>> = {}
|
|
9
|
+
* void props
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
interface Props extends DataAttributes {
|
|
13
|
+
/** 常驻搜索或主要条件。 */
|
|
14
|
+
leading?: Snippet;
|
|
15
|
+
/** 查询、重置和业务操作。 */
|
|
16
|
+
actions?: Snippet;
|
|
17
|
+
/** 可收起的筛选字段。 */
|
|
18
|
+
children?: Snippet;
|
|
19
|
+
/** 是否展开;默认收起,可 bind:expanded。 */
|
|
20
|
+
expanded?: boolean;
|
|
21
|
+
/** 已启用条件数量,收起时仍提示。 */
|
|
22
|
+
activeCount?: number;
|
|
23
|
+
/** 清空查询与全部筛选;按钮文案由 UI 提供。 */
|
|
24
|
+
onreset?: () => void;
|
|
25
|
+
class?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* FilterBar
|
|
29
|
+
* 常用搜索与操作保持可见,更多筛选可展开收起;收起不卸载控件或清除值。
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* import type { ComponentProps } from 'svelte'
|
|
33
|
+
* import { FilterBar } from '@h-ai/ui/components/compounds/index'
|
|
34
|
+
* const props: Pick<ComponentProps<typeof FilterBar>, 'expanded' | 'activeCount'> = { expanded: false, activeCount: 2 }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
declare const FilterBar: import("svelte").Component<Props, {}, "expanded">;
|
|
38
|
+
type FilterBar = ReturnType<typeof FilterBar>;
|
|
39
|
+
export default FilterBar;
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
<script lang='ts'>
|
|
16
16
|
import type { DataAttributes, ModalProps } from '../../types.js'
|
|
17
17
|
import { setContext } from 'svelte'
|
|
18
|
+
import { focusDialog, handleDialogKeydown } from '../../internal/dialog-focus.js'
|
|
18
19
|
import { FORM_VISIBILITY_CONTEXT } from '../../internal/form-context.js'
|
|
19
20
|
import { uiM } from '../../messages.js'
|
|
20
21
|
import { cn, getDataAttributes } from '../../utils.js'
|
|
@@ -109,51 +110,17 @@
|
|
|
109
110
|
onclose?.()
|
|
110
111
|
}
|
|
111
112
|
|
|
112
|
-
function focusableElements(): HTMLElement[] {
|
|
113
|
-
return [...(panel?.querySelectorAll<HTMLElement>('button, a[href], input:not([type="hidden"]), select, textarea, [tabindex]') ?? [])]
|
|
114
|
-
.filter(element => element.tabIndex >= 0 && !element.hasAttribute('disabled') && element.getClientRects().length > 0)
|
|
115
|
-
}
|
|
116
|
-
|
|
117
113
|
// 打开时把焦点移入弹窗,关闭后恢复原操作位置。
|
|
118
114
|
$effect(() => {
|
|
119
115
|
if (!open || !panel)
|
|
120
116
|
return
|
|
121
|
-
|
|
122
|
-
const elements = focusableElements()
|
|
123
|
-
const input = elements.find(element => element.matches('input:not([readonly]), textarea, select'))
|
|
124
|
-
const target = input ?? elements[0] ?? panel
|
|
125
|
-
target.focus()
|
|
126
|
-
return () => {
|
|
127
|
-
if (previous?.isConnected)
|
|
128
|
-
previous.focus()
|
|
129
|
-
}
|
|
117
|
+
return focusDialog(panel)
|
|
130
118
|
})
|
|
131
119
|
|
|
132
120
|
function handleKeydown(event: KeyboardEvent) {
|
|
133
|
-
if (!open)
|
|
121
|
+
if (!open || !panel)
|
|
134
122
|
return
|
|
135
|
-
|
|
136
|
-
event.preventDefault()
|
|
137
|
-
event.stopPropagation()
|
|
138
|
-
handleClose()
|
|
139
|
-
}
|
|
140
|
-
else if (event.key === 'Tab') {
|
|
141
|
-
const elements = focusableElements()
|
|
142
|
-
const first = elements[0]
|
|
143
|
-
const last = elements.at(-1)
|
|
144
|
-
if (!first) {
|
|
145
|
-
event.preventDefault()
|
|
146
|
-
panel?.focus()
|
|
147
|
-
}
|
|
148
|
-
else if (event.shiftKey && (document.activeElement === first || document.activeElement === panel)) {
|
|
149
|
-
event.preventDefault()
|
|
150
|
-
last?.focus()
|
|
151
|
-
}
|
|
152
|
-
else if (!event.shiftKey && document.activeElement === last) {
|
|
153
|
-
event.preventDefault()
|
|
154
|
-
first.focus()
|
|
155
|
-
}
|
|
156
|
-
}
|
|
123
|
+
handleDialogKeydown(event, panel, closeOnEscape ? handleClose : undefined)
|
|
157
124
|
}
|
|
158
125
|
|
|
159
126
|
</script>
|
|
@@ -19,7 +19,10 @@
|
|
|
19
19
|
<script lang='ts'>
|
|
20
20
|
import type { Snippet } from 'svelte'
|
|
21
21
|
import type { DataAttributes } from '../../types.js'
|
|
22
|
+
import type { WorkspaceContext } from '../../workspace-context.js'
|
|
23
|
+
import { getContext } from 'svelte'
|
|
22
24
|
import { getDataAttributes } from '../../utils.js'
|
|
25
|
+
import { workspaceContextKey } from '../../workspace-context.js'
|
|
23
26
|
|
|
24
27
|
/**
|
|
25
28
|
* PageHeader 组件的属性契约;通过公开组件配置使用。
|
|
@@ -44,18 +47,22 @@
|
|
|
44
47
|
const { title, description, actions, class: className = '', ...restProps }: Props & DataAttributes = $props()
|
|
45
48
|
|
|
46
49
|
const dataAttributes = $derived(getDataAttributes(restProps))
|
|
50
|
+
const workspace = getContext<WorkspaceContext | undefined>(workspaceContextKey)
|
|
51
|
+
const showTitle = $derived(Boolean(title) && workspace?.title !== title)
|
|
47
52
|
</script>
|
|
48
53
|
|
|
49
|
-
|
|
50
|
-
<div>
|
|
51
|
-
<
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
{#if showTitle || description || actions}
|
|
55
|
+
<div {...dataAttributes} class='flex flex-col sm:flex-row sm:items-center justify-between gap-2 mb-3 {className}'>
|
|
56
|
+
{#if showTitle || description}<div class='min-w-0'>
|
|
57
|
+
{#if showTitle}<h1 class='text-xl font-semibold tracking-tight'>{title}</h1>{/if}
|
|
58
|
+
{#if description}
|
|
59
|
+
<p class='text-sm text-base-content/45' class:mt-0.5={showTitle}>{description}</p>
|
|
60
|
+
{/if}
|
|
61
|
+
</div>{/if}
|
|
62
|
+
{#if actions}
|
|
63
|
+
<div class='flex items-center gap-2'>
|
|
64
|
+
{@render actions()}
|
|
65
|
+
</div>
|
|
54
66
|
{/if}
|
|
55
67
|
</div>
|
|
56
|
-
|
|
57
|
-
<div class='flex items-center gap-2'>
|
|
58
|
-
{@render actions()}
|
|
59
|
-
</div>
|
|
60
|
-
{/if}
|
|
61
|
-
</div>
|
|
68
|
+
{/if}
|
|
@@ -438,7 +438,7 @@
|
|
|
438
438
|
class='input input-sm w-full pl-9 bg-base-100 border-base-content/15'
|
|
439
439
|
placeholder={searchPlaceholder || uiM('crud_search_placeholder')}
|
|
440
440
|
onkeydown={(e) => {
|
|
441
|
-
if (e.key === 'Enter') {
|
|
441
|
+
if (e.key === 'Enter' && !e.isComposing) {
|
|
442
442
|
e.preventDefault()
|
|
443
443
|
onsearch?.(searchValue)
|
|
444
444
|
}
|
|
@@ -22,6 +22,7 @@ export { default as DatePicker } from './DatePicker.svelte';
|
|
|
22
22
|
export { default as Drawer } from './Drawer.svelte';
|
|
23
23
|
export { default as Dropdown } from './Dropdown.svelte';
|
|
24
24
|
export { default as Empty } from './Empty.svelte';
|
|
25
|
+
export { default as FilterBar } from './FilterBar.svelte';
|
|
25
26
|
export { default as Form } from './Form.svelte';
|
|
26
27
|
export { default as FormField } from './FormField.svelte';
|
|
27
28
|
export { default as FormLayout } from './FormLayout.svelte';
|
|
@@ -28,6 +28,7 @@ export { default as Drawer } from './Drawer.svelte';
|
|
|
28
28
|
export { default as Dropdown } from './Dropdown.svelte';
|
|
29
29
|
// 状态占位
|
|
30
30
|
export { default as Empty } from './Empty.svelte';
|
|
31
|
+
export { default as FilterBar } from './FilterBar.svelte';
|
|
31
32
|
// 表单组合
|
|
32
33
|
export { default as Form } from './Form.svelte';
|
|
33
34
|
export { default as FormField } from './FormField.svelte';
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
-->
|
|
15
15
|
<script lang='ts'>
|
|
16
16
|
import type { ButtonProps, DataAttributes } from '../../types.js'
|
|
17
|
+
import { uiM } from '../../messages.js'
|
|
17
18
|
import { cn, getDataAttributes, getSizeClass, getVariantClass } from '../../utils.js'
|
|
18
19
|
|
|
19
20
|
const {
|
|
@@ -27,6 +28,7 @@
|
|
|
27
28
|
circle = false,
|
|
28
29
|
class: className = '',
|
|
29
30
|
type = 'button',
|
|
31
|
+
submitHint = false,
|
|
30
32
|
onclick,
|
|
31
33
|
children,
|
|
32
34
|
...restProps
|
|
@@ -63,6 +65,8 @@
|
|
|
63
65
|
class={buttonClass}
|
|
64
66
|
disabled={disabled || loading}
|
|
65
67
|
aria-label={ariaLabel || undefined}
|
|
68
|
+
aria-keyshortcuts={type === 'submit' && submitHint ? 'Enter' : undefined}
|
|
69
|
+
title={type === 'submit' && submitHint ? uiM('keyboard_submit_enter') : undefined}
|
|
66
70
|
onclick={handleClick}
|
|
67
71
|
>
|
|
68
72
|
{#if loading}
|
|
@@ -71,4 +75,7 @@
|
|
|
71
75
|
{#if children}
|
|
72
76
|
{@render children()}
|
|
73
77
|
{/if}
|
|
78
|
+
{#if type === 'submit' && submitHint}
|
|
79
|
+
<kbd aria-hidden='true' class='ml-1 rounded border border-current/35 px-1 text-xs font-normal leading-tight'>↵</kbd>
|
|
80
|
+
{/if}
|
|
74
81
|
</button>
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
evidence = { items: [], total: 0, page: 1, pageSize: 20 },
|
|
31
31
|
attachments = [],
|
|
32
32
|
history = [],
|
|
33
|
+
webhook,
|
|
33
34
|
permissions = {},
|
|
34
35
|
loading = false,
|
|
35
36
|
error = '',
|
|
@@ -48,6 +49,8 @@
|
|
|
48
49
|
evidence?: FeedbackPage<FeedbackEvidenceView>
|
|
49
50
|
attachments?: FeedbackAttachmentView[]
|
|
50
51
|
history?: FeedbackHistoryView[]
|
|
52
|
+
/** 持久 Webhook 任务的公开状态,由反馈详情 jobs 中的 webhook 项提供。 */
|
|
53
|
+
webhook?: { status: 'pending' | 'running' | 'succeeded' | 'failed', attempts: number, lastError?: string }
|
|
51
54
|
permissions?: FeedbackPermissions
|
|
52
55
|
loading?: boolean
|
|
53
56
|
error?: string
|
|
@@ -79,6 +82,7 @@
|
|
|
79
82
|
{ key: 'scene', label: uiM('feedback_scene') },
|
|
80
83
|
{ key: 'replay', label: uiM('feedback_replay') },
|
|
81
84
|
{ key: 'logs', label: uiM('feedback_logs') },
|
|
85
|
+
{ key: 'business', label: uiM('feedback_business') },
|
|
82
86
|
{ key: 'environment', label: uiM('feedback_environment') },
|
|
83
87
|
{ key: 'history', label: uiM('feedback_history') },
|
|
84
88
|
])
|
|
@@ -117,11 +121,13 @@
|
|
|
117
121
|
}
|
|
118
122
|
function changeTab(tab: string) {
|
|
119
123
|
if (tab === 'environment')
|
|
120
|
-
void query({ page: 1, kind: 'environment' })
|
|
124
|
+
void query({ page: 1, kind: 'environment', requestId: undefined, errorId: undefined })
|
|
121
125
|
else if (tab === 'scene')
|
|
122
|
-
void query({ page: 1, kind: 'interaction' })
|
|
126
|
+
void query({ page: 1, kind: 'interaction', requestId: undefined, errorId: undefined })
|
|
123
127
|
else if (tab === 'logs')
|
|
124
128
|
void query({ page: 1, kind: undefined })
|
|
129
|
+
else if (tab === 'business')
|
|
130
|
+
void query({ page: 1, kind: 'business', requestId: undefined, errorId: undefined })
|
|
125
131
|
}
|
|
126
132
|
</script>
|
|
127
133
|
|
|
@@ -147,17 +153,21 @@
|
|
|
147
153
|
<dl class='grid grid-cols-1 gap-3 text-sm sm:grid-cols-2 xl:grid-cols-3'>
|
|
148
154
|
<div><dt class='text-base-content/55'>{uiM('feedback_collection')}</dt><dd>{collectionLabel(report.collectionStatus)}</dd></div>
|
|
149
155
|
<div><dt class='text-base-content/55'>{uiM('feedback_notification')}</dt><dd>{notificationLabel(report.notificationStatus)}</dd></div>
|
|
156
|
+
{#if webhook}
|
|
157
|
+
<div><dt class='text-base-content/55'>{uiM('feedback_webhook')}</dt><dd>{notificationLabel(webhook.status === 'succeeded' ? 'sent' : webhook.status === 'running' ? 'sending' : webhook.status)} · {uiM('feedback_attempts')}: {webhook.attempts}</dd>{#if webhook.lastError}<dd class='break-all text-error'>{webhook.lastError}</dd>{/if}</div>
|
|
158
|
+
{/if}
|
|
150
159
|
<div><dt class='text-base-content/55'>{uiM('feedback_submitter')}</dt><dd class='break-all'>{report.userId || '—'}</dd></div>
|
|
151
160
|
<div><dt class='text-base-content/55'>{uiM('feedback_revision')}</dt><dd>{report.evidenceRevision}</dd></div>
|
|
152
161
|
{#if report.buildId}<div><dt class='text-base-content/55'>{uiM('feedback_build_id')}</dt><dd class='break-all'>{report.buildId}</dd></div>{/if}
|
|
153
162
|
{#if report.commit}<div><dt class='text-base-content/55'>{uiM('feedback_commit')}</dt><dd class='break-all'>{report.commit}</dd></div>{/if}
|
|
154
163
|
</dl>
|
|
164
|
+
{#if webhook?.status === 'failed' && permissions.retry && onretry}<Button size='sm' disabled={busy} onclick={() => run(() => onretry(report!))}>{uiM('feedback_retry')}</Button>{/if}
|
|
155
165
|
</div>
|
|
156
166
|
{:else if tab === 'replay'}
|
|
157
167
|
<div class='py-4'>
|
|
158
168
|
{#if onreplay}<FeedbackReplay load={onreplay} />{:else}<p class='text-sm'>{uiM('feedback_replay_empty')}</p>{/if}
|
|
159
169
|
</div>
|
|
160
|
-
{:else if tab === 'scene' || tab === 'logs' || tab === 'environment'}
|
|
170
|
+
{:else if tab === 'scene' || tab === 'logs' || tab === 'environment' || tab === 'business'}
|
|
161
171
|
<div class='space-y-4 py-4'>
|
|
162
172
|
{#if tab === 'scene'}
|
|
163
173
|
<div class='grid grid-cols-1 gap-3 xl:grid-cols-2'>
|
|
@@ -5,6 +5,12 @@ type $$ComponentProps = {
|
|
|
5
5
|
evidence?: FeedbackPage<FeedbackEvidenceView>;
|
|
6
6
|
attachments?: FeedbackAttachmentView[];
|
|
7
7
|
history?: FeedbackHistoryView[];
|
|
8
|
+
/** 持久 Webhook 任务的公开状态,由反馈详情 jobs 中的 webhook 项提供。 */
|
|
9
|
+
webhook?: {
|
|
10
|
+
status: 'pending' | 'running' | 'succeeded' | 'failed';
|
|
11
|
+
attempts: number;
|
|
12
|
+
lastError?: string;
|
|
13
|
+
};
|
|
8
14
|
permissions?: FeedbackPermissions;
|
|
9
15
|
loading?: boolean;
|
|
10
16
|
error?: string;
|
|
@@ -268,7 +268,7 @@
|
|
|
268
268
|
{#if oncapture}<Button size='sm' variant='outline' disabled={loading || annotating || staging || exporting} onclick={() => oncapture()}>{uiM('feedback_capture_add')}</Button>{/if}
|
|
269
269
|
<label class='btn btn-sm btn-ghost focus-within:outline focus-within:outline-primary'>
|
|
270
270
|
{uiM('feedback_add_files')}
|
|
271
|
-
<BareInput id={`${instanceId}-files`} type='file' aria-label={uiM('feedback_add_files')} accept='.png,.jpg,.jpeg,.webp,.webm,.mp4,.txt,.log,.json,.pdf,image/png,image/jpeg,image/webp,video/webm,video/mp4,text/plain,application/json,application/pdf' multiple disabled={loading || staging || exporting} class='sr-only' onchange={selectFiles} />
|
|
271
|
+
<BareInput id={`${instanceId}-files`} type='file' aria-label={uiM('feedback_add_files')} accept='.png,.jpg,.jpeg,.webp,.webm,.mp4,.txt,.log,.json,.pdf,.zip,.gz,.tgz,image/png,image/jpeg,image/webp,video/webm,video/mp4,text/plain,application/json,application/pdf,application/zip,application/gzip' multiple disabled={loading || staging || exporting} class='sr-only' onchange={selectFiles} />
|
|
272
272
|
</label>
|
|
273
273
|
{#if onfileschange}<FeedbackRecorder maxBytes={recordingBytes} disabled={loading || annotating || staging || exporting || attachmentLimitReached} onactive={recordingChanged} onrecord={recorded} />{/if}
|
|
274
274
|
</div>
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
import TableToolbar from '../../compounds/TableToolbar.svelte'
|
|
20
20
|
import Badge from '../../primitives/Badge.svelte'
|
|
21
21
|
import Button from '../../primitives/Button.svelte'
|
|
22
|
-
import { collectionLabel, feedbackTime, notificationLabel } from './feedback-functions.js'
|
|
22
|
+
import { collectionLabel, feedbackDateValue, feedbackDayBoundary, feedbackTime, notificationLabel } from './feedback-functions.js'
|
|
23
23
|
|
|
24
24
|
let {
|
|
25
25
|
data,
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
let busyId = $state('')
|
|
56
56
|
let search = $derived(effectiveQuery.search ?? '')
|
|
57
57
|
let sortDirection = $derived(effectiveQuery.sortDirection ?? 'desc')
|
|
58
|
-
let filterValues = $derived<Record<string, unknown>>({ status: effectiveQuery.status ?? '', collectionStatus: effectiveQuery.collectionStatus ?? '', appId: effectiveQuery.appId ?? '', appVersion: effectiveQuery.appVersion ?? '', from:
|
|
58
|
+
let filterValues = $derived<Record<string, unknown>>({ status: effectiveQuery.status ?? '', collectionStatus: effectiveQuery.collectionStatus ?? '', appId: effectiveQuery.appId ?? '', appVersion: effectiveQuery.appVersion ?? '', from: feedbackDateValue(effectiveQuery.from), to: feedbackDateValue(effectiveQuery.to) })
|
|
59
59
|
const columns = $derived([
|
|
60
60
|
{ key: 'number', label: uiM('feedback_number') },
|
|
61
61
|
{ key: 'description', label: uiM('feedback_summary') },
|
|
@@ -86,8 +86,8 @@
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
function filter(values: Record<string, unknown>) {
|
|
89
|
-
const from = values.from
|
|
90
|
-
const to = values.to
|
|
89
|
+
const from = feedbackDayBoundary(values.from, 'start')
|
|
90
|
+
const to = feedbackDayBoundary(values.to, 'end')
|
|
91
91
|
void update({ page: 1, status: values.status === 'pending' || values.status === 'handled' ? values.status : undefined, collectionStatus: ['collecting', 'complete', 'partial', 'failed'].includes(String(values.collectionStatus)) ? values.collectionStatus as FeedbackReportView['collectionStatus'] : undefined, appId: String(values.appId ?? '') || undefined, appVersion: String(values.appVersion ?? '') || undefined, from: Number.isFinite(from) ? from : undefined, to: Number.isFinite(to) ? to : undefined })
|
|
92
92
|
}
|
|
93
93
|
async function run(report: FeedbackReportView, action: (() => void | Promise<void>) | undefined) {
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
import type { Snippet } from 'svelte'
|
|
22
22
|
import type { DataAttributes } from '../../../types.js'
|
|
23
23
|
import { cn, getDataAttributes } from '../../../utils.js'
|
|
24
|
+
import PageHeader from '../../compounds/PageHeader.svelte'
|
|
24
25
|
import BareButton from '../../primitives/BareButton.svelte'
|
|
25
26
|
|
|
26
27
|
/**
|
|
@@ -76,25 +77,13 @@
|
|
|
76
77
|
}
|
|
77
78
|
</script>
|
|
78
79
|
|
|
79
|
-
<div {...dataAttributes} class={cn('space-y-
|
|
80
|
+
<div {...dataAttributes} class={cn('space-y-4', className)}>
|
|
80
81
|
<!-- 标题区 -->
|
|
81
82
|
{#if title || description || headerActions}
|
|
82
|
-
<
|
|
83
|
-
<div>
|
|
84
|
-
{#if title}
|
|
85
|
-
<h1 class='text-xl font-semibold tracking-tight'>{title}</h1>
|
|
86
|
-
{/if}
|
|
87
|
-
{#if description}
|
|
88
|
-
<p class='mt-0.5 text-sm text-base-content/45'>{description}</p>
|
|
89
|
-
{/if}
|
|
90
|
-
</div>
|
|
91
|
-
{#if headerActions}
|
|
92
|
-
<div class='flex items-center gap-2'>{@render headerActions()}</div>
|
|
93
|
-
{/if}
|
|
94
|
-
</div>
|
|
83
|
+
<PageHeader {title} {description} actions={headerActions} class='mb-0' />
|
|
95
84
|
{/if}
|
|
96
85
|
|
|
97
|
-
<div class='grid gap-
|
|
86
|
+
<div class='grid gap-4 lg:grid-cols-[13rem_minmax(0,1fr)]'>
|
|
98
87
|
<!-- 左侧分区导航 -->
|
|
99
88
|
{#if sections.length > 0}
|
|
100
89
|
<aside class='lg:sticky lg:top-4 lg:self-start'>
|