refactor(clues): pack, detail and Feishu windows use the shared components

Pack footers, conflict/binding/add errors and empty states; detail failure
and footer actions (ActionButton); Feishu task/doc fields and save rows.
Field and ActionFooter pass data-* through for e2e locators. Drops the
window sheets' now-unreferenced rules.
This commit is contained in:
Menghuan1918 committed 2026-11-24 16:43:27 +08:00
1 parent 2f99b1ffea
commit 3af5dd0a9c
10 files changed
+122 -314

No files matched your search

@@ -29,7 +29,7 @@ import {
import { TextDocumentContent } from '../../../windows/format-content.tsx'
import { MdToc } from '../../../md-toc.tsx'
import { t } from '../../../locales.ts'
import { ActionButton, TextArea, TextInput } from '../../../ui/index.ts'
import { ActionButton, ActionFooter, Field, TextArea, TextInput } from '../../../ui/index.ts'
import css from './feishu.module.css'
import type { FeishuClientLabels } from './labels.ts'
import { appDateTime } from './time.ts'
@@ -388,8 +388,7 @@ function EditBlock(props: {
const { block, labels, onChange, disabled, describedBy } = props
const label = `${labels.blocks}: ${block.tag}`
return (
<div className={css.field} data-feishu-docs-block={block.id} data-feishu-docs-block-tag={block.tag}>
<span className={css.fieldLabel}>{block.tag}</span>
<Field label={block.tag} data-feishu-docs-block={block.id} data-feishu-docs-block-tag={block.tag}>
<TextArea
className={css.textarea}
value={block.text}
@@ -401,7 +400,7 @@ function EditBlock(props: {
data-feishu-docs-block-input={block.id}
onChange={(event) => { onChange(event.target.value) }}
/>
</div>
</Field>
)
}
@@ -454,41 +453,30 @@ function EditPreview(props: {
</div>
)}
<div className={css.field}>
<label className={css.fieldLabel} htmlFor={`${prefix}-title`}>{labels.title}</label>
<Field label={labels.title} {...(data.titleEditable ? { htmlFor: `${prefix}-title` } : {})}
error={titleInvalid
? <span id={`${prefix}-title-error`} data-feishu-docs-error="title">{labels.docsTitleRequired}</span>
: undefined}>
{data.titleEditable ? (
<>
<TextInput
id={`${prefix}-title`}
className={css.input}
type="text"
value={data.title}
disabled={saving}
data-feishu-docs-title=""
aria-invalid={titleInvalid}
aria-describedby={titleInvalid ? `${prefix}-title-error` : undefined}
onChange={(event) => { emit({ ...data, title: event.target.value }) }}
/>
{titleInvalid && (
<p
className={css.error}
id={`${prefix}-title-error`}
data-feishu-docs-error="title"
role="alert"
>
{labels.docsTitleRequired}
</p>
)}
</>
<TextInput
id={`${prefix}-title`}
className={css.input}
type="text"
value={data.title}
disabled={saving}
data-feishu-docs-title=""
aria-invalid={titleInvalid}
aria-describedby={titleInvalid ? `${prefix}-title-error` : undefined}
onChange={(event) => { emit({ ...data, title: event.target.value }) }}
/>
) : (
<div className={css.hint} data-feishu-docs-title-read-only="">
{data.title} — {labels.blockReadOnly}
</div>
)}
</div>
</Field>
<div className={css.field}>
<span className={css.fieldLabel}>{labels.blocks}</span>
<Field label={labels.blocks}>
{data.blocks.length === 0 && data.readOnlyBlocks.length === 0 && (
<p className={css.hint} data-feishu-docs-no-blocks="">{labels.noBlocks}</p>
)}
@@ -507,7 +495,7 @@ function EditPreview(props: {
labels={labels}
/>
)))}
</div>
</Field>
{embedded !== true && (
<>
@@ -516,7 +504,7 @@ function EditPreview(props: {
</>
)}
{onSave !== undefined && embedded !== true && (
<div className={css.actions}>
<ActionFooter end={
<ActionButton
variant="primary"
busy={saving}
@@ -526,7 +514,7 @@ function EditPreview(props: {
>
{saving ? labels.saving : labels.save}
</ActionButton>
</div>
} />
)}
</section>
)
@@ -47,13 +47,6 @@
overflow-wrap: anywhere;
}
.error {
margin: 0;
color: var(--dsw-alias-state-error-primary);
font-size: 12px;
overflow-wrap: anywhere;
}
.pre {
max-height: 60vh;
margin: 0;
@@ -94,18 +87,6 @@
overflow-wrap: anywhere;
}
.field {
display: flex;
flex-direction: column;
gap: 4px;
min-width: 0;
}
.fieldLabel {
color: var(--dsw-alias-label-secondary);
font-size: 12px;
}
.input,
.textarea {
width: 100%;
@@ -137,26 +118,9 @@
align-self: flex-start;
text-decoration: none;
}
.actions {
display: flex;
gap: 8px;
justify-content: flex-end;
}
.saveButton {
composes: buttonPrimary from "../../../ui/kit.module.css";
}
.saveButton:disabled {
cursor: default;
opacity: 0.4;
}
.saveButton:hover:not(:disabled) { background: var(--dsw-alias-button-primary-hover); }
.linkButton:hover { text-decoration: underline; }
.textarea { max-height: 360px; overflow: auto; }
@media (pointer: coarse) { .saveButton, .linkButton, .input { min-height: 44px; } }
@media (pointer: coarse) { .linkButton, .input { min-height: 44px; } }
/* ── Readable document projection (S9 refresh) ─────────────────────────── */
+17 -31
View File
@@ -33,7 +33,7 @@ import css from './feishu.module.css'
import type { FeishuClientLabels } from './labels.ts'
import { appDate, appDateTime } from './time.ts'
import { t } from '../../../locales.ts'
import { ActionButton, Checkbox, TextArea, TextInput } from '../../../ui/index.ts'
import { ActionButton, ActionFooter, Checkbox, Field, TextArea, TextInput } from '../../../ui/index.ts'
/** Props of {@link FeishuTaskEditor}. */
export interface FeishuTaskEditorProps extends ClueFormatRendererProps {
@@ -189,8 +189,7 @@ function TimeField(props: {
}, [time])
if (time === null) {
return (
<div className={css.field} data-feishu-task-field={field}>
<span className={css.fieldLabel}>{label}</span>
<Field label={label} data-feishu-task-field={field}>
<button
type="button"
className={css.linkButton}
@@ -201,14 +200,16 @@ function TimeField(props: {
>
{labels.setTime}
</button>
</div>
</Field>
)
}
const shownError = error ?? clearError
const errorId = `${id}-error`
return (
<div className={css.field} data-feishu-task-field={field}>
<label className={css.fieldLabel} htmlFor={id}>{label}</label>
<Field label={label} htmlFor={id} data-feishu-task-field={field}
error={shownError === undefined ? undefined : (
<span id={errorId} data-feishu-task-error={field} data-feishu-task-time-error={field}>{shownError}</span>
)}>
<div className={css.timeRow}>
<TextInput
ref={inputRef}
@@ -245,18 +246,7 @@ function TimeField(props: {
{labels.allDay}
</label>
</div>
{shownError !== undefined && (
<p
className={css.error}
id={errorId}
data-feishu-task-error={field}
data-feishu-task-time-error={field}
role="alert"
>
{shownError}
</p>
)}
</div>
</Field>
)
}
@@ -331,8 +321,10 @@ export function FeishuTaskEditor(props: FeishuTaskEditorProps): ReactNode {
</div>
)}
<div className={css.field}>
<label className={css.fieldLabel} htmlFor={idOf('title')}>{labels.title}</label>
<Field label={labels.title} htmlFor={idOf('title')}
error={errorOf('title') === undefined ? undefined : (
<span id={errorIdOf('title')} data-feishu-task-error="title">{errorOf('title')}</span>
)}>
<TextInput
id={idOf('title')}
className={css.input}
@@ -344,15 +336,9 @@ export function FeishuTaskEditor(props: FeishuTaskEditorProps): ReactNode {
aria-describedby={errorOf('title') === undefined ? undefined : errorIdOf('title')}
onChange={(event) => { emit({ title: event.target.value }) }}
/>
{errorOf('title') !== undefined && (
<p className={css.error} id={errorIdOf('title')} data-feishu-task-error="title" role="alert">
{errorOf('title')}
</p>
)}
</div>
</Field>
<div className={css.field}>
<label className={css.fieldLabel} htmlFor={idOf('description')}>{labels.description}</label>
<Field label={labels.description} htmlFor={idOf('description')}>
<TextArea
id={idOf('description')}
className={css.textarea}
@@ -362,7 +348,7 @@ export function FeishuTaskEditor(props: FeishuTaskEditorProps): ReactNode {
rows={4}
onChange={(event) => { emit({ description: event.target.value }) }}
/>
</div>
</Field>
<TimeField
id={idOf('start')}
@@ -397,7 +383,7 @@ export function FeishuTaskEditor(props: FeishuTaskEditorProps): ReactNode {
</label>
{props.onSave !== undefined && props.embedded !== true && (
<div className={css.actions}>
<ActionFooter end={
<ActionButton
variant="primary"
busy={props.saving}
@@ -407,7 +393,7 @@ export function FeishuTaskEditor(props: FeishuTaskEditorProps): ReactNode {
>
{props.saving ? labels.saving : labels.save}
</ActionButton>
</div>
} />
)}
</form>
)
@@ -25,21 +25,6 @@
overflow-wrap: anywhere;
}
.failureTitle {
font-weight: 600;
color: var(--dsw-alias-label-primary);
}
.failureBody {
color: var(--dsw-alias-label-secondary);
}
.failureActions {
display: flex;
flex-wrap: wrap;
gap: var(--ds-sidebar-space-2);
}
.action {
composes: button from "../../ui/kit.module.css";
text-decoration: none;
@@ -76,14 +61,6 @@
min-width: 0;
}
.bindingHeading {
margin: 0;
font-size: 11px;
line-height: 16px;
font-weight: 600;
color: var(--dsw-alias-label-primary);
}
.bindingHint {
margin: 0;
color: var(--dsw-alias-label-tertiary);
@@ -147,14 +124,6 @@
.bindingDetails[open] > .binding {
margin-top: 6px;
}
.primary {
composes: buttonPrimary from "../../ui/kit.module.css";
background: var(--dsw-alias-button-primary-fill);
color: var(--dsw-alias-label-primary-foreground);
}
.primary:hover:not(:disabled) {
background: var(--dsw-alias-button-primary-hover);
}
@media (pointer: coarse) {
.bindingDetails > summary { min-height: 44px; }
}
@@ -172,21 +141,6 @@
background: var(--dsw-alias-bg-layer-1);
}
.header {
display: flex;
flex-direction: column;
flex: none;
min-width: 0;
}
.subtitle {
padding: 4px var(--ds-sidebar-gutter) 0;
color: var(--dsw-alias-label-tertiary);
font-size: 11px;
line-height: 16px;
overflow-wrap: anywhere;
}
/* Resource actions sit at the end of the header's metadata block: Refresh is
always visible, and its tooltip carries the cache age. */
.headerActions {
@@ -213,6 +167,5 @@
@media (max-width: 480px) {
.bindingDetails { flex-basis: 100%; }
.footerActions { width: 100%; }
.footerActions > .primary { flex: 1 1 auto; justify-content: center; }
}
@media (pointer: coarse) { .footerActions > .action { min-height: 44px; } }
+24 -37
View File
@@ -36,7 +36,8 @@
import { createElement, useCallback, useEffect, useRef, useState, useSyncExternalStore } from 'react'
import type { ReactNode } from 'react'
import { IconRefreshOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives'
import { IconButton } from '../../ui/kit.tsx'
import { ActionButton, IconButton } from '../../ui/kit.tsx'
import { ErrorBlock } from '../../ui/patterns.tsx'
import type { WindowDocumentContent, WindowHandle } from '../../windows/types.ts'
import type { BetterSidebarWindowsClientFace } from '../../windows/types.ts'
import type {
@@ -273,28 +274,20 @@ function DetailFailure(props: {
}): ReactNode {
return createElement(
'div',
{ className: css.failure, role: 'alert' },
createElement('div', { className: css.failureTitle }, t('clueDetailFailed')),
createElement('div', { className: css.failureBody }, props.message),
createElement(
'div',
{ className: css.failureActions },
props.onRetry === undefined
? null
: createElement('button', {
type: 'button',
className: css.action,
onClick: props.onRetry,
}, t('retry')),
props.url === undefined
? null
: createElement('a', {
className: css.action,
href: props.url,
target: '_blank',
rel: 'noreferrer',
}, t('clueDetailOpenSource')),
),
{ className: css.failure },
createElement(ErrorBlock, {
message: t('clueDetailFailed'),
detail: props.message,
...(props.onRetry === undefined ? {} : { retryLabel: t('retry'), onRetry: props.onRetry }),
}),
props.url === undefined
? null
: createElement('a', {
className: css.action,
href: props.url,
target: '_blank',
rel: 'noreferrer',
}, t('clueDetailOpenSource')),
)
}
@@ -1016,10 +1009,8 @@ function createDetailController(options: ClueDetailWindowOptions): DetailControl
!guard.dirty
? null
: createElement(
'button',
ActionButton,
{
type: 'button',
className: css.action,
disabled: currentEdit?.saving === true,
onClick: () => {
// Explicit discard: the ONLY path that drops the draft.
@@ -1032,8 +1023,8 @@ function createDetailController(options: ClueDetailWindowOptions): DetailControl
),
currentEdit !== null && (state.conflict || state.authBlocked)
? createElement(
'button',
{ type: 'button', className: css.action, 'data-clue-detail-reread': '', onClick: () => { void reloadEdit() } },
ActionButton,
{ 'data-clue-detail-reread': '', onClick: () => { void reloadEdit() } },
t('clueDetailReload'),
)
: null,
@@ -1044,10 +1035,9 @@ function createDetailController(options: ClueDetailWindowOptions): DetailControl
|| state.authBlocked
? null
: createElement(
'button',
ActionButton,
{
type: 'button',
className: `${css.action} ${css.primary}`,
variant: 'primary',
'data-clue-detail-save': '',
disabled: currentEdit.saving || !formatEditable,
onClick: () => { void save() },
@@ -1059,10 +1049,8 @@ function createDetailController(options: ClueDetailWindowOptions): DetailControl
options.onAddToPack === undefined
? null
: createElement(
'button',
ActionButton,
{
type: 'button',
className: css.action,
'data-clue-detail-add-to-pack': '',
disabled: referenceBusy || (target.clueId === undefined && state.read === null),
onClick: () => {
@@ -1083,10 +1071,9 @@ function createDetailController(options: ClueDetailWindowOptions): DetailControl
options.onInsertClue === undefined
? null
: createElement(
'button',
ActionButton,
{
type: 'button',
className: currentEdit?.dirty === true && formatEditable ? css.action : `${css.action} ${css.primary}`,
variant: currentEdit?.dirty === true && formatEditable ? 'outline' : 'primary',
'data-clue-detail-insert': '',
disabled: referenceBusy || (target.clueId === undefined && state.read === null),
onClick: () => { void insertReference() },
-44
View File
@@ -60,28 +60,6 @@
outline: 2px solid var(--dsw-alias-brand-primary);
outline-offset: 1px;
}
.status {
color: var(--dsw-alias-label-tertiary);
font-size: 12px;
line-height: 18px;
margin: 0;
overflow-wrap: anywhere;
}
.error,
.conflict {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: var(--ds-sidebar-space-2);
padding: 6px 8px;
border: 1px solid var(--dsw-alias-state-error-primary);
border-radius: var(--ds-sidebar-radius);
color: var(--dsw-alias-label-secondary);
overflow-wrap: anywhere;
}
.conflict {
border-color: var(--dsw-alias-state-warn-primary);
}
.sectionHead {
display: flex;
flex-wrap: wrap;
@@ -191,17 +169,6 @@
background: var(--dsw-alias-bg-base);
color: var(--dsw-alias-label-primary);
}
.foot {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: var(--ds-sidebar-space-2);
justify-content: flex-end;
flex: none;
margin: 0 calc(-1 * var(--ds-sidebar-gutter)) calc(-1 * var(--ds-sidebar-gutter));
padding: var(--ds-sidebar-space-3) var(--ds-sidebar-gutter);
border-top: 1px solid var(--dsw-alias-border-l1);
}
.scopeBar {
display: flex;
flex-wrap: wrap;
@@ -238,15 +205,6 @@
font-size: 11px;
line-height: 16px;
}
.stateLine {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: var(--ds-sidebar-space-2);
padding: var(--ds-sidebar-space-2) 0;
color: var(--dsw-alias-label-tertiary);
overflow-wrap: anywhere;
}
.queryRow {
display: flex;
align-items: center;
@@ -312,6 +270,4 @@
.binding > :not(summary) { margin-top: 8px; }
.binding > summary:focus-visible { outline: 2px solid var(--dsw-alias-state-business-primary); outline-offset: 2px; }
.foot > .status { margin-inline-end: auto; }
.menuAnchor { position: absolute; }
+44 -71
View File
@@ -74,7 +74,9 @@ import { ResourceFilters } from '../resource-filters.tsx'
import { SourceReadiness } from '../sources/readiness.tsx'
import { SelectMenu } from '../../ui/SelectMenu.tsx'
import { LoadingIndicator } from '../../ui/LoadingIndicator.tsx'
import { ActionButton, Checkbox, IconButton, Menu, Notice, TextInput } from '../../ui/index.ts'
import {
ActionButton, ActionFooter, Checkbox, EmptyState, ErrorBlock, IconButton, Menu, Notice, TextInput,
} from '../../ui/index.ts'
import { useScrollLoad } from '../../ui/use-scroll-load.ts'
import { t } from '../../locales.ts'
import type { ClueDetailTarget } from './detail.tsx'
@@ -977,20 +979,17 @@ export function PackManagementPage(
{error !== null && <Notice kind="error">{error}</Notice>}
{saveError !== null && <Notice kind="error">{saveError}</Notice>}
{conflict && (
<div className={css.conflict} role="alert">
<span>{t('cluePackConflict')}</span>
<button type="button" className={css.action} onClick={() => {
// A CAS conflict means the pack library (and its members'
// titles/bindings) changed elsewhere; refresh those families,
// not the whole activation cache.
invalidateClueRequests(workspaceId, [
'clues.clues',
'clues.packs.list',
'clues.bindings.list',
])
void load()
}}>{t('retry')}</button>
</div>
<ErrorBlock message={t('cluePackConflict')} retryLabel={t('retry')} onRetry={() => {
// A CAS conflict means the pack library (and its members'
// titles/bindings) changed elsewhere; refresh those families,
// not the whole activation cache.
invalidateClueRequests(workspaceId, [
'clues.clues',
'clues.packs.list',
'clues.bindings.list',
])
void load()
}} />
)}
<div className={css.sectionHead}>
@@ -1019,11 +1018,11 @@ export function PackManagementPage(
activeId={addSourceId ?? ''}
onChange={pickSource}
/>
{enabledSources.length === 0 && <div className={css.status}>{t('clueBrowserAllDisabled')}</div>}
{enabledSources.length === 0 && <EmptyState title={t('clueBrowserAllDisabled')} />}
{addSourceId === null ? (
<div className={css.status}>{t('cluePackPickSource')}</div>
<EmptyState title={t('cluePackPickSource')} />
) : (
<>
<div className={css.scopeBar}>
@@ -1112,13 +1111,8 @@ export function PackManagementPage(
windows={props.windows} visible={addOpen} onReady={() => { if (addSourceId !== null) void loadAdd(addSourceId, addView) }} />}
{addNeedsScope !== null && (
<div className={css.stateLine} data-add-state="needs-scope">
<span>
{addNeedsScope === 'search'
? t('clueBrowserSearchScopeNeeded')
: t('clueBrowserScopeNeeded')}
</span>
</div>
<EmptyState data-add-state="needs-scope"
title={addNeedsScope === 'search' ? t('clueBrowserSearchScopeNeeded') : t('clueBrowserScopeNeeded')} />
)}
{addView.kind === 'search'
&& addSourceId === BUILTIN_SOURCE_IDS.feishuDocs
@@ -1128,11 +1122,9 @@ export function PackManagementPage(
</div>
)}
{addLoading && <LoadingIndicator />}
{addError !== null && <div className={css.error} role="alert">{addError}</div>}
{addError !== null && <ErrorBlock message={addError} />}
{!addLoading && addError === null && addNeedsScope === null && addCandidates.length === 0 && (
<div className={css.status}>
{addView.kind === 'search' ? t('clueBrowserNoResults') : t('clueBrowserEmpty')}
</div>
<EmptyState title={addView.kind === 'search' ? t('clueBrowserNoResults') : t('clueBrowserEmpty')} />
)}
<div className={css.addScroll} data-clue-add-scroll>
<ul className={css.addList}>
@@ -1166,21 +1158,16 @@ export function PackManagementPage(
</ul>
{addMoreLoading && <LoadingIndicator inline />}
{addMoreError !== null && (
<div className={css.error} data-clue-add-more-error role="alert">
<span>{addMoreError}</span>
<button type="button" className={css.action} onClick={() => {
// Retry only the paged resource reads; shelves, pins and
// runtime observations are unrelated to this failure.
invalidateClueRequests(workspaceId, [
'clues.list',
'clues.search',
'clues.resolve',
])
loadMoreAdd()
}}>
{t('retry')}
</button>
</div>
<ErrorBlock data-clue-add-more-error message={addMoreError} retryLabel={t('retry')} onRetry={() => {
// Retry only the paged resource reads; shelves, pins and
// runtime observations are unrelated to this failure.
invalidateClueRequests(workspaceId, [
'clues.list',
'clues.search',
'clues.resolve',
])
loadMoreAdd()
}} />
)}
<div ref={addSentinelRef} data-clue-add-sentinel aria-hidden="true" />
</div>
@@ -1191,7 +1178,7 @@ export function PackManagementPage(
) : (
<div className={css.body}>
{members.length === 0
? <div className={css.status}>{t('cluePackNoMembers')}</div>
? <EmptyState title={t('cluePackNoMembers')} />
: (
<ul className={css.memberList}>
{members.map(row => (
@@ -1239,16 +1226,8 @@ export function PackManagementPage(
<summary className={css.sectionTitle}>{t('cluePackBindingHeading')}</summary>
{bindingsError
? (
<div className={css.error} role="alert">
<span>{t('clueStateRequestFailed')}</span>
<button
type="button"
className={css.action}
onClick={() => { setBindingsAttempt(value => value + 1) }}
>
{t('retry')}
</button>
</div>
<ErrorBlock message={t('clueStateRequestFailed')} retryLabel={t('retry')}
onRetry={() => { setBindingsAttempt(value => value + 1) }} />
)
: bound
? (
@@ -1292,32 +1271,26 @@ export function PackManagementPage(
</div>
{addOpen && addSelected.size > 0 && (
<div className={css.foot} data-clue-pack-add-footer>
<span className={css.status} role="status">
{t('clueBrowserSelected', { n: addSelected.size })}
</span>
<ActionButton variant="primary" busy={saving} onClick={() => { void addMembers() }}>
<ActionFooter bleed data-clue-pack-add-footer
start={t('clueBrowserSelected', { n: addSelected.size })}
end={<ActionButton variant="primary" busy={saving} onClick={() => { void addMembers() }}>
{t('cluePackAddSelected')}
</ActionButton>
</div>
</ActionButton>} />
)}
{!addOpen && (
<div className={css.foot} data-clue-pack-footer>
<span className={css.status} role="status" data-clue-pack-save-status>
{pendingName ? t('unsaved') : nameSaved ? t('saved') : null}
</span>
{pendingName ? (
<ActionFooter bleed data-clue-pack-footer
start={<span data-clue-pack-save-status>{pendingName ? t('unsaved') : nameSaved ? t('saved') : null}</span>}
end={pendingName ? (
<>
<button type="button" className={css.action} disabled={saving} onClick={discardDraft}>{t('cancel')}</button>
<ActionButton disabled={saving} onClick={discardDraft}>{t('cancel')}</ActionButton>
<ActionButton variant="primary" busy={saving} disabled={name.trim() === ''}
onClick={() => { void saveName() }}>{t('save')}</ActionButton>
</>
) : (
<button type="button" className={css.primary} disabled={saving || loading || error !== null}
onClick={() => { props.onInsertPack(pack) }}>{t('cluePackInsert')}</button>
)}
</div>
<ActionButton variant="primary" disabled={saving || loading || error !== null}
onClick={() => { props.onInsertPack(pack) }}>{t('cluePackInsert')}</ActionButton>
)} />
)}
<Menu
+2 -1
View File
@@ -448,10 +448,11 @@
font: var(--dsw-font-xxxs-11);
}
/* The window recipe: edge-to-edge hairline, gutter-wide inset, 12px band. */
.actionFooterBleed {
flex: none;
margin: auto calc(-1 * var(--ds-sidebar-gutter)) calc(-1 * var(--ds-sidebar-gutter));
padding-inline: var(--ds-sidebar-gutter);
padding: var(--ds-sidebar-space-3) var(--ds-sidebar-gutter);
}
.actionFooterStart {
+6 -6
View File
@@ -266,7 +266,7 @@ export function ErrorBlock({ message, detail, retryLabel, onRetry, busy, classNa
}
/** Props of {@link Field}. */
export interface FieldProps {
export interface FieldProps extends DataAttributes {
readonly label: ReactNode
readonly description?: ReactNode
readonly error?: ReactNode
@@ -284,9 +284,9 @@ export interface FieldProps {
* three typographic rungs. The label is a real `<label>` when `htmlFor` is
* given, so clicking it focuses the control.
*/
export function Field({ label, description, error, htmlFor, layout = 'stacked', children, className }: FieldProps): ReactNode {
export function Field({ label, description, error, htmlFor, layout = 'stacked', children, className, ...dataProps }: FieldProps): ReactNode {
return (
<div className={clsx(css.field, layout === 'inline' && css.fieldInline, className)}>
<div {...dataProps} className={clsx(css.field, layout === 'inline' && css.fieldInline, className)}>
{htmlFor === undefined
? <span className={css.fieldLabel}>{label}</span>
: <label className={css.fieldLabel} htmlFor={htmlFor}>{label}</label>}
@@ -396,7 +396,7 @@ export function StatusLine({ text, tone, icon, meta, action, role, plain, classN
}
/** Props of {@link ActionFooter}. */
export interface ActionFooterProps {
export interface ActionFooterProps extends DataAttributes {
/** Leading content: a count, a hint, the progress copy. */
readonly start?: ReactNode
/** Trailing actions, in reading order. */
@@ -412,9 +412,9 @@ export interface ActionFooterProps {
* Its separator is the page's ONE horizontal hairline at that edge, so callers
* pass actions and never re-declare the border.
*/
export function ActionFooter({ start, end, bleed, className }: ActionFooterProps): ReactNode {
export function ActionFooter({ start, end, bleed, className, ...dataProps }: ActionFooterProps): ReactNode {
return (
<div className={clsx(css.actionFooter, bleed === true && css.actionFooterBleed, className)}>
<div {...dataProps} className={clsx(css.actionFooter, bleed === true && css.actionFooterBleed, className)}>
{start !== undefined && <span className={css.actionFooterStart} role="status">{start}</span>}
{end !== undefined && <span className={css.actionFooterEnd}>{end}</span>}
</div>
+5 -5
View File
@@ -1477,8 +1477,8 @@ describe('clue detail window', () => {
expect(insert).toBeDefined()
// The two reference actions are the rightmost pair, in this order.
expect(add!.compareDocumentPosition(insert!) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy()
expect(add!.className).not.toContain('primary')
expect(insert!.className).toContain('primary')
expect(add!.className).not.toMatch(/primary/i)
expect(insert!.className).toMatch(/primary/i)
act(() => { add!.dispatchEvent(new MouseEvent('click', { bubbles: true })) })
expect(added).toEqual([expect.objectContaining({ clueId: 'c-pack-order' })])
expect(calls.saveEdit).toBe(0)
@@ -1490,9 +1490,9 @@ describe('clue detail window', () => {
footer.rerender(createElement(Fragment, null, windows.last()?.footer))
const save = find('Save')
expect(save).toBeDefined()
expect(save!.className).toContain('primary')
expect(find('Add to pack')!.className).not.toContain('primary')
expect(find('Insert resources')!.className).not.toContain('primary')
expect(save!.className).toMatch(/primary/i)
expect(find('Add to pack')!.className).not.toMatch(/primary/i)
expect(find('Insert resources')!.className).not.toMatch(/primary/i)
expect(calls.saveEdit).toBe(0)
footer.unmount()
})