@inf-monkeys-tech/monkeys-design 0.4.30 → 0.4.32

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 CHANGED
@@ -1,192 +1,76 @@
1
1
  # @inf-monkeys-tech/monkeys-design
2
2
 
3
- Monkeys Design 组件库 - 用于 OEM 定制的独立 UI 组件包
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
- const { DynamicComponent } = uiThemes;
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
- ```tsx
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 { registerTheme } from '@inf-monkeys-tech/monkeys-design';
64
- import { MyCustomLandingPage } from './MyCustomLandingPage';
65
-
66
- registerTheme('my-theme', {
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
- 各主题的 Landing Page 组件支持以下通用 props:
94
-
95
- ```typescript
96
- interface LandingPageProps {
97
- // 认证状态
98
- isAuthenticated?: boolean;
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
- className?: string;
109
- style?: React.CSSProperties;
37
+ const appearance: BaseAppearance = {
38
+ preset: 'admin',
39
+ radius: 'lg',
40
+ border: 'subtle',
41
+ background: 'soft',
42
+ };
110
43
 
111
- // 主题特定配置(可选)
112
- featureCards?: FeatureCardData[]; // BSD
113
- quickActions?: QuickActionData[]; // Artist, Concept
114
- i18n?: { ... }; // BSD
115
- backgroundComponent?: React.ReactNode; // Artist
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
- ```bash
124
- # 安装依赖
125
- npm install
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,78 @@ 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
- `BaseAppearance` 负责基础组件的 preset、density、radius、border、background、
211
- slot 覆盖和 inline style 覆盖。业务仓库仍然负责请求、权限、路由、弹窗副作用和
212
- 具体回调。
87
+ 当前包含:
88
+
89
+ - `BaseButton`
90
+ - `BaseBadge`
91
+ - `BasePanel`
92
+ - `BaseEmptyState`
93
+ - `BaseLoadingState`
94
+ - `BaseField`
95
+ - `BaseInput`
96
+ - `BaseTextarea`
97
+ - `BaseSelect`
98
+ - `BaseLayout`
99
+ - `BaseLayoutPane`
100
+ - `BaseLayoutSplit`
101
+ - `BaseLayoutResizeHandle`
102
+ - `BaseSwitch`
103
+ - `BaseCheckbox`
104
+ - `BaseRadioGroup`
105
+ - `BaseDialog`
106
+ - `BaseDropdownMenu`
107
+ - `BaseTooltip`
108
+ - `BaseTable`
109
+ - `BaseTableFooterBar`
110
+ - `BaseNotice`
111
+ - `BaseDivider`
112
+ - `BaseSectionHeader`
113
+ - `BaseTabs`
114
+ - `BaseSegmentedControl`
115
+ - `BaseProgress`
116
+ - `BaseSkeleton`
117
+ - `BaseAvatar`
118
+ - `BaseToolbar`
119
+ - `BaseBreadcrumb`
120
+ - `BasePagination`
121
+ - `BaseDescriptionList`
122
+ - `BaseAccordion`
123
+ - `BaseContextMenu`
124
+
125
+ `BaseAppearance` 用于控制 preset、density、radius、border、background、slot className 和 inline style 覆盖。
126
+
127
+ `BaseLayout` 提供中立布局 primitives:`BaseLayout` 管 header/sidebar/main/aside/footer 区域,`BaseLayoutPane` 管主题化区域表面,`BaseLayoutSplit` 管固定或可调的左右/上下分割。`gap` 可显式控制区域间距,number 按 px,string 原样作为 CSS 长度;不传时继续使用 `BaseAppearance` 的主题间距。可调分割支持 `defaultSize`、受控 `size`、`minSize`、`maxSize` 和 `onSizeChange`;尺寸是否持久化仍由使用方控制。
128
+
129
+ ## Data Explorer
130
+
131
+ `components/data-explorer` 提供面向数据密集页面的组合组件。组件库负责可复用的控制、展示、预览、详情和布局结构;数据请求、权限、路由、弹窗和业务动作由使用方控制。
132
+
133
+ ```tsx
134
+ import {
135
+ DataExplorerView,
136
+ type DataExplorerViewDefinition,
137
+ } from '@inf-monkeys-tech/monkeys-design/components/data-explorer';
138
+ ```
213
139
 
214
- `BaseContextMenu` 提供 Radix-backed 右键菜单基础件,支持 label、separator、
215
- icon、shortcut、disabled、tone、checkbox、radio group 和 submenu 等组合。菜单
216
- 只负责基础交互与视觉 chrome;权限、确认弹窗、API 调用和路由跳转继续由使用方控制。
140
+ 常用组件包括:
217
141
 
218
- 基础组件默认带有轻量动效,并避免大幅位置移动:按钮、分页、面包屑、面板和描述项主要使用
219
- 颜色、背景、边框、阴影和透明度的平滑过渡;select 弹层、notice、tabs panel、accordion
220
- panel 使用淡入;select/accordion 图标和 Switch thumb 使用轻量 transform 过渡;progress 使用宽度过渡;
221
- skeleton/loading 使用脉冲或旋转加载反馈。可点击控件默认提供 pointer 光标,disabled 状态保留
222
- `cursor-not-allowed`。
223
- 需要静态或更强品牌化效果时,可以通过 `BaseAppearance.slots`
224
- `BaseAppearance.styles` 覆盖。
142
+ - `DataExplorerView`
143
+ - `DataExplorerViewCollection`
144
+ - `DataExplorerDisplayCard`
145
+ - `DataExplorerDisplayCollectionView`
146
+ - `DataExplorerDisplayActionMenu`
147
+ - `DataExplorerDetailShell`
148
+ - `DataExplorerImagePreview`
149
+ - `DataExplorerToolbarShell`
150
+ - `DataExplorerActionBar`
151
+ - `DataExplorerTree`
152
+ - `DataExplorerPage`
225
153
 
226
- ### 主题系统
154
+ ## 主题系统
227
155
 
228
- `theme-system` 子路径提供统一的主题配置解析和 DOM 应用入口,用于把后端配置、
229
- 品牌信息、palette tokens、基础组件外观和 data-explorer 外观收敛到一个对象。
156
+ `theme-system` 提供主题配置解析和 DOM 应用入口,用于统一处理品牌信息、palette tokens、基础组件外观和 Data Explorer 外观。
230
157
 
231
158
  ```tsx
232
159
  import {
@@ -234,106 +161,66 @@ import {
234
161
  resolveMonkeysTheme,
235
162
  } from '@inf-monkeys-tech/monkeys-design/theme-system';
236
163
 
237
- const theme = resolveMonkeysTheme(systemConfig);
164
+ const theme = resolveMonkeysTheme(config);
238
165
 
239
166
  applyMonkeysTheme(theme);
240
167
 
241
168
  <BasePanel appearance={theme.appearances.base.input} />;
242
169
  ```
243
170
 
244
- 当前兼容 `theme.colors.primaryColor`、`theme.themeMode`、`theme.roundedSize`、
245
- `theme.logo`、`theme.favicon` 等 `/api/configs` 形态;也支持库内原生的
246
- `tokens`、`brand`、`appearances.base` 和 `appearances.dataExplorer`。
247
- `registerTheme` 仍只负责组件替换注册,不作为业务配置 API。
171
+ 支持的配置包括 `tokens`、`brand`、`appearances.base` 和 `appearances.dataExplorer`。也兼容 `colors.primaryColor`、`themeMode`、`roundedSize`、`logo`、`favicon` 等常见配置形态。
248
172
 
249
- ### 目录结构
173
+ ## 样式资源
250
174
 
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
- ```
175
+ 可从包内直接引用样式文件:
277
176
 
278
- ### 新增主题
177
+ ```ts
178
+ import '@inf-monkeys-tech/monkeys-design/styles/global.scss';
179
+ import '@inf-monkeys-tech/monkeys-design/styles/workflow-nodes.css';
180
+ ```
279
181
 
280
- 1. 在 `src/themes/` 下创建新的主题目录
281
- 2. 创建组件文件和 `index.ts` 入口
282
- 3. 在入口中使用 `registerTheme` 注册主题
283
- 4. 在 `src/index.ts` 中导入新主题的入口文件
284
- 5. 更新 `tsup.config.ts` 添加新的构建入口
182
+ ## Storybook
285
183
 
286
- 示例:
184
+ 本仓库内置 Storybook,用于预览和调试组件:
287
185
 
288
- ```typescript
289
- // src/themes/my-theme/index.ts
290
- import { registerTheme } from '../../registry';
291
- import { MyLandingPage } from './components/LandingPage';
186
+ ```bash
187
+ npm run storybook
188
+ ```
292
189
 
293
- registerTheme('my-theme', {
294
- 'landing-page': MyLandingPage,
295
- }, {
296
- name: 'My Theme',
297
- version: '1.0.0',
298
- });
190
+ 构建静态 Storybook:
299
191
 
300
- export { MyLandingPage };
192
+ ```bash
193
+ npm run storybook:build
301
194
  ```
302
195
 
303
- ### 注意事项
196
+ ## 开发
304
197
 
305
- - **sideEffects**: `package.json` 中设置 `"sideEffects": true` 以防止 tree-shaking 移除主题注册代码
306
- - **导入方式**: 在主项目中使用 `import * as uiThemes` 确保所有主题注册代码被执行
307
- - **Vite 配置**: 在主项目的 `vite.config.ts` 中将此包添加到 `optimizeDeps.include`
198
+ ```bash
199
+ # 安装依赖
200
+ npm install
308
201
 
309
- ## 发布新版本
202
+ # 开发模式
203
+ npm run dev
310
204
 
311
- > 首次发布需要 npmjs 账号拥有发布权限。
205
+ # 构建生产产物
206
+ npm run build
312
207
 
313
- ### 1. 登录 npmjs
208
+ # 类型检查
209
+ npm run typecheck
314
210
 
315
- ```bash
316
- npm login --registry=https://registry.npmjs.org/
317
- # Email: 你的邮箱
211
+ # 代码检查
212
+ npm run lint
318
213
  ```
319
214
 
320
- ### 2. 更新版本号
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
- ```
215
+ ## 发布
328
216
 
329
- ### 3. 构建并发布
217
+ > 需要 npmjs 账号拥有 `@inf-monkeys-tech` scope 的发布权限。
330
218
 
331
219
  ```bash
332
- yarn build && npm publish
220
+ npm login --registry=https://registry.npmjs.org/
221
+ npm version patch
222
+ npm run build
223
+ npm publish --registry=https://registry.npmjs.org/ --access public
333
224
  ```
334
225
 
335
- ### 4. 在消费端更新
336
-
337
- ```bash
338
- yarn upgrade @inf-monkeys-tech/monkeys-design
339
- ```
226
+ 如果账号启用了浏览器钥匙串或 passkey,npm CLI 会给出一个浏览器验证链接。完成验证后发布会继续。