@h-ai/ui 0.1.0-alpha.74 → 0.1.0-alpha.76

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.
Files changed (67) hide show
  1. package/README.en.md +46 -17
  2. package/README.ja.md +46 -17
  3. package/README.md +46 -17
  4. package/auto-import.d.ts +2 -0
  5. package/auto-import.js +2 -0
  6. package/dist/components/compounds/Alert.svelte +2 -2
  7. package/dist/components/compounds/Alert.svelte.d.ts +1 -1
  8. package/dist/components/compounds/Confirm.svelte +12 -2
  9. package/dist/components/compounds/Drawer.svelte +32 -14
  10. package/dist/components/compounds/FilterBar.svelte +77 -0
  11. package/dist/components/compounds/FilterBar.svelte.d.ts +39 -0
  12. package/dist/components/compounds/Modal.svelte +4 -37
  13. package/dist/components/compounds/PageHeader.svelte +18 -11
  14. package/dist/components/compounds/TableToolbar.svelte +1 -1
  15. package/dist/components/compounds/ToastContainer.svelte +96 -42
  16. package/dist/components/compounds/ToastContainer.svelte.d.ts +1 -1
  17. package/dist/components/compounds/index.d.ts +1 -0
  18. package/dist/components/compounds/index.js +1 -0
  19. package/dist/components/primitives/Button.svelte +7 -0
  20. package/dist/components/primitives/Input.svelte +1 -1
  21. package/dist/components/primitives/Textarea.svelte +1 -1
  22. package/dist/components/scenes/app/FeedbackDetail.svelte +2 -2
  23. package/dist/components/scenes/app/FeedbackForm.svelte +5 -7
  24. package/dist/components/scenes/app/FeedbackList.svelte +4 -4
  25. package/dist/components/scenes/app/SettingsLayout.svelte +4 -15
  26. package/dist/components/scenes/app/ThemeSelector.svelte +56 -16
  27. package/dist/components/scenes/app/WorkspaceLayout.svelte +64 -0
  28. package/dist/components/scenes/app/WorkspaceLayout.svelte.d.ts +36 -0
  29. package/dist/components/scenes/app/feedback-functions.d.ts +16 -0
  30. package/dist/components/scenes/app/feedback-functions.js +31 -0
  31. package/dist/components/scenes/app/index.d.ts +1 -0
  32. package/dist/components/scenes/app/index.js +1 -0
  33. package/dist/components/scenes/crud/CrudEditPanel.svelte +18 -9
  34. package/dist/components/scenes/crud/CrudFilterBar.svelte +39 -30
  35. package/dist/components/scenes/crud/CrudFilterBar.svelte.d.ts +4 -1
  36. package/dist/components/scenes/crud/CrudPage.svelte +27 -7
  37. package/dist/components/scenes/crud/CrudPage.svelte.d.ts +1 -1
  38. package/dist/components/scenes/crud/crud-types.d.ts +1 -1
  39. package/dist/components/scenes/guide/GuideHost.svelte +22 -102
  40. package/dist/components/scenes/guide/GuideHost.svelte.d.ts +5 -13
  41. package/dist/components/scenes/guide/GuideHostContent.svelte +143 -0
  42. package/dist/components/scenes/guide/GuideHostContent.svelte.d.ts +43 -0
  43. package/dist/components/scenes/guide/HelpCenter.svelte +22 -9
  44. package/dist/components/scenes/iam/AuthPanel.svelte +5 -3
  45. package/dist/components/scenes/iam/LoginForm.svelte +25 -1
  46. package/dist/components/scenes/iam/PasswordInput.svelte +1 -1
  47. package/dist/components/scenes/iam/SensitiveOperationsForm.svelte +1 -1
  48. package/dist/components/scenes/types.d.ts +2 -0
  49. package/dist/guide.svelte.js +61 -26
  50. package/dist/internal/dialog-focus.d.ts +21 -0
  51. package/dist/internal/dialog-focus.js +77 -0
  52. package/dist/internal/form-validation.svelte.d.ts +2 -1
  53. package/dist/internal/form-validation.svelte.js +9 -1
  54. package/dist/messages/en-US.json +9 -2
  55. package/dist/messages/ja-JP.json +9 -2
  56. package/dist/messages/zh-CN.json +9 -2
  57. package/dist/styles/formal.css +55 -0
  58. package/dist/styles/high-contrast.css +64 -0
  59. package/dist/styles/theme.css +2 -0
  60. package/dist/theme-config.d.ts +2 -2
  61. package/dist/theme-config.js +5 -2
  62. package/dist/toast.svelte.d.ts +7 -6
  63. package/dist/toast.svelte.js +23 -23
  64. package/dist/types.d.ts +6 -2
  65. package/dist/workspace-context.d.ts +20 -0
  66. package/dist/workspace-context.js +9 -0
  67. package/package.json +7 -2
