diff --git a/.changeset/react-versioned-guides.md b/.changeset/react-versioned-guides.md new file mode 100644 index 0000000..c66030b --- /dev/null +++ b/.changeset/react-versioned-guides.md @@ -0,0 +1,5 @@ +--- +"@devslab/dds-react": patch +--- + +Ship English and Korean guides for toast notifications, input controls, and layouts with the React package so consumers can read the documentation for their installed version. diff --git a/packages/dds-react/README.ko.md b/packages/dds-react/README.ko.md index 6e149eb..27512b2 100644 --- a/packages/dds-react/README.ko.md +++ b/packages/dds-react/README.ko.md @@ -1,5 +1,7 @@ # DDS React +아래 사용 가이드 링크는 설치한 버전의 `dist/docs/` 파일을 엽니다. 저장소에서 읽을 때는 [Toast](https://github.com/devslab-kr/dds/blob/HEAD/docs/toast.ko.md), [입력·선택 컨트롤](https://github.com/devslab-kr/dds/blob/HEAD/docs/components-input-choice-calendar.ko.md), [레이아웃](https://github.com/devslab-kr/dds/blob/HEAD/docs/layouts.ko.md) 원문을 참고하세요. + Ark UI 5.39.3과 DDS 토큰·CSS·아이콘을 사용하는 React 접근성 컴포넌트입니다. React/React DOM 18.3 또는 19를 peer dependency로 사용합니다. ```tsx @@ -21,7 +23,7 @@ React DOM 속성(`className`, `htmlFor`, `onChange`)과 객체/콜백 ref를 사 Dialog는 기본적으로 portal을 사용하며 Ark가 중첩 모달, 포커스 복원, Escape, 스크롤 잠금을 관리합니다. `portal={false}`로 SSR 열린 콘텐츠를 인라인 렌더링할 수 있습니다. `contentProps`, `actions`, `frame`, `initialFocus`, `finalFocus`, `unstyled`와 Ark root 옵션을 제공합니다. `closeLabel`을 주면 오른쪽 위(인라인 끝) 모서리에 그 이름의 닫기(X) 버튼이 생기고, `frame`은 이를 `parts.close`로 받습니다. 버튼 줄은 위 내용과 한 단계 간격을 둡니다. Solid의 커스텀 additionalFocusContainers는 모방하지 않습니다. 고급 구성은 ArkDialog/ArkTabs/ArkTooltip/ArkRadioGroup/ArkCheckbox/ArkSwitch/ArkField/ArkToast 네임스페이스를 사용하세요. -Tooltip은 하나의 포커스 가능한 요소 또는 trigger props를 받는 render 함수를 사용합니다. ToastProvider의 regionLabel/dismissLabel은 호출자가 지정합니다. dismissLabel이 없으면 닫기 버튼이 없습니다. useToast는 show/loading/update/promise/dismiss/clear를 반환하며 duration 0은 유지됩니다. 언마운트 때 알림을 정리합니다. React·Solid·Vue의 동일한 계약은 [Toast 가이드](../../docs/toast.ko.md)를 참고하세요. +Tooltip은 하나의 포커스 가능한 요소 또는 trigger props를 받는 render 함수를 사용합니다. ToastProvider의 regionLabel/dismissLabel은 호출자가 지정합니다. dismissLabel이 없으면 닫기 버튼이 없습니다. useToast는 show/loading/update/promise/dismiss/clear를 반환하며 duration 0은 유지됩니다. 언마운트 때 알림을 정리합니다. React·Solid·Vue의 동일한 계약은 [Toast 가이드](./dist/docs/toast.ko.md)를 참고하세요. ```tsx const toast = useToast(); // ToastProvider 내부 @@ -100,8 +102,7 @@ validity callback은 최초 mount, 의미 있는 입력·제약·외부 값 변 Input/InputGroup은 검색 전용이 아닌 일반 입력 기반이며 라벨 배치·내용 지우기를 지원합니다. Combobox/SelectPicker는 가상화를, DropdownMenu/Popover는 접근 가능한 팝업을, Calendar/DatePicker/DateRangePicker/MonthPicker는 공유 달력을 제공합니다. -상세 import: `@devslab/dds-react/input`, `/combobox`, `/select-picker`, `/dropdown-menu`, `/popover`, `/calendar`, `/date-picker`, `/date-range-picker`, `/month-picker`. 기존 루트 import와 `styles.css`는 유지합니다. [공통 사용 가이드](https://github.com/devslab-kr/dds/blob/main/docs/components-input-choice-calendar.ko.md)를 참고하세요. -상세 import: `@devslab/dds-react/input`, `/combobox`, `/select-picker`, `/dropdown-menu`, `/popover`, `/calendar`, `/date-picker`, `/time-picker`, `/date-range-picker`, `/month-picker`, `/segmented-control`, `/number-input`. 기존 루트 import와 `styles.css`는 유지합니다. [공통 사용 가이드](https://github.com/devslab-kr/dds/blob/main/docs/components-input-choice-calendar.ko.md)를 참고하세요. +상세 import: `@devslab/dds-react/input`, `/combobox`, `/select-picker`, `/dropdown-menu`, `/popover`, `/calendar`, `/date-picker`, `/time-picker`, `/date-range-picker`, `/month-picker`, `/segmented-control`, `/number-input`. 기존 루트 import와 `styles.css`는 유지합니다. [공통 사용 가이드](./dist/docs/components-input-choice-calendar.ko.md)를 참고하세요. ## 선택형 콘솔 메뉴 그룹 @@ -120,4 +121,4 @@ ID 생략 시 `group-`를 사용하므로 순서 변경·상태 보관에 ## 공통 업무 화면 -Layout·LeftNav·TopNav는 공통 간격과 타이포 규격을 사용합니다. [조립 방법과 수치](../../docs/layouts.ko.md)를 참고하세요. +Layout·LeftNav·TopNav는 공통 간격과 타이포 규격을 사용합니다. [조립 방법과 수치](./dist/docs/layouts.ko.md)를 참고하세요. diff --git a/packages/dds-react/README.md b/packages/dds-react/README.md index f84c03e..47587cc 100644 --- a/packages/dds-react/README.md +++ b/packages/dds-react/README.md @@ -1,5 +1,7 @@ # DDS React +The usage guides linked below ship in `dist/docs/` and match the installed package version. When browsing the repository, see the source guides for [toast](https://github.com/devslab-kr/dds/blob/HEAD/docs/toast.md), [input and selection controls](https://github.com/devslab-kr/dds/blob/HEAD/docs/components-input-choice-calendar.md), and [layouts](https://github.com/devslab-kr/dds/blob/HEAD/docs/layouts.md). + Accessible React primitives using Ark UI 5.39.3 and shared DDS tokens, CSS and icons. React and React DOM are peers (18.3 or 19). Import CSS once in the application: ```tsx @@ -25,7 +27,7 @@ Native DOM attributes use React spelling (`className`, `htmlFor`, `onChange`). D Tabs extends Ark root options, with `onValueChange(string)`; parts accept normal Ark DOM props including `asChild`. Dialog accepts Ark root options with `onOpenChange(boolean)`, `closeOnOutside`, `initialFocus`, `finalFocus`, `contentProps`, `actions`, `frame(parts)` and `unstyled`. Pass `closeLabel` to add a close (X) button in the top inline-end corner, named by that label; `frame` receives it as `parts.close`. Actions keep one step of space from the content above them. Dialog portals by default; use `portal={false}` for inline markup, including open SSR content. Ark owns nested modal isolation, focus, Escape handling and scroll locking. Additional focus containers from the Solid package are not emulated; use Ark `persistentElements` and `modal`/`trapFocus` according to application needs. -Tooltip accepts one element child (Ark `asChild`) or a render function receiving native button trigger props. Use a focusable trigger and preserve the supplied events. `ToastProvider` accepts optional caller `regionLabel` and `dismissLabel` (string or record-to-string function); without `dismissLabel` it renders no close button. `useToast()` returns `show`, `loading`, `update`, `promise`, `dismiss`, and `clear`; duration 0 persists. Providers clear their notifications on unmount. The [Toast guide](../../docs/toast.md) covers the identical React/Solid/Vue contract. +Tooltip accepts one element child (Ark `asChild`) or a render function receiving native button trigger props. Use a focusable trigger and preserve the supplied events. `ToastProvider` accepts optional caller `regionLabel` and `dismissLabel` (string or record-to-string function); without `dismissLabel` it renders no close button. `useToast()` returns `show`, `loading`, `update`, `promise`, `dismiss`, and `clear`; duration 0 persists. Providers clear their notifications on unmount. The [Toast guide](./dist/docs/toast.md) covers the identical React/Solid/Vue contract. ```tsx const toast = useToast(); // inside ToastProvider @@ -134,8 +136,7 @@ Delayed controlled echoes matching an outstanding local emission acknowledge tha 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/DateRangePicker/MonthPicker share a calendar view. -Use explicit subpaths `@devslab/dds-react/input`, `/combobox`, `/select-picker`, `/dropdown-menu`, `/popover`, `/calendar`, `/date-picker`, `/date-range-picker`, `/month-picker`, or the existing root exports. Keep importing `styles.css` once. See the [common usage guide](https://github.com/devslab-kr/dds/blob/main/docs/components-input-choice-calendar.md). -Use explicit subpaths `@devslab/dds-react/input`, `/combobox`, `/select-picker`, `/dropdown-menu`, `/popover`, `/calendar`, `/date-picker`, `/time-picker`, `/date-range-picker`, `/month-picker`, `/segmented-control`, `/number-input`, or the existing root exports. Keep importing `styles.css` once. See the [common usage guide](https://github.com/devslab-kr/dds/blob/main/docs/components-input-choice-calendar.md). +Use explicit subpaths `@devslab/dds-react/input`, `/combobox`, `/select-picker`, `/dropdown-menu`, `/popover`, `/calendar`, `/date-picker`, `/time-picker`, `/date-range-picker`, `/month-picker`, `/segmented-control`, `/number-input`, or the existing root exports. Keep importing `styles.css` once. See the [common usage guide](./dist/docs/components-input-choice-calendar.md). ## Optional console navigation groups @@ -165,4 +166,4 @@ the desktop rail and mobile drawer. ## Shared application layouts -Layout, LeftNav and TopNav use the common geometry and typography rules. See [composition and exact dimensions](../../docs/layouts.md). +Layout, LeftNav and TopNav use the common geometry and typography rules. See [composition and exact dimensions](./dist/docs/layouts.md). diff --git a/packages/dds-react/package.json b/packages/dds-react/package.json index 70bd5c5..153d433 100644 --- a/packages/dds-react/package.json +++ b/packages/dds-react/package.json @@ -126,6 +126,7 @@ "@types/node": "26.3.0", "@types/react": "^19.0.0", "@types/react-dom": "^19.0.0", + "@ui-sdk/core": "0.1.0-beta.14", "axe-core": "4.13.0", "jsdom": "30.0.1", "react": "19.3.0", diff --git a/packages/dds-react/src/__tests__/primitives.test.tsx b/packages/dds-react/src/__tests__/primitives.test.tsx index f26f35c..384b344 100644 --- a/packages/dds-react/src/__tests__/primitives.test.tsx +++ b/packages/dds-react/src/__tests__/primitives.test.tsx @@ -1,6 +1,7 @@ import { createRef, StrictMode, useEffect, useState } from "react"; import { act, render, screen, waitFor } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; +import { checkPattern } from "@ui-sdk/core/testing"; import { describe, it, expect, vi } from "vitest"; import { Button, @@ -63,8 +64,8 @@ describe("React DDS behavior", () => { await userEvent.click(screen.getByRole("checkbox")); expect(screen.getByRole("checkbox")).not.toBeChecked(); }); - it("delegates tab keyboard selection and panel visibility to Ark", async () => { - render( + it("follows the accessible tabs pattern and displays the panel selected with the keyboard", async () => { + const { container } = render( 첫째 @@ -83,6 +84,7 @@ describe("React DDS behavior", () => { ), ); expect(screen.getByRole("tabpanel")).toHaveTextContent("둘 내용"); + await checkPattern(container, "tabs"); }); it("uses Ark radio roving focus", async () => { render( diff --git a/packages/dds-react/vite.config.ts b/packages/dds-react/vite.config.ts index 15afcfa..36be69b 100644 --- a/packages/dds-react/vite.config.ts +++ b/packages/dds-react/vite.config.ts @@ -1,5 +1,31 @@ +import { readFile } from "node:fs/promises"; import { defineConfig } from "vite"; + export default defineConfig({ + plugins: [ + { + name: "dds-react-usage-guides", + async generateBundle() { + for (const topic of [ + "toast", + "components-input-choice-calendar", + "layouts", + ]) { + for (const suffix of [".md", ".ko.md"]) { + const filename = topic + suffix; + const source = await readFile( + new URL(`../../docs/${filename}`, import.meta.url), + ); + this.emitFile({ + type: "asset", + fileName: `docs/${filename}`, + source, + }); + } + } + }, + }, + ], build: { lib: { entry: { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cbe74b1..bb221c9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -188,6 +188,9 @@ importers: '@types/react-dom': specifier: ^19.0.0 version: 19.3.0(@types/react@19.3.0) + '@ui-sdk/core': + specifier: 0.1.0-beta.14 + version: 0.1.0-beta.14 axe-core: specifier: 4.13.0 version: 4.13.0 @@ -2385,6 +2388,9 @@ packages: cpu: [x64] os: [win32] + '@ui-sdk/core@0.1.0-beta.14': + resolution: {integrity: sha512-SHm5qLYBqxT5+d3svaBeP5uoBMIQbETKBqcZ/6b+WhhXlz6YoeNqjtMfpmq4yGA329DFwzu+y7+xGJjw4fnTPQ==} + '@vitejs/plugin-react@6.0.1': resolution: {integrity: sha512-l9X/E3cDb+xY3SWzlG1MOGt2usfEHGMNIaegaUGFsLkb3RCn/k8/TOXBcab+OndDI4TBtktT8/9BwwW8Vi9KUQ==} engines: {node: ^20.19.0 || >=22.12.0} @@ -6138,6 +6144,8 @@ snapshots: '@typescript/typescript-win32-x64@7.0.2': optional: true + '@ui-sdk/core@0.1.0-beta.14': {} + '@vitejs/plugin-react@6.0.1(vite@8.2.1(@types/node@26.3.0)(esbuild@0.28.2)(jiti@2.7.0)(yaml@2.9.0))': dependencies: '@rolldown/pluginutils': 1.0.0-rc.7 diff --git a/scripts/verify-react-release.mjs b/scripts/verify-react-release.mjs index fbfd472..2540fd6 100644 --- a/scripts/verify-react-release.mjs +++ b/scripts/verify-react-release.mjs @@ -138,6 +138,30 @@ try { const manifest = JSON.parse( await readFile(join(installed, "package.json"), "utf8"), ); + if (mode === "react") { + for (const suffix of [".md", ".ko.md"]) { + const readme = await readFile(join(installed, `README${suffix}`), "utf8"); + const links = Array.from( + readme.matchAll(/\]\(\.\/([^)\s#]+\.md)(?:#[^)\s]*)?\)/g), + (match) => match[1], + ); + for (const topic of [ + "toast", + "components-input-choice-calendar", + "layouts", + ]) { + const filename = topic + suffix; + const link = links.find((path) => basename(path) === filename); + assert.ok(link, `Packed README${suffix} must link to ${filename}`); + const guide = await readFile(join(installed, link), "utf8"); + assert.equal( + guide, + await readFile(join(workspace, "docs", filename), "utf8"), + `Packed ${filename} must match the guide for this release`, + ); + } + } + } for (const path of [ "dist/index.js", "dist/index.d.ts",