diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3efcf87..0679706 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,15 +5,19 @@ on: branches: [main] pull_request: +permissions: + contents: read + jobs: check: runs-on: ubuntu-latest + timeout-minutes: 20 steps: - uses: actions/checkout@v4 - - uses: pnpm/action-setup@v4 - uses: actions/setup-node@v4 with: - node-version: 22 + node-version-file: .node-version + - uses: pnpm/action-setup@v4 - run: pnpm install --frozen-lockfile - run: pnpm check - run: pnpm build diff --git a/.node-version b/.node-version new file mode 100644 index 0000000..df6ae33 --- /dev/null +++ b/.node-version @@ -0,0 +1 @@ +24.21.0 diff --git a/.oxfmtrc.json b/.oxfmtrc.json new file mode 100644 index 0000000..c36fe91 --- /dev/null +++ b/.oxfmtrc.json @@ -0,0 +1,22 @@ +{ + "semi": false, + "singleQuote": true, + "arrowParens": "avoid", + "quoteProps": "consistent", + "singleAttributePerLine": true, + "htmlWhitespaceSensitivity": "strict", + "ignorePatterns": [ + "docs/content/**", + "docs/.nuxt/**", + "docs/.data/**", + "dist/**", + "public/**", + "**/generated/**", + "**/fixtures/**", + ".agents/**", + "docs/plans/**", + "AGENTS.md", + "pnpm-lock.yaml", + "skills-lock.json" + ] +} diff --git a/.oxlintrc.json b/.oxlintrc.json new file mode 100644 index 0000000..f59640b --- /dev/null +++ b/.oxlintrc.json @@ -0,0 +1,14 @@ +{ + "plugins": ["typescript", "unicorn", "oxc", "vue"], + "categories": { + "correctness": "error" + }, + "ignorePatterns": [ + "docs/content/**", + "docs/.nuxt/**", + "docs/.data/**", + "dist/**", + "**/generated/**", + ".agents/**" + ] +} diff --git a/AGENTS.md b/AGENTS.md index 89df742..58d37a4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -133,7 +133,7 @@ git subtree pull --prefix=vendor/ui https://github.com/0froq/ui.git main --squas 用户定了之后再改代码,让它在库里和项目里都能运行。不要把项目文件原样复制进 `vendor/ui`。指向页面组件、项目 store、路由、项目类名和项目色值的地方,改成 props、slot,或库里已有的函数;样式改读 `--ui-*`。调用处仍由项目传入文案和数据。改完后,原来的页面还要能渲染。外观如果用了 token 契约里没有的颜色或字体,而且不能改写成那十二个变量,停下来告诉用户缺哪一个,不要给这个组件单开一套变量。 -写库里的代码之前,读 `vendor/ui/AGENTS.md` 的「代码规范」,并对照同一层已有文件。规范一节还没有细则时,以同一目录里已有组件为准,并让库的 eslint 通过。不要另起一套写法。 +写库里的代码之前,读 `vendor/ui/AGENTS.md` 的「代码规范」,并对照同一层已有文件。规范一节还没有细则时,以同一目录里已有组件为准,并让库的 `pnpm lint` 通过。不要另起一套写法。 1. 定名字和 props。库里已有同一种控件就沿用现有名字,例如 `Choice`、`Toggle`。新控件不要带项目名。props 只保留交互需要的,例如 `v-model`、`options`、`label`。项目专属参数留在本项目里包一层。 2. 行为。不依赖 DOM 结构的逻辑放进 `vendor/ui/src/core/`,不要引用 Vue。需要 Vue、但不关心样子的逻辑放进 `vendor/ui/src/vue/`,并从 `vendor/ui/src/vue/index.ts` 导出。已有 `useChoice` 或其他函数能用就用,不要复制一份。有动效时用 `vendor/ui/src/core` 里的 `prefersReducedMotion`。 @@ -161,7 +161,7 @@ git subtree pull --prefix=vendor/ui https://github.com/0froq/ui.git main --squas 抽进库的代码要符合这一节。移植前先读这里,再对照同一层已有文件。 -eslint 使用 `@antfu/eslint-config`。Vue 单行和多行都是每个属性单独一行。改完在库仓库里跑 `pnpm lint`,或在项目里对 `vendor/ui` 跑同一套配置。不要为了迁就项目原来的格式去关规则。 +库仓库使用 Oxlint 与 Oxfmt(Vite+ `vp lint` / `vp fmt`)。Vue 单行和多行都是每个属性单独一行。改完在库仓库里跑 `pnpm lint` 与 `pnpm fmt:check`,或在项目里对 `vendor/ui` 跑同一套配置。不要为了迁就项目原来的格式去关规则。 ### 细则 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..023a20c --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) froq + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index df44780..2ff7d56 100644 --- a/README.md +++ b/README.md @@ -25,26 +25,26 @@ docs/ Docs site. It depends on this package. Component and docs change Everything below is exported from `@froq/ui`. -| Component | Role | -| --- | --- | -| Button / CopyButton | Native button. Async clipboard, stable width | -| TextInput / TextArea / Select / Checkbox | Native fields. Attributes and events reach the control | -| FormField / NumberInput / DateInput / Slider / FileUpload / RadioGroup | Label, error, native value. Validation stays with the caller | -| Choice / ChoiceCircle / Toggle | Controlled choice and switch. Custom radio does not submit a form value | -| ToggleGroup | Single or multiple. Arrow keys move focus. A selected value can be cleared | -| Combobox | Search and multiple selection. Remote requests stay with the caller | -| Calendar / DatePicker | One month. ISO dates, locale, range, disabled dates | -| Navigation / Sidebar | Flat links and collapsible groups. Routing stays with the caller | -| Breadcrumb / Pagination | Path and page links. No router and no data fetching | -| Collapsible / Accordion / Tabs | Controlled panels. Content stays mounted | -| Skeleton / Progress / Spinner / Alert | Loading, progress, wait, inline notice | -| Banner | Site notice. Actions slot. The caller owns dismissal | -| Toast / ToastRegion | Temporary notice and a shared region. The queue stays with the caller | -| IconButton / EmptyState | Named icon button. Empty content and an actions slot | -| Badge / Avatar / Separator / Card / AspectRatio / Table | Mark, image, rule, surface, ratio, native table | -| Dialog / AlertDialog / Drawer / Popover / Menu / Tooltip | Dialog, confirm, side panel, anchored layer, menu, tip | -| ContextMenu / HoverCard | Context menu and link preview. The preview is not required content | -| Paper | Paper texture | +| Component | Role | +| ---------------------------------------------------------------------- | -------------------------------------------------------------------------- | +| Button / CopyButton | Native button. Async clipboard, stable width | +| TextInput / TextArea / Select / Checkbox | Native fields. Attributes and events reach the control | +| FormField / NumberInput / DateInput / Slider / FileUpload / RadioGroup | Label, error, native value. Validation stays with the caller | +| Choice / ChoiceCircle / Toggle | Controlled choice and switch. Custom radio does not submit a form value | +| ToggleGroup | Single or multiple. Arrow keys move focus. A selected value can be cleared | +| Combobox | Search and multiple selection. Remote requests stay with the caller | +| Calendar / DatePicker | One month. ISO dates, locale, range, disabled dates | +| Navigation / Sidebar | Flat links and collapsible groups. Routing stays with the caller | +| Breadcrumb / Pagination | Path and page links. No router and no data fetching | +| Collapsible / Accordion / Tabs | Controlled panels. Content stays mounted | +| Skeleton / Progress / Spinner / Alert | Loading, progress, wait, inline notice | +| Banner | Site notice. Actions slot. The caller owns dismissal | +| Toast / ToastRegion | Temporary notice and a shared region. The queue stays with the caller | +| IconButton / EmptyState | Named icon button. Empty content and an actions slot | +| Badge / Avatar / Separator / Card / AspectRatio / Table | Mark, image, rule, surface, ratio, native table | +| Dialog / AlertDialog / Drawer / Popover / Menu / Tooltip | Dialog, confirm, side panel, anchored layer, menu, tip | +| ContextMenu / HoverCard | Context menu and link preview. The preview is not required content | +| Paper | Paper texture | Each component has a demo, an English note, and a Chinese note. The docs site discovers them from the source. @@ -64,6 +64,14 @@ Set `data-theme="light"` or `data-theme="dark"` on the scope, or an ancestor, to `@froq/ui/tokens.css` is enough when a project wants the tokens without the components. `pnpm check:tokens` fails if a variable is missing, or if a component reads one outside this list. +## Install + +```bash +pnpm add @froq/ui +``` + +Requires Node `^24.21.0 || >=26.0.0` for development of this repo; consumers may use any Node version their bundler supports. + ## Use ```ts @@ -162,9 +170,13 @@ pnpm dev # docs at http://localhost:3000 pnpm generate # static files in dist/ pnpm deploy # generate, then cf deploy pnpm preview:deploy # generate, then cf previews deploy -pnpm check # lint, types, token contract +pnpm check # oxlint, oxfmt, types, token contract +pnpm lint:fix # oxlint --fix +pnpm fmt # oxfmt ``` +Node **24.21.0** (`.node-version`, `mise.toml`). Lint and format use [Vite+](https://github.com/voidzero-dev/vite-plus) (`vp`) with `.oxlintrc.json` and `.oxfmtrc.json`. + ## Docs site https://ui.froq.me @@ -174,7 +186,7 @@ The static output is `dist/` at the repo root. It deploys to the Cloudflare Worker `ui`. The Worker config is `cloudflare.config.ts`; the assets directory is in `wrangler.config.ts`. -Workers Builds (GitHub connection, no API token in the repo): `NODE_VERSION=22`, build `pnpm generate`, production `pnpm exec cf deploy`, preview `pnpm exec cf previews deploy`. +Workers Builds (GitHub connection, no API token in the repo): `NODE_VERSION=24.21.0`, build `pnpm generate`, production `pnpm exec cf deploy`, preview `pnpm exec cf previews deploy`. The docs live in the `docs/` subpackage, so root `cf deploy` does not run generate on its own. That is why `deploy` is `pnpm generate && cf deploy`. @@ -188,7 +200,7 @@ CI installs from the lockfile. ## License -This package has no root license file. +MIT. See [LICENSE](LICENSE). The handwriting strokes in `src/core/signature/` are SIL OFL 1.1. Copyright 2010 The Allura Project Authors. See `OFL.txt` and `NOTICE.md` beside that data. diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 0000000..808a0f3 --- /dev/null +++ b/RELEASE.md @@ -0,0 +1,56 @@ +# Release `@froq/ui` + +## 0.1.0 (first npm publish) + +First public release on npm under the `@froq` scope. The package ships TypeScript and Vue source; consumers compile it with Vite or Nuxt (`build.transpile: ['@froq/ui']`). Runtime peer: `vue` ^3.5.0 (optional for `@froq/ui/core` only). + +### After merge: publish to npm + +Maintainer only. Do not publish from CI or cloud agents. + +1. Confirm [main](https://github.com/0froq/ui) is green and `package.json` `version` is **0.1.0**. +2. Use Node **24.21.0** (`.node-version` / `mise.toml`) and pnpm **12.11.2** (`packageManager` in `package.json`). +3. From the repo root: + +```bash +pnpm install --frozen-lockfile +pnpm check +pnpm pack --pack-destination /tmp +tar -tzf /tmp/froq-ui-0.1.0.tgz | head +``` + +4. Log in as the **froq** npm user (org **`@froq`**): + +```bash +npm whoami +# expect: froq +``` + +5. Publish (public scoped package): + +```bash +npm publish --access public +``` + +6. Tag the release in git (optional but recommended): + +```bash +git tag v0.1.0 +git push origin v0.1.0 +``` + +7. Update [ui.froq.me](https://ui.froq.me) changelog if the docs site should mention the npm install path (`pnpm add @froq/ui`). + +### Publish readiness checklist + +| Item | Status | +| ------------------------------------------------ | ------------------------------------------------ | +| `name` is `@froq/ui` | yes | +| `private` is false | yes | +| `publishConfig.access` is `public` | yes | +| `files` includes publishable `src/` | yes | +| `exports` for `.`, `./core`, `./vue`, CSS | yes | +| Runtime deps use registry ranges (no `catalog:`) | yes | +| `engines.node` ^24.21.0 \|\| >=26.0.0 | yes | +| Not yet on npm (first publish) | confirm before publish | +| Root `LICENSE` / license field | MIT; signature assets remain SIL OFL 1.1 in tree | diff --git a/docs/app/app.vue b/docs/app/app.vue index 4494701..3a7e792 100644 --- a/docs/app/app.vue +++ b/docs/app/app.vue @@ -17,9 +17,8 @@ useHead({ htmlAttrs: { lang, }, - titleTemplate: (title) => { - if (!title || title === 'froq/ui') - return 'froq/ui' + titleTemplate: title => { + if (!title || title === 'froq/ui') return 'froq/ui' return `${title} — froq/ui` }, }) diff --git a/docs/app/assets/css/fonts.css b/docs/app/assets/css/fonts.css index ff2f455..3dc7ff3 100644 --- a/docs/app/assets/css/fonts.css +++ b/docs/app/assets/css/fonts.css @@ -6,7 +6,8 @@ font-style: normal; font-display: optional; font-weight: 100 900; - src: url('@fontsource-variable/geist/files/geist-cyrillic-ext-wght-normal.woff2') format('woff2-variations'); + src: url('@fontsource-variable/geist/files/geist-cyrillic-ext-wght-normal.woff2') + format('woff2-variations'); unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; } @@ -16,7 +17,8 @@ font-style: normal; font-display: optional; font-weight: 100 900; - src: url('@fontsource-variable/geist/files/geist-cyrillic-wght-normal.woff2') format('woff2-variations'); + src: url('@fontsource-variable/geist/files/geist-cyrillic-wght-normal.woff2') + format('woff2-variations'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; } @@ -26,10 +28,11 @@ font-style: normal; font-display: optional; font-weight: 100 900; - src: url('@fontsource-variable/geist/files/geist-vietnamese-wght-normal.woff2') format('woff2-variations'); + src: url('@fontsource-variable/geist/files/geist-vietnamese-wght-normal.woff2') + format('woff2-variations'); unicode-range: - U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, - U+0323, U+0329, U+1EA0-1EF9, U+20AB; + U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, + U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; } /* geist-latin-ext-wght-normal */ @@ -38,10 +41,12 @@ font-style: normal; font-display: optional; font-weight: 100 900; - src: url('@fontsource-variable/geist/files/geist-latin-ext-wght-normal.woff2') format('woff2-variations'); + src: url('@fontsource-variable/geist/files/geist-latin-ext-wght-normal.woff2') + format('woff2-variations'); unicode-range: - U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, - U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; + U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, + U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, + U+A720-A7FF; } /* geist-latin-wght-normal */ @@ -50,10 +55,11 @@ font-style: normal; font-display: optional; font-weight: 100 900; - src: url('@fontsource-variable/geist/files/geist-latin-wght-normal.woff2') format('woff2-variations'); + src: url('@fontsource-variable/geist/files/geist-latin-wght-normal.woff2') + format('woff2-variations'); unicode-range: - U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, - U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; + U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, + U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; } /* geist-mono-cyrillic-ext-wght-normal */ @@ -62,7 +68,8 @@ font-style: normal; font-display: optional; font-weight: 100 900; - src: url('@fontsource-variable/geist-mono/files/geist-mono-cyrillic-ext-wght-normal.woff2') format('woff2-variations'); + src: url('@fontsource-variable/geist-mono/files/geist-mono-cyrillic-ext-wght-normal.woff2') + format('woff2-variations'); unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; } @@ -72,7 +79,8 @@ font-style: normal; font-display: optional; font-weight: 100 900; - src: url('@fontsource-variable/geist-mono/files/geist-mono-cyrillic-wght-normal.woff2') format('woff2-variations'); + src: url('@fontsource-variable/geist-mono/files/geist-mono-cyrillic-wght-normal.woff2') + format('woff2-variations'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; } @@ -82,7 +90,8 @@ font-style: normal; font-display: optional; font-weight: 100 900; - src: url('@fontsource-variable/geist-mono/files/geist-mono-symbols2-wght-normal.woff2') format('woff2-variations'); + src: url('@fontsource-variable/geist-mono/files/geist-mono-symbols2-wght-normal.woff2') + format('woff2-variations'); unicode-range: U+2000-2001, U+2004-2008, U+200A, U+23B8-23BD, U+2500-259F; } @@ -92,10 +101,11 @@ font-style: normal; font-display: optional; font-weight: 100 900; - src: url('@fontsource-variable/geist-mono/files/geist-mono-vietnamese-wght-normal.woff2') format('woff2-variations'); + src: url('@fontsource-variable/geist-mono/files/geist-mono-vietnamese-wght-normal.woff2') + format('woff2-variations'); unicode-range: - U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, - U+0323, U+0329, U+1EA0-1EF9, U+20AB; + U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, + U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; } /* geist-mono-latin-ext-wght-normal */ @@ -104,10 +114,12 @@ font-style: normal; font-display: optional; font-weight: 100 900; - src: url('@fontsource-variable/geist-mono/files/geist-mono-latin-ext-wght-normal.woff2') format('woff2-variations'); + src: url('@fontsource-variable/geist-mono/files/geist-mono-latin-ext-wght-normal.woff2') + format('woff2-variations'); unicode-range: - U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, - U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; + U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, + U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, + U+A720-A7FF; } /* geist-mono-latin-wght-normal */ @@ -116,10 +128,11 @@ font-style: normal; font-display: optional; font-weight: 100 900; - src: url('@fontsource-variable/geist-mono/files/geist-mono-latin-wght-normal.woff2') format('woff2-variations'); + src: url('@fontsource-variable/geist-mono/files/geist-mono-latin-wght-normal.woff2') + format('woff2-variations'); unicode-range: - U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, - U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; + U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, + U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; } /* instrument-serif-latin-ext-400-normal */ @@ -129,11 +142,14 @@ font-display: optional; font-weight: 400; src: - url('@fontsource/instrument-serif/files/instrument-serif-latin-ext-400-normal.woff2') format('woff2'), - url('@fontsource/instrument-serif/files/instrument-serif-latin-ext-400-normal.woff') format('woff'); + url('@fontsource/instrument-serif/files/instrument-serif-latin-ext-400-normal.woff2') + format('woff2'), + url('@fontsource/instrument-serif/files/instrument-serif-latin-ext-400-normal.woff') + format('woff'); unicode-range: - U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, - U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; + U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, + U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, + U+A720-A7FF; } /* instrument-serif-latin-400-normal */ @@ -143,11 +159,12 @@ font-display: optional; font-weight: 400; src: - url('@fontsource/instrument-serif/files/instrument-serif-latin-400-normal.woff2') format('woff2'), + url('@fontsource/instrument-serif/files/instrument-serif-latin-400-normal.woff2') + format('woff2'), url('@fontsource/instrument-serif/files/instrument-serif-latin-400-normal.woff') format('woff'); unicode-range: - U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, - U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; + U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, + U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; } /* instrument-serif-latin-ext-400-italic */ @@ -157,11 +174,14 @@ font-display: optional; font-weight: 400; src: - url('@fontsource/instrument-serif/files/instrument-serif-latin-ext-400-italic.woff2') format('woff2'), - url('@fontsource/instrument-serif/files/instrument-serif-latin-ext-400-italic.woff') format('woff'); + url('@fontsource/instrument-serif/files/instrument-serif-latin-ext-400-italic.woff2') + format('woff2'), + url('@fontsource/instrument-serif/files/instrument-serif-latin-ext-400-italic.woff') + format('woff'); unicode-range: - U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, - U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; + U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, + U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, + U+A720-A7FF; } /* instrument-serif-latin-400-italic */ @@ -171,9 +191,10 @@ font-display: optional; font-weight: 400; src: - url('@fontsource/instrument-serif/files/instrument-serif-latin-400-italic.woff2') format('woff2'), + url('@fontsource/instrument-serif/files/instrument-serif-latin-400-italic.woff2') + format('woff2'), url('@fontsource/instrument-serif/files/instrument-serif-latin-400-italic.woff') format('woff'); unicode-range: - U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, - U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; + U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, + U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; } diff --git a/docs/app/components/ComponentApi.vue b/docs/app/components/ComponentApi.vue index 6c5dd18..872e091 100644 --- a/docs/app/components/ComponentApi.vue +++ b/docs/app/components/ComponentApi.vue @@ -15,10 +15,14 @@ const { t } = useI18n() modelValue - {{ doc.model.type }} + {{ doc.model.type }} {{ t('components.required') }} - {{ t('components.default') }} {{ doc.model.default }} + {{ t('components.default') }} {{ doc.model.default }} {{ doc.model.description }} @@ -34,7 +38,9 @@ const { t } = useI18n() :key="prop.name" > {{ prop.name }} - {{ prop.type }} + {{ prop.type }} {{ t('components.required') }} {{ t('components.default') }} {{ prop.default }} @@ -53,7 +59,9 @@ const { t } = useI18n() :key="event.name" > {{ event.name }} - {{ event.payload }} + {{ event.payload }} {{ event.description }} diff --git a/docs/app/components/ComponentStatus.vue b/docs/app/components/ComponentStatus.vue index 4577d54..4623818 100644 --- a/docs/app/components/ComponentStatus.vue +++ b/docs/app/components/ComponentStatus.vue @@ -1,13 +1,13 @@ - + diff --git a/src/components/display/Table.vue b/src/components/display/Table.vue index 5363edd..52df54d 100644 --- a/src/components/display/Table.vue +++ b/src/components/display/Table.vue @@ -10,7 +10,7 @@ defineProps<{ }>() defineSlots<{ header?: (scope: { column: TableColumn }) => unknown - cell?: (scope: { row: T, column: TableColumn, value: T[keyof T], index: number }) => unknown + cell?: (scope: { row: T; column: TableColumn; value: T[keyof T]; index: number }) => unknown empty?: () => unknown }>() diff --git a/src/components/display/Table.zh.md b/src/components/display/Table.zh.md index 628cabb..2c3e392 100644 --- a/src/components/display/Table.zh.md +++ b/src/components/display/Table.zh.md @@ -48,9 +48,7 @@ interface DocumentRow { status: string } -const rows: DocumentRow[] = [ - { id: 'one', title: 'Tokens and typography', status: 'Published' }, -] +const rows: DocumentRow[] = [{ id: 'one', title: 'Tokens and typography', status: 'Published' }] const columns: TableColumn[] = [ { key: 'title', label: 'Document' }, { key: 'status', label: 'Status', align: 'end' }, @@ -73,9 +71,7 @@ const columns: TableColumn[] = [ {{ value }} - + diff --git a/src/components/feedback/Alert.vue b/src/components/feedback/Alert.vue index a8b0057..9605367 100644 --- a/src/components/feedback/Alert.vue +++ b/src/components/feedback/Alert.vue @@ -1,16 +1,25 @@ diff --git a/src/components/feedback/Progress.md b/src/components/feedback/Progress.md index 9f6d4e3..fc49175 100644 --- a/src/components/feedback/Progress.md +++ b/src/components/feedback/Progress.md @@ -12,7 +12,7 @@ props: description: Current progress. Omit it or pass a non-finite number for indeterminate progress; finite values are clamped between zero and max. - name: max type: number - default: "100" + default: '100' description: Upper bound for progress. Non-finite or non-positive values fall back to 100. --- diff --git a/src/components/feedback/Progress.vue b/src/components/feedback/Progress.vue index 4847f9c..a01897e 100644 --- a/src/components/feedback/Progress.vue +++ b/src/components/feedback/Progress.vue @@ -1,15 +1,20 @@ diff --git a/src/components/field/FormField.demo.vue b/src/components/field/FormField.demo.vue index 733957e..d779af2 100644 --- a/src/components/field/FormField.demo.vue +++ b/src/components/field/FormField.demo.vue @@ -4,7 +4,9 @@ import FormField from './FormField.vue' const value = ref('') const touched = ref(false) -const error = computed(() => touched.value && !value.value.trim() ? 'Enter a document title.' : undefined) +const error = computed(() => + touched.value && !value.value.trim() ? 'Enter a document title.' : undefined, +) diff --git a/src/components/field/FormField.md b/src/components/field/FormField.md index bd0fb3e..a1546ce 100644 --- a/src/components/field/FormField.md +++ b/src/components/field/FormField.md @@ -18,7 +18,7 @@ props: description: Consumer-provided error text; a nonempty value marks the control invalid. - name: required type: boolean - default: "false" + default: 'false' description: Visible required marker and native/ARIA required control props. slots: - name: default @@ -58,7 +58,7 @@ const error = ref() class="ui-field-control" type="text" name="title" - > + /> diff --git a/src/components/field/FormField.vue b/src/components/field/FormField.vue index edb0058..d42b1ae 100644 --- a/src/components/field/FormField.vue +++ b/src/components/field/FormField.vue @@ -2,13 +2,16 @@ import type { FieldControlProps } from '../../vue' import { computed, useId } from 'vue' -const props = withDefaults(defineProps<{ - label: string - id?: string - description?: string - error?: string - required?: boolean -}>(), { required: false }) +const props = withDefaults( + defineProps<{ + label: string + id?: string + description?: string + error?: string + required?: boolean + }>(), + { required: false }, +) defineSlots<{ default?: (scope: { controlProps: FieldControlProps }) => unknown }>() const generated = useId() const controlId = computed(() => props.id ?? generated) @@ -19,7 +22,10 @@ const controlProps = computed(() => ({ 'id': controlId.value, 'required': props.required, 'aria-labelledby': labelId.value, - 'aria-describedby': [props.description ? descriptionId.value : '', props.error ? errorId.value : ''].filter(Boolean).join(' ') || undefined, + 'aria-describedby': + [props.description ? descriptionId.value : '', props.error ? errorId.value : ''] + .filter(Boolean) + .join(' ') || undefined, 'aria-invalid': props.error ? true : undefined, 'aria-required': props.required ? true : undefined, })) @@ -36,7 +42,8 @@ const controlProps = computed(() => ({ + >*