@@ -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
- const previous = document.activeElement instanceof HTMLElement ? document.activeElement : null
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
- if (event.key === 'Escape' && closeOnEscape) {
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
- <div {...dataAttributes} class='flex flex-col sm:flex-row sm:items-center justify-between gap-3 mb-5 {className}'>
50
- <div>
51
- <h1 class='text-xl font-semibold tracking-tight'>{title}</h1>
52
- {#if description}
53
- <p class='text-sm text-base-content/45 mt-0.5'>{description}</p>
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
- {#if actions}
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
  }
@@ -3,7 +3,7 @@
3
3
  =============================================================================
4
4
  @h-ai/ui - ToastContainer 组件
5
5
  =============================================================================
6
- Toast 容器组件,显示所有 Toast 通知
6
+ 浮动操作提示容器,按先后顺序逐条显示,不占用页面布局。
7
7
 
8
8
  使用 Svelte 5 Runes ($derived / $effect)
9
9
 
@@ -29,19 +29,17 @@
29
29
  import { onMount } from 'svelte'
30
30
  import { uiM } from '../../messages.js'
31
31
  import { toast } from '../../toast.svelte.js'
32
- import { cn, getAlertVariantClass, getDataAttributes } from '../../utils.js'
32
+ import { cn, getDataAttributes } from '../../utils.js'
33
33
  import IconButton from '../primitives/IconButton.svelte'
34
34
 
35
35
  const { ...restProps }: DataAttributes = $props()
36
36
  const dataAttributes = $derived(getDataAttributes(restProps))
37
37
 
38
- const positionMap = {
39
- 'top-right': 'toast-top toast-end',
40
- 'top-left': 'toast-top toast-start',
41
- 'bottom-right': 'toast-bottom toast-end',
42
- 'bottom-left': 'toast-bottom toast-start',
43
- 'top-center': 'toast-top toast-center',
44
- 'bottom-center': 'toast-bottom toast-center',
38
+ const iconMap = {
39
+ info: 'icon-[tabler--info-circle] text-info',
40
+ success: 'icon-[tabler--circle-check] text-success',
41
+ warning: 'icon-[tabler--alert-triangle] text-warning',
42
+ error: 'icon-[tabler--circle-x] text-error',
45
43
  }
46
44
 
47
45
  // 容器根元素引用。
@@ -49,20 +47,7 @@
49
47
 
50
48
  const hasItems = $derived(toast.items.length > 0)
51
49
 
52
- // 按位置分组
53
- const groupedItems = $derived(() => {
54
- const groups: Record<string, typeof toast.items> = {}
55
-
56
- for (const item of toast.items) {
57
- const position = item.position ?? 'top-right'
58
- if (!groups[position]) {
59
- groups[position] = []
60
- }
61
- groups[position].push(item)
62
- }
63
-
64
- return groups
65
- })
50
+ const currentItems = $derived(toast.items.slice(0, 1))
66
51
 
67
52
  /** 找到最顶层处于打开状态的原生 modal dialog(位于浏览器 top layer)。 */
68
53
  function findTopModalDialog(): HTMLDialogElement | null {
@@ -166,23 +151,23 @@
166
151
  </script>
167
152
 
168
153
  <div {...dataAttributes} bind:this={layerElement} popover='manual' class='hai-toast-layer'>
169
- {#each Object.entries(groupedItems()) as [position, items] (position)}
170
- <div class={cn('toast', positionMap[position as keyof typeof positionMap])}>
171
- {#each items as item (item.id)}
172
- <div class={cn('alert', getAlertVariantClass(item.variant ?? 'info'))}>
173
- <span>{item.message}</span>
174
- {#if item.dismissible}
175
- <IconButton
176
- variant='ghost'
177
- size='sm'
178
- onclick={() => toast.remove(item.id)}
179
- ariaLabel={uiM('toast_dismiss')}
180
- >
181
- ✕
182
- </IconButton>
183
- {/if}
184
- </div>
185
- {/each}
154
+ {#each currentItems as item (item.id)}
155
+ <div class='hai-toast-position' data-position={item.position ?? 'bottom-right'}>
156
+ <div {...getDataAttributes(item)} class='hai-toast-item text-base-content' role={item.variant === 'error' ? 'alert' : 'status'} aria-live={item.variant === 'error' ? 'assertive' : 'polite'} aria-atomic='true' data-variant={item.variant ?? 'info'}>
157
+ <span aria-hidden='true' class={cn('size-5 shrink-0', iconMap[item.variant as keyof typeof iconMap] ?? iconMap.info)}></span>
158
+ <span class='hai-toast-message'>{item.message}</span>
159
+ {#if item.dismissible}
160
+ <IconButton
161
+ variant='ghost'
162
+ size='sm'
163
+ class='shrink-0 text-base-content/45'
164
+ onclick={() => toast.remove(item.id)}
165
+ ariaLabel={uiM('toast_dismiss')}
166
+ >
167
+ ✕
168
+ </IconButton>
169
+ {/if}
170
+ </div>
186
171
  </div>
187
172
  {/each}
188
173
  </div>
@@ -202,12 +187,81 @@
202
187
  background: transparent;
203
188
  overflow: visible;
204
189
  pointer-events: none;
190
+ z-index: var(--hai-z-toast, 1200);
205
191
  }
206
192
 
207
- /* 未支持 Popover API 的浏览器忽略 popover 属性,容器常驻文档流;
193
+ /* 未支持 Popover API 的浏览器忽略 popover 属性,容器仍保持固定定位;
208
194
  此时无 toast 项则内部不渲染任何内容,容器透明且不拦截交互。 */
209
195
 
210
- .hai-toast-layer :global(.toast) {
196
+ .hai-toast-position {
197
+ position: absolute;
198
+ width: min(24rem, calc(100% - 2rem - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
199
+ right: max(1rem, env(safe-area-inset-right, 0px));
200
+ bottom: max(1rem, env(safe-area-inset-bottom, 0px));
201
+ }
202
+
203
+ .hai-toast-position[data-position^='top-'] {
204
+ top: max(1rem, env(safe-area-inset-top, 0px));
205
+ bottom: auto;
206
+ }
207
+
208
+ .hai-toast-position[data-position$='-left'] {
209
+ left: max(1rem, env(safe-area-inset-left, 0px));
210
+ right: auto;
211
+ }
212
+
213
+ .hai-toast-position[data-position$='-center'] {
214
+ left: 50%;
215
+ right: auto;
216
+ transform: translateX(-50%);
217
+ }
218
+
219
+ .hai-toast-item {
220
+ --hai-toast-accent: var(--color-info);
221
+ display: flex;
222
+ align-items: center;
223
+ gap: 0.75rem;
224
+ padding: 0.75rem 1rem;
225
+ border-width: 1px;
226
+ border-style: solid;
227
+ border-color: color-mix(in oklab, var(--hai-toast-accent) 20%, var(--color-base-100));
228
+ border-inline-start: 3px solid var(--hai-toast-accent);
229
+ background: color-mix(in oklab, var(--hai-toast-accent) 5%, var(--color-base-100));
230
+ border-radius: var(--hai-radius-md, 8px);
231
+ box-shadow: 0 4px 18px oklch(0 0 0 / 0.08);
211
232
  pointer-events: auto;
233
+ animation: hai-toast-enter 150ms ease-out;
234
+ }
235
+
236
+ .hai-toast-item[data-variant='success'] {
237
+ --hai-toast-accent: var(--color-success);
238
+ }
239
+
240
+ .hai-toast-item[data-variant='warning'] {
241
+ --hai-toast-accent: var(--color-warning);
242
+ }
243
+
244
+ .hai-toast-item[data-variant='error'] {
245
+ --hai-toast-accent: var(--color-error);
246
+ }
247
+
248
+ .hai-toast-message {
249
+ flex: 1;
250
+ min-width: 0;
251
+ max-height: min(20rem, 60dvh);
252
+ overflow: auto;
253
+ overflow-wrap: anywhere;
254
+ white-space: pre-wrap;
255
+ font-size: 0.875rem;
256
+ line-height: 1.5;
257
+ }
258
+
259
+ @keyframes hai-toast-enter {
260
+ from { opacity: 0; transform: translateY(0.25rem); }
261
+ to { opacity: 1; transform: translateY(0); }
262
+ }
263
+
264
+ @media (prefers-reduced-motion: reduce) {
265
+ .hai-toast-item { animation: none; }
212
266
  }
213
267
  </style>
@@ -4,7 +4,7 @@ import type { DataAttributes } from '../../types.js';
4
4
  * =============================================================================
5
5
  * @h-ai/ui - ToastContainer 组件
6
6
  * =============================================================================
7
- * Toast 容器组件,显示所有 Toast 通知
7
+ * 浮动操作提示容器,按先后顺序逐条显示,不占用页面布局。
8
8
  *
9
9
  * 使用 Svelte 5 Runes ($derived / $effect)
10
10
  *
@@ -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>
@@ -99,7 +99,7 @@
99
99
  }
100
100
 
101
101
  function handleBlur(e: FocusEvent & { currentTarget: HTMLInputElement }) {
102
- validation.validate(e.currentTarget)
102
+ validation.blur(e.currentTarget)
103
103
  onblur?.(e)
104
104
  }
105
105
 
@@ -123,7 +123,7 @@
123
123
  class={textareaClass}
124
124
  bind:value
125
125
  oninput={handleInput}
126
- onblur={e => validation.validate(e.currentTarget)}
126
+ onblur={e => validation.blur(e.currentTarget)}
127
127
  oninvalid={handleInvalid}
128
128
  ></textarea>
129
129
  </div>
@@ -121,9 +121,9 @@
121
121
  }
122
122
  function changeTab(tab: string) {
123
123
  if (tab === 'environment')
124
- void query({ page: 1, kind: 'environment' })
124
+ void query({ page: 1, kind: 'environment', requestId: undefined, errorId: undefined })
125
125
  else if (tab === 'scene')
126
- void query({ page: 1, kind: 'interaction' })
126
+ void query({ page: 1, kind: 'interaction', requestId: undefined, errorId: undefined })
127
127
  else if (tab === 'logs')
128
128
  void query({ page: 1, kind: undefined })
129
129
  else if (tab === 'business')
@@ -13,7 +13,7 @@
13
13
  import type { FeedbackAnnotation, FeedbackAttachmentView, FeedbackEvidenceSummary, FeedbackEvidenceView, FeedbackFormData, FeedbackReceipt } from './feedback-types.js'
14
14
  import { untrack } from 'svelte'
15
15
  import { uiM } from '../../../messages.js'
16
- import { errorMessage } from '../../../toast.svelte.js'
16
+ import { errorMessage, toast } from '../../../toast.svelte.js'
17
17
  import { getDataAttributes } from '../../../utils.js'
18
18
  import FormField from '../../compounds/FormField.svelte'
19
19
  import FormLayout from '../../compounds/FormLayout.svelte'
@@ -110,7 +110,6 @@
110
110
  let filesError = $state(false)
111
111
  let exporting = $state(false)
112
112
  let recording = $state(false)
113
- let exported = $state(false)
114
113
  let expandedMaterials = $state<string[]>([])
115
114
  let error = $state('')
116
115
  let previousKey = $state(untrack(() => resetKey))
@@ -141,7 +140,6 @@
141
140
  filesError = false
142
141
  removedAttachmentIds = []
143
142
  receipt = undefined
144
- exported = false
145
143
  error = ''
146
144
  }
147
145
  })
@@ -181,7 +179,8 @@
181
179
  exporting = true
182
180
  error = ''
183
181
  try {
184
- exported = await onexport(values()) !== false
182
+ if (await onexport(values()) !== false)
183
+ toast.info(uiM('feedback_local_saved'))
185
184
  }
186
185
  catch (cause) {
187
186
  error = errorMessage(cause, uiM('feedback_action_failed'))
@@ -252,7 +251,7 @@
252
251
  {/if}
253
252
  {#if error}<div class='alert alert-error break-words' role='alert'>{error}</div>{/if}
254
253
  {#if receipt}
255
- <div role='status' class='alert alert-success block space-y-2 break-words'>
254
+ <div role='status' class='alert alert-soft alert-success shadow-none block space-y-2 break-words'>
256
255
  <p class='font-medium'>{uiM('feedback_accepted', { number: receipt.number })}</p>
257
256
  <p>{collectionLabel(receipt.collectionStatus)}</p>
258
257
  <p class='text-sm'>{uiM('feedback_accepted_hint')}</p>
@@ -268,7 +267,7 @@
268
267
  {#if oncapture}<Button size='sm' variant='outline' disabled={loading || annotating || staging || exporting} onclick={() => oncapture()}>{uiM('feedback_capture_add')}</Button>{/if}
269
268
  <label class='btn btn-sm btn-ghost focus-within:outline focus-within:outline-primary'>
270
269
  {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,.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} />
270
+ <BareInput id={`${instanceId}-files`} type='file' 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
271
  </label>
273
272
  {#if onfileschange}<FeedbackRecorder maxBytes={recordingBytes} disabled={loading || annotating || staging || exporting || attachmentLimitReached} onactive={recordingChanged} onrecord={recorded} />{/if}
274
273
  </div>
@@ -328,7 +327,6 @@
328
327
  </details>
329
328
  {/if}
330
329
  {/if}
331
- {#if exported}<p class='text-sm text-success' role='status'>{uiM('feedback_local_saved')}</p>{/if}
332
330
  </div>
333
331
  <div class='shrink-0 flex flex-wrap justify-end gap-2 border-t border-base-content/10 bg-base-100 pt-4 pb-2'>
334
332
  {#if onexport}<Button variant='ghost' loading={exporting} disabled={annotating || staging} onclick={saveLocal}>{uiM('feedback_local_export')}</Button>{/if}
@@ -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: effectiveQuery.from ? new Date(effectiveQuery.from).toISOString().slice(0, 10) : '', to: effectiveQuery.to ? new Date(effectiveQuery.to).toISOString().slice(0, 10) : '' })
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 ? Date.parse(String(values.from)) : undefined
90
- const to = values.to ? Date.parse(String(values.to)) + 86_400_000 - 1 : undefined
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-5', className)}>
80
+ <div {...dataAttributes} class={cn('space-y-4', className)}>
80
81
  <!-- 标题区 -->
81
82
  {#if title || description || headerActions}
82
- <div class='flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between'>
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-6 lg:grid-cols-[13rem_minmax(0,1fr)]'>
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'>