niuma-ui 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/README.en.md +1 -118
- package/README.md +58 -62
- package/README.zh-CN.md +128 -0
- package/dist/components/_shared/src/reka.d.ts +1 -1
- package/dist/components/_shared/src/reka.js +2 -2
- package/dist/components/avatar/src/RsAvatar.impl.js +1 -1
- package/dist/components/card/src/RsCard.impl.js +1 -1
- package/dist/components/config-provider/src/RsConfigProvider.css +1 -1
- package/dist/components/config-provider/src/RsConfigProvider.d.ts +2 -3
- package/dist/components/config-provider/src/RsConfigProvider.impl.js +20 -11
- package/dist/components/config-provider/src/RsConfigProvider.js +1 -1
- package/dist/components/context-menu/src/RsContextMenuItems.impl.js +1 -1
- package/dist/components/date-picker/src/RsDatePicker.impl.js +1 -1
- package/dist/components/dialog/src/RsConfirmDialog.impl.js +1 -1
- package/dist/components/dialog/src/RsDialog.impl.js +1 -1
- package/dist/components/drawer/src/RsDrawer.impl.js +1 -1
- package/dist/components/dropdown/src/RsDropdown.impl.js +1 -1
- package/dist/components/form/src/form-rules.js +2 -2
- package/dist/components/input/src/input-rules.js +3 -3
- package/dist/components/menu/src/RsMenuItems.impl.js +1 -1
- package/dist/components/radio/src/RsRadio.impl.js +1 -1
- package/dist/components/radio/src/RsRadioItem.impl.js +1 -1
- package/dist/components/select/src/RsSelect.impl.js +1 -1
- package/dist/components/switch/src/RsSwitch.impl.js +1 -1
- package/dist/components/tabs/src/RsTabs.impl.js +1 -1
- package/dist/components/time-picker/src/RsTimePicker.impl.js +1 -1
- package/dist/components/tooltip/src/RsTooltip.impl.js +1 -1
- package/dist/composables/createRsDialog.js +3 -3
- package/dist/composables/useRsConfig.js +2 -2
- package/dist/composables/useRsI18n.d.ts +1 -1
- package/dist/composables/useRsI18n.js +3 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -0
- package/dist/locale/interpolate.js +15 -3
- package/dist/locale/messages.d.ts +2 -0
- package/dist/locale/messages.js +3 -1
- package/dist/locale/registry-public.d.ts +1 -0
- package/dist/locale/resolve-host.d.ts +7 -0
- package/dist/locale/resolve-host.js +46 -0
- package/dist/locale/types.d.ts +2 -0
- package/dist/locale/types.js +2 -0
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,21 @@
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [2.0.2] - 2026-09-21
|
|
10
|
+
|
|
11
|
+
### 变更
|
|
12
|
+
|
|
13
|
+
- 未设 `locale` 时按本机语言选择(`navigator.languages`):`zh*` → `zh-CN`,`en*` → `en-US`,已登记语言按前缀匹配。无法识别或 SSR 回退 `zh-CN`。显式传 `locale` 的应用不受影响。
|
|
14
|
+
|
|
15
|
+
### 新增
|
|
16
|
+
|
|
17
|
+
- `t()` ICU 子集复数:`{count, plural, one {#} other {#}}`,`Intl.PluralRules`。
|
|
18
|
+
- `rsLocaleMessageKeys`:社区语言包 key 清单。说明见 `docs/locales.md`。
|
|
19
|
+
- `RsConfigProvider` 把解析后的 `dir` / `locale` 传给 Reka,Select 等浮层跟书写方向。
|
|
20
|
+
- 公开导出 `resolveDirMode`、`resolveHostLocale`。
|
|
21
|
+
- 文档站 / npm README 默认英文;中文见 `README.zh-CN.md`。
|
|
22
|
+
- RTL 像素回归:`/#/visual/rs-rtl`。
|
|
23
|
+
|
|
9
24
|
## [2.0.1] - 2026-09-21
|
|
10
25
|
|
|
11
26
|
### 变更
|
package/README.en.md
CHANGED
|
@@ -1,120 +1,3 @@
|
|
|
1
1
|
# niuma-ui
|
|
2
2
|
|
|
3
|
-
[
|
|
4
|
-
[](https://www.npmjs.com/package/niuma-ui)
|
|
5
|
-
[](https://vuejs.org/)
|
|
6
|
-
[](https://nodejs.org/)
|
|
7
|
-
|
|
8
|
-
English | [简体中文](./README.md)
|
|
9
|
-
|
|
10
|
-
Vue 3 **workbench** design system: consistent `Rs*` components, `--rs-*` tokens, and optional editor / terminal wrappers.
|
|
11
|
-
|
|
12
|
-
Built for ops consoles, database workbenches, and internal admin UIs. Marketing sites can use named imports. `npm install` pulls Monaco, CodeMirror, and xterm; named imports control the bundle.
|
|
13
|
-
|
|
14
|
-
**Status:** [Apache License 2.0](./LICENSE) since v1.0.0. Compiled ESM on npm since v1.2.0. Current line is **2.0.0**. The `1.x` branch keeps the 1.3 line.
|
|
15
|
-
|
|
16
|
-
## Features
|
|
17
|
-
|
|
18
|
-
- **Design tokens** — light / dark / system via `data-rs-theme` and CSS variables; hosts override a brand layer
|
|
19
|
-
- **Rs\* components** — Button, Form, Dialog, Table, Tree, Tabs, Anchor, and more
|
|
20
|
-
- **Tooling** — Monaco, CodeMirror, xterm (import only on routes that need them)
|
|
21
|
-
- **Accessibility** — [Reka UI](https://reka-ui.com/) underneath; apps depend only on `niuma-ui`
|
|
22
|
-
- **Vite** — `import { RsButton } from 'niuma-ui'` is enough to bundle; `niumaUiHost` is local `pnpm dev` HMR only
|
|
23
|
-
|
|
24
|
-
## Requirements
|
|
25
|
-
|
|
26
|
-
| Item | Version |
|
|
27
|
-
|------|---------|
|
|
28
|
-
| Node.js | ≥ 20 |
|
|
29
|
-
| Package manager | npm / pnpm / yarn (this repo develops with pnpm ≥ 9) |
|
|
30
|
-
| Vue | ^3.5 (`peerDependency`) |
|
|
31
|
-
| Bundler | Vite 5+ recommended; `RsMonacoEditor` needs Vite `?worker` |
|
|
32
|
-
| Styles | `import 'niuma-ui/styles.css'` (standalone CSS, no Tailwind) |
|
|
33
|
-
|
|
34
|
-
## Install
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
pnpm add niuma-ui
|
|
38
|
-
# or: npm install niuma-ui / yarn add niuma-ui
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
Prefer a range such as `^2.0.0`. Pin **2.0.0** for a bit-for-bit install. Use `niuma-ui@1` for the 1.x line.
|
|
42
|
-
|
|
43
|
-
Local `link`, Vite plugins, and bundle size: **[Consumer guide](./docs/consumers.en.md)** ([中文](./docs/consumers.md)).
|
|
44
|
-
|
|
45
|
-
## Quick start
|
|
46
|
-
|
|
47
|
-
```ts
|
|
48
|
-
// main.ts
|
|
49
|
-
import { createApp } from 'vue'
|
|
50
|
-
import 'niuma-ui/styles.css'
|
|
51
|
-
import App from './App.vue'
|
|
52
|
-
|
|
53
|
-
createApp(App).mount('#app')
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
```vue
|
|
57
|
-
<!-- App.vue -->
|
|
58
|
-
<script setup lang="ts">
|
|
59
|
-
import { RsConfigProvider, RsButton } from 'niuma-ui'
|
|
60
|
-
</script>
|
|
61
|
-
|
|
62
|
-
<template>
|
|
63
|
-
<RsConfigProvider theme="light" locale="en-US">
|
|
64
|
-
<RsButton variant="primary">Hello</RsButton>
|
|
65
|
-
</RsConfigProvider>
|
|
66
|
-
</template>
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
Shipped locales: `zh-CN` | `en-US`.
|
|
70
|
-
|
|
71
|
-
## Usage
|
|
72
|
-
|
|
73
|
-
1. Named-import from the package root only. **Do not** depend on `reka-ui`. Do not `import *`.
|
|
74
|
-
2. Import `niuma-ui/styles.css` once, then your brand CSS.
|
|
75
|
-
3. Wrap the app with `RsConfigProvider` (theme, locale, default control size).
|
|
76
|
-
4. Light sites re-export used symbols from their own `ui.ts`. Do not alias the package to this repo’s `src/index.ts`.
|
|
77
|
-
|
|
78
|
-
Component APIs live on the docs site. The architecture contract is for maintainers: [components.en.md](./docs/components.en.md) ([中文](./docs/components.md)).
|
|
79
|
-
|
|
80
|
-
## Docs
|
|
81
|
-
|
|
82
|
-
- **Component site:** [https://blair-shang.github.io/niuma-ui/](https://blair-shang.github.io/niuma-ui/) (source: `site/`)
|
|
83
|
-
- Local docs: `pnpm dev:site` → http://127.0.0.1:5181
|
|
84
|
-
- `playground/` is internal smoke / visual regression only (`pnpm dev` → :5180). It is not usage documentation.
|
|
85
|
-
|
|
86
|
-
| Doc | Audience |
|
|
87
|
-
|-----|----------|
|
|
88
|
-
| [docs/consumers.en.md](./docs/consumers.en.md) | People installing the library ([中文](./docs/consumers.md)) |
|
|
89
|
-
| [docs/components.en.md](./docs/components.en.md) | People changing this repository ([中文](./docs/components.md)) |
|
|
90
|
-
| [CONTRIBUTING.en.md](./CONTRIBUTING.en.md) | PRs, tests, releases ([中文](./CONTRIBUTING.md)) |
|
|
91
|
-
| [CHANGELOG.md](./CHANGELOG.md) | Release notes |
|
|
92
|
-
| [SECURITY.md](./SECURITY.md) | Private vulnerability reports |
|
|
93
|
-
|
|
94
|
-
## Local development
|
|
95
|
-
|
|
96
|
-
```bash
|
|
97
|
-
pnpm install
|
|
98
|
-
pnpm dev:site # docs site
|
|
99
|
-
pnpm test
|
|
100
|
-
pnpm build # library → dist/
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
See [CONTRIBUTING.md](./CONTRIBUTING.md) for the full contributor flow.
|
|
104
|
-
|
|
105
|
-
## Versioning
|
|
106
|
-
|
|
107
|
-
[Semantic Versioning](https://semver.org/): compatible fixes are PATCH, compatible features MINOR, breaking API or token renames MAJOR.
|
|
108
|
-
|
|
109
|
-
Stable publishes set npm dist-tag **`latest`**; prereleases use **`next`**. There is no Git tag named `latest`. Release steps live only in [CONTRIBUTING.md](./CONTRIBUTING.md).
|
|
110
|
-
|
|
111
|
-
## License and credits
|
|
112
|
-
|
|
113
|
-
[Apache License 2.0](./LICENSE). Attribution: [NOTICE](./NOTICE).
|
|
114
|
-
|
|
115
|
-
Primitives: [Reka UI](https://reka-ui.com/). Icons: [Lucide](https://lucide.dev/). Editors: [Monaco](https://microsoft.github.io/monaco-editor/), [CodeMirror](https://codemirror.net/). Terminal: [xterm.js](https://xtermjs.org/).
|
|
116
|
-
|
|
117
|
-
- Docs: https://blair-shang.github.io/niuma-ui/
|
|
118
|
-
- npm: https://www.npmjs.com/package/niuma-ui
|
|
119
|
-
- Source: https://github.com/Blair-Shang/niuma-ui
|
|
120
|
-
- Issues: https://github.com/Blair-Shang/niuma-ui/issues
|
|
3
|
+
The English README is [README.md](./README.md). 中文:[README.zh-CN.md](./README.zh-CN.md).
|
package/README.md
CHANGED
|
@@ -5,44 +5,45 @@
|
|
|
5
5
|
[](https://vuejs.org/)
|
|
6
6
|
[](https://nodejs.org/)
|
|
7
7
|
|
|
8
|
-
[
|
|
8
|
+
English | [简体中文](./README.zh-CN.md)
|
|
9
9
|
|
|
10
|
-
Vue 3
|
|
10
|
+
Vue 3 **workbench** design system: consistent `Rs*` components, `--rs-*` tokens, and optional editor / terminal wrappers.
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
Built for ops consoles, database workbenches, and internal admin UIs. Marketing sites can use named imports. `npm install` pulls Monaco, CodeMirror, and xterm; named imports control the bundle.
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
**Status:** [Apache License 2.0](./LICENSE) since v1.0.0. Compiled ESM on npm since v1.2.0. Current line is **2.0.0**. The `1.x` branch keeps the 1.3 line.
|
|
15
15
|
|
|
16
|
-
##
|
|
16
|
+
## Features
|
|
17
17
|
|
|
18
|
-
- **Design
|
|
19
|
-
- **Rs\*
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
- **
|
|
18
|
+
- **Design tokens** — light / dark / system via `data-rs-theme` and CSS variables; hosts override a brand layer
|
|
19
|
+
- **Rs\* components** — Button, Form, Dialog, Table, Tree, Tabs, Anchor, and more
|
|
20
|
+
- **Tooling** — Monaco, CodeMirror, xterm (import only on routes that need them)
|
|
21
|
+
- **Accessibility** — [Reka UI](https://reka-ui.com/) underneath; apps depend only on `niuma-ui`
|
|
22
|
+
- **i18n** — omitted `locale` follows the host language (`zh*` → `zh-CN`, `en*` → `en-US`); unknown tags fall back to `zh-CN`. Extra languages: `registerRsLocale` ([guide](./docs/locales.en.md))
|
|
23
|
+
- **Vite** — `import { RsButton } from 'niuma-ui'` is enough to bundle; `niumaUiHost` is local `pnpm dev` HMR only
|
|
23
24
|
|
|
24
|
-
##
|
|
25
|
+
## Requirements
|
|
25
26
|
|
|
26
|
-
|
|
|
27
|
-
|
|
27
|
+
| Item | Version |
|
|
28
|
+
|------|---------|
|
|
28
29
|
| Node.js | ≥ 20 |
|
|
29
|
-
|
|
|
30
|
-
| Vue | ^3.5
|
|
31
|
-
|
|
|
32
|
-
|
|
|
30
|
+
| Package manager | npm / pnpm / yarn (this repo develops with pnpm ≥ 9) |
|
|
31
|
+
| Vue | ^3.5 (`peerDependency`) |
|
|
32
|
+
| Bundler | Vite 5+ recommended; `RsMonacoEditor` needs Vite `?worker` |
|
|
33
|
+
| Styles | `import 'niuma-ui/styles.css'` (standalone CSS, no Tailwind) |
|
|
33
34
|
|
|
34
|
-
##
|
|
35
|
+
## Install
|
|
35
36
|
|
|
36
37
|
```bash
|
|
37
38
|
pnpm add niuma-ui
|
|
38
|
-
#
|
|
39
|
+
# or: npm install niuma-ui / yarn add niuma-ui
|
|
39
40
|
```
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
Prefer a range such as `^2.0.0`. Pin **2.0.0** for a bit-for-bit install. Use `niuma-ui@1` for the 1.x line.
|
|
42
43
|
|
|
43
|
-
|
|
44
|
+
Local `link`, Vite plugins, and bundle size: **[Consumer guide](./docs/consumers.en.md)** ([中文](./docs/consumers.md)).
|
|
44
45
|
|
|
45
|
-
##
|
|
46
|
+
## Quick start
|
|
46
47
|
|
|
47
48
|
```ts
|
|
48
49
|
// main.ts
|
|
@@ -60,67 +61,62 @@ import { RsConfigProvider, RsButton } from 'niuma-ui'
|
|
|
60
61
|
</script>
|
|
61
62
|
|
|
62
63
|
<template>
|
|
63
|
-
<RsConfigProvider theme="light" locale="
|
|
64
|
+
<RsConfigProvider theme="light" locale="en-US">
|
|
64
65
|
<RsButton variant="primary">Hello</RsButton>
|
|
65
66
|
</RsConfigProvider>
|
|
66
67
|
</template>
|
|
67
68
|
```
|
|
68
69
|
|
|
69
|
-
`locale`
|
|
70
|
+
Omit `locale` to follow the host language. Chinese systems stay on `zh-CN`. Community packs: [locales.en.md](./docs/locales.en.md).
|
|
70
71
|
|
|
71
|
-
##
|
|
72
|
+
## Usage
|
|
72
73
|
|
|
73
|
-
1.
|
|
74
|
-
2.
|
|
75
|
-
3.
|
|
76
|
-
4.
|
|
74
|
+
1. Named-import from the package root only. **Do not** depend on `reka-ui`. Do not `import *`.
|
|
75
|
+
2. Import `niuma-ui/styles.css` once, then your brand CSS.
|
|
76
|
+
3. Wrap the app with `RsConfigProvider` (theme, locale, default control size).
|
|
77
|
+
4. Light sites re-export used symbols from their own `ui.ts`. Do not alias the package to this repo’s `src/index.ts`.
|
|
77
78
|
|
|
78
|
-
|
|
79
|
+
Component APIs live on the docs site. The architecture contract is for maintainers: [components.en.md](./docs/components.en.md) ([中文](./docs/components.md)).
|
|
79
80
|
|
|
80
|
-
##
|
|
81
|
+
## Docs
|
|
81
82
|
|
|
82
|
-
-
|
|
83
|
-
-
|
|
84
|
-
- `playground/`
|
|
83
|
+
- **Component site:** [https://blair-shang.github.io/niuma-ui/](https://blair-shang.github.io/niuma-ui/) (source: `site/`)
|
|
84
|
+
- Local docs: `pnpm dev:site` → http://127.0.0.1:5181
|
|
85
|
+
- `playground/` is internal smoke / visual regression only (`pnpm dev` → :5180). It is not usage documentation.
|
|
85
86
|
|
|
86
|
-
|
|
|
87
|
-
|
|
88
|
-
| [docs/consumers.md](./docs/consumers.md) |
|
|
89
|
-
| [docs/
|
|
90
|
-
| [
|
|
91
|
-
| [
|
|
92
|
-
| [
|
|
87
|
+
| Doc | Audience |
|
|
88
|
+
|-----|----------|
|
|
89
|
+
| [docs/consumers.en.md](./docs/consumers.en.md) | People installing the library ([中文](./docs/consumers.md)) |
|
|
90
|
+
| [docs/locales.en.md](./docs/locales.en.md) | Registering extra languages ([中文](./docs/locales.md)) |
|
|
91
|
+
| [docs/components.en.md](./docs/components.en.md) | People changing this repository ([中文](./docs/components.md)) |
|
|
92
|
+
| [CONTRIBUTING.en.md](./CONTRIBUTING.en.md) | PRs, tests, releases ([中文](./CONTRIBUTING.md)) |
|
|
93
|
+
| [CHANGELOG.md](./CHANGELOG.md) | Release notes |
|
|
94
|
+
| [SECURITY.md](./SECURITY.md) | Private vulnerability reports |
|
|
93
95
|
|
|
94
|
-
##
|
|
96
|
+
## Local development
|
|
95
97
|
|
|
96
98
|
```bash
|
|
97
99
|
pnpm install
|
|
98
|
-
pnpm dev:site #
|
|
99
|
-
pnpm test
|
|
100
|
-
pnpm build #
|
|
100
|
+
pnpm dev:site # docs site
|
|
101
|
+
pnpm test
|
|
102
|
+
pnpm build # library → dist/
|
|
101
103
|
```
|
|
102
104
|
|
|
103
|
-
|
|
105
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md) for the full contributor flow.
|
|
104
106
|
|
|
105
|
-
##
|
|
107
|
+
## Versioning
|
|
106
108
|
|
|
107
|
-
|
|
109
|
+
[Semantic Versioning](https://semver.org/): compatible fixes are PATCH, compatible features MINOR, breaking API or token renames MAJOR.
|
|
108
110
|
|
|
109
|
-
|
|
110
|
-
|------|------|
|
|
111
|
-
| 兼容的缺陷 / 文档 | PATCH |
|
|
112
|
-
| 兼容的新组件 / 能力 | MINOR |
|
|
113
|
-
| 破坏性 API 或 Token 更名 | MAJOR |
|
|
111
|
+
Stable publishes set npm dist-tag **`latest`**; prereleases use **`next`**. There is no Git tag named `latest`. Release steps live only in [CONTRIBUTING.md](./CONTRIBUTING.md).
|
|
114
112
|
|
|
115
|
-
|
|
113
|
+
## License and credits
|
|
116
114
|
|
|
117
|
-
|
|
115
|
+
[Apache License 2.0](./LICENSE). Attribution: [NOTICE](./NOTICE).
|
|
118
116
|
|
|
119
|
-
[
|
|
117
|
+
Primitives: [Reka UI](https://reka-ui.com/). Icons: [Lucide](https://lucide.dev/). Editors: [Monaco](https://microsoft.github.io/monaco-editor/), [CodeMirror](https://codemirror.net/). Terminal: [xterm.js](https://xtermjs.org/).
|
|
120
118
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
-
|
|
124
|
-
-
|
|
125
|
-
- 源码:https://github.com/Blair-Shang/niuma-ui
|
|
126
|
-
- Issues:https://github.com/Blair-Shang/niuma-ui/issues
|
|
119
|
+
- Docs: https://blair-shang.github.io/niuma-ui/
|
|
120
|
+
- npm: https://www.npmjs.com/package/niuma-ui
|
|
121
|
+
- Source: https://github.com/Blair-Shang/niuma-ui
|
|
122
|
+
- Issues: https://github.com/Blair-Shang/niuma-ui/issues
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# niuma-ui
|
|
2
|
+
|
|
3
|
+
[](./LICENSE)
|
|
4
|
+
[](https://www.npmjs.com/package/niuma-ui)
|
|
5
|
+
[](https://vuejs.org/)
|
|
6
|
+
[](https://nodejs.org/)
|
|
7
|
+
|
|
8
|
+
[English](./README.md) | 简体中文
|
|
9
|
+
|
|
10
|
+
Vue 3 **工作台**设计系统:一致的 `Rs*` 组件与 `--rs-*` Token,以及按需使用的编辑器 / 终端封装。
|
|
11
|
+
|
|
12
|
+
适用于运维控制台、数据库工作台、内部后台。营销站也可以用具名导入。`npm install` 会带上 Monaco、CodeMirror、xterm,体积靠具名导入摇树。
|
|
13
|
+
|
|
14
|
+
**状态:** [Apache License 2.0](./LICENSE),自 v1.0.0 开源。自 v1.2.0 起 npm 发布编译 ESM。当前主线 **2.0.0**。1.x 见分支 `1.x`。
|
|
15
|
+
|
|
16
|
+
## 特性
|
|
17
|
+
|
|
18
|
+
- **Design Token**:明暗主题走 `data-rs-theme`(`light` / `dark` / `system`)与 CSS 变量,宿主用品牌层覆盖
|
|
19
|
+
- **Rs\* 组件**:Button、Form、Dialog、Table、Tree、Tabs、Anchor 等
|
|
20
|
+
- **专业工具**:Monaco、CodeMirror、xterm(只在用到的路由引入)
|
|
21
|
+
- **无障碍**:底层 [Reka UI](https://reka-ui.com/),应用只依赖 `niuma-ui`
|
|
22
|
+
- **国际化**:未设 `locale` 时跟本机语言(中文系统就是 `zh-CN`);认不出回退中文。第三方语言用 `registerRsLocale`,见 [docs/locales.md](./docs/locales.md)
|
|
23
|
+
- **Vite**:`import { RsButton } from 'niuma-ui'` 即可打包;`niumaUiHost` 仅本机 `pnpm dev` 联调源码
|
|
24
|
+
|
|
25
|
+
## 要求
|
|
26
|
+
|
|
27
|
+
| 项 | 版本 |
|
|
28
|
+
|----|------|
|
|
29
|
+
| Node.js | ≥ 20 |
|
|
30
|
+
| 包管理器 | npm / pnpm / yarn(本仓库开发用 pnpm ≥ 9) |
|
|
31
|
+
| Vue | ^3.5(peerDependency) |
|
|
32
|
+
| 打包器 | 推荐 Vite 5+;`RsMonacoEditor` 需要 Vite 处理 `?worker` |
|
|
33
|
+
| 样式 | `import 'niuma-ui/styles.css'`(独立 CSS,不含 Tailwind) |
|
|
34
|
+
|
|
35
|
+
## 安装
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pnpm add niuma-ui
|
|
39
|
+
# 或 npm install niuma-ui / yarn add niuma-ui
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
建议锁定兼容范围,例如 `^2.0.0`。精确复现请钉死 **2.0.0**。1.x 请用 `niuma-ui@1`。
|
|
43
|
+
|
|
44
|
+
本地改源码、Vite 插件、包体积见 **[消费方指南](./docs/consumers.md)**([English](./docs/consumers.en.md))。
|
|
45
|
+
|
|
46
|
+
## 快速开始
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
// main.ts
|
|
50
|
+
import { createApp } from 'vue'
|
|
51
|
+
import 'niuma-ui/styles.css'
|
|
52
|
+
import App from './App.vue'
|
|
53
|
+
|
|
54
|
+
createApp(App).mount('#app')
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
```vue
|
|
58
|
+
<!-- App.vue -->
|
|
59
|
+
<script setup lang="ts">
|
|
60
|
+
import { RsConfigProvider, RsButton } from 'niuma-ui'
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<template>
|
|
64
|
+
<RsConfigProvider theme="light" locale="zh-CN">
|
|
65
|
+
<RsButton variant="primary">你好</RsButton>
|
|
66
|
+
</RsConfigProvider>
|
|
67
|
+
</template>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
未设 `locale` 时跟本机语言:中文环境仍是中文。更多语言见 [社区语言包](./docs/locales.md)。
|
|
71
|
+
|
|
72
|
+
## 使用约定
|
|
73
|
+
|
|
74
|
+
1. 只从包根具名导入:`import { RsButton } from 'niuma-ui'`。**不要**直接依赖 `reka-ui`,不要 `import *`。
|
|
75
|
+
2. 样式只引一次 `niuma-ui/styles.css`,再加载你的品牌 CSS。
|
|
76
|
+
3. 根节点包 `RsConfigProvider`(主题、语言、默认控件尺寸)。
|
|
77
|
+
4. 轻量站点在自己的 `ui.ts` 里再导出用到的符号。不要把包名别名到本仓库的 `src/index.ts`。
|
|
78
|
+
|
|
79
|
+
组件 API 以文档站为准。仓库里的架构契约给维护者:[组件规范](./docs/components.md)([English](./docs/components.en.md))。
|
|
80
|
+
|
|
81
|
+
## 文档
|
|
82
|
+
|
|
83
|
+
- **组件文档(官网)**:[https://blair-shang.github.io/niuma-ui/](https://blair-shang.github.io/niuma-ui/)(源码 `site/`)
|
|
84
|
+
- 本地文档站:`pnpm dev:site` → http://127.0.0.1:5181
|
|
85
|
+
- `playground/` 仅内部冒烟与像素回归(`pnpm dev` → :5180),不提供对外用法
|
|
86
|
+
|
|
87
|
+
| 文档 | 给谁看 |
|
|
88
|
+
|------|--------|
|
|
89
|
+
| [docs/consumers.md](./docs/consumers.md) | 把库装进产品的人([English](./docs/consumers.en.md)) |
|
|
90
|
+
| [docs/locales.md](./docs/locales.md) | 登记第三方语言([English](./docs/locales.en.md)) |
|
|
91
|
+
| [docs/components.md](./docs/components.md) | 改本仓库的人([English](./docs/components.en.md)) |
|
|
92
|
+
| [CONTRIBUTING.md](./CONTRIBUTING.md) | PR、测试、发版([English](./CONTRIBUTING.en.md)) |
|
|
93
|
+
| [CHANGELOG.md](./CHANGELOG.md) | 版本记录 |
|
|
94
|
+
| [SECURITY.md](./SECURITY.md) | 漏洞私下报告 |
|
|
95
|
+
|
|
96
|
+
## 本地开发
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
pnpm install
|
|
100
|
+
pnpm dev:site # 文档站
|
|
101
|
+
pnpm test # Vitest
|
|
102
|
+
pnpm build # 库 → dist/
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
贡献步骤见 [CONTRIBUTING.md](./CONTRIBUTING.md)。
|
|
106
|
+
|
|
107
|
+
## 版本
|
|
108
|
+
|
|
109
|
+
遵循 [Semantic Versioning](https://semver.org/lang/zh-CN/):
|
|
110
|
+
|
|
111
|
+
| 变更 | 版本 |
|
|
112
|
+
|------|------|
|
|
113
|
+
| 兼容的缺陷 / 文档 | PATCH |
|
|
114
|
+
| 兼容的新组件 / 能力 | MINOR |
|
|
115
|
+
| 破坏性 API 或 Token 更名 | MAJOR |
|
|
116
|
+
|
|
117
|
+
正式版更新 npm dist-tag **`latest`**,预发布走 **`next`**。没有名为 `latest` 的 Git 标签。发版流程只在 [CONTRIBUTING.md](./CONTRIBUTING.md),不在本页。
|
|
118
|
+
|
|
119
|
+
## 许可与致谢
|
|
120
|
+
|
|
121
|
+
[Apache License 2.0](./LICENSE)。版权与第三方声明见 [NOTICE](./NOTICE)。
|
|
122
|
+
|
|
123
|
+
交互原语:[Reka UI](https://reka-ui.com/)。图标:[Lucide](https://lucide.dev/)。编辑器:[Monaco](https://microsoft.github.io/monaco-editor/)、[CodeMirror](https://codemirror.net/)。终端:[xterm.js](https://xtermjs.org/)。
|
|
124
|
+
|
|
125
|
+
- 文档站:https://blair-shang.github.io/niuma-ui/
|
|
126
|
+
- npm:https://www.npmjs.com/package/niuma-ui
|
|
127
|
+
- 源码:https://github.com/Blair-Shang/niuma-ui
|
|
128
|
+
- Issues:https://github.com/Blair-Shang/niuma-ui/issues
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogOverlay, AlertDialogPortal, AlertDialogRoot, AlertDialogTitle, AlertDialogTrigger, Primitive, AvatarFallback, AvatarImage, AvatarRoot, CollapsibleContent, CollapsibleRoot, CollapsibleTrigger, ComboboxAnchor, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxItemIndicator, ComboboxLabel, ComboboxPortal, ComboboxRoot, ComboboxTrigger, ComboboxViewport, ComboboxVirtualizer, ContextMenuContent, ContextMenuItem, ContextMenuPortal, ContextMenuRoot, ContextMenuSeparator, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, DialogClose, DialogContent, DialogDescription, DialogOverlay, DialogPortal, DialogRoot, DialogTitle, DialogTrigger, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuRoot, DropdownMenuTrigger, PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger, RadioGroupIndicator, RadioGroupItem, RadioGroupRoot, SwitchRoot, SwitchThumb, PaginationEllipsis, PaginationFirst, PaginationLast, PaginationList, PaginationListItem, PaginationNext, PaginationPrev, PaginationRoot, ScrollAreaCorner, ScrollAreaRoot, ScrollAreaScrollbar, ScrollAreaThumb, ScrollAreaViewport, SelectContent, SelectItem, SelectItemIndicator, SelectItemText, SelectPortal, SelectRoot, SelectTrigger, SelectValue, SelectViewport, StepperDescription, StepperIndicator, StepperItem, StepperRoot, StepperSeparator, StepperTitle, StepperTrigger, TabsContent, TabsList, TabsRoot, TabsTrigger, TooltipContent, TooltipPortal, TooltipProvider, TooltipRoot, TooltipTrigger, TreeItem, TreeRoot, TreeVirtualizer, useForwardExpose, useFilter, } from 'reka-ui';
|
|
1
|
+
export { AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogOverlay, AlertDialogPortal, AlertDialogRoot, AlertDialogTitle, AlertDialogTrigger, Primitive, AvatarFallback, AvatarImage, AvatarRoot, CollapsibleContent, CollapsibleRoot, CollapsibleTrigger, ComboboxAnchor, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxItemIndicator, ComboboxLabel, ComboboxPortal, ComboboxRoot, ComboboxTrigger, ComboboxViewport, ComboboxVirtualizer, ConfigProvider, ContextMenuContent, ContextMenuItem, ContextMenuPortal, ContextMenuRoot, ContextMenuSeparator, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, DialogClose, DialogContent, DialogDescription, DialogOverlay, DialogPortal, DialogRoot, DialogTitle, DialogTrigger, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuRoot, DropdownMenuTrigger, PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger, RadioGroupIndicator, RadioGroupItem, RadioGroupRoot, SwitchRoot, SwitchThumb, PaginationEllipsis, PaginationFirst, PaginationLast, PaginationList, PaginationListItem, PaginationNext, PaginationPrev, PaginationRoot, ScrollAreaCorner, ScrollAreaRoot, ScrollAreaScrollbar, ScrollAreaThumb, ScrollAreaViewport, SelectContent, SelectItem, SelectItemIndicator, SelectItemText, SelectPortal, SelectRoot, SelectTrigger, SelectValue, SelectViewport, StepperDescription, StepperIndicator, StepperItem, StepperRoot, StepperSeparator, StepperTitle, StepperTrigger, TabsContent, TabsList, TabsRoot, TabsTrigger, TooltipContent, TooltipPortal, TooltipProvider, TooltipRoot, TooltipTrigger, TreeItem, TreeRoot, TreeVirtualizer, useForwardExpose, useFilter, } from 'reka-ui';
|
|
2
2
|
export type { AcceptableValue, PrimitiveProps, TooltipRootEmits, TooltipRootProps } from 'reka-ui';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { AlertDialogContent, AlertDialogDescription, AlertDialogOverlay, AlertDialogPortal, AlertDialogRoot, AlertDialogTitle, AvatarFallback, AvatarImage, AvatarRoot, CollapsibleContent, CollapsibleRoot, CollapsibleTrigger, ComboboxAnchor, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxItemIndicator, ComboboxLabel, ComboboxPortal, ComboboxRoot, ComboboxTrigger, ComboboxViewport, ComboboxVirtualizer, ContextMenuContent, ContextMenuItem, ContextMenuPortal, ContextMenuRoot, ContextMenuSeparator, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, DialogContent, DialogDescription, DialogOverlay, DialogPortal, DialogRoot, DialogTitle, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuRoot, DropdownMenuTrigger, PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger, Primitive, RadioGroupIndicator, RadioGroupItem, RadioGroupRoot, ScrollAreaCorner, ScrollAreaRoot, ScrollAreaScrollbar, ScrollAreaThumb, ScrollAreaViewport, SwitchRoot, SwitchThumb, TabsContent, TabsList, TabsRoot, TabsTrigger, TooltipContent, TooltipPortal, TooltipProvider, TooltipRoot, TooltipTrigger, useFilter } from "reka-ui";
|
|
2
|
-
export { AlertDialogContent, AlertDialogDescription, AlertDialogOverlay, AlertDialogPortal, AlertDialogRoot, AlertDialogTitle, AvatarFallback, AvatarImage, AvatarRoot, CollapsibleContent, CollapsibleRoot, CollapsibleTrigger, ComboboxAnchor, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxItemIndicator, ComboboxLabel, ComboboxPortal, ComboboxRoot, ComboboxTrigger, ComboboxViewport, ComboboxVirtualizer, ContextMenuContent, ContextMenuItem, ContextMenuPortal, ContextMenuRoot, ContextMenuSeparator, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, DialogContent, DialogDescription, DialogOverlay, DialogPortal, DialogRoot, DialogTitle, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuRoot, DropdownMenuTrigger, PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger, Primitive, RadioGroupIndicator, RadioGroupItem, RadioGroupRoot, ScrollAreaCorner, ScrollAreaRoot, ScrollAreaScrollbar, ScrollAreaThumb, ScrollAreaViewport, SwitchRoot, SwitchThumb, TabsContent, TabsList, TabsRoot, TabsTrigger, TooltipContent, TooltipPortal, TooltipProvider, TooltipRoot, TooltipTrigger, useFilter };
|
|
1
|
+
import { AlertDialogContent, AlertDialogDescription, AlertDialogOverlay, AlertDialogPortal, AlertDialogRoot, AlertDialogTitle, AvatarFallback, AvatarImage, AvatarRoot, CollapsibleContent, CollapsibleRoot, CollapsibleTrigger, ComboboxAnchor, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxItemIndicator, ComboboxLabel, ComboboxPortal, ComboboxRoot, ComboboxTrigger, ComboboxViewport, ComboboxVirtualizer, ConfigProvider, ContextMenuContent, ContextMenuItem, ContextMenuPortal, ContextMenuRoot, ContextMenuSeparator, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, DialogContent, DialogDescription, DialogOverlay, DialogPortal, DialogRoot, DialogTitle, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuRoot, DropdownMenuTrigger, PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger, Primitive, RadioGroupIndicator, RadioGroupItem, RadioGroupRoot, ScrollAreaCorner, ScrollAreaRoot, ScrollAreaScrollbar, ScrollAreaThumb, ScrollAreaViewport, SwitchRoot, SwitchThumb, TabsContent, TabsList, TabsRoot, TabsTrigger, TooltipContent, TooltipPortal, TooltipProvider, TooltipRoot, TooltipTrigger, useFilter } from "reka-ui";
|
|
2
|
+
export { AlertDialogContent, AlertDialogDescription, AlertDialogOverlay, AlertDialogPortal, AlertDialogRoot, AlertDialogTitle, AvatarFallback, AvatarImage, AvatarRoot, CollapsibleContent, CollapsibleRoot, CollapsibleTrigger, ComboboxAnchor, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxItemIndicator, ComboboxLabel, ComboboxPortal, ComboboxRoot, ComboboxTrigger, ComboboxViewport, ComboboxVirtualizer, ConfigProvider, ContextMenuContent, ContextMenuItem, ContextMenuPortal, ContextMenuRoot, ContextMenuSeparator, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, DialogContent, DialogDescription, DialogOverlay, DialogPortal, DialogRoot, DialogTitle, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuRoot, DropdownMenuTrigger, PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger, Primitive, RadioGroupIndicator, RadioGroupItem, RadioGroupRoot, ScrollAreaCorner, ScrollAreaRoot, ScrollAreaScrollbar, ScrollAreaThumb, ScrollAreaViewport, SwitchRoot, SwitchThumb, TabsContent, TabsList, TabsRoot, TabsTrigger, TooltipContent, TooltipPortal, TooltipProvider, TooltipRoot, TooltipTrigger, useFilter };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import RsIcon_default from "../../icon/src/RsIcon.js";
|
|
2
1
|
import { AvatarFallback, AvatarImage, AvatarRoot } from "../../_shared/src/reka.js";
|
|
2
|
+
import RsIcon_default from "../../icon/src/RsIcon.js";
|
|
3
3
|
import { getAvatarInitials } from "./avatar-utils.js";
|
|
4
4
|
import { computed, createBlock, createCommentVNode, createElementBlock, createVNode, defineComponent, normalizeClass, openBlock, renderSlot, toDisplayString, unref, withCtx } from "vue";
|
|
5
5
|
//#region src/components/avatar/src/RsAvatar.vue?vue&type=script&setup=true&lang.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { rsRadiusCss } from "../../_shared/src/resolve-radius.js";
|
|
2
1
|
import { Primitive } from "../../_shared/src/reka.js";
|
|
2
|
+
import { rsRadiusCss } from "../../_shared/src/resolve-radius.js";
|
|
3
3
|
import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, defineComponent, normalizeClass, normalizeStyle, openBlock, renderSlot, toDisplayString, unref, useSlots, withCtx } from "vue";
|
|
4
4
|
//#region src/components/card/src/RsCard.vue?vue&type=script&setup=true&lang.ts
|
|
5
5
|
var _hoisted_1 = {
|
|
@@ -18,14 +18,13 @@ type __VLS_Props = {
|
|
|
18
18
|
*/
|
|
19
19
|
themeScope?: 'global' | 'local';
|
|
20
20
|
};
|
|
21
|
-
declare var
|
|
21
|
+
declare var __VLS_8: {};
|
|
22
22
|
type __VLS_Slots = {} & {
|
|
23
|
-
default?: (props: typeof
|
|
23
|
+
default?: (props: typeof __VLS_8) => any;
|
|
24
24
|
};
|
|
25
25
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
26
26
|
dir: RsDirMode;
|
|
27
27
|
theme: RsThemeMode;
|
|
28
|
-
locale: RsLocale;
|
|
29
28
|
controlSize: RsComponentSize;
|
|
30
29
|
themeScope: "global" | "local";
|
|
31
30
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveHostLocale } from "../../../locale/resolve-host.js";
|
|
2
2
|
import { applyTheme, subscribePreferredColorScheme } from "../../../theme/apply.js";
|
|
3
3
|
import { createRsConfigState, provideRsConfig } from "../../../composables/useRsConfig.js";
|
|
4
|
-
import { applyLocale } from "../../../locale/apply.js";
|
|
5
|
-
import {
|
|
4
|
+
import { applyLocale, resolveDirMode } from "../../../locale/apply.js";
|
|
5
|
+
import { ConfigProvider } from "../../_shared/src/reka.js";
|
|
6
|
+
import { computed, createBlock, createElementVNode, defineComponent, onBeforeUnmount, openBlock, ref, renderSlot, unref, watch, withCtx } from "vue";
|
|
6
7
|
//#region src/components/config-provider/src/RsConfigProvider.vue?vue&type=script&setup=true&lang.ts
|
|
7
8
|
var RsConfigProvider_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
8
9
|
name: "RsConfigProvider",
|
|
9
10
|
__name: "RsConfigProvider",
|
|
10
11
|
props: {
|
|
11
12
|
theme: { default: "light" },
|
|
12
|
-
locale: {
|
|
13
|
+
locale: {},
|
|
13
14
|
dir: { default: "auto" },
|
|
14
15
|
controlSize: { default: "md" },
|
|
15
16
|
controlRadius: {},
|
|
@@ -18,7 +19,7 @@ var RsConfigProvider_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
|
|
|
18
19
|
setup(__props) {
|
|
19
20
|
const props = __props;
|
|
20
21
|
const rootEl = ref(null);
|
|
21
|
-
const config = createRsConfigState(props.theme, props.locale, props.controlSize, props.controlRadius, props.dir);
|
|
22
|
+
const config = createRsConfigState(props.theme, props.locale ?? resolveHostLocale(), props.controlSize, props.controlRadius, props.dir);
|
|
22
23
|
provideRsConfig(config);
|
|
23
24
|
let stopPreferred;
|
|
24
25
|
function chromeTarget() {
|
|
@@ -47,7 +48,7 @@ var RsConfigProvider_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
|
|
|
47
48
|
if (value !== config.theme.value) config.setTheme(value);
|
|
48
49
|
});
|
|
49
50
|
watch(() => props.locale, (value) => {
|
|
50
|
-
if (value !== config.locale.value) config.setLocale(value);
|
|
51
|
+
if (value != null && value !== config.locale.value) config.setLocale(value);
|
|
51
52
|
});
|
|
52
53
|
watch(() => props.dir, (value) => {
|
|
53
54
|
if (value !== config.dir.value) config.setDir(value);
|
|
@@ -73,15 +74,23 @@ var RsConfigProvider_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
|
|
|
73
74
|
syncLocale();
|
|
74
75
|
}
|
|
75
76
|
});
|
|
77
|
+
const resolvedDir = computed(() => resolveDirMode(config.dir.value, config.locale.value));
|
|
78
|
+
const rekaLocale = computed(() => config.locale.value);
|
|
76
79
|
onBeforeUnmount(() => {
|
|
77
80
|
stopPreferred?.();
|
|
78
81
|
});
|
|
79
82
|
return (_ctx, _cache) => {
|
|
80
|
-
return openBlock(),
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
return openBlock(), createBlock(unref(ConfigProvider), {
|
|
84
|
+
dir: resolvedDir.value,
|
|
85
|
+
locale: rekaLocale.value
|
|
86
|
+
}, {
|
|
87
|
+
default: withCtx(() => [createElementVNode("div", {
|
|
88
|
+
ref_key: "rootEl",
|
|
89
|
+
ref: rootEl,
|
|
90
|
+
class: "rs-config-provider"
|
|
91
|
+
}, [renderSlot(_ctx.$slots, "default", {}, void 0, true)], 512)]),
|
|
92
|
+
_: 3
|
|
93
|
+
}, 8, ["dir", "locale"]);
|
|
85
94
|
};
|
|
86
95
|
}
|
|
87
96
|
});
|
|
@@ -3,6 +3,6 @@ import RsConfigProvider_vue_vue_type_script_setup_true_lang_default from "./RsCo
|
|
|
3
3
|
|
|
4
4
|
import _plugin_vue_export_helper_default from "../../../_virtual/_plugin-vue_export-helper.js";
|
|
5
5
|
//#region src/components/config-provider/src/RsConfigProvider.vue
|
|
6
|
-
var RsConfigProvider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(RsConfigProvider_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-
|
|
6
|
+
var RsConfigProvider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(RsConfigProvider_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-2be1193e"]]);
|
|
7
7
|
//#endregion
|
|
8
8
|
export { RsConfigProvider_default as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import RsIcon_default from "../../icon/src/RsIcon.js";
|
|
2
1
|
import { ContextMenuItem, ContextMenuPortal, ContextMenuSeparator, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger } from "../../_shared/src/reka.js";
|
|
2
|
+
import RsIcon_default from "../../icon/src/RsIcon.js";
|
|
3
3
|
import RsContextMenuItems_default from "./RsContextMenuItems.js";
|
|
4
4
|
import { Fragment, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, normalizeClass, openBlock, renderList, toDisplayString, unref, withCtx } from "vue";
|
|
5
5
|
//#region src/components/context-menu/src/RsContextMenuItems.vue?vue&type=script&setup=true&lang.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { RS_COMPONENT_SIZE_ICON_PX } from "../../../theme/types.js";
|
|
2
|
+
import { PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger } from "../../_shared/src/reka.js";
|
|
2
3
|
import { useRsI18n } from "../../../composables/useRsI18n.js";
|
|
3
4
|
import RsIcon_default from "../../icon/src/RsIcon.js";
|
|
4
5
|
import { buildLocalInputRules, runFormFieldRules } from "../../form/src/form-rules.js";
|
|
5
6
|
import { isRsFormItemBoundControl, useRsFormContext, useRsFormField, useRsFormItemContext } from "../../form/src/form-utils.js";
|
|
6
7
|
import { useResolvedRsComponentSize } from "../../_shared/src/resolve-size.js";
|
|
7
|
-
import { PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger } from "../../_shared/src/reka.js";
|
|
8
8
|
import { EMPTY_DATE_RANGE, compareDates, extractTimeFromDateTime, formatDateDisplay, formatDateParts, formatDateRangeLabel, formatDateTimeDisplay, formatDateTimeParts, formatDateTimeRangeLabel, formatTimestampValue, fromInternalPickerValue, getNextMonth, getNowDateTime, getTodayDate, isDateRangeEmpty, isDateRangeOrdered, isDateWithinBounds, isTimestampRange, normalizeShortcutValue, parseDateTimeValue, parseDateValue, parseTimestampValue, toInternalPickerValue, toRangeEndpointString } from "./date-picker-utils.js";
|
|
9
9
|
import RsCalendarGrid_default from "../../calendar-grid/src/RsCalendarGrid.js";
|
|
10
10
|
import { formatTimeParts } from "../../time-picker/src/time-picker-utils.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { AlertDialogContent, AlertDialogDescription, AlertDialogOverlay, AlertDialogPortal, AlertDialogRoot, AlertDialogTitle } from "../../_shared/src/reka.js";
|
|
1
2
|
import { useRsI18n } from "../../../composables/useRsI18n.js";
|
|
2
3
|
import RsButton_default from "../../button/src/RsButton.js";
|
|
3
|
-
import { AlertDialogContent, AlertDialogDescription, AlertDialogOverlay, AlertDialogPortal, AlertDialogRoot, AlertDialogTitle } from "../../_shared/src/reka.js";
|
|
4
4
|
import { isRsDialogWidthPreset, resolveDialogOverlayStyle, resolveRsDialogCssWidth, runRsConfirmBeforeClose } from "./dialog-utils.js";
|
|
5
5
|
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, mergeModels, normalizeClass, normalizeStyle, openBlock, renderSlot, resolveDynamicComponent, toDisplayString, unref, useModel, withCtx } from "vue";
|
|
6
6
|
//#region src/components/dialog/src/RsConfirmDialog.vue?vue&type=script&setup=true&lang.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { DialogContent, DialogDescription, DialogOverlay, DialogPortal, DialogRoot, DialogTitle } from "../../_shared/src/reka.js";
|
|
1
2
|
import { useRsI18n } from "../../../composables/useRsI18n.js";
|
|
2
3
|
import RsButton_default from "../../button/src/RsButton.js";
|
|
3
|
-
import { DialogContent, DialogDescription, DialogOverlay, DialogPortal, DialogRoot, DialogTitle } from "../../_shared/src/reka.js";
|
|
4
4
|
import { dialogViewportSize } from "./dialog-viewport.js";
|
|
5
5
|
import { isRsDialogWidthPreset, resolveDialogOverlayStyle, resolveRsDialogCssWidth, resolveRsDialogWidthPx, runRsDialogBeforeClose } from "./dialog-utils.js";
|
|
6
6
|
import { useRsDialogWindow } from "./dialog-window.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { DialogContent, DialogDescription, DialogOverlay, DialogPortal, DialogRoot, DialogTitle } from "../../_shared/src/reka.js";
|
|
1
2
|
import { useRsI18n } from "../../../composables/useRsI18n.js";
|
|
2
3
|
import RsButton_default from "../../button/src/RsButton.js";
|
|
3
|
-
import { DialogContent, DialogDescription, DialogOverlay, DialogPortal, DialogRoot, DialogTitle } from "../../_shared/src/reka.js";
|
|
4
4
|
import { RS_DRAWER_MAX_VIEWPORT_RATIO, clampRsDrawerSize, resolveDrawerOverlayStyle, resolveRsDrawerDimensionCss, resolveRsDrawerSizeCss, resolveRsDrawerSizePx, runRsDrawerBeforeClose } from "./drawer-utils.js";
|
|
5
5
|
import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, mergeModels, nextTick, normalizeClass, normalizeStyle, onBeforeUnmount, openBlock, ref, renderSlot, toDisplayString, unref, useModel, watch, withCtx } from "vue";
|
|
6
6
|
//#region src/components/drawer/src/RsDrawer.vue?vue&type=script&setup=true&lang.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { DropdownMenuContent, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRoot, DropdownMenuTrigger } from "../../_shared/src/reka.js";
|
|
1
2
|
import { useRsI18n } from "../../../composables/useRsI18n.js";
|
|
2
3
|
import RsIcon_default from "../../icon/src/RsIcon.js";
|
|
3
|
-
import { DropdownMenuContent, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRoot, DropdownMenuTrigger } from "../../_shared/src/reka.js";
|
|
4
4
|
import { flattenDropdownItems } from "./dropdown-utils.js";
|
|
5
5
|
import RsDropdownItems_default from "./RsDropdownItems.js";
|
|
6
6
|
import { computed, createBlock, createElementVNode, createVNode, defineComponent, mergeModels, normalizeClass, openBlock, renderSlot, toDisplayString, unref, useModel, withCtx } from "vue";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { interpolateRsMessage } from "../../../locale/interpolate.js";
|
|
2
|
-
import "../../../locale/
|
|
2
|
+
import { resolveHostLocale } from "../../../locale/resolve-host.js";
|
|
3
3
|
import { createTranslator } from "../../../composables/useRsI18n.js";
|
|
4
4
|
import { getInputRuleMessage, validateInputRule } from "../../input/src/input-rules.js";
|
|
5
5
|
//#region src/components/form/src/form-rules.ts
|
|
@@ -106,7 +106,7 @@ async function evaluateFormRule(value, rule, tr, options) {
|
|
|
106
106
|
* 按顺序执行字段规则,首条失败即返回。
|
|
107
107
|
*/
|
|
108
108
|
async function runFormFieldRules(value, rules, options) {
|
|
109
|
-
const tr = options?.t ?? createTranslator(
|
|
109
|
+
const tr = options?.t ?? createTranslator(resolveHostLocale());
|
|
110
110
|
const trigger = options?.trigger;
|
|
111
111
|
for (const rule of rules) {
|
|
112
112
|
if (!matchFormRuleTrigger(rule, trigger)) continue;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../../../locale/
|
|
1
|
+
import { resolveHostLocale } from "../../../locale/resolve-host.js";
|
|
2
2
|
import { createTranslator } from "../../../composables/useRsI18n.js";
|
|
3
3
|
//#region src/components/input/src/input-rules.ts
|
|
4
4
|
var inputRuleMessageKeys = {
|
|
@@ -29,10 +29,10 @@ function validateInputRule(value, rule) {
|
|
|
29
29
|
}
|
|
30
30
|
function getInputRuleMessage(rule, t) {
|
|
31
31
|
const key = inputRuleMessageKeys[rule];
|
|
32
|
-
return (t ?? createTranslator(
|
|
32
|
+
return (t ?? createTranslator(resolveHostLocale()))(key);
|
|
33
33
|
}
|
|
34
34
|
function runInputValidation(value, options, t) {
|
|
35
|
-
const tr = t ?? createTranslator(
|
|
35
|
+
const tr = t ?? createTranslator(resolveHostLocale());
|
|
36
36
|
if (options.required && value.trim() === "") return {
|
|
37
37
|
valid: false,
|
|
38
38
|
message: tr("input.required")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { CollapsibleContent, CollapsibleRoot, CollapsibleTrigger, PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger } from "../../_shared/src/reka.js";
|
|
1
2
|
import { useRsI18n } from "../../../composables/useRsI18n.js";
|
|
2
3
|
import RsIcon_default from "../../icon/src/RsIcon.js";
|
|
3
|
-
import { CollapsibleContent, CollapsibleRoot, CollapsibleTrigger, PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger } from "../../_shared/src/reka.js";
|
|
4
4
|
import { menuItemContainsKey } from "./menu-utils.js";
|
|
5
5
|
import RsMenuItems_default from "./RsMenuItems.js";
|
|
6
6
|
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, normalizeClass, normalizeStyle, onBeforeUnmount, openBlock, ref, renderList, toDisplayString, unref, withCtx } from "vue";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useResolvedRsComponentSize } from "../../_shared/src/resolve-size.js";
|
|
2
1
|
import { RadioGroupRoot } from "../../_shared/src/reka.js";
|
|
2
|
+
import { useResolvedRsComponentSize } from "../../_shared/src/resolve-size.js";
|
|
3
3
|
import { RS_RADIO_GROUP_KEY } from "./radio-utils.js";
|
|
4
4
|
import { computed, createBlock, defineComponent, mergeModels, normalizeClass, openBlock, provide, renderSlot, unref, useModel, withCtx } from "vue";
|
|
5
5
|
//#region src/components/radio/src/RsRadio.vue?vue&type=script&setup=true&lang.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useResolvedRsComponentSize } from "../../_shared/src/resolve-size.js";
|
|
2
1
|
import { RadioGroupIndicator, RadioGroupItem } from "../../_shared/src/reka.js";
|
|
2
|
+
import { useResolvedRsComponentSize } from "../../_shared/src/resolve-size.js";
|
|
3
3
|
import { RS_RADIO_GROUP_KEY } from "./radio-utils.js";
|
|
4
4
|
import { computed, createCommentVNode, createElementBlock, createVNode, defineComponent, inject, normalizeClass, openBlock, renderSlot, unref, useId, withCtx } from "vue";
|
|
5
5
|
//#region src/components/radio/src/RsRadioItem.vue?vue&type=script&setup=true&lang.ts
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { RS_COMPONENT_SIZE_ICON_PX } from "../../../theme/types.js";
|
|
2
|
+
import { ComboboxAnchor, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxItemIndicator, ComboboxLabel, ComboboxPortal, ComboboxRoot, ComboboxTrigger, ComboboxViewport, ComboboxVirtualizer } from "../../_shared/src/reka.js";
|
|
2
3
|
import { useRsI18n } from "../../../composables/useRsI18n.js";
|
|
3
4
|
import RsIcon_default from "../../icon/src/RsIcon.js";
|
|
4
5
|
import { buildLocalInputRules, runFormFieldRules } from "../../form/src/form-rules.js";
|
|
5
6
|
import { isRsFormItemBoundControl, useRsFormContext, useRsFormField, useRsFormItemContext } from "../../form/src/form-utils.js";
|
|
6
7
|
import { useResolvedRsComponentSize } from "../../_shared/src/resolve-size.js";
|
|
7
8
|
import { rsRadiusCss, useResolvedRsRadius } from "../../_shared/src/resolve-radius.js";
|
|
8
|
-
import { ComboboxAnchor, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxItemIndicator, ComboboxLabel, ComboboxPortal, ComboboxRoot, ComboboxTrigger, ComboboxViewport, ComboboxVirtualizer } from "../../_shared/src/reka.js";
|
|
9
9
|
import { isSelectOptionGroup, splitSelectLabelHighlight, toComboboxValue } from "./select-utils.js";
|
|
10
10
|
import { useRsSelect } from "./use-rs-select.js";
|
|
11
11
|
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, isRef, mergeModels, mergeProps, nextTick, normalizeClass, normalizeStyle, onMounted, onUnmounted, openBlock, ref, renderList, renderSlot, toDisplayString, unref, useAttrs, useModel, watch, withCtx, withModifiers } from "vue";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useResolvedRsComponentSize } from "../../_shared/src/resolve-size.js";
|
|
2
1
|
import { SwitchRoot, SwitchThumb } from "../../_shared/src/reka.js";
|
|
2
|
+
import { useResolvedRsComponentSize } from "../../_shared/src/resolve-size.js";
|
|
3
3
|
import { computed, createCommentVNode, createElementBlock, createVNode, defineComponent, mergeModels, normalizeClass, openBlock, renderSlot, unref, useId, useModel, withCtx } from "vue";
|
|
4
4
|
//#region src/components/switch/src/RsSwitch.vue?vue&type=script&setup=true&lang.ts
|
|
5
5
|
var _hoisted_1 = ["for"];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { DropdownMenuContent, DropdownMenuItem, DropdownMenuPortal, DropdownMenuRoot, DropdownMenuTrigger, TabsContent, TabsList, TabsRoot, TabsTrigger } from "../../_shared/src/reka.js";
|
|
1
2
|
import { useRsI18n } from "../../../composables/useRsI18n.js";
|
|
2
3
|
import RsIcon_default from "../../icon/src/RsIcon.js";
|
|
3
|
-
import { DropdownMenuContent, DropdownMenuItem, DropdownMenuPortal, DropdownMenuRoot, DropdownMenuTrigger, TabsContent, TabsList, TabsRoot, TabsTrigger } from "../../_shared/src/reka.js";
|
|
4
4
|
import { buildTabContextMenuItems, getNextTabAfterBatchClose, getNextTabAfterClose, isTabClosable, isTabFixed, isTabRenamable, resolveTabsToClose } from "./tabs-utils.js";
|
|
5
5
|
import { useRsTabsNav } from "../../../composables/useRsTabsNav.js";
|
|
6
6
|
import RsContextMenu_default from "../../context-menu/src/RsContextMenu.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { RS_COMPONENT_SIZE_ICON_PX } from "../../../theme/types.js";
|
|
2
|
+
import { PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger } from "../../_shared/src/reka.js";
|
|
2
3
|
import { useRsI18n } from "../../../composables/useRsI18n.js";
|
|
3
4
|
import RsIcon_default from "../../icon/src/RsIcon.js";
|
|
4
5
|
import { isRsFormItemBoundControl, useRsFormItemContext } from "../../form/src/form-utils.js";
|
|
5
6
|
import { useResolvedRsComponentSize } from "../../_shared/src/resolve-size.js";
|
|
6
|
-
import { PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger } from "../../_shared/src/reka.js";
|
|
7
7
|
import { EMPTY_TIME_RANGE, formatTimeFromParts, formatTimeRangeDisplay, getCurrentTime, isTimeRangeEmpty, isTimeRangeOrderedValues, isTimeWithinBounds, parseTimeValue, pickEarlierTime, pickLaterTime } from "./time-picker-utils.js";
|
|
8
8
|
import RsTimePickerColumns_default from "./RsTimePickerColumns.js";
|
|
9
9
|
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, mergeModels, mergeProps, nextTick, normalizeClass, openBlock, ref, resolveComponent, toDisplayString, unref, useAttrs, useId, useModel, useTemplateRef, watch, withCtx } from "vue";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { TooltipContent, TooltipPortal, TooltipRoot, TooltipTrigger } from "../../_shared/src/reka.js";
|
|
1
2
|
import { useRsI18n } from "../../../composables/useRsI18n.js";
|
|
2
3
|
import RsIcon_default from "../../icon/src/RsIcon.js";
|
|
3
|
-
import { TooltipContent, TooltipPortal, TooltipRoot, TooltipTrigger } from "../../_shared/src/reka.js";
|
|
4
4
|
import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, normalizeClass, openBlock, renderSlot, toDisplayString, unref, useSlots, withCtx } from "vue";
|
|
5
5
|
//#region src/components/tooltip/src/RsTooltip.vue?vue&type=script&setup=true&lang.ts
|
|
6
6
|
var _hoisted_1 = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defaultLocale } from "../locale/types.js";
|
|
2
1
|
import { isRsLocaleRegistered } from "../locale/registry.js";
|
|
2
|
+
import { resolveHostLocale } from "../locale/resolve-host.js";
|
|
3
3
|
import { readResolvedTheme } from "../theme/apply.js";
|
|
4
4
|
import RsConfigProvider_default from "../components/config-provider/src/RsConfigProvider.js";
|
|
5
5
|
import RsDialog_default from "../components/dialog/src/RsDialog.js";
|
|
@@ -10,9 +10,9 @@ function readDomTheme() {
|
|
|
10
10
|
return readResolvedTheme();
|
|
11
11
|
}
|
|
12
12
|
function readDomLocale() {
|
|
13
|
-
if (typeof document === "undefined") return
|
|
13
|
+
if (typeof document === "undefined") return resolveHostLocale();
|
|
14
14
|
const value = document.documentElement.getAttribute("data-rs-locale");
|
|
15
|
-
return value && isRsLocaleRegistered(value) ? value :
|
|
15
|
+
return value && isRsLocaleRegistered(value) ? value : resolveHostLocale();
|
|
16
16
|
}
|
|
17
17
|
/** 命令式实例的销毁函数;测试收尾用 destroyAllRsDialogHosts 走正规 unmount。 */
|
|
18
18
|
var liveHosts = /* @__PURE__ */ new Set();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { interpolateRsMessage, resolveRsTranslateArgs } from "../locale/interpolate.js";
|
|
2
|
-
import { defaultLocale } from "../locale/types.js";
|
|
3
2
|
import { resolveRsMessage } from "../locale/registry.js";
|
|
3
|
+
import { resolveHostLocale } from "../locale/resolve-host.js";
|
|
4
4
|
import { resolveThemeMode } from "../theme/apply.js";
|
|
5
5
|
import { inject, provide, ref } from "vue";
|
|
6
6
|
//#region src/composables/useRsConfig.ts
|
|
@@ -14,7 +14,7 @@ function useRsConfig() {
|
|
|
14
14
|
function useRsConfigOptional() {
|
|
15
15
|
return inject(rsConfigKey, null);
|
|
16
16
|
}
|
|
17
|
-
function createRsConfigState(initialTheme = "light", initialLocale =
|
|
17
|
+
function createRsConfigState(initialTheme = "light", initialLocale = resolveHostLocale(), initialControlSize = "md", initialControlRadius, initialDir = "auto") {
|
|
18
18
|
const theme = ref(initialTheme);
|
|
19
19
|
const resolvedTheme = ref(resolveThemeMode(initialTheme));
|
|
20
20
|
const locale = ref(initialLocale);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type RsI18nVars, type RsTranslateFn } from '../locale/interpolate';
|
|
2
2
|
import { type RsLocale } from '../locale/types';
|
|
3
3
|
export type { RsI18nVars, RsTranslateFn };
|
|
4
|
-
/** 组件内安全取文案:Provider 内跟随 locale
|
|
4
|
+
/** 组件内安全取文案:Provider 内跟随 locale,否则按本机语言,再回退 zh-CN */
|
|
5
5
|
export declare function useRsI18n(): {
|
|
6
6
|
t: RsTranslateFn;
|
|
7
7
|
locale: import("vue").ComputedRef<RsLocale>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { interpolateRsMessage, resolveRsTranslateArgs } from "../locale/interpolate.js";
|
|
2
|
-
import "../locale/types.js";
|
|
3
2
|
import { resolveRsMessage } from "../locale/registry.js";
|
|
3
|
+
import { resolveHostLocale } from "../locale/resolve-host.js";
|
|
4
4
|
import { rsConfigKey } from "./useRsConfig.js";
|
|
5
5
|
import { computed, inject } from "vue";
|
|
6
6
|
//#region src/composables/useRsI18n.ts
|
|
@@ -8,10 +8,10 @@ function translate(locale, key, fallbackOrVars, vars) {
|
|
|
8
8
|
const parsed = resolveRsTranslateArgs(fallbackOrVars, vars);
|
|
9
9
|
return interpolateRsMessage(resolveRsMessage(locale, key) ?? parsed.fallback ?? key, parsed.vars, locale);
|
|
10
10
|
}
|
|
11
|
-
/** 组件内安全取文案:Provider 内跟随 locale
|
|
11
|
+
/** 组件内安全取文案:Provider 内跟随 locale,否则按本机语言,再回退 zh-CN */
|
|
12
12
|
function useRsI18n() {
|
|
13
13
|
const ctx = inject(rsConfigKey, null);
|
|
14
|
-
const locale = computed(() => ctx?.locale.value ??
|
|
14
|
+
const locale = computed(() => ctx?.locale.value ?? resolveHostLocale());
|
|
15
15
|
const t = (key, fallbackOrVars, vars) => translate(locale.value, key, fallbackOrVars, vars);
|
|
16
16
|
return {
|
|
17
17
|
t,
|
package/dist/index.d.ts
CHANGED
|
@@ -220,7 +220,8 @@ export type { RsThemeMode, RsResolvedTheme, RsThemeTokens, RsComponentSize, RsRa
|
|
|
220
220
|
export { RS_COMPONENT_SIZES, RS_COMPONENT_SIZE_ICON_PX, RS_RADII, RS_RADIUS_CSS, RS_FONT_SIZES, RS_FONT_SIZE_CSS, RS_FONT_WEIGHTS, RS_FONT_WEIGHT_CSS, } from './theme/types';
|
|
221
221
|
export type { RsBuiltinLocale, RsDirMode, RsLocale, RsLocaleMessages, RsTextDirection, } from './locale/types';
|
|
222
222
|
export { defaultLocale, fallbackLocale } from './locale/types';
|
|
223
|
-
export {
|
|
223
|
+
export { rsLocaleMessageKeys } from './locale/messages';
|
|
224
|
+
export { applyLocale, inferRsLocaleDir, isRsLocaleRegistered, listRsLocales, registerRsLocale, resolveDirMode, resolveHostLocale, resolveRsLocaleDir, resolveRsMessage, } from './locale/registry-public';
|
|
224
225
|
export { useRsConfig, useRsConfigOptional, createRsConfigState } from './composables/useRsConfig';
|
|
225
226
|
export { useResolvedRsComponentSize, resolveRsComponentSize } from './components/_shared';
|
|
226
227
|
export { useResolvedRsRadius, rsRadiusCss } from './components/_shared';
|
package/dist/index.js
CHANGED
|
@@ -346,11 +346,13 @@ export { resolveCodeEditorTheme } from './components/code-editor/src/code-editor
|
|
|
346
346
|
export { resolveCodeMirrorLanguage } from './components/code-editor/src/code-mirror-lang.js'
|
|
347
347
|
export { resolveColumnOrder } from './components/table/src/utils/table-utils.js'
|
|
348
348
|
export { resolveDialogOverlayStyle } from './components/dialog/src/dialog-utils.js'
|
|
349
|
+
export { resolveDirMode } from './locale/apply.js'
|
|
349
350
|
export { resolveDrawerOverlayStyle } from './components/drawer/src/drawer-utils.js'
|
|
350
351
|
export { resolveEntryKey } from './components/table/src/utils/table-utils.js'
|
|
351
352
|
export { resolveFieldRules } from './components/form/src/form-utils.js'
|
|
352
353
|
export { resolveFixedColumnStyles } from './components/table/src/utils/table-utils.js'
|
|
353
354
|
export { resolveGridNavDirection } from './components/table/src/utils/rs-table-grid-nav.js'
|
|
355
|
+
export { resolveHostLocale } from './locale/resolve-host.js'
|
|
354
356
|
export { resolveInstanceFeatures } from './components/table/src/context/rs-table-module-registry.js'
|
|
355
357
|
export { resolveItemSize } from './components/virtual-list/src/virtual-list-utils.js'
|
|
356
358
|
export { resolveLogCopyText } from './components/log/src/log-utils.js'
|
|
@@ -400,6 +402,7 @@ export { rsBrandIconNames } from './icons/brand.js'
|
|
|
400
402
|
export { rsCommonIconNames } from './icons/registry.js'
|
|
401
403
|
export { rsConfirm } from './composables/createRsDialog.js'
|
|
402
404
|
export { rsFeedbackIconClass } from './components/_shared/src/overlay-utils.js'
|
|
405
|
+
export { rsLocaleMessageKeys } from './locale/messages.js'
|
|
403
406
|
export { rsRadiusCss } from './components/_shared/src/resolve-radius.js'
|
|
404
407
|
export { rsToastPositions } from './components/_shared/src/overlay-utils.js'
|
|
405
408
|
export { runFormFieldRules } from './components/form/src/form-rules.js'
|
|
@@ -89,15 +89,27 @@ function readBalanced(source, open) {
|
|
|
89
89
|
}
|
|
90
90
|
return null;
|
|
91
91
|
}
|
|
92
|
+
var pluralRulesByLocale = /* @__PURE__ */ new Map();
|
|
93
|
+
function pluralRulesFor(locale) {
|
|
94
|
+
const cached = pluralRulesByLocale.get(locale);
|
|
95
|
+
if (cached) return cached;
|
|
96
|
+
try {
|
|
97
|
+
const rules = new Intl.PluralRules(locale);
|
|
98
|
+
pluralRulesByLocale.set(locale, rules);
|
|
99
|
+
return rules;
|
|
100
|
+
} catch {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
92
104
|
function pickPluralClause(locale, n, clauses) {
|
|
93
105
|
if (Number.isFinite(n)) {
|
|
94
106
|
const exact = clauses.get(`=${n}`);
|
|
95
107
|
if (exact != null) return exact;
|
|
96
|
-
|
|
97
|
-
|
|
108
|
+
const category = pluralRulesFor(locale)?.select(n);
|
|
109
|
+
if (category) {
|
|
98
110
|
const matched = clauses.get(category);
|
|
99
111
|
if (matched != null) return matched;
|
|
100
|
-
}
|
|
112
|
+
}
|
|
101
113
|
}
|
|
102
114
|
return clauses.get("other") ?? "";
|
|
103
115
|
}
|
package/dist/locale/messages.js
CHANGED
|
@@ -465,5 +465,7 @@ var enUS = {
|
|
|
465
465
|
"markdown.placeholder": "Markdown supported (headings, lists, links, code…)",
|
|
466
466
|
"markdown.empty": "Nothing to preview"
|
|
467
467
|
};
|
|
468
|
+
/** 社区语言包应对齐的 key 清单(与 en-US 表相同)。 */
|
|
469
|
+
var rsLocaleMessageKeys = Object.keys(enUS);
|
|
468
470
|
//#endregion
|
|
469
|
-
export { enUS, zhCN };
|
|
471
|
+
export { enUS, rsLocaleMessageKeys, zhCN };
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { applyLocale, readDocumentLocale, resolveDirMode } from './apply';
|
|
2
|
+
export { resolveHostLocale } from './resolve-host';
|
|
2
3
|
export { inferRsLocaleDir, isRsLocaleRegistered, listRsLocales, registerRsLocale, resolveRsLocaleDir, resolveRsLocalePack, resolveRsMessage, } from './registry';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { defaultLocale } from "./types.js";
|
|
2
|
+
import { isRsLocaleRegistered, listRsLocales } from "./registry.js";
|
|
3
|
+
//#region src/locale/resolve-host.ts
|
|
4
|
+
/**
|
|
5
|
+
* 未设 locale 时按本机语言选已登记的包。
|
|
6
|
+
* `zh*` → zh-CN,`en*` → en-US,其它按已登记码的语言前缀匹配。
|
|
7
|
+
* 没有 navigator(SSR)或无法识别时回退 `defaultLocale`(zh-CN)。
|
|
8
|
+
*/
|
|
9
|
+
function resolveHostLocale() {
|
|
10
|
+
for (const tag of readHostLanguageTags()) {
|
|
11
|
+
const matched = matchRegisteredLocale(tag);
|
|
12
|
+
if (matched) return matched;
|
|
13
|
+
}
|
|
14
|
+
return defaultLocale;
|
|
15
|
+
}
|
|
16
|
+
function readHostLanguageTags() {
|
|
17
|
+
const tags = [];
|
|
18
|
+
if (typeof navigator !== "undefined") {
|
|
19
|
+
if (Array.isArray(navigator.languages)) tags.push(...navigator.languages);
|
|
20
|
+
if (navigator.language) tags.push(navigator.language);
|
|
21
|
+
}
|
|
22
|
+
const seen = /* @__PURE__ */ new Set();
|
|
23
|
+
const unique = [];
|
|
24
|
+
for (const tag of tags) {
|
|
25
|
+
const normalized = tag.trim();
|
|
26
|
+
if (!normalized) continue;
|
|
27
|
+
const key = normalized.toLowerCase();
|
|
28
|
+
if (seen.has(key)) continue;
|
|
29
|
+
seen.add(key);
|
|
30
|
+
unique.push(normalized);
|
|
31
|
+
}
|
|
32
|
+
return unique;
|
|
33
|
+
}
|
|
34
|
+
function matchRegisteredLocale(tag) {
|
|
35
|
+
const normalized = tag.trim().replace(/_/g, "-");
|
|
36
|
+
if (!normalized) return void 0;
|
|
37
|
+
if (isRsLocaleRegistered(normalized)) return normalized;
|
|
38
|
+
const lower = normalized.toLowerCase();
|
|
39
|
+
for (const code of listRsLocales()) if (code.toLowerCase() === lower) return code;
|
|
40
|
+
const base = lower.split("-")[0] ?? "";
|
|
41
|
+
if (base === "zh" && isRsLocaleRegistered("zh-CN")) return "zh-CN";
|
|
42
|
+
if (base === "en" && isRsLocaleRegistered("en-US")) return "en-US";
|
|
43
|
+
for (const code of listRsLocales()) if (code.toLowerCase().split(/[-_]/)[0] === base) return code;
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { resolveHostLocale };
|
package/dist/locale/types.d.ts
CHANGED
|
@@ -6,7 +6,9 @@ export type RsLocaleMessages = Record<string, string>;
|
|
|
6
6
|
export type RsTextDirection = 'ltr' | 'rtl';
|
|
7
7
|
/** 书写方向:auto 跟当前 locale 的 dir。 */
|
|
8
8
|
export type RsDirMode = RsTextDirection | 'auto';
|
|
9
|
+
/** 无法从本机语言识别时的回退。当前用户以中文为主,回退 zh-CN。 */
|
|
9
10
|
export declare const defaultLocale: RsBuiltinLocale;
|
|
11
|
+
/** 缺 key 时先回退到该语言,再回退 zh-CN。 */
|
|
10
12
|
export declare const fallbackLocale: RsBuiltinLocale;
|
|
11
13
|
export declare const localeAttribute = "data-rs-locale";
|
|
12
14
|
export declare const dirAttribute = "data-rs-dir";
|
package/dist/locale/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "niuma-ui",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Vue 3 workbench design system — Rs* components, --rs-* tokens, optional Monaco / CodeMirror / xterm",
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
"LICENSE",
|
|
69
69
|
"NOTICE",
|
|
70
70
|
"README.md",
|
|
71
|
+
"README.zh-CN.md",
|
|
71
72
|
"README.en.md",
|
|
72
73
|
"CHANGELOG.md"
|
|
73
74
|
],
|