rujian-ui-kit 0.0.0-stage → 0.1.0

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.
Files changed (86) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +29 -0
  3. package/README.md +66 -2
  4. package/dist/base/LayerPortal.d.ts +23 -0
  5. package/dist/base/choice-options.d.ts +29 -0
  6. package/dist/base/class-names.d.ts +8 -0
  7. package/dist/base/controllable-state.d.ts +8 -0
  8. package/dist/base/field-context.d.ts +35 -0
  9. package/dist/base/isomorphic-layout-effect.d.ts +3 -0
  10. package/dist/base/merge-refs.d.ts +7 -0
  11. package/dist/base/pointer-tracking.d.ts +9 -0
  12. package/dist/base/text-format.d.ts +12 -0
  13. package/dist/components/audio-preview/AudioPreview.d.ts +30 -0
  14. package/dist/components/audio-preview/index.d.ts +1 -0
  15. package/dist/components/button/Button.d.ts +31 -0
  16. package/dist/components/button/index.d.ts +1 -0
  17. package/dist/components/choice-controls/Checkbox.d.ts +27 -0
  18. package/dist/components/choice-controls/CheckboxGroup.d.ts +31 -0
  19. package/dist/components/choice-controls/ChoiceItem.d.ts +13 -0
  20. package/dist/components/choice-controls/RadioGroup.d.ts +33 -0
  21. package/dist/components/choice-controls/Switch.d.ts +25 -0
  22. package/dist/components/choice-controls/SwitchList.d.ts +9 -0
  23. package/dist/components/choice-controls/choice-group-class.d.ts +8 -0
  24. package/dist/components/choice-controls/index.d.ts +6 -0
  25. package/dist/components/dialog/DialogController.d.ts +58 -0
  26. package/dist/components/dialog/DialogProvider.d.ts +70 -0
  27. package/dist/components/dialog/DialogWindow.d.ts +17 -0
  28. package/dist/components/dialog/dialog-types.d.ts +89 -0
  29. package/dist/components/dialog/index.d.ts +2 -0
  30. package/dist/components/disclosure/Disclosure.d.ts +22 -0
  31. package/dist/components/disclosure/index.d.ts +1 -0
  32. package/dist/components/facts/Facts.d.ts +23 -0
  33. package/dist/components/facts/index.d.ts +1 -0
  34. package/dist/components/feedback/feedback-blocks.d.ts +69 -0
  35. package/dist/components/feedback/index.d.ts +1 -0
  36. package/dist/components/field/Field.d.ts +38 -0
  37. package/dist/components/field/index.d.ts +1 -0
  38. package/dist/components/file-picker/FilePicker.d.ts +48 -0
  39. package/dist/components/file-picker/index.d.ts +1 -0
  40. package/dist/components/icons/Icon.d.ts +23 -0
  41. package/dist/components/icons/icon-data.d.ts +110 -0
  42. package/dist/components/icons/icon-element.d.ts +9 -0
  43. package/dist/components/icons/icon-rules.d.ts +22 -0
  44. package/dist/components/icons/index.d.ts +3 -0
  45. package/dist/components/image/Thumb.d.ts +38 -0
  46. package/dist/components/image/index.d.ts +1 -0
  47. package/dist/components/input-controls/TextArea.d.ts +24 -0
  48. package/dist/components/input-controls/TextInput.d.ts +22 -0
  49. package/dist/components/input-controls/index.d.ts +2 -0
  50. package/dist/components/layout/index.d.ts +1 -0
  51. package/dist/components/layout/layout-primitives.d.ts +12 -0
  52. package/dist/components/list/List.d.ts +58 -0
  53. package/dist/components/list/index.d.ts +1 -0
  54. package/dist/components/menu/MenuButton.d.ts +42 -0
  55. package/dist/components/menu/index.d.ts +1 -0
  56. package/dist/components/notification/NotificationProvider.d.ts +22 -0
  57. package/dist/components/notification/index.d.ts +1 -0
  58. package/dist/components/panel/Panel.d.ts +30 -0
  59. package/dist/components/panel/index.d.ts +1 -0
  60. package/dist/components/provider/UiProvider.d.ts +14 -0
  61. package/dist/components/provider/index.d.ts +1 -0
  62. package/dist/components/scrollbar/index.d.ts +1 -0
  63. package/dist/components/scrollbar/scrollbar-hover.d.ts +7 -0
  64. package/dist/components/select/Select.d.ts +40 -0
  65. package/dist/components/select/index.d.ts +1 -0
  66. package/dist/components/slider/Slider.d.ts +29 -0
  67. package/dist/components/slider/index.d.ts +1 -0
  68. package/dist/components/splitter/Splitter.d.ts +33 -0
  69. package/dist/components/splitter/index.d.ts +1 -0
  70. package/dist/components/table/Table.d.ts +79 -0
  71. package/dist/components/table/index.d.ts +1 -0
  72. package/dist/components/tabs/Tabs.d.ts +41 -0
  73. package/dist/components/tabs/index.d.ts +1 -0
  74. package/dist/components/text-block/TextBlock.d.ts +17 -0
  75. package/dist/components/text-block/index.d.ts +1 -0
  76. package/dist/components/tooltip/index.d.ts +3 -0
  77. package/dist/components/tooltip/tooltip-watcher.d.ts +31 -0
  78. package/dist/components/tooltip/use-tooltip.d.ts +7 -0
  79. package/dist/components/typography/index.d.ts +1 -0
  80. package/dist/components/typography/text-roles.d.ts +19 -0
  81. package/dist/index.d.ts +32 -0
  82. package/dist/index.js +2864 -0
  83. package/dist/index.js.map +1 -0
  84. package/dist/rujian-ui-kit.css +2 -0
  85. package/dist/styles/theme-names.d.ts +10 -0
  86. package/package.json +56 -4
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,29 @@
1
+ rujian-ui-kit
2
+ Copyright 2026 sungbin <chengbin@3578.cn>
3
+
4
+ This product is licensed under the Apache License, Version 2.0 (see LICENSE).
5
+
6
+ This product includes icon shapes from Tabler Icons (https://tabler.io/icons),
7
+ licensed under the MIT License:
8
+
9
+ MIT License
10
+
11
+ Copyright (c) 2020-2026 Paweł Kuna
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ of this software and associated documentation files (the "Software"), to deal
15
+ in the Software without restriction, including without limitation the rights
16
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ copies of the Software, and to permit persons to whom the Software is
18
+ furnished to do so, subject to the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be included in all
21
+ copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,67 @@
1
- # Temporary Holding Version
1
+ # rujian-ui-kit
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 如见的 React 界面组件库:设计令牌、深浅两套主题和常用控件(按钮、输入、选择、下拉、菜单、表格、列表、面板、对话框、通知、悬停提示等),供如见桌面客户端与网站共用。
4
+
5
+ ## 安装
6
+
7
+ 环境要求:Node.js 22.12 及以上,React 18.3 或 19。
8
+
9
+ ```bash
10
+ npm install rujian-ui-kit
11
+ ```
12
+
13
+ ## 使用
14
+
15
+ 在应用入口引入一次样式表,在根组件外包一层 `UiProvider`,并在 `html` 元素上写主题类:
16
+
17
+ ```tsx
18
+ import 'rujian-ui-kit/styles.css';
19
+ import { Button, UiProvider, themeClassName, useNotify } from 'rujian-ui-kit';
20
+
21
+ document.documentElement.classList.add(themeClassName('dark'));
22
+
23
+ function SaveButton() {
24
+ const notify = useNotify();
25
+ return <Button onClick={() => notify('已保存', 'success')}>保存</Button>;
26
+ }
27
+
28
+ export function App() {
29
+ return (
30
+ <UiProvider>
31
+ <SaveButton />
32
+ </UiProvider>
33
+ );
34
+ }
35
+ ```
36
+
37
+ - 主题:`html` 元素上的 `theme-dark` 或 `theme-light` 类决定颜色;切换主题只换这个类。
38
+ - 对话框:`useDialog()` 提供 `openDialog`、`openPage`、`alert`、`confirm`、`confirmDiscard`、`confirmDelete`。
39
+ - 通知:`useNotify()` 返回发通知的函数,级别为 `info`、`success`、`warning`、`error`。
40
+ - 悬停提示:元素写 `title` 属性即可;需要标题与分条说明时用 `useTooltip`。
41
+ - 按钮图标按文字自动匹配;应用自己的按钮文字用 `registerIconRules` 登记规则。
42
+
43
+ ### 在 Next.js 中使用
44
+
45
+ 构建产物开头带 `'use client'`,服务端组件可以直接引入组件库的组件。在 `app/layout.tsx` 中引入样式表,把主题类写在 `<html>` 上,并用 `UiProvider` 包住页面内容。
46
+
47
+ ## 开发
48
+
49
+ ```bash
50
+ npm install
51
+ npm run storybook # 在 http://localhost:6006 预览全部组件
52
+ npm test # 运行测试
53
+ npm run typecheck # 类型检查
54
+ npm run build # 构建到 dist
55
+ npm run check # 依次运行类型检查、测试与构建
56
+ ```
57
+
58
+ 发布新版本:修改 `package.json` 的 `version`,提交后运行 `npm publish`(发布前会自动运行 `npm run check`),再打同名标签(如 `v0.2.0`)并推送。
59
+
60
+ ## 限制
61
+
62
+ - 对话框正文渲染在 `UiProvider` 所在位置,只能使用 `UiProvider` 外层的上下文(React Context)。
63
+ - 自绘滚动条只在 Chromium 内核中生效,其他浏览器使用系统滚动条。
64
+
65
+ ## 许可证
66
+
67
+ [Apache-2.0](LICENSE)。图标图形取自 [Tabler Icons](https://tabler.io/icons)(MIT 许可),声明见 [NOTICE](NOTICE)。
@@ -0,0 +1,23 @@
1
+ import { type ReactNode } from 'react';
2
+ import './ui-layer.css';
3
+ /**
4
+ * 取得文档里唯一的层容器,没有或已被移除时新建。
5
+ * @param ownerDocument 文档。
6
+ * @returns 层容器元素。
7
+ */
8
+ export declare function getLayerContainer(ownerDocument: Document): HTMLElement;
9
+ /** 弹层传送门的属性。 */
10
+ export interface LayerPortalProps {
11
+ /** 渲染到层容器中的内容。 */
12
+ children: ReactNode;
13
+ }
14
+ /**
15
+ * 是否已在浏览器中渲染:服务端渲染与水合时为 false,之后为 true。
16
+ * @returns 是否在浏览器中。
17
+ */
18
+ export declare function useIsClient(): boolean;
19
+ /**
20
+ * 把内容渲染到层容器中;服务端渲染与水合时不输出,之后的渲染同步输出,弹层可在绘制前定位。
21
+ * @param props 属性。
22
+ */
23
+ export declare function LayerPortal({ children }: LayerPortalProps): import("react").ReactPortal | null;
@@ -0,0 +1,29 @@
1
+ /** 对象形式的选项。 */
2
+ export interface ChoiceOptionObject {
3
+ /** 选项值。 */
4
+ value: string;
5
+ /** 显示文字,缺省同值。 */
6
+ label?: string;
7
+ /** 是否禁用:显示但不能选中。 */
8
+ disabled?: boolean;
9
+ /** 第二行说明(下拉弹层中显示)。 */
10
+ description?: string;
11
+ /** 悬停提示,常用来说明禁用原因。 */
12
+ tooltip?: string;
13
+ }
14
+ /** 选项:字符串的值与文字相同。 */
15
+ export type ChoiceOption = string | ChoiceOptionObject;
16
+ /** 规范化后的选项。 */
17
+ export interface NormalizedOption {
18
+ value: string;
19
+ label: string;
20
+ disabled: boolean;
21
+ description: string;
22
+ tooltip: string;
23
+ }
24
+ /**
25
+ * 把选项规范化为统一形状;字符串选项的值与文字相同,默认不禁用,没有说明和悬停提示。
26
+ * @param options 选项。
27
+ * @returns 规范化后的选项数组。
28
+ */
29
+ export declare function normalizeOptions(options: readonly ChoiceOption[]): NormalizedOption[];
@@ -0,0 +1,8 @@
1
+ /** 可参与拼接的类名片段;空值与 false 会被跳过。 */
2
+ export type ClassNamePart = string | false | null | undefined;
3
+ /**
4
+ * 拼接类名。
5
+ * @param parts 类名片段。
6
+ * @returns 用空格连接的类名;没有有效片段时为空串。
7
+ */
8
+ export declare function classNames(...parts: ClassNamePart[]): string;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 受控与非受控两用的状态。
3
+ * @param value 受控值;undefined 表示非受控。
4
+ * @param defaultValue 非受控时的初始值。
5
+ * @param onChange 值变化时的回调。
6
+ * @returns 当前值与设置函数;设置相同的值不回调。
7
+ */
8
+ export declare function useControllableState<T>(value: T | undefined, defaultValue: T, onChange?: (next: T) => void): [T, (next: T) => void];
@@ -0,0 +1,35 @@
1
+ /** 字段向控件提供的关联信息。 */
2
+ export interface FieldContextValue {
3
+ /** 控件聚焦目标的 id,标签用 for 指向它。 */
4
+ controlId: string;
5
+ /** 标签元素的 id;没有标签时为 undefined。 */
6
+ labelId: string | undefined;
7
+ /** 说明与错误元素的 id,空格分隔。 */
8
+ describedBy: string;
9
+ /** 是否校验失败。 */
10
+ invalid: boolean;
11
+ }
12
+ /** 字段上下文;不在字段中时为 null。 */
13
+ export declare const FieldContext: import("react").Context<FieldContextValue | null>;
14
+ /** 控件自己传入的关联属性。 */
15
+ export interface FieldControlOverrides {
16
+ id?: string | undefined;
17
+ invalid?: boolean | undefined;
18
+ 'aria-labelledby'?: string | undefined;
19
+ 'aria-describedby'?: string | undefined;
20
+ }
21
+ /** 控件最终使用的关联属性。 */
22
+ export interface FieldControlProps {
23
+ id: string | undefined;
24
+ invalid: boolean;
25
+ 'aria-labelledby': string | undefined;
26
+ 'aria-describedby': string | undefined;
27
+ 'aria-invalid': true | undefined;
28
+ }
29
+ /**
30
+ * 合并字段上下文与控件自己的属性。
31
+ * @param overrides 控件自己传入的属性,优先使用。
32
+ * @param labelable 控件能否被 label for 关联(原生输入、文本域);不能时用 aria-labelledby 关联标签。
33
+ * @returns 控件应设置到聚焦目标或承载 aria 的元素上的属性。
34
+ */
35
+ export declare function useFieldControl(overrides: FieldControlOverrides, labelable: boolean): FieldControlProps;
@@ -0,0 +1,3 @@
1
+ import { useLayoutEffect } from 'react';
2
+ /** 浏览器中为 useLayoutEffect,服务端为 useEffect。 */
3
+ export declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
@@ -0,0 +1,7 @@
1
+ import type { Ref, RefCallback } from 'react';
2
+ /**
3
+ * 合并多个 ref 为一个回调 ref。
4
+ * @param refs 要同步赋值的 ref。
5
+ * @returns 回调 ref。
6
+ */
7
+ export declare function mergeRefs<T>(...refs: Array<Ref<T> | undefined>): RefCallback<T>;
@@ -0,0 +1,9 @@
1
+ import type { PointerEvent as ReactPointerEvent } from 'react';
2
+ /**
3
+ * 跟踪一次拖动。
4
+ * @param target 接收指针事件的元素(会捕获指针,移出元素后仍能收到事件)。
5
+ * @param downEvent 按下事件。
6
+ * @param onMove 移动时回调,参数为相对按下点的位移。
7
+ * @param onEnd 结束时回调。
8
+ */
9
+ export declare function trackPointer(target: HTMLElement, downEvent: PointerEvent | ReactPointerEvent, onMove: (deltaX: number, deltaY: number) => void, onEnd?: () => void): void;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 值统一转为文本,空值(undefined、null)按空串。
3
+ * @param value 任意值。
4
+ * @returns 文本。
5
+ */
6
+ export declare function toText(value: unknown): string;
7
+ /**
8
+ * 字节数的可读文字:按 1024 进位,单位 B、KB、MB、GB;B 取整,其余保留一位小数,如“1.5 MB”。
9
+ * @param size 字节数。
10
+ * @returns 可读大小。
11
+ */
12
+ export declare function formatBytes(size: number): string;
@@ -0,0 +1,30 @@
1
+ import './ui-audio-preview.css';
2
+ /** 音频来源:地址,或 MIME 类型加不带前缀的 Base64 内容。 */
3
+ export type AudioSource = {
4
+ src: string;
5
+ } | {
6
+ mime: string;
7
+ data: string;
8
+ };
9
+ /** 试听的属性。 */
10
+ export interface AudioPreviewProps {
11
+ /** 读取音频;读取失败时由调用方提示原因并返回 undefined。 */
12
+ load: () => Promise<AudioSource | undefined>;
13
+ /** 空闲时的按钮文字,默认“试听”。 */
14
+ text?: string;
15
+ /** 播放时的按钮文字,默认“停止”。 */
16
+ stopText?: string;
17
+ /** 空闲时的可访问名称,同一页有多个试听按钮时用来区分;播放时自动变为“停止”加这个名称。 */
18
+ 'aria-label'?: string;
19
+ /** 只显示图标。 */
20
+ iconOnly?: boolean;
21
+ /** 紧凑尺寸,默认 true。 */
22
+ compact?: boolean;
23
+ /** 追加的类名。 */
24
+ className?: string;
25
+ }
26
+ /**
27
+ * 试听。
28
+ * @param props 属性。
29
+ */
30
+ export declare function AudioPreview({ load, text, stopText, iconOnly, compact, className, ...aria }: AudioPreviewProps): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ export { AudioPreview, type AudioPreviewProps, type AudioSource } from './AudioPreview';
@@ -0,0 +1,31 @@
1
+ import { type ButtonHTMLAttributes, type ReactNode } from 'react';
2
+ import { type IconName, type IconPosition } from '../icons';
3
+ import './ui-button.css';
4
+ /** 按钮样式。 */
5
+ export type ButtonVariant = 'primary' | 'secondary' | 'danger' | 'accent' | 'ghost' | 'link';
6
+ /** 操作预设。 */
7
+ export type ButtonKind = 'add' | 'edit' | 'delete';
8
+ /** 按钮的属性;其余属性透传给 button 元素。 */
9
+ export interface ButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children'> {
10
+ /** 按钮文字;用 kind 时缺省为预设文字。纯图标按钮的文字作为可访问名称。 */
11
+ children?: ReactNode;
12
+ /** 使用“添加/修改/删除”预设(样式、默认文字、图标),children 与 variant 可覆盖。 */
13
+ kind?: ButtonKind;
14
+ /** 样式,默认 secondary;ghost 平时无底色,link 显示为嵌在文字里的链接。 */
15
+ variant?: ButtonVariant;
16
+ /** 指定图标覆盖自动匹配;false 不显示图标。 */
17
+ icon?: IconName | false;
18
+ /** 图标在文字前(start)或后(end);缺省按匹配规则,规则未指定时在前。 */
19
+ iconPosition?: IconPosition;
20
+ /** 只显示图标,文字作为可访问名称;没有图标时仍显示文字。 */
21
+ iconOnly?: boolean;
22
+ /** 紧凑按钮(表格行内操作),只有最小宽度不同。 */
23
+ compact?: boolean;
24
+ /** 切换按钮的按下状态;undefined 表示不是切换按钮。 */
25
+ pressed?: boolean;
26
+ }
27
+ /**
28
+ * 按钮。
29
+ * @param props 属性。
30
+ */
31
+ export declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1 @@
1
+ export { Button, type ButtonKind, type ButtonProps, type ButtonVariant } from './Button';
@@ -0,0 +1,27 @@
1
+ import './ui-choice-controls.css';
2
+ /** 复选框的属性。 */
3
+ export interface CheckboxProps {
4
+ /** 选项文字。 */
5
+ label: string;
6
+ /** 受控的勾选状态。 */
7
+ checked?: boolean;
8
+ /** 非受控时的初始状态。 */
9
+ defaultChecked?: boolean;
10
+ /** 禁用。 */
11
+ disabled?: boolean;
12
+ /** 校验失败。 */
13
+ invalid?: boolean;
14
+ /** 元素 id。 */
15
+ id?: string;
16
+ /** 可访问名称,缺省为文字。 */
17
+ 'aria-label'?: string;
18
+ /** 追加的类名。 */
19
+ className?: string;
20
+ /** 勾选状态变化时回调。 */
21
+ onChange?: (checked: boolean) => void;
22
+ }
23
+ /**
24
+ * 复选框。
25
+ * @param props 属性。
26
+ */
27
+ export declare function Checkbox({ label, checked, defaultChecked, disabled, invalid, id, className, onChange, ...aria }: CheckboxProps): import("react").JSX.Element;
@@ -0,0 +1,31 @@
1
+ import { type ChoiceOption } from '../../base/choice-options';
2
+ import { type ChoiceDirection } from './choice-group-class';
3
+ import './ui-choice-controls.css';
4
+ /** 复选框组的属性。 */
5
+ export interface CheckboxGroupProps {
6
+ /** 选项;单个选项可禁用。 */
7
+ options: readonly ChoiceOption[];
8
+ /** 受控的已选值。 */
9
+ value?: readonly string[];
10
+ /** 非受控时的初始已选值。 */
11
+ defaultValue?: readonly string[];
12
+ /** 排列方向,默认 vertical。 */
13
+ direction?: ChoiceDirection;
14
+ /** 整组禁用。 */
15
+ disabled?: boolean;
16
+ /** 校验失败。 */
17
+ invalid?: boolean;
18
+ /** 根元素 id。 */
19
+ id?: string;
20
+ /** 可访问名称;在 Field 中时由标签提供。 */
21
+ 'aria-label'?: string;
22
+ /** 追加到根元素的类名。 */
23
+ className?: string;
24
+ /** 已选值变化时回调,按选项顺序排列。 */
25
+ onChange?: (value: readonly string[]) => void;
26
+ }
27
+ /**
28
+ * 复选框组。
29
+ * @param props 属性。
30
+ */
31
+ export declare function CheckboxGroup({ options, value, defaultValue, direction, disabled, invalid, id, className, onChange, ...aria }: CheckboxGroupProps): import("react").JSX.Element;
@@ -0,0 +1,13 @@
1
+ import { type HTMLAttributes } from 'react';
2
+ /** 选项元素的属性。 */
3
+ export interface ChoiceItemProps extends Omit<HTMLAttributes<HTMLDivElement>, 'role'> {
4
+ role: 'radio' | 'checkbox';
5
+ label: string;
6
+ checked: boolean;
7
+ disabled: boolean;
8
+ }
9
+ /**
10
+ * 单个选项元素。
11
+ * @param props 属性。
12
+ */
13
+ export declare const ChoiceItem: import("react").ForwardRefExoticComponent<ChoiceItemProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,33 @@
1
+ import { type ChoiceOption } from '../../base/choice-options';
2
+ import { type ChoiceDirection } from './choice-group-class';
3
+ import './ui-choice-controls.css';
4
+ /** 单选组的属性。 */
5
+ export interface RadioGroupProps {
6
+ /** 选项;单个选项可禁用,tooltip 常用来说明禁用原因。 */
7
+ options: readonly ChoiceOption[];
8
+ /** 受控值,未选为空串。 */
9
+ value?: string;
10
+ /** 非受控时的初始值。 */
11
+ defaultValue?: string;
12
+ /** 排列方向,默认 vertical。 */
13
+ direction?: ChoiceDirection;
14
+ /** segmented 时选项等宽排成一行。 */
15
+ variant?: 'segmented';
16
+ /** 整组禁用。 */
17
+ disabled?: boolean;
18
+ /** 校验失败。 */
19
+ invalid?: boolean;
20
+ /** 根元素 id。 */
21
+ id?: string;
22
+ /** 可访问名称;在 Field 中时由标签提供。 */
23
+ 'aria-label'?: string;
24
+ /** 追加到根元素的类名。 */
25
+ className?: string;
26
+ /** 选中项变化时回调。 */
27
+ onChange?: (value: string) => void;
28
+ }
29
+ /**
30
+ * 单选组。
31
+ * @param props 属性。
32
+ */
33
+ export declare function RadioGroup({ options, value, defaultValue, direction, variant, disabled, invalid, id, className, onChange, ...aria }: RadioGroupProps): import("react").JSX.Element;
@@ -0,0 +1,25 @@
1
+ import './ui-choice-controls.css';
2
+ /** 开关的属性。 */
3
+ export interface SwitchProps {
4
+ /** 左侧文字,同时作为可访问名称。 */
5
+ label: string;
6
+ /** 受控的开启状态。 */
7
+ checked?: boolean;
8
+ /** 非受控时的初始状态。 */
9
+ defaultChecked?: boolean;
10
+ /** 禁用。 */
11
+ disabled?: boolean;
12
+ /** 校验失败。 */
13
+ invalid?: boolean;
14
+ /** 开关按钮的 id。 */
15
+ id?: string;
16
+ /** 追加到行元素的类名。 */
17
+ className?: string;
18
+ /** 开启状态变化时回调。 */
19
+ onChange?: (checked: boolean) => void;
20
+ }
21
+ /**
22
+ * 开关。
23
+ * @param props 属性。
24
+ */
25
+ export declare function Switch({ label, checked, defaultChecked, disabled, invalid, id, className, onChange }: SwitchProps): import("react").JSX.Element;