@inf-monkeys-tech/monkeys-design 0.4.30 → 0.4.31
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/README.md +142 -261
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,192 +1,76 @@
|
|
|
1
1
|
# @inf-monkeys-tech/monkeys-design
|
|
2
2
|
|
|
3
|
-
Monkeys Design
|
|
4
|
-
|
|
5
|
-
## 概述
|
|
6
|
-
|
|
7
|
-
这是一个为 Monkeys 平台设计的主题组件库,将 OEM 定制的 UI 组件从主项目中分离出来,实现:
|
|
8
|
-
|
|
9
|
-
- **组件隔离**: 各 OEM 主题组件独立维护
|
|
10
|
-
- **动态加载**: 根据 themeId 自动解析对应组件
|
|
11
|
-
- **业务分离**: 纯 UI 组件,业务逻辑由主项目注入
|
|
12
|
-
- **易于扩展**: 新增主题只需添加组件并注册,无需修改主项目
|
|
3
|
+
Monkeys Design 是一个独立的 React 组件库,提供可复用的基础组件、数据展示组件、主题工具和样式资源。
|
|
13
4
|
|
|
14
5
|
## 安装
|
|
15
6
|
|
|
16
|
-
本包发布在 npmjs public registry 上,可直接安装:
|
|
17
|
-
|
|
18
7
|
```bash
|
|
19
8
|
yarn add @inf-monkeys-tech/monkeys-design
|
|
20
9
|
```
|
|
21
10
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
### 在主项目中使用
|
|
25
|
-
|
|
26
|
-
```tsx
|
|
27
|
-
// 确保导入整个包以执行主题注册
|
|
28
|
-
import * as uiThemes from '@inf-monkeys-tech/monkeys-design';
|
|
11
|
+
或:
|
|
29
12
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
function LandingPageWrapper({ themeId }) {
|
|
33
|
-
return (
|
|
34
|
-
<DynamicComponent
|
|
35
|
-
themeId={themeId}
|
|
36
|
-
name="landing-page"
|
|
37
|
-
// 注入业务逻辑
|
|
38
|
-
isAuthenticated={isLoggedIn}
|
|
39
|
-
user={currentUser}
|
|
40
|
-
onEnterWorkbench={() => navigate('/workspace')}
|
|
41
|
-
onLogin={() => navigate('/login')}
|
|
42
|
-
onCardClick={(title) => handleNavigation(title)}
|
|
43
|
-
/>
|
|
44
|
-
);
|
|
45
|
-
}
|
|
13
|
+
```bash
|
|
14
|
+
npm install @inf-monkeys-tech/monkeys-design
|
|
46
15
|
```
|
|
47
16
|
|
|
48
|
-
|
|
17
|
+
## 使用
|
|
49
18
|
|
|
50
|
-
|
|
51
|
-
import { resolveComponent } from '@inf-monkeys-tech/monkeys-design';
|
|
52
|
-
|
|
53
|
-
const LandingPage = resolveComponent('bsd', 'landing-page');
|
|
54
|
-
|
|
55
|
-
if (LandingPage) {
|
|
56
|
-
return <LandingPage {...props} />;
|
|
57
|
-
}
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### 注册自定义主题
|
|
19
|
+
从主入口导入通用能力:
|
|
61
20
|
|
|
62
21
|
```tsx
|
|
63
|
-
import {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
'landing-page': MyCustomLandingPage,
|
|
68
|
-
}, {
|
|
69
|
-
name: 'My Custom Theme',
|
|
70
|
-
description: 'A custom theme for my application',
|
|
71
|
-
version: '1.0.0',
|
|
72
|
-
});
|
|
22
|
+
import {
|
|
23
|
+
applyMonkeysTheme,
|
|
24
|
+
resolveMonkeysTheme,
|
|
25
|
+
} from '@inf-monkeys-tech/monkeys-design';
|
|
73
26
|
```
|
|
74
27
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
| 主题 ID | 名称 | 描述 |
|
|
78
|
-
|---------|------|------|
|
|
79
|
-
| `default` | Default Theme | 默认主题,提供基础落地页组件 |
|
|
80
|
-
| `bsd` | BSD Theme | 波司登定制主题 |
|
|
81
|
-
| `artist` | Artist Theme | 艺术家定制主题 |
|
|
82
|
-
| `concept-design` | Concept Design Theme | 概念设计定制主题 |
|
|
83
|
-
|
|
84
|
-
## 组件列表
|
|
85
|
-
|
|
86
|
-
| 组件名 | 描述 | 支持主题 |
|
|
87
|
-
|--------|------|----------|
|
|
88
|
-
| `landing-page` | 落地页组件 | default, bsd, artist, concept-design |
|
|
89
|
-
| `toolbox-panel` | 工具箱面板 | bsd |
|
|
90
|
-
|
|
91
|
-
## Landing Page Props
|
|
28
|
+
从子路径导入组件:
|
|
92
29
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
user?: { name?: string; photo?: string } | null;
|
|
100
|
-
|
|
101
|
-
// 回调函数
|
|
102
|
-
onEnterWorkbench?: () => void;
|
|
103
|
-
onLogin?: () => void;
|
|
104
|
-
onCardClick?: (title: string) => void;
|
|
105
|
-
onQuickActionClick?: (name: string) => void;
|
|
30
|
+
```tsx
|
|
31
|
+
import {
|
|
32
|
+
BaseButton,
|
|
33
|
+
BasePanel,
|
|
34
|
+
type BaseAppearance,
|
|
35
|
+
} from '@inf-monkeys-tech/monkeys-design/components/base';
|
|
106
36
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
37
|
+
const appearance: BaseAppearance = {
|
|
38
|
+
preset: 'admin',
|
|
39
|
+
radius: 'lg',
|
|
40
|
+
border: 'subtle',
|
|
41
|
+
background: 'soft',
|
|
42
|
+
};
|
|
110
43
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
44
|
+
export function Example() {
|
|
45
|
+
return (
|
|
46
|
+
<BasePanel
|
|
47
|
+
appearance={appearance}
|
|
48
|
+
title="Design System"
|
|
49
|
+
description="Composable UI primitives for Monkeys products."
|
|
50
|
+
footer={<BaseButton appearance={appearance} label="Refresh" />}
|
|
51
|
+
>
|
|
52
|
+
Content stays in the consuming application.
|
|
53
|
+
</BasePanel>
|
|
54
|
+
);
|
|
116
55
|
}
|
|
117
56
|
```
|
|
118
57
|
|
|
119
|
-
##
|
|
120
|
-
|
|
121
|
-
### 环境准备
|
|
58
|
+
## 包入口
|
|
122
59
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
60
|
+
| 路径 | 内容 |
|
|
61
|
+
|------|------|
|
|
62
|
+
| `@inf-monkeys-tech/monkeys-design` | 主入口,导出注册表、主题工具和公共类型 |
|
|
63
|
+
| `@inf-monkeys-tech/monkeys-design/components/base` | 基础组件 |
|
|
64
|
+
| `@inf-monkeys-tech/monkeys-design/components/data-explorer` | 数据展示与页面组合组件 |
|
|
65
|
+
| `@inf-monkeys-tech/monkeys-design/components/login` | 登录相关 UI 组件 |
|
|
66
|
+
| `@inf-monkeys-tech/monkeys-design/components/layout` | 布局组件 |
|
|
67
|
+
| `@inf-monkeys-tech/monkeys-design/components/toolbar` | 工具栏组件 |
|
|
68
|
+
| `@inf-monkeys-tech/monkeys-design/palette` | palette 工具 |
|
|
69
|
+
| `@inf-monkeys-tech/monkeys-design/theme-system` | 主题解析与应用工具 |
|
|
126
70
|
|
|
127
|
-
|
|
128
|
-
npm run dev
|
|
71
|
+
## 基础组件
|
|
129
72
|
|
|
130
|
-
|
|
131
|
-
npm run build
|
|
132
|
-
|
|
133
|
-
# 类型检查
|
|
134
|
-
npm run typecheck
|
|
135
|
-
|
|
136
|
-
# 代码检查
|
|
137
|
-
npm run lint
|
|
138
|
-
|
|
139
|
-
# 启动组件展示站
|
|
140
|
-
npm run storybook
|
|
141
|
-
|
|
142
|
-
# 构建组件展示站静态产物
|
|
143
|
-
npm run storybook:build
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
### 组件展示
|
|
147
|
-
|
|
148
|
-
`@inf-monkeys-tech/monkeys-design` 现在内置了一个基于 Storybook 的展示入口,用来直接预览
|
|
149
|
-
组件库里的通用组件,尤其是 `data-explorer` 这类偏组合式的页面组件。
|
|
150
|
-
|
|
151
|
-
首批已提供的展示内容包括:
|
|
152
|
-
|
|
153
|
-
- `Base Components/Theme`
|
|
154
|
-
- `Base Components/Button`
|
|
155
|
-
- `Base Components/Badge`
|
|
156
|
-
- `Base Components/Panel`
|
|
157
|
-
- `Base Components/Empty State`
|
|
158
|
-
- `Base Components/Loading State`
|
|
159
|
-
- `Base Components/Field`
|
|
160
|
-
- `Base Components/Input`
|
|
161
|
-
- `Base Components/Textarea`
|
|
162
|
-
- `Base Components/Select`
|
|
163
|
-
- `Base Components/Switch`
|
|
164
|
-
- `Base Components/Notice`
|
|
165
|
-
- `Base Components/Divider`
|
|
166
|
-
- `Base Components/Section Header`
|
|
167
|
-
- `Base Components/Tabs`
|
|
168
|
-
- `Base Components/Segmented Control`
|
|
169
|
-
- `Base Components/Progress`
|
|
170
|
-
- `Base Components/Skeleton`
|
|
171
|
-
- `Base Components/Avatar`
|
|
172
|
-
- `Base Components/Toolbar`
|
|
173
|
-
- `Base Components/Breadcrumb`
|
|
174
|
-
- `Base Components/Pagination`
|
|
175
|
-
- `Base Components/Description List`
|
|
176
|
-
- `Base Components/Accordion`
|
|
177
|
-
- `Base Components/Context Menu`
|
|
178
|
-
- `Data Explorer/Display Card`
|
|
179
|
-
- `Data Explorer/View Collection`
|
|
180
|
-
- `Data Explorer/Tree`
|
|
181
|
-
- `Data Explorer/Detail Shell`
|
|
182
|
-
- `Data Explorer/Page`
|
|
183
|
-
|
|
184
|
-
这些 stories 使用本地 mock data 和 mock callbacks,目标是让组件库本身可以像其
|
|
185
|
-
它组件库一样直接浏览、对照和调试,而不依赖 `ui-admin` 或 `monkey` 的业务页。
|
|
186
|
-
|
|
187
|
-
### 基础组件
|
|
188
|
-
|
|
189
|
-
通用基础组件从 `components/base` 子路径导入:
|
|
73
|
+
基础组件从 `components/base` 子路径导入:
|
|
190
74
|
|
|
191
75
|
```tsx
|
|
192
76
|
import {
|
|
@@ -198,35 +82,72 @@ import {
|
|
|
198
82
|
BasePanel,
|
|
199
83
|
type BaseAppearance,
|
|
200
84
|
} from '@inf-monkeys-tech/monkeys-design/components/base';
|
|
201
|
-
|
|
202
|
-
const appearance: BaseAppearance = {
|
|
203
|
-
preset: 'admin',
|
|
204
|
-
radius: 'lg',
|
|
205
|
-
border: 'subtle',
|
|
206
|
-
background: 'soft',
|
|
207
|
-
};
|
|
208
85
|
```
|
|
209
86
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
87
|
+
当前包含:
|
|
88
|
+
|
|
89
|
+
- `BaseButton`
|
|
90
|
+
- `BaseBadge`
|
|
91
|
+
- `BasePanel`
|
|
92
|
+
- `BaseEmptyState`
|
|
93
|
+
- `BaseLoadingState`
|
|
94
|
+
- `BaseField`
|
|
95
|
+
- `BaseInput`
|
|
96
|
+
- `BaseTextarea`
|
|
97
|
+
- `BaseSelect`
|
|
98
|
+
- `BaseSwitch`
|
|
99
|
+
- `BaseCheckbox`
|
|
100
|
+
- `BaseRadioGroup`
|
|
101
|
+
- `BaseDialog`
|
|
102
|
+
- `BaseDropdownMenu`
|
|
103
|
+
- `BaseTooltip`
|
|
104
|
+
- `BaseTable`
|
|
105
|
+
- `BaseTableFooterBar`
|
|
106
|
+
- `BaseNotice`
|
|
107
|
+
- `BaseDivider`
|
|
108
|
+
- `BaseSectionHeader`
|
|
109
|
+
- `BaseTabs`
|
|
110
|
+
- `BaseSegmentedControl`
|
|
111
|
+
- `BaseProgress`
|
|
112
|
+
- `BaseSkeleton`
|
|
113
|
+
- `BaseAvatar`
|
|
114
|
+
- `BaseToolbar`
|
|
115
|
+
- `BaseBreadcrumb`
|
|
116
|
+
- `BasePagination`
|
|
117
|
+
- `BaseDescriptionList`
|
|
118
|
+
- `BaseAccordion`
|
|
119
|
+
- `BaseContextMenu`
|
|
120
|
+
|
|
121
|
+
`BaseAppearance` 用于控制 preset、density、radius、border、background、slot className 和 inline style 覆盖。
|
|
122
|
+
|
|
123
|
+
## Data Explorer
|
|
124
|
+
|
|
125
|
+
`components/data-explorer` 提供面向数据密集页面的组合组件。组件库负责可复用的控制、展示、预览、详情和布局结构;数据请求、权限、路由、弹窗和业务动作由使用方控制。
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
import {
|
|
129
|
+
DataExplorerView,
|
|
130
|
+
type DataExplorerViewDefinition,
|
|
131
|
+
} from '@inf-monkeys-tech/monkeys-design/components/data-explorer';
|
|
132
|
+
```
|
|
213
133
|
|
|
214
|
-
|
|
215
|
-
icon、shortcut、disabled、tone、checkbox、radio group 和 submenu 等组合。菜单
|
|
216
|
-
只负责基础交互与视觉 chrome;权限、确认弹窗、API 调用和路由跳转继续由使用方控制。
|
|
134
|
+
常用组件包括:
|
|
217
135
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
`
|
|
223
|
-
|
|
224
|
-
`
|
|
136
|
+
- `DataExplorerView`
|
|
137
|
+
- `DataExplorerViewCollection`
|
|
138
|
+
- `DataExplorerDisplayCard`
|
|
139
|
+
- `DataExplorerDisplayCollectionView`
|
|
140
|
+
- `DataExplorerDisplayActionMenu`
|
|
141
|
+
- `DataExplorerDetailShell`
|
|
142
|
+
- `DataExplorerImagePreview`
|
|
143
|
+
- `DataExplorerToolbarShell`
|
|
144
|
+
- `DataExplorerActionBar`
|
|
145
|
+
- `DataExplorerTree`
|
|
146
|
+
- `DataExplorerPage`
|
|
225
147
|
|
|
226
|
-
|
|
148
|
+
## 主题系统
|
|
227
149
|
|
|
228
|
-
`theme-system`
|
|
229
|
-
品牌信息、palette tokens、基础组件外观和 data-explorer 外观收敛到一个对象。
|
|
150
|
+
`theme-system` 提供主题配置解析和 DOM 应用入口,用于统一处理品牌信息、palette tokens、基础组件外观和 Data Explorer 外观。
|
|
230
151
|
|
|
231
152
|
```tsx
|
|
232
153
|
import {
|
|
@@ -234,106 +155,66 @@ import {
|
|
|
234
155
|
resolveMonkeysTheme,
|
|
235
156
|
} from '@inf-monkeys-tech/monkeys-design/theme-system';
|
|
236
157
|
|
|
237
|
-
const theme = resolveMonkeysTheme(
|
|
158
|
+
const theme = resolveMonkeysTheme(config);
|
|
238
159
|
|
|
239
160
|
applyMonkeysTheme(theme);
|
|
240
161
|
|
|
241
162
|
<BasePanel appearance={theme.appearances.base.input} />;
|
|
242
163
|
```
|
|
243
164
|
|
|
244
|
-
|
|
245
|
-
`theme.logo`、`theme.favicon` 等 `/api/configs` 形态;也支持库内原生的
|
|
246
|
-
`tokens`、`brand`、`appearances.base` 和 `appearances.dataExplorer`。
|
|
247
|
-
`registerTheme` 仍只负责组件替换注册,不作为业务配置 API。
|
|
165
|
+
支持的配置包括 `tokens`、`brand`、`appearances.base` 和 `appearances.dataExplorer`。也兼容 `colors.primaryColor`、`themeMode`、`roundedSize`、`logo`、`favicon` 等常见配置形态。
|
|
248
166
|
|
|
249
|
-
|
|
167
|
+
## 样式资源
|
|
250
168
|
|
|
251
|
-
|
|
252
|
-
src/
|
|
253
|
-
├── index.ts # 主入口,导出所有公共 API
|
|
254
|
-
├── registry/ # 组件注册表核心
|
|
255
|
-
│ └── index.ts # registerTheme, resolveComponent
|
|
256
|
-
├── components/ # 通用组件
|
|
257
|
-
│ └── DynamicComponent.tsx # 动态组件解析器
|
|
258
|
-
└── themes/ # 各主题组件
|
|
259
|
-
├── default/ # 默认主题
|
|
260
|
-
│ ├── index.ts # 主题注册入口
|
|
261
|
-
│ └── components/
|
|
262
|
-
│ └── LandingPage.tsx
|
|
263
|
-
├── bsd/ # BSD 主题
|
|
264
|
-
│ ├── index.ts
|
|
265
|
-
│ └── components/
|
|
266
|
-
│ ├── LandingPage.tsx
|
|
267
|
-
│ └── ToolboxPanel.tsx
|
|
268
|
-
├── artist/ # Artist 主题
|
|
269
|
-
│ ├── index.ts
|
|
270
|
-
│ └── components/
|
|
271
|
-
│ └── LandingPage.tsx
|
|
272
|
-
└── concept/ # Concept Design 主题
|
|
273
|
-
├── index.ts
|
|
274
|
-
└── components/
|
|
275
|
-
└── LandingPage.tsx
|
|
276
|
-
```
|
|
169
|
+
可从包内直接引用样式文件:
|
|
277
170
|
|
|
278
|
-
|
|
171
|
+
```ts
|
|
172
|
+
import '@inf-monkeys-tech/monkeys-design/styles/global.scss';
|
|
173
|
+
import '@inf-monkeys-tech/monkeys-design/styles/workflow-nodes.css';
|
|
174
|
+
```
|
|
279
175
|
|
|
280
|
-
|
|
281
|
-
2. 创建组件文件和 `index.ts` 入口
|
|
282
|
-
3. 在入口中使用 `registerTheme` 注册主题
|
|
283
|
-
4. 在 `src/index.ts` 中导入新主题的入口文件
|
|
284
|
-
5. 更新 `tsup.config.ts` 添加新的构建入口
|
|
176
|
+
## Storybook
|
|
285
177
|
|
|
286
|
-
|
|
178
|
+
本仓库内置 Storybook,用于预览和调试组件:
|
|
287
179
|
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
import { MyLandingPage } from './components/LandingPage';
|
|
180
|
+
```bash
|
|
181
|
+
npm run storybook
|
|
182
|
+
```
|
|
292
183
|
|
|
293
|
-
|
|
294
|
-
'landing-page': MyLandingPage,
|
|
295
|
-
}, {
|
|
296
|
-
name: 'My Theme',
|
|
297
|
-
version: '1.0.0',
|
|
298
|
-
});
|
|
184
|
+
构建静态 Storybook:
|
|
299
185
|
|
|
300
|
-
|
|
186
|
+
```bash
|
|
187
|
+
npm run storybook:build
|
|
301
188
|
```
|
|
302
189
|
|
|
303
|
-
|
|
190
|
+
## 开发
|
|
304
191
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
192
|
+
```bash
|
|
193
|
+
# 安装依赖
|
|
194
|
+
npm install
|
|
308
195
|
|
|
309
|
-
|
|
196
|
+
# 开发模式
|
|
197
|
+
npm run dev
|
|
310
198
|
|
|
311
|
-
|
|
199
|
+
# 构建生产产物
|
|
200
|
+
npm run build
|
|
312
201
|
|
|
313
|
-
|
|
202
|
+
# 类型检查
|
|
203
|
+
npm run typecheck
|
|
314
204
|
|
|
315
|
-
|
|
316
|
-
npm
|
|
317
|
-
# Email: 你的邮箱
|
|
205
|
+
# 代码检查
|
|
206
|
+
npm run lint
|
|
318
207
|
```
|
|
319
208
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
```bash
|
|
323
|
-
# 根据改动类型选择:
|
|
324
|
-
npm version patch # 修复 bug:0.1.0 → 0.1.1
|
|
325
|
-
npm version minor # 新功能: 0.1.0 → 0.2.0
|
|
326
|
-
npm version major # 破坏性变更:0.1.0 → 1.0.0
|
|
327
|
-
```
|
|
209
|
+
## 发布
|
|
328
210
|
|
|
329
|
-
|
|
211
|
+
> 需要 npmjs 账号拥有 `@inf-monkeys-tech` scope 的发布权限。
|
|
330
212
|
|
|
331
213
|
```bash
|
|
332
|
-
|
|
214
|
+
npm login --registry=https://registry.npmjs.org/
|
|
215
|
+
npm version patch
|
|
216
|
+
npm run build
|
|
217
|
+
npm publish --registry=https://registry.npmjs.org/ --access public
|
|
333
218
|
```
|
|
334
219
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
```bash
|
|
338
|
-
yarn upgrade @inf-monkeys-tech/monkeys-design
|
|
339
|
-
```
|
|
220
|
+
如果账号启用了浏览器钥匙串或 passkey,npm CLI 会给出一个浏览器验证链接。完成验证后发布会继续。
|