@h-ai/ui 0.1.0-alpha.74 → 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 +36 -4
- package/README.ja.md +36 -4
- package/README.md +36 -4
- package/auto-import.d.ts +2 -0
- package/auto-import.js +2 -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 +2 -2
- 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/LoginForm.svelte +25 -1
- package/dist/components/scenes/iam/PasswordInput.svelte +1 -1
- package/dist/components/scenes/types.d.ts +2 -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 +9 -2
- package/dist/messages/ja-JP.json +9 -2
- package/dist/messages/zh-CN.json +9 -2
- 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
|
@@ -48,19 +48,31 @@
|
|
|
48
48
|
const searchId = $props.id()
|
|
49
49
|
let currentId = $derived(selectedId)
|
|
50
50
|
// 显式依赖宿主语言,确保回调返回的业务翻译也重新求值。
|
|
51
|
-
const
|
|
51
|
+
const articleState = $derived.by(() => {
|
|
52
52
|
void locale
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
let failed = false
|
|
54
|
+
const localized = articles.flatMap((article) => {
|
|
55
|
+
try {
|
|
56
|
+
if (article.enabled && !article.enabled())
|
|
57
|
+
return []
|
|
58
|
+
return [{ ...article, title: resolveGuideText(article.title), description: resolveGuideText(article.description), category: resolveGuideText(article.category), content: resolveGuideText(article.content) }]
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
failed = true
|
|
62
|
+
return []
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
return { localized, failed }
|
|
60
66
|
})
|
|
67
|
+
const localized = $derived(articleState.localized)
|
|
61
68
|
const availableTours = $derived.by(() => {
|
|
62
69
|
void locale
|
|
63
|
-
return tours.
|
|
70
|
+
return tours.flatMap((tour) => {
|
|
71
|
+
try {
|
|
72
|
+
return !tour.enabled || tour.enabled() ? [{ id: tour.id, title: resolveGuideText(tour.title) }] : []
|
|
73
|
+
}
|
|
74
|
+
catch { return [] }
|
|
75
|
+
})
|
|
64
76
|
})
|
|
65
77
|
const visible = $derived(localized.filter(article => (`${article.title} ${article.description} ${article.category} ${article.content}`).toLowerCase().includes(search.trim().toLowerCase())))
|
|
66
78
|
const selected = $derived(visible.find(article => article.id === currentId) ?? visible[0])
|
|
@@ -97,6 +109,7 @@
|
|
|
97
109
|
{/if}
|
|
98
110
|
</nav>
|
|
99
111
|
<article class='min-w-0 flex-1 p-5 md:p-7' data-testid='guide-article-content'>
|
|
112
|
+
{#if articleState.failed}<p class='text-sm text-error' role='alert'>{text.failed}</p>{/if}
|
|
100
113
|
{#if selected}
|
|
101
114
|
<h2 class='text-xl font-semibold'>{selected.title}</h2>
|
|
102
115
|
{#if selected.description}<p class='mt-2 text-sm text-base-content/60'>{selected.description}</p>{/if}
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
|
|
32
32
|
const {
|
|
33
33
|
methods = ['password'],
|
|
34
|
+
autoFocus = true,
|
|
34
35
|
initialIdentifier = '',
|
|
35
36
|
otpLength = 6,
|
|
36
37
|
resendInterval = 60,
|
|
@@ -58,12 +59,33 @@
|
|
|
58
59
|
}: LoginFormProps & DataAttributes = $props()
|
|
59
60
|
|
|
60
61
|
const dataAttributes = $derived(getDataAttributes(restProps))
|
|
62
|
+
let formElement = $state<HTMLFormElement>()
|
|
63
|
+
let focusedInitially = false
|
|
61
64
|
|
|
62
65
|
let username = $state(untrack(() => initialIdentifier))
|
|
63
66
|
let password = $state('')
|
|
64
67
|
let selectedMethod = $state<AuthLoginMethod>('password')
|
|
65
68
|
const method = $derived(methods.includes(selectedMethod) ? selectedMethod : methods[0])
|
|
66
69
|
const isOtp = $derived(method === 'email' || method === 'sms')
|
|
70
|
+
$effect(() => {
|
|
71
|
+
if (!autoFocus || focusedInitially || disabled || loading || !method || !formElement)
|
|
72
|
+
return
|
|
73
|
+
const input = formElement.querySelector<HTMLInputElement>('input[autocomplete="username"]')
|
|
74
|
+
if (!input?.getClientRects().length)
|
|
75
|
+
return
|
|
76
|
+
if (globalThis.matchMedia?.('(pointer: coarse)').matches) {
|
|
77
|
+
focusedInitially = true
|
|
78
|
+
return
|
|
79
|
+
}
|
|
80
|
+
input.autofocus = true
|
|
81
|
+
// 首帧布局和宿主导航完成后设置默认焦点;尊重用户已经选择的其它控件。
|
|
82
|
+
const frame = requestAnimationFrame(() => {
|
|
83
|
+
focusedInitially = true
|
|
84
|
+
if (document.activeElement === document.body || document.activeElement === document.documentElement)
|
|
85
|
+
input.focus()
|
|
86
|
+
})
|
|
87
|
+
return () => cancelAnimationFrame(frame)
|
|
88
|
+
})
|
|
67
89
|
let code = $state('')
|
|
68
90
|
let sending = $state(false)
|
|
69
91
|
let sendFailure = $state<Pick<HaiError, 'code' | 'message'> | 'network'>()
|
|
@@ -139,7 +161,7 @@
|
|
|
139
161
|
}
|
|
140
162
|
</script>
|
|
141
163
|
|
|
142
|
-
<form {...dataAttributes} class={formClass} onsubmit={handleSubmit}>
|
|
164
|
+
<form {...dataAttributes} bind:this={formElement} class={formClass} onsubmit={handleSubmit}>
|
|
143
165
|
<FormLayout {columns} {labelPosition} {labelWidth}>
|
|
144
166
|
<!-- 标题 -->
|
|
145
167
|
{#if showTitle}
|
|
@@ -168,6 +190,7 @@
|
|
|
168
190
|
{/each}
|
|
169
191
|
</div>
|
|
170
192
|
{/if}
|
|
193
|
+
{#if method === 'ldap'}<p class='text-sm text-base-content/70'>{uiM('login_method_ldap_hint')}</p>{/if}
|
|
171
194
|
{#if !method}
|
|
172
195
|
<Alert variant='warning'>{uiM('auth_unavailable')}</Alert>
|
|
173
196
|
{:else}
|
|
@@ -244,6 +267,7 @@
|
|
|
244
267
|
<!-- 提交按钮 -->
|
|
245
268
|
<Button
|
|
246
269
|
type='submit'
|
|
270
|
+
submitHint
|
|
247
271
|
variant='primary'
|
|
248
272
|
{loading}
|
|
249
273
|
disabled={loading || disabled || !method}
|
|
@@ -201,7 +201,7 @@
|
|
|
201
201
|
ariaDescribedby={[field?.messageId, localError && !field?.error ? messageId : ''].filter(Boolean).join(' ') || undefined}
|
|
202
202
|
oninput={handleInput}
|
|
203
203
|
onchange={handleChange}
|
|
204
|
-
onblur={e => validation.
|
|
204
|
+
onblur={e => validation.blur(e.currentTarget)}
|
|
205
205
|
oninvalid={(e) => {
|
|
206
206
|
validation.validate(e.currentTarget)
|
|
207
207
|
oninvalid?.(e)
|
|
@@ -107,6 +107,8 @@ export interface LoginFormData {
|
|
|
107
107
|
* ```
|
|
108
108
|
*/
|
|
109
109
|
export interface LoginFormProps extends FormLayoutOptions, DataAttributes {
|
|
110
|
+
/** 默认在桌面首次就绪且页面尚无焦点时聚焦登录标识;触屏不主动弹出键盘。 */
|
|
111
|
+
autoFocus?: boolean;
|
|
110
112
|
/** 初始登录标识;原地恢复时预填原用户名,仍走正常鉴别。 */
|
|
111
113
|
initialIdentifier?: string;
|
|
112
114
|
/** 实际可用的方式;空数组表示无可用登录方式。 */
|
package/dist/guide.svelte.js
CHANGED
|
@@ -29,13 +29,18 @@ function escapeGuideText(text) {
|
|
|
29
29
|
})[character]);
|
|
30
30
|
}
|
|
31
31
|
function findTarget(step) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
try {
|
|
33
|
+
const element = typeof step.target === 'function'
|
|
34
|
+
? step.target()
|
|
35
|
+
: [...document.querySelectorAll('[data-guide]')].find(item => item.getAttribute('data-guide') === step.target);
|
|
36
|
+
if (!element?.isConnected || !element.getClientRects().length || element.closest('[hidden], [aria-hidden="true"]'))
|
|
37
|
+
return null;
|
|
38
|
+
const style = getComputedStyle(element);
|
|
39
|
+
return style.visibility === 'hidden' || style.display === 'none' ? null : element;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
36
42
|
return null;
|
|
37
|
-
|
|
38
|
-
return style.visibility === 'hidden' || style.display === 'none' ? null : element;
|
|
43
|
+
}
|
|
39
44
|
}
|
|
40
45
|
/** 等待异步渲染、页签展开或布局变化,所有退出路径均清理监听和计时器。 */
|
|
41
46
|
function waitForTarget(step, signal, timeout, ready) {
|
|
@@ -58,17 +63,28 @@ function waitForTarget(step, signal, timeout, ready) {
|
|
|
58
63
|
finish(null);
|
|
59
64
|
return;
|
|
60
65
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
66
|
+
try {
|
|
67
|
+
const element = ready() ? findTarget(step) : null;
|
|
68
|
+
if (element)
|
|
69
|
+
finish(element);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
finish(null);
|
|
73
|
+
}
|
|
64
74
|
};
|
|
65
75
|
if (signal.aborted) {
|
|
66
76
|
finish(null);
|
|
67
77
|
return;
|
|
68
78
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
79
|
+
try {
|
|
80
|
+
const initial = ready() ? findTarget(step) : null;
|
|
81
|
+
if (initial) {
|
|
82
|
+
finish(initial);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
finish(null);
|
|
72
88
|
return;
|
|
73
89
|
}
|
|
74
90
|
observer = new MutationObserver(check);
|
|
@@ -116,7 +132,14 @@ export function createGuide(options) {
|
|
|
116
132
|
let targetObserver;
|
|
117
133
|
const msg = (key) => uiM(key, undefined, locale);
|
|
118
134
|
const progressKey = (id) => `${persistKey}:${scope}:${id}`;
|
|
119
|
-
const tourFor = (id) =>
|
|
135
|
+
const tourFor = (id) => {
|
|
136
|
+
try {
|
|
137
|
+
return options.tours.find(tour => tour.id === id && (!tour.enabled || tour.enabled()));
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
120
143
|
function clearPending() {
|
|
121
144
|
try {
|
|
122
145
|
sessionStorage.removeItem(pendingKey);
|
|
@@ -183,7 +206,7 @@ export function createGuide(options) {
|
|
|
183
206
|
helpOpen = false;
|
|
184
207
|
const tour = tourFor(id);
|
|
185
208
|
if (!tour?.steps.length) {
|
|
186
|
-
error
|
|
209
|
+
error ||= 'guide_unavailable';
|
|
187
210
|
return false;
|
|
188
211
|
}
|
|
189
212
|
const run = generation;
|
|
@@ -339,16 +362,22 @@ export function createGuide(options) {
|
|
|
339
362
|
}
|
|
340
363
|
},
|
|
341
364
|
onPopoverRender: (popover) => {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
365
|
+
try {
|
|
366
|
+
// 第三方默认支持 HTML;业务翻译和插值统一按纯文本写入。
|
|
367
|
+
const index = driver?.getActiveIndex() ?? 0;
|
|
368
|
+
const step = tour.steps[index];
|
|
369
|
+
popover.title.textContent = resolveGuideText(step?.title);
|
|
370
|
+
popover.description.textContent = resolveGuideText(step?.description);
|
|
371
|
+
popover.nextButton.textContent = msg(index === tour.steps.length - 1 ? 'guide_done' : 'guide_next');
|
|
372
|
+
popover.previousButton.textContent = msg('guide_previous');
|
|
373
|
+
popover.progress.textContent = uiM('guide_progress', { current: index + 1, total: tour.steps.length }, locale);
|
|
374
|
+
popover.nextButton.disabled = busy;
|
|
375
|
+
popover.previousButton.disabled = busy || !hasPreviousStep(index);
|
|
376
|
+
}
|
|
377
|
+
catch {
|
|
378
|
+
error = 'guide_startFailed';
|
|
379
|
+
stop();
|
|
380
|
+
}
|
|
352
381
|
},
|
|
353
382
|
});
|
|
354
383
|
const started = await showStep(0);
|
|
@@ -425,8 +454,14 @@ export function createGuide(options) {
|
|
|
425
454
|
locale = value;
|
|
426
455
|
const tour = activeTourId ? tourFor(activeTourId) : undefined;
|
|
427
456
|
if (driver && tour) {
|
|
428
|
-
|
|
429
|
-
|
|
457
|
+
try {
|
|
458
|
+
driver.setConfig({ ...driver.getConfig(), ...translatedConfig(tour) });
|
|
459
|
+
driver.drive(driver.getActiveIndex() ?? 0);
|
|
460
|
+
}
|
|
461
|
+
catch {
|
|
462
|
+
error = 'guide_startFailed';
|
|
463
|
+
stop();
|
|
464
|
+
}
|
|
430
465
|
}
|
|
431
466
|
},
|
|
432
467
|
setScope(value) {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 打开后优先聚焦可编辑字段,清理时取消首帧校准并恢复触发控件。
|
|
3
|
+
* @example 模块内部上下文
|
|
4
|
+
* ```ts
|
|
5
|
+
* function example(panel: HTMLElement) {
|
|
6
|
+
* const restore = focusDialog(panel)
|
|
7
|
+
* return restore
|
|
8
|
+
* }
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare function focusDialog(panel: HTMLElement): () => void;
|
|
12
|
+
/**
|
|
13
|
+
* 原生 Tab 顺序只在边缘循环;嵌套弹层已处理的键盘事件不再拦截。
|
|
14
|
+
* @example 模块内部上下文
|
|
15
|
+
* ```ts
|
|
16
|
+
* function example(event: KeyboardEvent, panel: HTMLElement) {
|
|
17
|
+
* handleDialogKeydown(event, panel, () => {})
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function handleDialogKeydown(event: KeyboardEvent, panel: HTMLElement, close?: () => void): void;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/** 弹窗和抽屉共享可见、可操作的焦点边界。 */
|
|
2
|
+
function focusable(panel) {
|
|
3
|
+
return [...panel.querySelectorAll('button, a[href], input:not([type="hidden"]), select, textarea, [tabindex]')]
|
|
4
|
+
.filter(element => element.tabIndex >= 0 && !element.matches(':disabled') && element.getClientRects().length > 0);
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* 打开后优先聚焦可编辑字段,清理时取消首帧校准并恢复触发控件。
|
|
8
|
+
* @example 模块内部上下文
|
|
9
|
+
* ```ts
|
|
10
|
+
* function example(panel: HTMLElement) {
|
|
11
|
+
* const restore = focusDialog(panel)
|
|
12
|
+
* return restore
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export function focusDialog(panel) {
|
|
17
|
+
const previous = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
18
|
+
function preferred() {
|
|
19
|
+
const elements = focusable(panel);
|
|
20
|
+
return elements.find(element => element.matches('input:not([readonly]), textarea, select, [role="combobox"]')) ?? elements[0] ?? panel;
|
|
21
|
+
}
|
|
22
|
+
const initial = preferred();
|
|
23
|
+
initial.focus({ preventScroll: true });
|
|
24
|
+
function alignFocus() {
|
|
25
|
+
const active = document.activeElement;
|
|
26
|
+
if (panel.isConnected && (active === previous || active === initial || active === panel || active === document.body))
|
|
27
|
+
preferred().focus({ preventScroll: true });
|
|
28
|
+
}
|
|
29
|
+
function onTransition(event) {
|
|
30
|
+
if (event.target === panel)
|
|
31
|
+
alignFocus();
|
|
32
|
+
}
|
|
33
|
+
panel.addEventListener('transitionend', onTransition);
|
|
34
|
+
const frame = typeof requestAnimationFrame === 'function' ? requestAnimationFrame(alignFocus) : undefined;
|
|
35
|
+
return () => {
|
|
36
|
+
panel.removeEventListener('transitionend', onTransition);
|
|
37
|
+
if (frame !== undefined)
|
|
38
|
+
cancelAnimationFrame(frame);
|
|
39
|
+
if (previous?.isConnected && !previous.matches(':disabled'))
|
|
40
|
+
previous.focus();
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* 原生 Tab 顺序只在边缘循环;嵌套弹层已处理的键盘事件不再拦截。
|
|
45
|
+
* @example 模块内部上下文
|
|
46
|
+
* ```ts
|
|
47
|
+
* function example(event: KeyboardEvent, panel: HTMLElement) {
|
|
48
|
+
* handleDialogKeydown(event, panel, () => {})
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export function handleDialogKeydown(event, panel, close) {
|
|
53
|
+
if (event.defaultPrevented)
|
|
54
|
+
return;
|
|
55
|
+
if (event.key === 'Escape' && close) {
|
|
56
|
+
event.preventDefault();
|
|
57
|
+
event.stopPropagation();
|
|
58
|
+
close();
|
|
59
|
+
}
|
|
60
|
+
else if (event.key === 'Tab') {
|
|
61
|
+
const elements = focusable(panel);
|
|
62
|
+
const first = elements[0];
|
|
63
|
+
const last = elements.at(-1);
|
|
64
|
+
if (!first) {
|
|
65
|
+
event.preventDefault();
|
|
66
|
+
panel.focus();
|
|
67
|
+
}
|
|
68
|
+
else if (event.shiftKey && (document.activeElement === first || document.activeElement === panel)) {
|
|
69
|
+
event.preventDefault();
|
|
70
|
+
last?.focus();
|
|
71
|
+
}
|
|
72
|
+
else if (!event.shiftKey && document.activeElement === last) {
|
|
73
|
+
event.preventDefault();
|
|
74
|
+
first.focus();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -37,7 +37,7 @@ export declare function resolveFormText(text?: FormText): string;
|
|
|
37
37
|
* 在组件初始化阶段创建原生约束校验状态;宿主关闭或表单 reset 时清除过期错误。
|
|
38
38
|
* @param getOverride - 读取自定义校验提示的函数。
|
|
39
39
|
* @param getValue - 读取当前控件值以跟踪程序回填的函数。
|
|
40
|
-
* @returns 带响应式 message 和 validate/input/reset 方法的校验状态。
|
|
40
|
+
* @returns 带响应式 message 和 validate/blur/input/reset 方法的校验状态。
|
|
41
41
|
*
|
|
42
42
|
* @example 模块内部上下文
|
|
43
43
|
* ```ts
|
|
@@ -52,6 +52,7 @@ export declare function resolveFormText(text?: FormText): string;
|
|
|
52
52
|
export declare function createControlValidation(getOverride?: () => FormText | undefined, getValue?: () => unknown): {
|
|
53
53
|
readonly message: string;
|
|
54
54
|
validate(control: FormControl): void;
|
|
55
|
+
blur(control: FormControl): void;
|
|
55
56
|
input(control: FormControl): void;
|
|
56
57
|
reset: () => void;
|
|
57
58
|
};
|
|
@@ -49,7 +49,7 @@ function readIssue(control) {
|
|
|
49
49
|
* 在组件初始化阶段创建原生约束校验状态;宿主关闭或表单 reset 时清除过期错误。
|
|
50
50
|
* @param getOverride - 读取自定义校验提示的函数。
|
|
51
51
|
* @param getValue - 读取当前控件值以跟踪程序回填的函数。
|
|
52
|
-
* @returns 带响应式 message 和 validate/input/reset 方法的校验状态。
|
|
52
|
+
* @returns 带响应式 message 和 validate/blur/input/reset 方法的校验状态。
|
|
53
53
|
*
|
|
54
54
|
* @example 模块内部上下文
|
|
55
55
|
* ```ts
|
|
@@ -65,8 +65,10 @@ export function createControlValidation(getOverride = () => undefined, getValue)
|
|
|
65
65
|
const visibility = getFormVisibilityContext();
|
|
66
66
|
let issue = $state();
|
|
67
67
|
let currentControl = $state();
|
|
68
|
+
let edited = false;
|
|
68
69
|
function reset() {
|
|
69
70
|
issue = undefined;
|
|
71
|
+
edited = false;
|
|
70
72
|
currentControl?.setCustomValidity('');
|
|
71
73
|
}
|
|
72
74
|
$effect(() => {
|
|
@@ -101,7 +103,13 @@ export function createControlValidation(getOverride = () => undefined, getValue)
|
|
|
101
103
|
issue = readIssue(control);
|
|
102
104
|
control.setCustomValidity(issue ? resolveFormText(getOverride()) || uiM(issue.key, issue.params) : '');
|
|
103
105
|
},
|
|
106
|
+
blur(control) {
|
|
107
|
+
// 默认焦点离开未输入的空字段时不挤动按钮/链接;提交仍由原生 invalid 校验。
|
|
108
|
+
if (edited || control.value || issue)
|
|
109
|
+
this.validate(control);
|
|
110
|
+
},
|
|
104
111
|
input(control) {
|
|
112
|
+
edited = true;
|
|
105
113
|
currentControl = control;
|
|
106
114
|
control.setCustomValidity('');
|
|
107
115
|
if (issue)
|
package/dist/messages/en-US.json
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"settings_close": "Close",
|
|
21
21
|
"settings_language": "Language",
|
|
22
22
|
"settings_theme": "Theme",
|
|
23
|
+
"theme_high_contrast": "High contrast",
|
|
23
24
|
"combobox_no_match": "No match",
|
|
24
25
|
"combobox_remove": "Remove",
|
|
25
26
|
"data_table_actions": "Actions",
|
|
@@ -325,8 +326,9 @@
|
|
|
325
326
|
"error_500_desc": "Something went wrong on our end. We're working on it, please try again later.",
|
|
326
327
|
"error_503_title": "Under Maintenance",
|
|
327
328
|
"error_503_desc": "The system is currently undergoing maintenance. Please check back soon.",
|
|
328
|
-
"login_method_password": "
|
|
329
|
+
"login_method_password": "Account & password",
|
|
329
330
|
"login_method_ldap": "Organization",
|
|
331
|
+
"login_method_ldap_hint": "Use the account and password provided by your company or organization",
|
|
330
332
|
"login_method_email": "Email code",
|
|
331
333
|
"login_method_sms": "SMS code",
|
|
332
334
|
"login_methods": "Login method",
|
|
@@ -496,5 +498,10 @@
|
|
|
496
498
|
"session_recovery_account_error": "Sign in to the original account. The pending action has not continued.",
|
|
497
499
|
"sensitive_operations_label": "Operation IDs requiring reauthentication",
|
|
498
500
|
"sensitive_operations_hint": "One operation ID per line, matching the server guard. Database and file rules are combined. Clearing removes only this permission’s rules. The master switch must be enabled.",
|
|
499
|
-
"sensitive_operations_invalid": "Use at most 1000 operation IDs, each no longer than 128 characters."
|
|
501
|
+
"sensitive_operations_invalid": "Use at most 1000 operation IDs, each no longer than 128 characters.",
|
|
502
|
+
"filter_bar_expand": "Expand filters",
|
|
503
|
+
"filter_bar_collapse": "Collapse filters",
|
|
504
|
+
"filter_bar_active": "Active filters: {count}",
|
|
505
|
+
"theme_formal": "Formal",
|
|
506
|
+
"keyboard_submit_enter": "Press Enter in a single-line field to submit"
|
|
500
507
|
}
|
package/dist/messages/ja-JP.json
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"settings_close": "閉じる",
|
|
21
21
|
"settings_language": "言語",
|
|
22
22
|
"settings_theme": "テーマ",
|
|
23
|
+
"theme_high_contrast": "ハイコントラスト",
|
|
23
24
|
"combobox_no_match": "一致する項目がありません",
|
|
24
25
|
"combobox_remove": "削除",
|
|
25
26
|
"data_table_actions": "操作",
|
|
@@ -325,8 +326,9 @@
|
|
|
325
326
|
"error_500_desc": "サーバー側で問題が発生しました。しばらくしてから再試行してください。",
|
|
326
327
|
"error_503_title": "メンテナンス中",
|
|
327
328
|
"error_503_desc": "現在システムのメンテナンスを行っています。しばらくしてからアクセスしてください。",
|
|
328
|
-
"login_method_password": "
|
|
329
|
+
"login_method_password": "アカウントとパスワード",
|
|
329
330
|
"login_method_ldap": "組織アカウント",
|
|
331
|
+
"login_method_ldap_hint": "会社や組織から提供されたアカウントとパスワードを使用します",
|
|
330
332
|
"login_method_email": "メール認証コード",
|
|
331
333
|
"login_method_sms": "SMS認証コード",
|
|
332
334
|
"login_methods": "ログイン方法",
|
|
@@ -496,5 +498,10 @@
|
|
|
496
498
|
"session_recovery_account_error": "元のアカウントでログインしてください。操作はまだ続行していません。",
|
|
497
499
|
"sensitive_operations_label": "再認証が必要な操作 ID",
|
|
498
500
|
"sensitive_operations_hint": "サーバーのガードと一致する操作 ID を1行ずつ入力します。DB とファイルの規則は和集合です。空欄はこの権限の規則だけを削除します。主スイッチが有効な場合に適用されます。",
|
|
499
|
-
"sensitive_operations_invalid": "操作 ID は最大1000件、各128文字以内です。"
|
|
501
|
+
"sensitive_operations_invalid": "操作 ID は最大1000件、各128文字以内です。",
|
|
502
|
+
"filter_bar_expand": "絞り込みを展開",
|
|
503
|
+
"filter_bar_collapse": "絞り込みを折りたたむ",
|
|
504
|
+
"filter_bar_active": "適用中の条件:{count}件",
|
|
505
|
+
"theme_formal": "ビジネス(角丸なし)",
|
|
506
|
+
"keyboard_submit_enter": "1行の入力欄で Enter を押して送信"
|
|
500
507
|
}
|
package/dist/messages/zh-CN.json
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"settings_close": "关闭",
|
|
21
21
|
"settings_language": "语言",
|
|
22
22
|
"settings_theme": "主题",
|
|
23
|
+
"theme_high_contrast": "高对比",
|
|
23
24
|
"combobox_no_match": "无匹配结果",
|
|
24
25
|
"combobox_remove": "移除",
|
|
25
26
|
"data_table_actions": "操作",
|
|
@@ -325,8 +326,9 @@
|
|
|
325
326
|
"error_500_desc": "服务器出现了一些问题。我们正在处理,请稍后重试。",
|
|
326
327
|
"error_503_title": "服务维护中",
|
|
327
328
|
"error_503_desc": "系统正在维护升级,请稍后再访问。",
|
|
328
|
-
"login_method_password": "
|
|
329
|
+
"login_method_password": "账号密码",
|
|
329
330
|
"login_method_ldap": "企业账号",
|
|
331
|
+
"login_method_ldap_hint": "使用公司或组织提供的账号和密码",
|
|
330
332
|
"login_method_email": "邮件验证码",
|
|
331
333
|
"login_method_sms": "短信验证码",
|
|
332
334
|
"login_methods": "登录方式",
|
|
@@ -496,5 +498,10 @@
|
|
|
496
498
|
"session_recovery_account_error": "请使用原账号完成登录,当前操作尚未继续。",
|
|
497
499
|
"sensitive_operations_label": "需要重新认证的操作 ID",
|
|
498
500
|
"sensitive_operations_hint": "每行一个操作 ID,与服务端守卫一致。数据库与文件配置取并集;清空只移除本权限的规则。主开关关闭时不要求二次认证。",
|
|
499
|
-
"sensitive_operations_invalid": "最多 1000 项,每个操作 ID 不超过 128 字符。"
|
|
501
|
+
"sensitive_operations_invalid": "最多 1000 项,每个操作 ID 不超过 128 字符。",
|
|
502
|
+
"filter_bar_expand": "展开筛选",
|
|
503
|
+
"filter_bar_collapse": "收起筛选",
|
|
504
|
+
"filter_bar_active": "已启用 {count} 项筛选",
|
|
505
|
+
"theme_formal": "简洁商务",
|
|
506
|
+
"keyboard_submit_enter": "在单行输入框中按 Enter 提交"
|
|
500
507
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/* 直角商务主题:语义色和圆角统一由共享主题控制。 */
|
|
2
|
+
[data-theme='formal'] {
|
|
3
|
+
color-scheme: light;
|
|
4
|
+
color: #132238;
|
|
5
|
+
background-color: #ffffff;
|
|
6
|
+
--color-base-100: #ffffff;
|
|
7
|
+
--color-base-200: #f5f7fa;
|
|
8
|
+
--color-base-300: #e1e6ed;
|
|
9
|
+
--color-base-content: #132238;
|
|
10
|
+
--color-primary: #123d70;
|
|
11
|
+
--color-primary-content: #ffffff;
|
|
12
|
+
--color-secondary: #45556c;
|
|
13
|
+
--color-secondary-content: #ffffff;
|
|
14
|
+
--color-accent: #126342;
|
|
15
|
+
--color-accent-content: #ffffff;
|
|
16
|
+
--color-neutral: #25354a;
|
|
17
|
+
--color-neutral-content: #ffffff;
|
|
18
|
+
--color-info: #155d91;
|
|
19
|
+
--color-info-content: #ffffff;
|
|
20
|
+
--color-success: #126342;
|
|
21
|
+
--color-success-content: #ffffff;
|
|
22
|
+
--color-warning: #6b4b00;
|
|
23
|
+
--color-warning-content: #ffffff;
|
|
24
|
+
--color-error: #b42318;
|
|
25
|
+
--color-error-content: #ffffff;
|
|
26
|
+
--radius-selector: 0;
|
|
27
|
+
--radius-field: 0;
|
|
28
|
+
--radius-box: 0;
|
|
29
|
+
--hai-radius-sm: 0;
|
|
30
|
+
--hai-radius-md: 0;
|
|
31
|
+
--hai-radius-lg: 0;
|
|
32
|
+
--hai-radius-full: 0;
|
|
33
|
+
--size-selector: 0.25rem;
|
|
34
|
+
--size-field: 0.25rem;
|
|
35
|
+
--border: 1px;
|
|
36
|
+
--depth: 0;
|
|
37
|
+
--noise: 0;
|
|
38
|
+
--hai-focus-color: #123d70;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* 覆盖组件中的显式 rounded 类;单选指示和加载图形保留其交互含义。 */
|
|
42
|
+
[data-theme='formal'] :is([class*='rounded-'], .btn, .input, .select, .textarea, .card, .modal-box, .alert),
|
|
43
|
+
[data-theme='formal'] :focus-visible {
|
|
44
|
+
border-radius: 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
[data-theme='formal'] :is([class^='text-base-content/'], [class*=' text-base-content/']),
|
|
48
|
+
[data-theme='formal'] .table th {
|
|
49
|
+
color: #4b5563;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
[data-theme='formal'] :is(input, textarea)::placeholder {
|
|
53
|
+
color: #4b5563;
|
|
54
|
+
opacity: 1;
|
|
55
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/* 共享高对比主题随 theme.css 发布,不依赖 DaisyUI 的内置主题名单。 */
|
|
2
|
+
[data-theme='high-contrast'] {
|
|
3
|
+
color-scheme: dark;
|
|
4
|
+
color: #ffffff;
|
|
5
|
+
background-color: #000000;
|
|
6
|
+
--color-base-100: #000000;
|
|
7
|
+
--color-base-200: #121212;
|
|
8
|
+
--color-base-300: #242424;
|
|
9
|
+
--color-base-content: #ffffff;
|
|
10
|
+
--color-primary: #ffe04d;
|
|
11
|
+
--color-primary-content: #111111;
|
|
12
|
+
--color-secondary: #80d4ff;
|
|
13
|
+
--color-secondary-content: #111111;
|
|
14
|
+
--color-accent: #9df3c4;
|
|
15
|
+
--color-accent-content: #111111;
|
|
16
|
+
--color-neutral: #dce5f0;
|
|
17
|
+
--color-neutral-content: #111111;
|
|
18
|
+
--color-info: #80d4ff;
|
|
19
|
+
--color-info-content: #111111;
|
|
20
|
+
--color-success: #9df3c4;
|
|
21
|
+
--color-success-content: #111111;
|
|
22
|
+
--color-warning: #ffe04d;
|
|
23
|
+
--color-warning-content: #111111;
|
|
24
|
+
--color-error: #ffb4ab;
|
|
25
|
+
--color-error-content: #111111;
|
|
26
|
+
--radius-selector: 0.375rem;
|
|
27
|
+
--radius-field: 0.375rem;
|
|
28
|
+
--radius-box: 0.5rem;
|
|
29
|
+
--size-selector: 0.25rem;
|
|
30
|
+
--size-field: 0.25rem;
|
|
31
|
+
--border: 2px;
|
|
32
|
+
--depth: 0;
|
|
33
|
+
--noise: 0;
|
|
34
|
+
--hai-focus-color: #ffe04d;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* 低透明度的次要正文在此主题中保持可读,伪类和占位符类不误匹配。 */
|
|
38
|
+
[data-theme='high-contrast'] :is([class^='text-base-content/'], [class*=' text-base-content/']),
|
|
39
|
+
[data-theme='high-contrast'] .table th {
|
|
40
|
+
color: #e5e7eb;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
[data-theme='high-contrast'] :is([class^='border-base-content/'], [class*=' border-base-content/']) {
|
|
44
|
+
border-color: #b5c1cf;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
[data-theme='high-contrast'] :is(input, textarea)::placeholder {
|
|
48
|
+
color: #dce5f0;
|
|
49
|
+
opacity: 1;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
[data-theme='high-contrast'] :focus-visible {
|
|
53
|
+
outline: 3px solid #ffe04d;
|
|
54
|
+
outline-offset: 3px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
[data-theme='high-contrast'] a:not(.btn) {
|
|
58
|
+
text-decoration: underline;
|
|
59
|
+
text-underline-offset: 0.15em;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
[data-theme='high-contrast'] ::-webkit-scrollbar-thumb {
|
|
63
|
+
background: #b5c1cf;
|
|
64
|
+
}
|
package/dist/styles/theme.css
CHANGED
package/dist/theme-config.d.ts
CHANGED
|
@@ -59,7 +59,7 @@ export interface ThemeGroup {
|
|
|
59
59
|
themes: ThemeInfo[];
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
|
-
* DaisyUI
|
|
62
|
+
* 精选 DaisyUI 主题及 UI 共享样式提供的高对比、直角商务主题。
|
|
63
63
|
*
|
|
64
64
|
* @example
|
|
65
65
|
* ```ts
|
|
@@ -288,7 +288,7 @@ export declare function createThemeBootstrapScript(options: ThemeBootstrapScript
|
|
|
288
288
|
*/
|
|
289
289
|
export declare function getThemeInitScript(): string;
|
|
290
290
|
/**
|
|
291
|
-
*
|
|
291
|
+
* 应用主题,并同步原生表单控件配色;自定义主题由宿主 CSS 决定配色。
|
|
292
292
|
* @param theme - 主题 ID
|
|
293
293
|
* @param persist - 是否持久化到 localStorage
|
|
294
294
|
* @returns {void} 无返回值;更新当前文档,并按 persist 决定是否保存偏好。
|