@devslab/dds-solid

中文文档
0.33.0发布于 2026/11/12SEE LICENSE IN LICENSETypeScriptES Module构建来源已验证近 30 天下载 3096

Accessible SolidJS primitives for the DevsLab Design System

原始使用文档
文档目录8 节
  1. Async Toast and actions
  2. Button loading
  3. createPendingAction
  4. ConsoleShell navigation groups
  5. DatePicker
  6. TimePicker
  7. Inputs, choices, overlays and shared calendars
  8. Shared application layouts

@devslab/dds-solid

Public SolidJS primitives for DDS. Import @devslab/dds-solid/styles.css once in the application shell, then consume the native-semantic components from @devslab/dds-solid.

Stateful components accept both controlled (value/open/checked) and uncontrolled (defaultValue/defaultOpen/defaultChecked) forms. Dialog owns focus trap/return and Escape/outside dismissal; Tabs implements the WAI-ARIA keyboard model; ToastProvider owns lifecycle timers; Tooltip requires a render prop so aria-describedby is always attached to the actual trigger.

Pass a localized dismissLabel to ToastProvider when toasts need a manual dismiss control. Omitting it preserves the existing provider API while leaving out the control, so the package never emits an English accessible-name fallback.

Interactive primitives use Ark UI internally while DDS owns the public API and visual tokens. Existing imports and callback values stay the same. See the migration guide for integration details.

RadioGroup adds a labelled group from options (value, label, optional disabled), with name, value/defaultValue and onValueChange. Existing standalone Radio remains native. Use one application-level ToastProvider; inject a localized regionLabel if the notification region needs a name. Toast timers pause during pointer/focus interaction and when the browser page is idle. A non-positive duration keeps the toast until dismissed.

Async Toast and actions

Inside ToastProvider, useToast() returns show, loading, update, promise, dismiss and clear. All IDs and lifecycle state belong to that provider. A loading tone persists until it is updated or dismissed; its spinner is decorative, so supply a message that describes the work.

const toast = useToast();
const id = toast.loading({ message: "Saving changes" });
toast.update(id, { message: "Changes saved", tone: "success" });

const task = toast.promise(() => saveChanges(), {
  loading: { message: "Saving changes" },
  success: { message: "Changes saved" },
  error: { message: "Could not save changes" },
});
// The same ID is available immediately; awaiting preserves the operation's result/error.
const saved = await task;

toast.show({
  message: "Changes saved",
  action: { label: "View changes", onClick: () => openChanges(saved) },
});

update(id, patch) keeps omitted fields and changes the toast in place. An explicit undefined resets an optional field to its default; action: null removes the action. Unknown, expired and dismissed IDs are ignored. An action is a native button: it dismisses the toast before invoking its callback once and does not submit a surrounding form.

promise accepts a promise or a once-only factory, including synchronous throws. Its success and error inputs can also be synchronous functions receiving the result or original error. It merges terminal input into the loading input, defaults terminal tones to success/danger, and uses the provider's normal duration after loading. It returns Promise<T> & { readonly id: string }. Handle rejected operations as you would any other promise. Dismissing, clearing, closing, activating an action, manually updating or disposing the provider supersedes the pending notification; settlement still reaches the caller but does not run its terminal message factory or recreate the notification. If a terminal message factory throws, the current notification is dismissed and the original operation outcome is preserved. Actions and promises introduce no retry, cancellation or inference of business success.

Button loading

loading keeps the button's size and accessible name: the label is hidden, not removed, and the spinner is drawn over it, so the controls beside it do not move and a wrapped label does not wrap again (D-043). Keep the label the same while loading; the hidden text still sets the width.

createPendingAction

A screen with several buttons needs to know which one started the work. Pass one shared flag to every button and they all spin on a single click.

import { Button, createPendingAction } from "@devslab/dds-solid";
const action = createPendingAction<"approve" | "reject">();
<Button tone="danger" loading={action.is("reject")} disabled={action.busy()}
  onClick={() => action.run("reject", () => decide("reject"))}>Reject</Button>
<Button loading={action.is("approve")} disabled={action.busy()}
  onClick={() => action.run("approve", () => decide("approve"))}>Approve</Button>

is(key) is true only for the running action, so only that control shows progress; busy() locks the rest. run clears the state when the task settles, passes its error on, and does nothing while another action runs, so a second click cannot start a second request. Pass { replace: true } where the latest request should win instead, such as a list reload.

The task receives an AbortSignal that aborts when its run stops counting: reset(), a run that replaced it, or the component going away. Check signal.aborted after each await before touching the screen, or pass the signal to fetch; no separate request counter or "still mounted" flag is needed. A late completion never clears a newer action.

const list = createPendingAction<"search" | "page">();
const reload = (key: "search" | "page") => list.run(key, async (signal) => {
  const rows = await loadRows(filter());
  if (!signal.aborted) setRows(rows);
}, { replace: true });

ConsoleShell navigation groups

