README来源: main@1aca7e45
@miorin/dsh-plugin-knobs-ui
Shared React building blocks for the fine-grained settings ("knobs") that DeepSeek Harness plugins draw on their plugin detail pages.
The name says what the package is not: it is not the native DSH settings interface, and it covers small adjustments such as modes, visibility, and thresholds. It supplies the layout from the workspace settings panel style guide; plugins place native DSH controls in its slots. See DESIGN.md for scope, distribution, and invariants.
Installation
Install as a build-time dependency; the plugin build inlines it while keeping react and @deepseek-ai/* external.
pnpm add -D @miorin/dsh-plugin-knobs-ui
npm install --save-dev @miorin/dsh-plugin-knobs-ui
Usage
import { SegmentedControl, StateDot } from '@deepseek-ai/dsh-client-ui-primitives'
import { KnobRow, KnobsPanel, knobsFeedbackKey, knobsFeedbackTone, useKnobSave } from '@miorin/dsh-plugin-knobs-ui'
function ModeSetting({ view, t, form }) {
const save = useKnobSave(form.saveMode)
const id = useId()
if (view !== 'page') return null
const feedback = knobsFeedbackKey({
status: form.status,
writable: form.writable,
saving: save.pending !== undefined,
failed: save.failed,
})
return (
<KnobsPanel scope="@miorin/dsh-example" heading={t('sectionTitle')}>
<KnobRow
wrap="wide"
title={t('mode')}
indicator={save.pending !== undefined && <StateDot state="ongoing" size={12} />}
description={t('modeHint')}
feedback={feedback && { id: `${id}-status`, text: t(feedback), tone: knobsFeedbackTone(feedback) }}
control={
<SegmentedControl
id={id}
value={save.pending ?? form.mode}
options={options}
label={t('mode')}
onChange={next => { void save.commit(next) }}
/>
}
/>
</KnobsPanel>
)
}
| Export | Purpose |
|---|---|
KnobsPanel |
Root with scoped <style> (scope + optional styles), heading (headingAction, keepHeadingInAggregate), row list, feedback, and after (such as a portaled Modal). |
KnobRow |
Icon, title, indicator, description, extraCopy, control column, align, wrap (compact / wide), and inline feedback. |
KnobItem |
Item wrapper inside KnobsPanel so custom rows share dividers and edge padding. |
useKnobSave |
Optimistic value, failure flag, and a single in-flight save. |
knobsFeedbackKey, knobsFeedbackTone |
Which feedback line to show and how assistive technology announces it. |
KNOBS_LABELS, KNOBS_LOCALES, withKnobsLabels |
Feedback text in en zh ja de es fr pt ru, merged into a plugin's label tables. |
KNOBS_DANGER_CLASS, KNOBS_LINK_BUTTON_CLASS |
Outline danger Button overrides and button-styled external <a> link. |
KNOBS_PREVIEW_CLASS, KNOBS_INPUT_GROUP_CLASS, KNOBS_RESET_BUTTON_CLASS |
Secondary live preview line, single-line Input + reset Button wrapper, and 32 × 32 reset button class. |
knobsCss, knobsScopeSelector |
Underlying scoped stylesheet builder and escaped scope attribute selector. |
Development
pnpm install --frozen-lockfile
npm run check
See README.zh.md for the Chinese overview.
还没有评论,来写第一条。