wip
fix: docs
This commit is contained in:
@@ -13,7 +13,9 @@ import type { GoalSnapshot } from '@deepseek-ai/dsh-goal/client'
|
||||
import {
|
||||
IconCheckOutline16, IconCloseOutline16, IconEditOutline16, IconPauseOutline16, IconPlayOutline16, IconSparkle16, IconTrashOutline16,
|
||||
} from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import type { GoalActionResult, GoalBarActions } from './slots.ts'
|
||||
import type { GoalKey } from './locales.ts'
|
||||
import css from './GoalBar.module.css'
|
||||
|
||||
export interface GoalBarProps extends GoalBarActions {
|
||||
@@ -21,14 +23,14 @@ export interface GoalBarProps extends GoalBarActions {
|
||||
goal: GoalSnapshot | null | undefined
|
||||
}
|
||||
|
||||
/** Strip labels per visible phase; complete goals render nothing. */
|
||||
/** Strip label keys per visible phase; complete goals render nothing. */
|
||||
const PHASE_LABELS = {
|
||||
active: 'Ongoing Goal',
|
||||
paused: 'Paused Goal',
|
||||
blocked: 'Blocked Goal',
|
||||
} as const
|
||||
active: 'phase.active',
|
||||
paused: 'phase.paused',
|
||||
blocked: 'phase.blocked',
|
||||
} as const satisfies Record<string, GoalKey>
|
||||
|
||||
export function GoalBar({ goal, onEdit, onPause, onResume, onClear }: GoalBarProps) {
|
||||
export function GoalBar({ goal, onEdit, onPause, onResume, onClear, t }: GoalBarProps & PropsLocale<'goal'>) {
|
||||
const [editing, setEditing] = useState(false)
|
||||
const [draft, setDraft] = useState('')
|
||||
const [pending, setPending] = useState(false)
|
||||
@@ -74,7 +76,7 @@ export function GoalBar({ goal, onEdit, onPause, onResume, onClear }: GoalBarPro
|
||||
<input
|
||||
className={css.objectiveInput}
|
||||
type="text"
|
||||
aria-label="Goal objective"
|
||||
aria-label={t('objective.aria')}
|
||||
value={draft}
|
||||
onChange={(e) => { setDraft(e.target.value) }}
|
||||
onKeyDown={(e) => {
|
||||
@@ -90,8 +92,8 @@ export function GoalBar({ goal, onEdit, onPause, onResume, onClear }: GoalBarPro
|
||||
className={css.iconBtn}
|
||||
onClick={() => { void handleEdit() }}
|
||||
disabled={pending || draft.trim() === ''}
|
||||
title="Save goal"
|
||||
aria-label="Save goal"
|
||||
title={t('action.save')}
|
||||
aria-label={t('action.save')}
|
||||
>
|
||||
<IconCheckOutline16 />
|
||||
</button>
|
||||
@@ -100,8 +102,8 @@ export function GoalBar({ goal, onEdit, onPause, onResume, onClear }: GoalBarPro
|
||||
className={css.iconBtn}
|
||||
onClick={() => { setEditing(false) }}
|
||||
disabled={pending}
|
||||
title="Cancel edit"
|
||||
aria-label="Cancel edit"
|
||||
title={t('action.cancel')}
|
||||
aria-label={t('action.cancel')}
|
||||
>
|
||||
<IconCloseOutline16 />
|
||||
</button>
|
||||
@@ -116,17 +118,17 @@ export function GoalBar({ goal, onEdit, onPause, onResume, onClear }: GoalBarPro
|
||||
<div className={css.dock} data-goal-bar>
|
||||
<div className={css.bar} title={title}>
|
||||
<span className={css.sparkle}><IconSparkle16 /></span>
|
||||
<span className={css.label}>{PHASE_LABELS[goal.phase]}</span>
|
||||
<span className={css.label}>{t(PHASE_LABELS[goal.phase])}</span>
|
||||
<span className={css.objective}>{goal.objective}</span>
|
||||
{actionError !== null && <span className={css.error} role="alert">{actionError}</span>}
|
||||
<div className={css.actions}>
|
||||
{goal.phase === 'active' && (
|
||||
<button type="button" className={css.iconBtn} disabled={pending} onClick={() => { void runAction(onPause) }} title="Pause goal" aria-label="Pause goal">
|
||||
<button type="button" className={css.iconBtn} disabled={pending} onClick={() => { void runAction(onPause) }} title={t('action.pause')} aria-label={t('action.pause')}>
|
||||
<IconPauseOutline16 />
|
||||
</button>
|
||||
)}
|
||||
{goal.phase === 'paused' && (
|
||||
<button type="button" className={css.iconBtn} disabled={pending} onClick={() => { void runAction(onResume) }} title="Resume goal" aria-label="Resume goal">
|
||||
<button type="button" className={css.iconBtn} disabled={pending} onClick={() => { void runAction(onResume) }} title={t('action.resume')} aria-label={t('action.resume')}>
|
||||
<IconPlayOutline16 />
|
||||
</button>
|
||||
)}
|
||||
@@ -135,12 +137,12 @@ export function GoalBar({ goal, onEdit, onPause, onResume, onClear }: GoalBarPro
|
||||
className={css.iconBtn}
|
||||
disabled={pending}
|
||||
onClick={() => { setDraft(goal.objective); setEditing(true) }}
|
||||
title="Edit goal"
|
||||
aria-label="Edit goal"
|
||||
title={t('action.edit')}
|
||||
aria-label={t('action.edit')}
|
||||
>
|
||||
<IconEditOutline16 />
|
||||
</button>
|
||||
<button type="button" className={css.iconBtn} disabled={pending} onClick={() => { void runAction(onClear) }} title="Clear goal" aria-label="Clear goal">
|
||||
<button type="button" className={css.iconBtn} disabled={pending} onClick={() => { void runAction(onClear) }} title={t('action.clear')} aria-label={t('action.clear')}>
|
||||
<IconTrashOutline16 />
|
||||
</button>
|
||||
</div>
|
||||
@@ -149,11 +151,11 @@ export function GoalBar({ goal, onEdit, onPause, onResume, onClear }: GoalBarPro
|
||||
)
|
||||
}
|
||||
|
||||
/** Full props of the dock entry: InputZone owner share + session standard kit + injected verbs. */
|
||||
export type GoalDockProps = import('@deepseek-ai/dsh-client-ui-slots').PropsRuntime<'conversation.input.dock'> & GoalBarActions
|
||||
/** Full props of the dock entry: InputZone owner share + session standard kit + injected verbs + the locale seat. */
|
||||
export type GoalDockProps = import('@deepseek-ai/dsh-client-ui-slots').PropsRuntime<'conversation.input.dock'> & GoalBarActions & PropsLocale<'goal'>
|
||||
|
||||
/** Dock adapter: reads the host-computed 'goal' projection (whole value; absent or null renders nothing). */
|
||||
export function GoalDock({ useProjection, onEdit, onPause, onResume, onClear }: GoalDockProps) {
|
||||
export function GoalDock({ useProjection, onEdit, onPause, onResume, onClear, t }: GoalDockProps) {
|
||||
const projection = useProjection('goal')
|
||||
return (
|
||||
<GoalBar
|
||||
@@ -162,6 +164,7 @@ export function GoalDock({ useProjection, onEdit, onPause, onResume, onClear }:
|
||||
onPause={onPause}
|
||||
onResume={onResume}
|
||||
onClear={onClear}
|
||||
t={t}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -13,16 +13,30 @@ import type { RpcResult } from '@deepseek-ai/dsh-client-connection/client'
|
||||
import type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client'
|
||||
// Type-only: pulls the ui-conversation SlotMap merge (the input.dock entry).
|
||||
import type {} from '@deepseek-ai/dsh-client-ui-conversation/client'
|
||||
// Type-only: pulls the locale plugin's Context merge (ctx.locale).
|
||||
import type {} from '@deepseek-ai/dsh-client-locale/client'
|
||||
// Type-only: the `goal` SessionProjectionMap key merge (single source, the domain's pure outlet).
|
||||
import type { GoalProjection } from '@deepseek-ai/dsh-goal/client'
|
||||
import type { GoalActionResult, GoalBarActions } from './slots.ts'
|
||||
import { GoalDock } from './GoalBar.tsx'
|
||||
import { en, zh, type GoalKey } from './locales.ts'
|
||||
|
||||
export { GoalBar, GoalDock } from './GoalBar.tsx'
|
||||
export type { GoalActionResult, GoalBarActions } from './slots.ts'
|
||||
export type { GoalKey } from './locales.ts'
|
||||
|
||||
/** Required services: slots for the dock entry, sessions for the projected ref, connection for the wire verbs. */
|
||||
export const inject = ['slots', 'sessions', 'connection']
|
||||
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
||||
interface LocaleNamespaceMap {
|
||||
/** The goal strip's copy. */
|
||||
goal: GoalKey
|
||||
}
|
||||
}
|
||||
|
||||
/** Dictionary namespace owned by this plugin. */
|
||||
const NS = 'goal'
|
||||
|
||||
/** Required services: slots for the dock entry, sessions for the projected ref, connection for the wire verbs, locale for the copy. */
|
||||
export const inject = ['slots', 'sessions', 'connection', 'locale']
|
||||
|
||||
/** Map one settled RPC result onto the strip's inline-render shape. */
|
||||
function settle<T>(result: RpcResult<T>): GoalActionResult {
|
||||
@@ -35,6 +49,8 @@ function settle<T>(result: RpcResult<T>): GoalActionResult {
|
||||
* @param ctx - client root context.
|
||||
*/
|
||||
export function apply(ctx: ClientContext): void {
|
||||
ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'ui-goal: dictionaries')
|
||||
|
||||
const { goals } = (ctx.get('connection') as ConnectionHandle).api
|
||||
|
||||
// Conditional mount: 'conversation.input.dock' is declared by the
|
||||
@@ -60,6 +76,7 @@ export function apply(ctx: ClientContext): void {
|
||||
name: 'conversation.input.dock',
|
||||
id: 'goal',
|
||||
order: 0,
|
||||
locale: NS,
|
||||
inject: (sessionId): GoalBarActions => ({
|
||||
onEdit: async (objective) => {
|
||||
const ref = refOf(sessionId)
|
||||
|
||||
32
packages/client/ui-goal/src/client/locales.ts
Normal file
32
packages/client/ui-goal/src/client/locales.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
/** `goal` namespace dictionaries. */
|
||||
|
||||
/** Simplified Chinese dictionary (the key-set source of truth). */
|
||||
export const zh = {
|
||||
'phase.active': '进行中的目标',
|
||||
'phase.paused': '已暂停的目标',
|
||||
'phase.blocked': '受阻的目标',
|
||||
'objective.aria': '目标内容',
|
||||
'action.save': '保存目标',
|
||||
'action.cancel': '取消编辑',
|
||||
'action.pause': '暂停目标',
|
||||
'action.resume': '恢复目标',
|
||||
'action.edit': '编辑目标',
|
||||
'action.clear': '清除目标',
|
||||
} satisfies Record<string, string>
|
||||
|
||||
/** The goal namespace key union. */
|
||||
export type GoalKey = keyof typeof zh
|
||||
|
||||
/** English dictionary, checked complete against the zh key set. */
|
||||
export const en = {
|
||||
'phase.active': 'Ongoing Goal',
|
||||
'phase.paused': 'Paused Goal',
|
||||
'phase.blocked': 'Blocked Goal',
|
||||
'objective.aria': 'Goal objective',
|
||||
'action.save': 'Save goal',
|
||||
'action.cancel': 'Cancel edit',
|
||||
'action.pause': 'Pause goal',
|
||||
'action.resume': 'Resume goal',
|
||||
'action.edit': 'Edit goal',
|
||||
'action.clear': 'Clear goal',
|
||||
} satisfies Record<GoalKey, string>
|
||||
Reference in New Issue
Block a user