() class="ui-field-control" type="text" name="title" - > + /> diff --git a/src/components/field/NumberInput.vue b/src/components/field/NumberInput.vue index 34a1f76..c32f759 100644 --- a/src/components/field/NumberInput.vue +++ b/src/components/field/NumberInput.vue @@ -10,7 +10,9 @@ defineProps<{ step?: number | 'any' }>() const model = defineModel() -const value = computed(() => model.value !== undefined && Number.isFinite(model.value) ? model.value : '') +const value = computed(() => + model.value !== undefined && Number.isFinite(model.value) ? model.value : '', +) const { wrapperAttrs, controlAttrs } = useControlAttrs() function update(event: Event): void { const next = (event.currentTarget as HTMLInputElement).valueAsNumber @@ -33,6 +35,6 @@ function update(event: Event): void { :max="max" :step="step" @input="update" - > + /> diff --git a/src/components/field/Slider.demo.vue b/src/components/field/Slider.demo.vue index a9e055b..2f0c48c 100644 --- a/src/components/field/Slider.demo.vue +++ b/src/components/field/Slider.demo.vue @@ -13,7 +13,5 @@ const value = ref(40) :step="5" :aria-valuetext="`${value} percent`" /> -

- {{ value }}% -

+

{{ value }}%

diff --git a/src/components/field/Slider.md b/src/components/field/Slider.md index 22951a8..8a8dfac 100644 --- a/src/components/field/Slider.md +++ b/src/components/field/Slider.md @@ -4,7 +4,7 @@ designStatus: ai-draft description: A labeled native single-thumb range input. model: type: number - default: "50" + default: '50' description: The controlled slider value. Displayed values are clamped to the normalized bounds. props: - name: label @@ -13,15 +13,15 @@ props: description: Visible text label for the range input. - name: min type: number - default: "0" + default: '0' description: Minimum bound. A non-finite value falls back to zero. - name: max type: number - default: "100" + default: '100' description: Maximum bound. A non-finite value falls back to the greater of min and 100; a finite value below min is normalized to min. - name: step type: number | 'any' - default: "1" + default: '1' description: Native range step. A non-finite or non-positive number falls back to 1; any disables step granularity. --- diff --git a/src/components/field/Slider.vue b/src/components/field/Slider.vue index 4c2486c..6619b20 100644 --- a/src/components/field/Slider.vue +++ b/src/components/field/Slider.vue @@ -3,24 +3,32 @@ import { computed } from 'vue' import { useControlAttrs } from '../../vue' defineOptions({ inheritAttrs: false }) -const props = withDefaults(defineProps<{ - label: string - min?: number - max?: number - step?: number | 'any' -}>(), { min: 0, max: 100, step: 1 }) +const props = withDefaults( + defineProps<{ + label: string + min?: number + max?: number + step?: number | 'any' + }>(), + { min: 0, max: 100, step: 1 }, +) const model = defineModel({ default: 50 }) const { wrapperAttrs, controlAttrs } = useControlAttrs() -const minimum = computed(() => Number.isFinite(props.min) ? props.min : 0) -const maximum = computed(() => Number.isFinite(props.max) ? Math.max(minimum.value, props.max) : Math.max(minimum.value, 100)) -const increment = computed(() => props.step === 'any' ? 'any' : Number.isFinite(props.step) && props.step > 0 ? props.step : 1) -const value = computed(() => Number.isFinite(model.value) - ? Math.min(maximum.value, Math.max(minimum.value, model.value)) - : minimum.value / 2 + maximum.value / 2) +const minimum = computed(() => (Number.isFinite(props.min) ? props.min : 0)) +const maximum = computed(() => + Number.isFinite(props.max) ? Math.max(minimum.value, props.max) : Math.max(minimum.value, 100), +) +const increment = computed(() => + props.step === 'any' ? 'any' : Number.isFinite(props.step) && props.step > 0 ? props.step : 1, +) +const value = computed(() => + Number.isFinite(model.value) + ? Math.min(maximum.value, Math.max(minimum.value, model.value)) + : minimum.value / 2 + maximum.value / 2, +) function update(event: Event): void { const next = (event.currentTarget as HTMLInputElement).valueAsNumber - if (Number.isFinite(next)) - model.value = next + if (Number.isFinite(next)) model.value = next } @@ -39,6 +47,6 @@ function update(event: Event): void { :max="maximum" :step="increment" @input="update" - > + /> diff --git a/src/components/field/Slider.zh.md b/src/components/field/Slider.zh.md index bb3ac5f..22de924 100644 --- a/src/components/field/Slider.zh.md +++ b/src/components/field/Slider.zh.md @@ -4,7 +4,7 @@ designStatus: ai-draft description: 带可见标签的原生单滑块范围输入。 model: type: number - default: "50" + default: '50' description: 受控滑块值;显示值会限制在规范化后的上下界内。 props: - name: label @@ -13,15 +13,15 @@ props: description: 范围输入的可见文本标签。 - name: min type: number - default: "0" + default: '0' description: 最小值。非有限数值会回退为 0。 - name: max type: number - default: "100" + default: '100' description: 最大值。非有限数值回退为 max(min, 100);有限且小于 min 的值会规范化为 min。 - name: step type: number | 'any' - default: "1" + default: '1' description: 原生范围输入步长。非有限或非正数值回退为 1;any 表示不限制步进粒度。 --- diff --git a/src/components/field/TextArea.md b/src/components/field/TextArea.md index 7219e64..8c39394 100644 --- a/src/components/field/TextArea.md +++ b/src/components/field/TextArea.md @@ -13,7 +13,7 @@ props: description: Visible text label for the textarea. - name: rows type: number - default: "3" + default: '3' description: Number of visible text rows. --- diff --git a/src/components/field/TextArea.vue b/src/components/field/TextArea.vue index 9808922..9296514 100644 --- a/src/components/field/TextArea.vue +++ b/src/components/field/TextArea.vue @@ -3,12 +3,15 @@ import { useControlAttrs } from '../../vue' defineOptions({ inheritAttrs: false }) -withDefaults(defineProps<{ - label: string - rows?: number -}>(), { - rows: 3, -}) +withDefaults( + defineProps<{ + label: string + rows?: number + }>(), + { + rows: 3, + }, +) const model = defineModel({ default: '' }) const { wrapperAttrs, controlAttrs } = useControlAttrs() diff --git a/src/components/field/TextArea.zh.md b/src/components/field/TextArea.zh.md index c896a08..df75a4d 100644 --- a/src/components/field/TextArea.zh.md +++ b/src/components/field/TextArea.zh.md @@ -13,7 +13,7 @@ props: description: 文本框上显示的文字标签。 - name: rows type: number - default: "3" + default: '3' description: 可见文本行数。 --- diff --git a/src/components/field/TextInput.vue b/src/components/field/TextInput.vue index 9689943..7b537bb 100644 --- a/src/components/field/TextInput.vue +++ b/src/components/field/TextInput.vue @@ -3,12 +3,15 @@ import { useControlAttrs } from '../../vue' defineOptions({ inheritAttrs: false }) -withDefaults(defineProps<{ - label: string - type?: 'text' | 'email' | 'search' -}>(), { - type: 'text', -}) +withDefaults( + defineProps<{ + label: string + type?: 'text' | 'email' | 'search' + }>(), + { + type: 'text', + }, +) const model = defineModel({ default: '' }) const { wrapperAttrs, controlAttrs } = useControlAttrs() @@ -25,6 +28,6 @@ const { wrapperAttrs, controlAttrs } = useControlAttrs() v-model="model" class="ui-field-control" :type="type" - > + /> diff --git a/src/components/navigation/Breadcrumb.vue b/src/components/navigation/Breadcrumb.vue index 42c8bf0..f31861e 100644 --- a/src/components/navigation/Breadcrumb.vue +++ b/src/components/navigation/Breadcrumb.vue @@ -8,7 +8,7 @@ const props = defineProps<{ current?: string }>() defineSlots<{ - link?: (scope: { item: NavigationItem, props: BreadcrumbLinkProps }) => unknown + link?: (scope: { item: NavigationItem; props: BreadcrumbLinkProps }) => unknown }>() const currentValue = computed(() => props.current ?? props.items.at(-1)?.value) function linkProps(item: NavigationItem): BreadcrumbLinkProps { @@ -38,7 +38,8 @@ function linkProps(item: NavigationItem): BreadcrumbLinkProps { v-if="index" class="ui-breadcrumb-separator" aria-hidden="true" - >/ + >/ {{ item.label }} + >{{ item.label }} diff --git a/src/components/navigation/Navigation.vue b/src/components/navigation/Navigation.vue index 5935933..2958581 100644 --- a/src/components/navigation/Navigation.vue +++ b/src/components/navigation/Navigation.vue @@ -2,12 +2,15 @@ import type { NavigationItem, NavigationLinkProps } from '../../vue' import { useNavigation } from '../../vue' -const props = withDefaults(defineProps<{ - items: NavigationItem[] - current?: 'page' | 'location' -}>(), { current: 'page' }) +const props = withDefaults( + defineProps<{ + items: NavigationItem[] + current?: 'page' | 'location' + }>(), + { current: 'page' }, +) defineSlots<{ - link?: (scope: { item: NavigationItem, props: NavigationLinkProps }) => unknown + link?: (scope: { item: NavigationItem; props: NavigationLinkProps }) => unknown }>() const model = defineModel({ default: '' }) const { isActive, activate } = useNavigation(model) diff --git a/src/components/navigation/Pagination.demo.vue b/src/components/navigation/Pagination.demo.vue index 0a531a6..ce621cd 100644 --- a/src/components/navigation/Pagination.demo.vue +++ b/src/components/navigation/Pagination.demo.vue @@ -15,8 +15,6 @@ const page = ref(4) next-label="Next" :page-label="value => `Page ${value}`" /> -

- Current page: {{ page }} -

+

Current page: {{ page }}

diff --git a/src/components/navigation/Pagination.vue b/src/components/navigation/Pagination.vue index 920390a..2c7d4d3 100644 --- a/src/components/navigation/Pagination.vue +++ b/src/components/navigation/Pagination.vue @@ -3,18 +3,26 @@ import type { PaginationControlProps } from '../../vue' import { computed } from 'vue' import { currentPage, pageCount, paginationEntries } from '../../core' -const props = withDefaults(defineProps<{ - label: string - pages: number - previousLabel: string - nextLabel: string - pageLabel: (page: number) => string - siblingCount?: number - disabled?: boolean - href?: (page: number) => string -}>(), { siblingCount: 1, disabled: false }) +const props = withDefaults( + defineProps<{ + label: string + pages: number + previousLabel: string + nextLabel: string + pageLabel: (page: number) => string + siblingCount?: number + disabled?: boolean + href?: (page: number) => string + }>(), + { siblingCount: 1, disabled: false }, +) defineSlots<{ - control?: (scope: { page: number, kind: 'page' | 'previous' | 'next', tag: 'a' | 'button', props: PaginationControlProps }) => unknown + control?: (scope: { + page: number + kind: 'page' | 'previous' | 'next' + tag: 'a' | 'button' + props: PaginationControlProps + }) => unknown }>() const model = defineModel({ default: 1 }) const count = computed(() => pageCount(props.pages)) @@ -23,14 +31,14 @@ const entries = computed(() => paginationEntries(current.value, count.value, pro const previous = computed(() => Math.max(1, current.value - 1)) const next = computed(() => Math.min(Math.max(1, count.value), current.value + 1)) -function disabled(page: number, kind: 'page' | 'previous' | 'next'): boolean { +function isDisabled(page: number, kind: 'page' | 'previous' | 'next'): boolean { return props.disabled || !count.value || (kind !== 'page' && page === current.value) } function tag(page: number, kind: 'page' | 'previous' | 'next'): 'a' | 'button' { - return props.href && !disabled(page, kind) ? 'a' : 'button' + return props.href && !isDisabled(page, kind) ? 'a' : 'button' } function controlProps(page: number, kind: 'page' | 'previous' | 'next'): PaginationControlProps { - const blocked = disabled(page, kind) + const blocked = isDisabled(page, kind) const isLink = tag(page, kind) === 'a' return { 'class': 'ui-pagination-control', @@ -38,14 +46,23 @@ function controlProps(page: number, kind: 'page' | 'previous' | 'next'): Paginat 'href': isLink ? props.href?.(page) : undefined, 'disabled': blocked || undefined, 'aria-disabled': blocked || undefined, - 'aria-label': kind === 'previous' ? props.previousLabel : kind === 'next' ? props.nextLabel : props.pageLabel(page), + 'aria-label': + kind === 'previous' + ? props.previousLabel + : kind === 'next' + ? props.nextLabel + : props.pageLabel(page), 'aria-current': kind === 'page' && page === current.value ? 'page' : undefined, - 'onClick': (event) => { + 'onClick': event => { if (blocked) { event.preventDefault() return } - if (event.defaultPrevented || (isLink && (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey))) + if ( + event.defaultPrevented || + (isLink && + (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)) + ) return model.value = page }, @@ -86,7 +103,8 @@ function controlProps(page: number, kind: 'page' | 'previous' | 'next'): Paginat v-if="typeof entry !== 'number'" class="ui-pagination-gap" aria-hidden="true" - >… + >…

Delete the current draft?

-

- Deletion confirmed in this example; no request was sent. -

+

Deletion confirmed in this example; no request was sent.

``` diff --git a/src/components/overlay/AlertDialog.vue b/src/components/overlay/AlertDialog.vue index 37cbe71..1041bf5 100644 --- a/src/components/overlay/AlertDialog.vue +++ b/src/components/overlay/AlertDialog.vue @@ -14,17 +14,20 @@ import { usePortalTarget } from '../../vue' import Button from '../button/Button.vue' defineOptions({ inheritAttrs: false }) -const props = withDefaults(defineProps<{ - title: string - description: string - cancelLabel: string - confirmLabel: string - triggerLabel?: string - disabled?: boolean - pending?: boolean - confirmDisabled?: boolean - portalTo?: string | HTMLElement -}>(), { disabled: false, pending: false, confirmDisabled: false }) +const props = withDefaults( + defineProps<{ + title: string + description: string + cancelLabel: string + confirmLabel: string + triggerLabel?: string + disabled?: boolean + pending?: boolean + confirmDisabled?: boolean + portalTo?: string | HTMLElement + }>(), + { disabled: false, pending: false, confirmDisabled: false }, +) const emit = defineEmits<{ confirm: [event: MouseEvent] }>() defineSlots<{ trigger?: () => unknown @@ -35,11 +38,9 @@ const slots = useSlots() const scope = useTemplateRef('scope') const target = usePortalTarget(scope) function confirm(event: MouseEvent) { - if (props.pending || props.confirmDisabled) - return + if (props.pending || props.confirmDisabled) return emit('confirm', event) - if (!event.defaultPrevented) - model.value = false + if (!event.defaultPrevented) model.value = false } diff --git a/src/components/overlay/AlertDialog.zh.md b/src/components/overlay/AlertDialog.zh.md index ae3ac65..6487f36 100644 --- a/src/components/overlay/AlertDialog.zh.md +++ b/src/components/overlay/AlertDialog.zh.md @@ -4,7 +4,7 @@ designStatus: ai-draft description: 提供明确确认和取消操作的模态确认对话框。 model: type: boolean - default: "false" + default: 'false' description: 对话框是否打开,支持 v-model。 props: - name: title @@ -28,15 +28,15 @@ props: description: 未提供 trigger 插槽时的触发按钮文案,默认使用 title。 - name: disabled type: boolean - default: "false" + default: 'false' description: 只禁用触发按钮。父组件仍可通过模型打开对话框。 - name: pending type: boolean - default: "false" + default: 'false' description: 禁用确认操作并在内容上设置 aria-busy;取消和 Escape 仍可用。 - name: confirmDisabled type: boolean - default: "false" + default: 'false' description: 独立于 pending 禁用确认按钮。 - name: portalTo type: string | HTMLElement @@ -93,9 +93,7 @@ function confirm() {

确定删除当前草稿吗?

-

- 此示例已确认删除意图,没有发送请求。 -

+

此示例已确认删除意图,没有发送请求。

``` diff --git a/src/components/overlay/ContextMenu.demo.vue b/src/components/overlay/ContextMenu.demo.vue index 45f5092..54da228 100644 --- a/src/components/overlay/ContextMenu.demo.vue +++ b/src/components/overlay/ContextMenu.demo.vue @@ -14,9 +14,7 @@ const menu = useTemplateRef<{ close: () => void }>('menu') v-model="disabled" label="Disable context menu" /> - + -
- Right-click or focus this region and press Shift+F10. -
+
Right-click or focus this region and press Shift+F10.
diff --git a/src/components/overlay/ContextMenu.vue b/src/components/overlay/ContextMenu.vue index e91baf3..c2079c1 100644 --- a/src/components/overlay/ContextMenu.vue +++ b/src/components/overlay/ContextMenu.vue @@ -7,16 +7,19 @@ import ContextMenuState from './_internal/ContextMenuState.vue' import MenuItems from './_internal/MenuItems.vue' defineOptions({ inheritAttrs: false }) -const props = withDefaults(defineProps<{ - label: string - items: MenuItem[] - disabled?: boolean - modal?: boolean - dir?: 'ltr' | 'rtl' - portalTo?: string | HTMLElement -}>(), { disabled: false, modal: true }) -const emit = defineEmits<{ select: [item: MenuItem, event: Event], openChange: [open: boolean] }>() -defineSlots<{ default: () => unknown, item?: (scope: { item: MenuItem }) => unknown }>() +const props = withDefaults( + defineProps<{ + label: string + items: MenuItem[] + disabled?: boolean + modal?: boolean + dir?: 'ltr' | 'rtl' + portalTo?: string | HTMLElement + }>(), + { disabled: false, modal: true }, +) +const emit = defineEmits<{ select: [item: MenuItem, event: Event]; openChange: [open: boolean] }>() +defineSlots<{ default: () => unknown; item?: (scope: { item: MenuItem }) => unknown }>() const open = ref(false) const scope = useTemplateRef('scope') const target = usePortalTarget(scope) @@ -30,20 +33,24 @@ function openChange(value: boolean) { emit('openChange', value) } function keyboard(event: KeyboardEvent) { - if (props.disabled || event.defaultPrevented || event.target !== event.currentTarget) - return - if (event.key !== 'ContextMenu' && !(event.key === 'F10' && event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey)) + if (props.disabled || event.defaultPrevented || event.target !== event.currentTarget) return + if ( + event.key !== 'ContextMenu' && + !(event.key === 'F10' && event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey) + ) return event.preventDefault() const element = event.currentTarget as HTMLElement const rect = element.getBoundingClientRect() - element.dispatchEvent(new MouseEvent('contextmenu', { - bubbles: true, - cancelable: true, - clientX: rect.left + rect.width / 2, - clientY: rect.top + rect.height / 2, - button: 2, - })) + element.dispatchEvent( + new MouseEvent('contextmenu', { + bubbles: true, + cancelable: true, + clientX: rect.left + rect.width / 2, + clientY: rect.top + rect.height / 2, + button: 2, + }), + ) } diff --git a/src/components/overlay/ContextMenu.zh.md b/src/components/overlay/ContextMenu.zh.md index e41e469..1885c01 100644 --- a/src/components/overlay/ContextMenu.zh.md +++ b/src/components/overlay/ContextMenu.zh.md @@ -13,17 +13,17 @@ props: description: 菜单项,可含禁用项、分隔符和嵌套子菜单。 - name: disabled type: boolean - default: "false" + default: 'false' description: 禁止在目标上打开菜单,但不禁用目标内的子内容。 - name: modal type: boolean - default: "true" + default: 'true' description: 打开菜单时是否限制外部交互。 - name: dir type: "'ltr' | 'rtl'" description: 菜单文字和键盘方向;默认沿用 Reka UI 方向上下文,无上下文时为 ltr。 - name: portalTo - type: "string | HTMLElement" + type: 'string | HTMLElement' description: Teleport 目标。默认使用最近的消费者 class 为 ui 的元素;找不到时以内联方式渲染。 events: - name: openChange @@ -92,9 +92,7 @@ function selectItem(item: MenuItem, event: Event) { @select="selectItem" @open-change="open => console.info('菜单状态:', open)" > -
- 右键此区域,或聚焦后按 Shift+F10。 -
+
右键此区域,或聚焦后按 Shift+F10。
diff --git a/src/components/overlay/Dialog.demo.vue b/src/components/overlay/Dialog.demo.vue index 2e9785a..d588fa8 100644 --- a/src/components/overlay/Dialog.demo.vue +++ b/src/components/overlay/Dialog.demo.vue @@ -29,9 +29,7 @@ function inspect(event: MouseEvent, document: string) { label="Document name" />
diff --git a/src/components/overlay/Dialog.md b/src/components/overlay/Dialog.md index ee7af6d..3db4c60 100644 --- a/src/components/overlay/Dialog.md +++ b/src/components/overlay/Dialog.md @@ -4,7 +4,7 @@ designStatus: ai-draft description: A modal dialog with controlled open state and configurable dismissal. model: type: boolean - default: "false" + default: 'false' description: Whether the dialog is open. props: - name: title @@ -24,25 +24,25 @@ props: description: Trigger text when no trigger slot is provided; defaults to title. - name: showTrigger type: boolean - default: "true" + default: 'true' description: Render the built-in trigger and trigger slot. When false, neither is rendered. - name: returnFocus type: HTMLElement description: Optional focusable element to receive focus when the dialog closes; takes precedence over the captured opener. - name: disabled type: boolean - default: "false" + default: 'false' description: Disable the trigger. A parent can still open the dialog through the model. - name: dismissible type: boolean - default: "true" + default: 'true' description: Show the built-in close button and allow Escape or outside dismissal. - name: closeOnOutside type: boolean - default: "true" + default: 'true' description: Allow outside interaction to close the dialog when dismissible is true. - name: portalTo - type: "string | HTMLElement" + type: 'string | HTMLElement' description: Teleport destination. Defaults to the nearest ancestor with class ui; without one, content renders inline on the client. slots: - name: trigger diff --git a/src/components/overlay/Dialog.vue b/src/components/overlay/Dialog.vue index 0313cb0..1415038 100644 --- a/src/components/overlay/Dialog.vue +++ b/src/components/overlay/Dialog.vue @@ -13,19 +13,22 @@ import { useSlots, useTemplateRef } from 'vue' import { useFocusReturn, usePortalTarget } from '../../vue' defineOptions({ inheritAttrs: false }) -const props = withDefaults(defineProps<{ - title: string - closeLabel: string - description?: string - triggerLabel?: string - showTrigger?: boolean - returnFocus?: HTMLElement - disabled?: boolean - dismissible?: boolean - closeOnOutside?: boolean - portalTo?: string | HTMLElement -}>(), { showTrigger: true, disabled: false, dismissible: true, closeOnOutside: true }) -const emit = defineEmits<{ openAutoFocus: [event: Event], closeAutoFocus: [event: Event] }>() +const props = withDefaults( + defineProps<{ + title: string + closeLabel: string + description?: string + triggerLabel?: string + showTrigger?: boolean + returnFocus?: HTMLElement + disabled?: boolean + dismissible?: boolean + closeOnOutside?: boolean + portalTo?: string | HTMLElement + }>(), + { showTrigger: true, disabled: false, dismissible: true, closeOnOutside: true }, +) +const emit = defineEmits<{ openAutoFocus: [event: Event]; closeAutoFocus: [event: Event] }>() defineSlots<{ trigger?: () => unknown default?: (scope: { close: () => void }) => unknown @@ -35,7 +38,11 @@ const model = defineModel({ default: false }) const slots = useSlots() const scope = useTemplateRef('scope') const target = usePortalTarget(scope) -const focusReturn = useFocusReturn(model, () => props.returnFocus, () => !props.showTrigger) +const focusReturn = useFocusReturn( + model, + () => props.returnFocus, + () => !props.showTrigger, +) function opening(event: Event) { focusReturn.capture(event) emit('openAutoFocus', event) @@ -48,8 +55,7 @@ function close() { model.value = false } function outside(event: Event) { - if (!props.dismissible || !props.closeOnOutside) - event.preventDefault() + if (!props.dismissible || !props.closeOnOutside) event.preventDefault() } diff --git a/src/components/overlay/Dialog.zh.md b/src/components/overlay/Dialog.zh.md index 23de488..581defa 100644 --- a/src/components/overlay/Dialog.zh.md +++ b/src/components/overlay/Dialog.zh.md @@ -4,7 +4,7 @@ designStatus: ai-draft description: 受控开关并可配置关闭方式的模态对话框。 model: type: boolean - default: "false" + default: 'false' description: 对话框是否打开。 props: - name: title @@ -24,25 +24,25 @@ props: description: 未提供 trigger 插槽时显示的触发按钮文字,默认使用 title。 - name: showTrigger type: boolean - default: "true" + default: 'true' description: 是否渲染内置触发器及 trigger 插槽;为 false 时两者都不渲染。 - name: returnFocus type: HTMLElement description: 关闭后接收焦点的可选可聚焦元素,优先于捕获到的打开前焦点。 - name: disabled type: boolean - default: "false" + default: 'false' description: 禁用触发按钮;父组件仍可通过模型打开对话框。 - name: dismissible type: boolean - default: "true" + default: 'true' description: 是否显示内置关闭按钮并允许 Escape 或点击外部关闭。 - name: closeOnOutside type: boolean - default: "true" + default: 'true' description: dismissible 为 true 时,是否允许外部交互关闭对话框。 - name: portalTo - type: "string | HTMLElement" + type: 'string | HTMLElement' description: Teleport 目标。默认使用最近的 ui 类祖先;找不到时客户端内联渲染。 slots: - name: trigger diff --git a/src/components/overlay/Drawer.demo.vue b/src/components/overlay/Drawer.demo.vue index 1153a64..e280553 100644 --- a/src/components/overlay/Drawer.demo.vue +++ b/src/components/overlay/Drawer.demo.vue @@ -12,9 +12,7 @@ import Drawer from './Drawer.vue' >

Metadata and document actions stay in the caller.

diff --git a/src/components/overlay/Drawer.md b/src/components/overlay/Drawer.md index fc69625..2e41a2c 100644 --- a/src/components/overlay/Drawer.md +++ b/src/components/overlay/Drawer.md @@ -4,7 +4,7 @@ designStatus: ai-draft description: A dialog panel attached to the left, right, or bottom edge. model: type: boolean - default: "false" + default: 'false' description: Whether the drawer is open. props: - name: title @@ -24,25 +24,25 @@ props: description: Trigger text when no trigger slot is provided; defaults to title. - name: showTrigger type: boolean - default: "true" + default: 'true' description: Render the built-in trigger and trigger slot. When false, neither is rendered. - name: returnFocus type: HTMLElement description: Optional focusable element to receive focus when the drawer closes; takes precedence over the captured opener. - name: disabled type: boolean - default: "false" + default: 'false' description: Disable the trigger only; a parent can still open the drawer through the model. - name: dismissible type: boolean - default: "true" + default: 'true' description: Show the built-in close button and allow Escape or outside dismissal. - name: closeOnOutside type: boolean - default: "true" + default: 'true' description: Allow outside interaction to close the drawer when dismissible is true. - name: portalTo - type: "string | HTMLElement" + type: 'string | HTMLElement' description: Teleport target. Defaults to the nearest ancestor with class ui; without one, content renders inline on the client. - name: side type: "'left' | 'right' | 'bottom'" diff --git a/src/components/overlay/Drawer.vue b/src/components/overlay/Drawer.vue index 65bad6f..3f659ee 100644 --- a/src/components/overlay/Drawer.vue +++ b/src/components/overlay/Drawer.vue @@ -3,19 +3,22 @@ import { computed, useSlots } from 'vue' import Dialog from './Dialog.vue' defineOptions({ inheritAttrs: false }) -const props = withDefaults(defineProps<{ - title: string - closeLabel: string - description?: string - triggerLabel?: string - showTrigger?: boolean - returnFocus?: HTMLElement - disabled?: boolean - dismissible?: boolean - closeOnOutside?: boolean - portalTo?: string | HTMLElement - side?: 'left' | 'right' | 'bottom' -}>(), { side: 'right', showTrigger: true, disabled: false, dismissible: true, closeOnOutside: true }) +const props = withDefaults( + defineProps<{ + title: string + closeLabel: string + description?: string + triggerLabel?: string + showTrigger?: boolean + returnFocus?: HTMLElement + disabled?: boolean + dismissible?: boolean + closeOnOutside?: boolean + portalTo?: string | HTMLElement + side?: 'left' | 'right' | 'bottom' + }>(), + { side: 'right', showTrigger: true, disabled: false, dismissible: true, closeOnOutside: true }, +) defineSlots<{ trigger?: () => unknown default?: (scope: { close: () => void }) => unknown diff --git a/src/components/overlay/Drawer.zh.md b/src/components/overlay/Drawer.zh.md index 0fe6060..24d44f8 100644 --- a/src/components/overlay/Drawer.zh.md +++ b/src/components/overlay/Drawer.zh.md @@ -4,7 +4,7 @@ designStatus: ai-draft description: 固定在左、右或底部边缘的对话框面板。 model: type: boolean - default: "false" + default: 'false' description: 抽屉是否打开。 props: - name: title @@ -24,25 +24,25 @@ props: description: 未提供 trigger 插槽时的触发按钮文案,默认使用 title。 - name: showTrigger type: boolean - default: "true" + default: 'true' description: 是否渲染内置触发器及 trigger 插槽;为 false 时两者都不渲染。 - name: returnFocus type: HTMLElement description: 关闭后接收焦点的可选可聚焦元素,优先于捕获到的打开前焦点。 - name: disabled type: boolean - default: "false" + default: 'false' description: 仅禁用触发按钮;父组件仍可通过模型打开抽屉。 - name: dismissible type: boolean - default: "true" + default: 'true' description: 显示内置关闭按钮,并允许 Escape 或外部交互关闭。 - name: closeOnOutside type: boolean - default: "true" + default: 'true' description: dismissible 为 true 时,是否允许外部交互关闭抽屉。 - name: portalTo - type: "string | HTMLElement" + type: 'string | HTMLElement' description: Teleport 目标。默认使用最近的 ui 类祖先;找不到时客户端内联渲染。 - name: side type: "'left' | 'right' | 'bottom'" diff --git a/src/components/overlay/HoverCard.md b/src/components/overlay/HoverCard.md index 4e2d9b6..ed04e4d 100644 --- a/src/components/overlay/HoverCard.md +++ b/src/components/overlay/HoverCard.md @@ -4,7 +4,7 @@ designStatus: ai-draft description: A delayed, non-interactive preview for an existing link. model: type: boolean - default: "false" + default: 'false' description: Preview open state. The disabled prop suppresses the preview without rewriting this model. props: - name: label @@ -17,15 +17,15 @@ props: description: Destination for the trigger link. - name: disabled type: boolean - default: "false" + default: 'false' description: Suppresses preview opening without disabling the link or changing the model. - name: openDelay type: number - default: "700" + default: '700' description: Delay in milliseconds before opening. Finite values are clamped to zero or greater; invalid values fall back to 700. - name: closeDelay type: number - default: "300" + default: '300' description: Delay in milliseconds before closing. Finite values are clamped to zero or greater; invalid values fall back to 300. - name: side type: "'top' | 'right' | 'bottom' | 'left'" @@ -37,7 +37,7 @@ props: description: Preferred alignment against the link; collision handling may reposition the preview. - name: sideOffset type: number - default: "8" + default: '8' description: Distance in pixels between the link and preview. - name: portalTo type: string | HTMLElement diff --git a/src/components/overlay/HoverCard.vue b/src/components/overlay/HoverCard.vue index 92f5b19..77fcd91 100644 --- a/src/components/overlay/HoverCard.vue +++ b/src/components/overlay/HoverCard.vue @@ -4,31 +4,44 @@ import { computed, onBeforeUnmount, useSlots, useTemplateRef } from 'vue' import { usePortalTarget } from '../../vue' defineOptions({ inheritAttrs: false }) -const props = withDefaults(defineProps<{ - label: string - href: string - disabled?: boolean - openDelay?: number - closeDelay?: number - side?: 'top' | 'right' | 'bottom' | 'left' - align?: 'start' | 'center' | 'end' - sideOffset?: number - portalTo?: string | HTMLElement -}>(), { disabled: false, openDelay: 700, closeDelay: 300, side: 'bottom', align: 'start', sideOffset: 8 }) -defineSlots<{ trigger?: () => unknown, default: () => unknown }>() +const props = withDefaults( + defineProps<{ + label: string + href: string + disabled?: boolean + openDelay?: number + closeDelay?: number + side?: 'top' | 'right' | 'bottom' | 'left' + align?: 'start' | 'center' | 'end' + sideOffset?: number + portalTo?: string | HTMLElement + }>(), + { + disabled: false, + openDelay: 700, + closeDelay: 300, + side: 'bottom', + align: 'start', + sideOffset: 8, + }, +) +defineSlots<{ trigger?: () => unknown; default: () => unknown }>() const model = defineModel({ default: false }) const slots = useSlots() const scope = useTemplateRef('scope') const target = usePortalTarget(scope) -const openDelay = computed(() => Number.isFinite(props.openDelay) ? Math.max(0, props.openDelay) : 700) -const closeDelay = computed(() => Number.isFinite(props.closeDelay) ? Math.max(0, props.closeDelay) : 300) +const openDelay = computed(() => + Number.isFinite(props.openDelay) ? Math.max(0, props.openDelay) : 700, +) +const closeDelay = computed(() => + Number.isFinite(props.closeDelay) ? Math.max(0, props.closeDelay) : 300, +) let alive = true onBeforeUnmount(() => { alive = false }) function update(value: boolean) { - if (alive && !props.disabled) - model.value = value + if (alive && !props.disabled) model.value = value } diff --git a/src/components/overlay/HoverCard.zh.md b/src/components/overlay/HoverCard.zh.md index 63dbb1f..1a326f7 100644 --- a/src/components/overlay/HoverCard.zh.md +++ b/src/components/overlay/HoverCard.zh.md @@ -4,7 +4,7 @@ designStatus: ai-draft description: 为现有链接提供延迟显示的非交互预览。 model: type: boolean - default: "false" + default: 'false' description: 预览打开状态。disabled 会隐藏预览,但不会改写此模型。 props: - name: label @@ -17,15 +17,15 @@ props: description: 触发链接的目标地址。 - name: disabled type: boolean - default: "false" + default: 'false' description: 阻止打开预览,但不禁用链接或改变模型。 - name: openDelay type: number - default: "700" + default: '700' description: 打开前的毫秒延迟。有限值会限制为不小于零;无效值回退为 700。 - name: closeDelay type: number - default: "300" + default: '300' description: 关闭前的毫秒延迟。有限值会限制为不小于零;无效值回退为 300。 - name: side type: "'top' | 'right' | 'bottom' | 'left'" @@ -37,7 +37,7 @@ props: description: 相对链接的首选对齐方式;碰撞处理可能重新定位预览。 - name: sideOffset type: number - default: "8" + default: '8' description: 链接与预览之间的像素距离。 - name: portalTo type: string | HTMLElement diff --git a/src/components/overlay/Menu.demo.vue b/src/components/overlay/Menu.demo.vue index 64a11eb..a2c6cca 100644 --- a/src/components/overlay/Menu.demo.vue +++ b/src/components/overlay/Menu.demo.vue @@ -6,10 +6,14 @@ import Menu from './Menu.vue' const items: MenuItem[] = [ { value: 'rename', label: 'Rename' }, - { value: 'export', label: 'Export', children: [ - { value: 'markdown', label: 'Markdown' }, - { value: 'html', label: 'HTML' }, - ] }, + { + value: 'export', + label: 'Export', + children: [ + { value: 'markdown', label: 'Markdown' }, + { value: 'html', label: 'HTML' }, + ], + }, { value: 'share', label: 'Share', disabled: true }, { value: 'archive', label: 'Archive', separatorBefore: true }, ] @@ -21,7 +25,7 @@ const selected = ref('No command selected')