Groups remain open by default. Set collapsible: true on a group to render a native disclosure button, and give it a stable id for expansion state (otherwise the key is group-${index}). Only active collapsible groups open initially, using the same route matching and item active override as the navigation links.

LeftNav is also exported separately for composing a menu in your own layout. It takes surface, activePath, nav, labels (nav and badge), the expansion props below, and optional onNavigate. To compose it inside ConsoleShell, pass it as navigation={<LeftNav ... />}; the slot replaces the built-in menu and the shell's nav can be omitted. The shell continues to own branding, the header, content and mobile drawer. For a custom menu, connect onNavigate to any application-specific drawer handling.

const [expandedGroups, setExpandedGroups] = createSignal<readonly string[]>(["build"]);
<ConsoleShell
  {...shellProps}
  nav={[{ id: "build", label: "Build", collapsible: true, items: [
    { id: "projects", href: "/dashboard/projects", label: "Projects", icon: <svg viewBox="0 0 16 16"><path d="M2 3h5l2 2h5v8H2z" /></svg> },
  ] }]}
  expandedGroups={expandedGroups()}
  onExpandedGroupsChange={setExpandedGroups}
>Content</ConsoleShell>

Use defaultExpandedGroups for uncontrolled initial state; [] explicitly closes every collapsible group. Use expandedGroups and onExpandedGroupsChange for controlled state. Later route-driven expansion and persistence belong to the application. Item icon is decorative; label still supplies the link name and badges keep their accessible labels.

DatePicker

import { DatePicker } from "@devslab/dds-solid";
const [date, setDate] = createSignal("");
<DatePicker label="시작 날짜" value={date()} onChange={setDate} />

Ark UI owns focus, selection and keyboard navigation; DDS owns styling. Controlled value uses YYYY-MM-DD or an empty string. locale defaults to ko-KR, timeZone to Asia/Seoul; optional min, max and disabled constrain selection. Time of day uses TimePicker.

TimePicker

import { TimePicker } from "@devslab/dds-solid";
const [closing, setClosing] = createSignal("18:00");
<TimePicker label="마감 시간" value={closing()} onValueChange={setClosing} clearable />

Replaces the native type="time" dropdown with the Combobox control and list. Values are 24-hour HH:MM or an empty string; HH:MM:SS from a server is shown as HH:MM. The list steps every step minutes (default 10) and opens centered on the selection; typing 10 filters to 10:00–10:50, and a complete typed time (even off the step, e.g. 10:45) is accepted with Enter or on leaving the field.

Inputs, choices, overlays and shared calendars

Input/InputGroup are general-purpose native inputs, not search-only, with label placement and clear actions. Combobox/SelectPicker support fixed-row virtualization; DropdownMenu/Popover provide accessible overlays; Calendar/DatePicker share a calendar view. SegmentedControl picks one of a few visible options (radio-group semantics); NumberInput is a localized number field with optional − / + buttons and a unit, whose value is a number or null.

Use explicit subpaths @devslab/dds-solid/input, /combobox, /select-picker, /dropdown-menu, /popover, /calendar, /date-picker, /time-picker, /segmented-control, /number-input, /date-range-picker, /month-picker, or the existing root exports. Keep importing styles.css once. See the common usage guide. Input/InputGroup are general-purpose native inputs, not search-only, with label placement and clear actions. Combobox/SelectPicker support fixed-row virtualization; DropdownMenu/Popover provide accessible overlays; Calendar/DatePicker share a calendar view, which DateRangePicker (start ~ end period) and MonthPicker (YYYY-MM) also use.

Shared application layouts

Layout, LeftNav and TopNav use the common geometry and typography rules. See composition and exact dimensions.

版本与发布记录

@devslab/dds-solid 共发布 46 个版本,首次发布于 2026/08/31;过去 12 个月发布了 46 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.33.0latest2026/11/12今天
0.32.22026/11/111 天前
0.32.12026/11/102 天前
0.32.02026/11/102 天前
0.31.02026/11/092 天前
0.30.02026/11/084 天前

关于 @devslab/dds-solid 的常见问题

@devslab/dds-solid 是什么?

Accessible SolidJS primitives for the DevsLab Design System

如何安装 @devslab/dds-solid?

在项目目录运行 npm install @devslab/dds-solid,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:solid-js(1.9.15)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@devslab/dds-solid 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@devslab/dds-solid 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@devslab/dds-solid 可以商用吗?

@devslab/dds-solid 使用 SEE LICENSE IN LICENSE 许可。许可条款写在包内的独立文件中,请阅读该文件确认可否商用。以上为概括,不构成法律意见,请以许可原文为准。

@devslab/dds-solid 的下载量有多少?

根据 npm 官方下载统计,@devslab/dds-solid 在 2026/10/12 – 2026/11/10 这 30 天内被下载 3,096 次,日均约 103 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@devslab/dds-solid 还在维护吗?

最新版本 0.33.0 发布于 2026/11/12(今天);至今共发布 46 个版本,其中过去 12 个月发布了 46 个;首次发布于 2026/08/31。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。