@blocklet/ui-react 3.1.48 → 3.1.49

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 (98) hide show
  1. package/.aigne/doc-smith/config.yaml +76 -0
  2. package/.aigne/doc-smith/history.yaml +9 -0
  3. package/.aigne/doc-smith/output/structure-plan.json +249 -0
  4. package/.aigne/doc-smith/upload-cache.yaml +528 -0
  5. package/docs/_sidebar.md +19 -0
  6. package/docs/components-component-management-blocklet-studio.ja.md +194 -0
  7. package/docs/components-component-management-blocklet-studio.md +194 -0
  8. package/docs/components-component-management-blocklet-studio.zh-TW.md +194 -0
  9. package/docs/components-component-management-blocklet-studio.zh.md +194 -0
  10. package/docs/components-component-management-component-installer.ja.md +256 -0
  11. package/docs/components-component-management-component-installer.md +256 -0
  12. package/docs/components-component-management-component-installer.zh-TW.md +256 -0
  13. package/docs/components-component-management-component-installer.zh.md +256 -0
  14. package/docs/components-component-management.ja.md +59 -0
  15. package/docs/components-component-management.md +59 -0
  16. package/docs/components-component-management.zh-TW.md +59 -0
  17. package/docs/components-component-management.zh.md +59 -0
  18. package/docs/components-layout-dashboard.ja.md +231 -0
  19. package/docs/components-layout-dashboard.md +231 -0
  20. package/docs/components-layout-dashboard.zh-TW.md +231 -0
  21. package/docs/components-layout-dashboard.zh.md +231 -0
  22. package/docs/components-layout-footer.ja.md +165 -0
  23. package/docs/components-layout-footer.md +165 -0
  24. package/docs/components-layout-footer.zh-TW.md +165 -0
  25. package/docs/components-layout-footer.zh.md +165 -0
  26. package/docs/components-layout-header.ja.md +233 -0
  27. package/docs/components-layout-header.md +233 -0
  28. package/docs/components-layout-header.zh-TW.md +233 -0
  29. package/docs/components-layout-header.zh.md +233 -0
  30. package/docs/components-layout.ja.md +50 -0
  31. package/docs/components-layout.md +50 -0
  32. package/docs/components-layout.zh-TW.md +50 -0
  33. package/docs/components-layout.zh.md +50 -0
  34. package/docs/components-notifications.ja.md +173 -0
  35. package/docs/components-notifications.md +173 -0
  36. package/docs/components-notifications.zh-TW.md +174 -0
  37. package/docs/components-notifications.zh.md +173 -0
  38. package/docs/components-user-management-user-center.ja.md +183 -0
  39. package/docs/components-user-management-user-center.md +183 -0
  40. package/docs/components-user-management-user-center.zh-TW.md +183 -0
  41. package/docs/components-user-management-user-center.zh.md +183 -0
  42. package/docs/components-user-management-user-sessions.ja.md +164 -0
  43. package/docs/components-user-management-user-sessions.md +164 -0
  44. package/docs/components-user-management-user-sessions.zh-TW.md +164 -0
  45. package/docs/components-user-management-user-sessions.zh.md +164 -0
  46. package/docs/components-user-management.ja.md +76 -0
  47. package/docs/components-user-management.md +76 -0
  48. package/docs/components-user-management.zh-TW.md +76 -0
  49. package/docs/components-user-management.zh.md +76 -0
  50. package/docs/components-utilities-icon.ja.md +106 -0
  51. package/docs/components-utilities-icon.md +106 -0
  52. package/docs/components-utilities-icon.zh-TW.md +106 -0
  53. package/docs/components-utilities-icon.zh.md +106 -0
  54. package/docs/components-utilities.ja.md +136 -0
  55. package/docs/components-utilities.md +136 -0
  56. package/docs/components-utilities.zh-TW.md +136 -0
  57. package/docs/components-utilities.zh.md +136 -0
  58. package/docs/components.ja.md +27 -0
  59. package/docs/components.md +27 -0
  60. package/docs/components.zh-TW.md +27 -0
  61. package/docs/components.zh.md +27 -0
  62. package/docs/core-concepts.ja.md +164 -0
  63. package/docs/core-concepts.md +164 -0
  64. package/docs/core-concepts.zh-TW.md +164 -0
  65. package/docs/core-concepts.zh.md +164 -0
  66. package/docs/getting-started.ja.md +132 -0
  67. package/docs/getting-started.md +132 -0
  68. package/docs/getting-started.zh-TW.md +132 -0
  69. package/docs/getting-started.zh.md +132 -0
  70. package/docs/hooks-api.ja.md +214 -0
  71. package/docs/hooks-api.md +214 -0
  72. package/docs/hooks-api.zh-TW.md +214 -0
  73. package/docs/hooks-api.zh.md +214 -0
  74. package/docs/how-to-guides.ja.md +413 -0
  75. package/docs/how-to-guides.md +413 -0
  76. package/docs/how-to-guides.zh-TW.md +413 -0
  77. package/docs/how-to-guides.zh.md +413 -0
  78. package/docs/overview.ja.md +91 -0
  79. package/docs/overview.md +91 -0
  80. package/docs/overview.zh-TW.md +91 -0
  81. package/docs/overview.zh.md +91 -0
  82. package/glossary.md +12 -0
  83. package/lib/Dashboard/index.js +46 -42
  84. package/lib/Footer/index.js +51 -36
  85. package/lib/Header/index.js +48 -44
  86. package/lib/UserCenter/components/settings.js +1 -0
  87. package/lib/UserCenter/components/user-center.js +133 -133
  88. package/lib/blocklets.d.ts +13 -2
  89. package/lib/blocklets.js +40 -40
  90. package/lib/common/header-addons.js +37 -33
  91. package/package.json +7 -7
  92. package/src/Dashboard/index.jsx +8 -3
  93. package/src/Footer/index.jsx +22 -4
  94. package/src/Header/index.tsx +7 -2
  95. package/src/UserCenter/components/settings.tsx +1 -0
  96. package/src/UserCenter/components/user-center.tsx +6 -6
  97. package/src/blocklets.js +18 -9
  98. package/src/common/header-addons.jsx +7 -2
@@ -0,0 +1,413 @@
1
+ # 操作指南
2
+
3
+ 本节提供了使用该库的组件完成常见任务和实现特定工作流的实用分步指南。每个指南都设计为一套独立的操作说明,旨在帮助您高效地实现特定目标。
4
+
5
+ <x-cards data-columns="2">
6
+ <x-card data-title="如何向 Header 添加自定义元素" data-icon="lucide:layout-template" data-href="#how-to-add-custom-elements-to-the-header">
7
+ 学习如何使用 `addons` 渲染属性来扩展 `Header` 组件,添加自定义按钮、导航或其他交互元素。
8
+ </x-card>
9
+ <x-card data-title="如何处理可选组件依赖" data-icon="lucide:puzzle" data-href="#how-to-handle-optional-component-dependencies">
10
+ 实现一个工作流,提示管理员按需安装所需组件,确保您的 Blocklet 功能顺利运行。
11
+ </x-card>
12
+ <x-card data-title="如何实现实时用户通知" data-icon="lucide:bell-ring" data-href="#how-to-implement-real-time-user-notifications">
13
+ 使用 WebSockets 建立一个实时通知系统,让用户随时了解应用内的重要事件。
14
+ </x-card>
15
+ <x-card data-title="如何使用 BlockletStudio 发布资源" data-icon="lucide:rocket" data-href="#how-to-publish-resources-with-blockletstudio">
16
+ 集成 `BlockletStudio` 组件,为发布和管理资源及依赖组件提供用户界面。
17
+ </x-card>
18
+ </x-cards>
19
+
20
+ ---
21
+
22
+ ## 如何向 Header 添加自定义元素
23
+
24
+ `Header` 组件被设计为可扩展的。您可以利用 `addons` 属性,直接在页眉中添加自定义按钮、搜索栏或其他 React 组件。
25
+
26
+ ### 目标
27
+
28
+ 在主应用页眉中添加一个自定义的“聊天”按钮、一个搜索输入框以及其他操作图标。
29
+
30
+ ### 前提条件
31
+
32
+ - 一个已安装 `@arcblock/ux` 库并能正常运行的 React 应用。
33
+ - 一个已有的 `<Header>` 组件实例。更多信息,请参阅 [Header 组件文档](./components-layout-header.md)。
34
+
35
+ ### 步骤
36
+
37
+ `addons` 属性接受一个渲染函数。该函数接收默认插件(如会话管理器)作为其第一个参数,让您能够决定将自定义元素放置在默认元素的相对位置。
38
+
39
+ 1. **定义 `addons` 渲染属性**
40
+
41
+ 在您的 `Header` 组件中,向 `addons` 属性传递一个函数。该函数应返回您想要渲染的 JSX。
42
+
43
+ ```jsx
44
+ <Header
45
+ meta={meta}
46
+ addons={(defaultAddons, { navigation }) => {
47
+ // 您的自定义组件将放在这里
48
+ return (
49
+ <>
50
+ {/* 渲染您的自定义组件 */}
51
+ {defaultAddons}
52
+ </>
53
+ );
54
+ }}
55
+ />
56
+ ```
57
+
58
+ 2. **添加自定义组件**
59
+
60
+ 在渲染函数内部,您可以添加任何您需要的组件。在此示例中,我们将添加一个标准的 Material-UI `Button`、几个用于图标的 `AddonButton` 组件和一个 `Divider`。
61
+
62
+ 3. **与默认插件结合**
63
+
64
+ 通常的做法是渲染传入函数的 `defaultAddons`。这可以确保像区域设置切换器和会话管理器这样的基本元素仍然显示。您可以将自定义组件放置在 `defaultAddons` 之前或之后。
65
+
66
+ ### 完整示例
67
+
68
+ 以下是一个完整的示例,演示了如何向页眉添加多个自定义元素。这包括导航、按钮和图标,它们与默认的会话管理器一起渲染。
69
+
70
+ ```javascript How to Add Custom Elements to the Header icon=logos:react
71
+ import { Box, Divider, Button } from '@mui/material';
72
+ import { SessionContext } from '@arcblock/did-connect-react/lib/Session';
73
+ import { AddonButton } from '@arcblock/ux/lib/Header/addon-button';
74
+ import NavMenu from '@arcblock/ux/lib/NavMenu';
75
+ import SessionManager from '@arcblock/ux/lib/SessionManager';
76
+ import Header from '@arcblock/ux/lib/Header';
77
+ import { Icon } from '@iconify/react';
78
+
79
+ // 用于演示的模拟数据
80
+ const mockBlockletMeta = {
81
+ title: 'My App',
82
+ description: 'A great application',
83
+ logoUrl: 'https://www.arcblock.io/image-bin/uploads/eb1cf5d60cd85c42362920c49e3768cb.svg'
84
+ };
85
+
86
+ const mockSessionContextValue = {
87
+ session: {
88
+ user: {
89
+ fullName: 'Demo User',
90
+ did: 'z1ex...',
91
+ role: 'admin',
92
+ },
93
+ // ... 其他会话属性
94
+ },
95
+ };
96
+
97
+ export default function CustomHeaderGuide() {
98
+ const meta = {
99
+ ...mockBlockletMeta,
100
+ enableConnect: true,
101
+ enableLocale: true,
102
+ };
103
+
104
+ return (
105
+ <SessionContext.Provider value={mockSessionContextValue}>
106
+ <Header
107
+ meta={meta}
108
+ homeLink="https://www.arcblock.io"
109
+ addons={(defaultAddons, { navigation }) => (
110
+ <>
111
+ {/* 1. 添加自定义导航 */}
112
+ {navigation.navItems?.length > 0 && (
113
+ <NavMenu
114
+ activeId={navigation.activeId}
115
+ items={navigation.navItems}
116
+ className="header-nav"
117
+ />
118
+ )}
119
+ {/* 2. 添加自定义按钮 */}
120
+ <Button variant="contained" color="primary" size="small">
121
+ Button
122
+ </Button>
123
+ {/* 3. 添加自定义图标按钮 */}
124
+ <AddonButton icon={<Icon icon="tabler:message-circle" />}>Chat</AddonButton>
125
+ <AddonButton icon={<Icon icon="tabler:bell" />} />
126
+ <Divider orientation="vertical" flexItem sx={{ height: 12, alignSelf: 'center' }} />
127
+ {/* 4. 渲染默认插件(包括会话管理器) */}
128
+ {defaultAddons}
129
+ </>
130
+ )}
131
+ />
132
+ </SessionContext.Provider>
133
+ );
134
+ }
135
+ ```
136
+
137
+ ---
138
+
139
+ ## 如何处理可选组件依赖
140
+
141
+ 许多 Blocklet 依赖其他组件来提供特定功能。`ComponentInstaller` 允许您构建依赖于可选组件的功能,如果这些组件未安装,它会为管理员提供一个用户友好的安装方式。
142
+
143
+ ### 目标
144
+
145
+ 保护一个需要安装其他 Blocklet 组件才能使用的功能。如果该组件缺失,管理员将看到一个安装界面,而其他用户则什么也看不到。
146
+
147
+ ### 前提条件
148
+
149
+ - 您的应用中有一个依赖于其他组件的功能(例如,一个需要“媒体套件”Blocklet 的“媒体管理器”)。
150
+ - 组件依赖项的 DID。
151
+ - 熟悉用户角色(`owner`、`admin`)。
152
+
153
+ ### 步骤
154
+
155
+ 1. **导入 `ComponentInstaller`**
156
+
157
+ 首先,从库中导入该组件。
158
+
159
+ ```javascript
160
+ import ComponentInstaller from '@arcblock/ux/lib/ComponentInstaller';
161
+ ```
162
+
163
+ 2. **包裹您的功能**
164
+
165
+ 用 `ComponentInstaller` 包裹具有依赖项的组件或功能。
166
+
167
+ 3. **提供组件 DID**
168
+
169
+ 将所需组件的 DID 传递给 `did` 属性。如果存在多个依赖项,这可以是一个字符串,也可以是一个字符串数组。
170
+
171
+ 4. **为非管理员配置行为**
172
+
173
+ 使用 `noPermissionMute` 属性。当设置为 `true` 时,没有权限安装组件的用户(即非管理员)将不会看到安装提示。您可以提供一个 `fallback` 组件来替代显示。
174
+
175
+ ### 完整示例
176
+
177
+ 在此场景中,我们有一个 `MyFeatureButton`,它只应在 DID 为 `z8ia...` 的组件安装后才渲染。
178
+
179
+ ```javascript How to Handle Optional Component Dependencies icon=logos:react
180
+ import ComponentInstaller from '@arcblock/ux/lib/ComponentInstaller';
181
+ import { Button } from '@mui/material';
182
+
183
+ const REQUIRED_COMPONENT_DID = 'z8ia1mAXo8ZE7ytGF36L5uBf9kD2kenhqFGp9'; // 示例 DID
184
+
185
+ // 这是需要依赖项的组件
186
+ function MyFeatureButton() {
187
+ return <Button variant="contained">Use Awesome Feature</Button>;
188
+ }
189
+
190
+ export default function OptionalComponentGuide() {
191
+ return (
192
+ <ComponentInstaller
193
+ // 要检查的组件的 DID
194
+ did={REQUIRED_COMPONENT_DID}
195
+ // 允许查看安装程序 UI 的角色列表
196
+ roles={['owner', 'admin']}
197
+ // 如果为 true,非管理员将看不到安装程序 UI
198
+ noPermissionMute
199
+ // 可选:如果组件未安装,向非管理员显示的内容
200
+ fallback={<div>This feature is not available.</div>}
201
+ // 成功安装后触发的回调
202
+ onInstalled={() => console.log('Component was installed successfully!')}
203
+ >
204
+ {/* 只有在组件已安装的情况下才会渲染此子组件 */}
205
+ <MyFeatureButton />
206
+ </ComponentInstaller>
207
+ );
208
+ }
209
+ ```
210
+
211
+ 当管理员访问此页面且组件未安装时,他们会看到一个允许他们安装的弹出窗口。普通用户将看到回退消息。一旦安装,所有用户都将看到 `MyFeatureButton`。
212
+
213
+ ---
214
+
215
+ ## 如何实现实时用户通知
216
+
217
+ 您可以通过监听来自 Blocklet Server 的 WebSocket 事件,为用户提供实时反馈和通知。`NotificationAddon` 组件是一个即用型解决方案,用于在页眉中显示未读通知计数。
218
+
219
+ ### 目标
220
+
221
+ 在应用页眉中添加一个通知铃铛图标,该图标会显示带有未读通知数量的徽章,并实时更新。
222
+
223
+ ### 前提条件
224
+
225
+ - 您的 Blocklet 必须运行在支持通知服务的 Blocklet Server 版本上(`1.16.42` 或更高)。
226
+ - 一个用于放置通知图标的 `<Header>` 组件。
227
+ - 一个提供用户信息的会话上下文。
228
+
229
+ ### 关键概念
230
+
231
+ - **WebSocket 事件**:当通知被创建或读取时,Blocklet Server 会广播事件。
232
+ - **`useListenWsClient`**:一个用于获取特定频道(例如 'user')的 WebSocket 客户端实例的钩子。
233
+ - **事件命名**:事件的作用域限定于用户和 Blocklet。新通知的格式为 `${blocklet.did}/${user.did}/notification:blocklet:create`。
234
+
235
+ ### 步骤
236
+
237
+ `NotificationAddon` 组件封装了监听 WebSocket 事件和显示未读计数所需的所有逻辑。
238
+
239
+ 1. **导入 `NotificationAddon`**
240
+
241
+ ```javascript
242
+ import NotificationAddon from '@arcblock/ux/lib/common/notification-addon';
243
+ ```
244
+
245
+ 2. **添加到 Header `addons`**
246
+
247
+ 使用此组件最简单的方法是将其添加到 `Header` 的 `addons` 渲染属性中。
248
+
249
+ 3. **传递会话对象**
250
+
251
+ `NotificationAddon` 组件需要 `session` 对象来识别当前用户并管理未读计数状态。
252
+
253
+ ### 完整示例
254
+
255
+ 此示例展示了如何将 `NotificationAddon` 集成到 `Header` 中。它将自动连接到 WebSocket,监听事件,并更新徽章计数。
256
+
257
+ ```javascript How to Implement Real-time User Notifications icon=logos:react
258
+ import { SessionContext } from '@arcblock/did-connect-react/lib/Session';
259
+ import Header from '@arcblock/ux/lib/Header';
260
+ import NotificationAddon from '@arcblock/ux/lib/common/notification-addon';
261
+
262
+ // 用于演示的模拟数据
263
+ const mockBlockletMeta = {
264
+ title: 'My App',
265
+ description: 'A great application',
266
+ logoUrl: 'https://www.arcblock.io/image-bin/uploads/eb1cf5d60cd85c42362920c49e3768cb.svg'
267
+ };
268
+
269
+ const mockSessionContextValue = {
270
+ session: {
271
+ user: {
272
+ fullName: 'Demo User',
273
+ did: 'z1ex...',
274
+ role: 'admin',
275
+ },
276
+ unReadCount: 3, // 初始未读计数
277
+ setUnReadCount: () => {}, // 状态设置函数
278
+ // ... 其他会话属性
279
+ },
280
+ };
281
+
282
+ export default function NotificationGuide() {
283
+ const meta = { ...mockBlockletMeta, enableConnect: true };
284
+
285
+ return (
286
+ <SessionContext.Provider value={mockSessionContextValue}>
287
+ <Header
288
+ meta={meta}
289
+ addons={(defaultAddons) => (
290
+ <>
291
+ {/* NotificationAddon 将处理实时更新 */}
292
+ <NotificationAddon session={mockSessionContextValue.session} />
293
+ {defaultAddons}
294
+ </>
295
+ )}
296
+ />
297
+ </SessionContext.Provider>
298
+ );
299
+ }
300
+ ```
301
+
302
+ 当为已登录用户创建新通知时,铃铛图标上的徽章计数将自动增加。点击该图标将导航用户到他们的通知页面。
303
+
304
+ ---
305
+
306
+ ## 如何使用 BlockletStudio 发布资源
307
+
308
+ `BlockletStudio` 组件提供了一个完整的、可嵌入的 UI,用于发布资源和组件。它处理用户连接、资源选择和发布流程,将一个复杂的工作流简化为一个单一的组件。
309
+
310
+ ### 目标
311
+
312
+ 添加一个按钮,该按钮可以打开一个对话框,允许用户从 Blocklet 中选择并发布文件和依赖组件。
313
+
314
+ ### 前提条件
315
+
316
+ - 您的 Blocklet 中有一个 API 端点,用于返回可用资源列表。
317
+ - 提供发布 UI 的组件(“工作室”组件)的 DID。
318
+
319
+ ### 步骤
320
+
321
+ 1. **导入 `BlockletStudio` 并管理状态**
322
+
323
+ 您需要使用组件状态来管理工作室对话框的可见性。
324
+
325
+ ```javascript
326
+ import { useState } from 'react';
327
+ import { BlockletStudio } from '@arcblock/ux/lib/BlockletStudio';
328
+ import { Button, CircularProgress } from '@mui/material';
329
+ ```
330
+
331
+ 2. **渲染组件**
332
+
333
+ 将 `<BlockletStudio />` 组件放置在您的应用中,并使用 `open` 和 `setOpen` 属性控制其可见性。
334
+
335
+ 3. **配置基本属性**
336
+
337
+ - `componentDid`:提供发布服务的工作室 Blocklet 的 DID。
338
+ - `title`、`description`:正在发布的项目的元数据。
339
+ - `resourcesParams`:作为查询参数传递给您的资源获取 API 的对象。
340
+ - `components`:要预选或必须包含的组件数组。
341
+ - `resources`:指定要预选的资源的对象。
342
+
343
+ 4. **处理生命周期事件**
344
+
345
+ 使用 `onOpened`、`onUploaded` 和 `onReleased` 回调来响应发布生命周期中的事件,例如隐藏加载指示器或显示成功消息。
346
+
347
+ ### 完整示例
348
+
349
+ 此示例展示了一个按钮,点击后会打开 `BlockletStudio` 对话框。它还演示了如何管理加载状态以提供更好的用户体验。
350
+
351
+ ```javascript How to Publish Resources with BlockletStudio icon=logos:react
352
+ import { useState } from 'react';
353
+ import { Button, CircularProgress } from '@mui/material';
354
+ import { BlockletStudio } from '@arcblock/ux/lib/BlockletStudio';
355
+
356
+ // 提供工作室/发布 UI 的 Blocklet 的 DID
357
+ const AI_STUDIO_COMPONENT_DID = 'z8ia1mAXo8ZE7ytGF36L5uBf9kD2kenhqFGp9'; // 示例 DID
358
+
359
+ export default function PublisherGuide() {
360
+ const [isStudioOpen, setStudioOpen] = useState(false);
361
+ const [isOpening, setOpening] = useState(false);
362
+
363
+ const handleShowDialog = () => {
364
+ setOpening(true);
365
+ setStudioOpen(true);
366
+ };
367
+
368
+ return (
369
+ <>
370
+ <Button
371
+ variant="contained"
372
+ onClick={handleShowDialog}
373
+ disabled={isOpening}
374
+ startIcon={isOpening ? <CircularProgress size={16} /> : null}>
375
+ Publish to Studio
376
+ </Button>
377
+
378
+ <BlockletStudio
379
+ // 控制对话框的可见性
380
+ open={isStudioOpen}
381
+ setOpen={setStudioOpen}
382
+ // 已发布项目的基本信息
383
+ title="My Demo Project"
384
+ description="This is a project published from my blocklet."
385
+ // 工作室服务组件的 DID
386
+ componentDid={AI_STUDIO_COMPONENT_DID}
387
+ // 发送到您的 Blocklet 资源 API 的参数
388
+ resourcesParams={{ projectId: 'test-project-123' }}
389
+ // 预选组件
390
+ components={[
391
+ { did: 'z8ia3xzq2tMq8CRHfaXj1BTYJyYnEcHbqP8cJ', included: true, required: true },
392
+ { did: 'z2qZyjnsRffFtn2PDnDwDHTRbAu53RpKqDtFZ', included: true, required: false },
393
+ ]}
394
+ // 预选资源
395
+ resources={{
396
+ // 键是资源提供者 Blocklet 的 DID
397
+ z8iZpog7mcgcgBZzTiXJCWESvmnRrQmnd3XBB: [
398
+ 'template-448698592710885376',
399
+ 'example-448698592710885376',
400
+ ],
401
+ }}
402
+ // 事件处理程序
403
+ onOpened={() => setOpening(false)}
404
+ onUploaded={() => alert('Upload complete!')}
405
+ onReleased={() => {
406
+ alert('Successfully released!');
407
+ setStudioOpen(false);
408
+ }}
409
+ />
410
+ </>
411
+ );
412
+ }
413
+ ```
@@ -0,0 +1,91 @@
1
+ # 概要
2
+
3
+ `@blocklet/ui-react`ライブラリは、Blockletと呼ばれるアプリケーションの開発を加速するために設計された、必須のReactコンポーネントのコレクションを提供します。これは、Blockletのメタデータをインテリジェントに使用することで、一般的なユーザーインターフェース要素の作成を合理化し、開発者が最小限の労力で一貫性のある機能豊富なUIを構築できるようにします。
4
+
5
+ このライブラリは、Material-UIのテーマ付き拡張である`@arcblock/ux`を基盤として構築されています。この基盤により、すべてのコンポーネントが堅牢で、アクセシビリティが高く、アプリケーションのブランディングに合わせて簡単にカスタマイズできることが保証されます。
6
+
7
+ ## 解決する課題
8
+
9
+ 現代のWebアプリケーションでは、レイアウト、ユーザー管理、通知のために標準的なUIコンポーネントのセットがしばしば必要とされます。これらをプロジェクトごとにゼロから実装するのは時間がかかり、一貫性の欠如につながる可能性があります。Blocklet UI Reactライブラリは、Blockletのメタデータ(`blocklet.yml`)に基づいて自動的に設定される、事前に構築されたコンポーネントを提供することで、この問題に対処します。
10
+
11
+ このメタデータ駆動のアプローチは、アプリケーション名、ロゴ、ナビゲーションリンク、テーマカラーなどの要素がコンポーネント全体に自動的に適用されることを意味し、定型的なコードを大幅に削減し、ブランドの一貫性を確保します。
12
+
13
+ ## コアアーキテクチャ
14
+
15
+ このライブラリのアーキテクチャは、シンプルさと自動化を目的として設計されています。`Header`や`Footer`のようなコンポーネントがレンダリングされると、`window.blocklet`オブジェクトから設定データを読み取ります。このオブジェクトは、Blocklet Serverによって`blocklet.yml`ファイルから読み込まれます。これにより、UIの構造とブランディングを中央の設定ファイルで定義でき、コンポーネントはそれに応じて適応します。
16
+
17
+ ```d2
18
+ direction: down
19
+
20
+ blocklet-yml: {
21
+ label: "blocklet.yml\n(メタデータソース)"
22
+ shape: rectangle
23
+ }
24
+
25
+ blocklet-server: {
26
+ label: "Blocklet Server"
27
+ shape: rectangle
28
+ }
29
+
30
+ window-blocklet: {
31
+ label: "window.blocklet\n(ランタイム設定)"
32
+ shape: rectangle
33
+ }
34
+
35
+ your-app: {
36
+ label: "あなたのアプリケーション"
37
+ shape: rectangle
38
+
39
+ Header: {
40
+ label: "<Header />"
41
+ shape: rectangle
42
+ }
43
+
44
+ Footer: {
45
+ label: "<Footer />"
46
+ shape: rectangle
47
+ }
48
+ }
49
+
50
+ rendered-ui: {
51
+ label: "レンダリングされたUI"
52
+ shape: rectangle
53
+ }
54
+
55
+ blocklet-yml -> blocklet-server: "1. メタデータを定義"
56
+ blocklet-server -> window-blocklet: "2. ランタイムに投入"
57
+ window-blocklet -> your-app: "3. コンポーネントが設定を読み取り"
58
+ your-app -> rendered-ui: "4. 設定されたUIをレンダリング"
59
+ ```
60
+
61
+ ## 主な機能
62
+
63
+ - **メタデータ駆動:** `blocklet.yml`で定義されたBlockletの名前、ロゴ、ナビゲーション構造を使用して、`Header`や`Footer`などのコンポーネントを自動的に設定します。
64
+ - **統合されたセッション管理:** コンポーネントはDID Connectセッションとシームレスに統合し、ユーザープロファイル情報、セッションコントロール、およびナビゲーションリンクへのロールベースのアクセスを自動的に表示します。
65
+ - **レスポンシブレイアウト:** `Dashboard`のような強力なレイアウトコンポーネントが含まれており、管理インターフェースのためのレスポンシブな構造をすぐに提供します。
66
+ - **コンポーネント管理:** `ComponentInstaller`や`BlockletStudio`などのツールを提供し、Blockletエコシステム内での依存関係やリソースの管理を支援します。
67
+
68
+ ## コアコンポーネント
69
+
70
+ ライブラリはいくつかの主要なモジュールに整理されており、それぞれがアプリケーションUIの特定の領域に対応しています。
71
+
72
+ <x-cards data-columns="2">
73
+ <x-card data-title="Layout" data-icon="lucide:layout-template" data-href="/components/layout">
74
+ Header、Footer、Dashboardのような主要コンポーネントで、Blockletアプリケーションの主要な構造を形成します。
75
+ </x-card>
76
+ <x-card data-title="User Management" data-icon="lucide:users" data-href="/components/user-management">
77
+ ユーザープロファイル、セッション管理、組織の切り替えを処理するための一連のコンポーネント。
78
+ </x-card>
79
+ <x-card data-title="Component Management" data-icon="lucide:box" data-href="/components/component-management">
80
+ アプリケーション内でBlockletコンポーネントを動的にインストール、公開、管理するためのツール。
81
+ </x-card>
82
+ <x-card data-title="Utilities" data-icon="lucide:wrench" data-href="/components/utilities">
83
+ 多機能なIconコンポーネントやテーマプロバイダーなど、ヘルパーコンポーネントとユーティリティのコレクション。
84
+ </x-card>
85
+ </x-cards>
86
+
87
+ ## まとめ
88
+
89
+ `@blocklet/ui-react`ライブラリを活用することで、開発時間を大幅に短縮し、アプリケーション独自の機能に集中することができます。メタデータ駆動のアプローチは一貫性を確保し、一般的なUI要素の管理を簡素化します。
90
+
91
+ アプリケーションの構築を開始するには、[はじめに](./getting-started.md)ガイドに進み、ライブラリのインストールと最初のコンポーネントのレンダリングに関するステップバイステップのチュートリアルをご覧ください。
@@ -0,0 +1,91 @@
1
+ # Overview
2
+
3
+ The `@blocklet/ui-react` library provides a collection of essential React components designed to accelerate the development of applications, known as Blocklets. It streamlines the creation of common user interface elements by intelligently using the blocklet's metadata, enabling developers to build consistent and feature-rich UIs with minimal effort.
4
+
5
+ This library is built upon `@arcblock/ux`, which is a themed extension of Material-UI. This foundation ensures that all components are robust, accessible, and easily customizable to fit your application's branding.
6
+
7
+ ## The Problem It Solves
8
+
9
+ Modern web applications often require a standard set of UI components for layout, user management, and notifications. Implementing these from scratch for every project is time-consuming and can lead to inconsistencies. The Blocklet UI React library addresses this by providing pre-built components that automatically configure themselves based on your blocklet's metadata (`blocklet.yml`).
10
+
11
+ This metadata-driven approach means that elements like your application's name, logo, navigation links, and theme colors are automatically applied across components, drastically reducing boilerplate code and ensuring brand consistency.
12
+
13
+ ## Core Architecture
14
+
15
+ The library's architecture is designed for simplicity and automation. When a component like `Header` or `Footer` is rendered, it reads configuration data from the `window.blocklet` object, which is populated by the Blocklet Server from your `blocklet.yml` file. This allows you to define your UI's structure and branding in a central configuration file, and the components adapt accordingly.
16
+
17
+ ```d2
18
+ direction: down
19
+
20
+ blocklet-yml: {
21
+ label: "blocklet.yml\n(Metadata Source)"
22
+ shape: rectangle
23
+ }
24
+
25
+ blocklet-server: {
26
+ label: "Blocklet Server"
27
+ shape: rectangle
28
+ }
29
+
30
+ window-blocklet: {
31
+ label: "window.blocklet\n(Runtime Configuration)"
32
+ shape: rectangle
33
+ }
34
+
35
+ your-app: {
36
+ label: "Your Application"
37
+ shape: rectangle
38
+
39
+ Header: {
40
+ label: "<Header />"
41
+ shape: rectangle
42
+ }
43
+
44
+ Footer: {
45
+ label: "<Footer />"
46
+ shape: rectangle
47
+ }
48
+ }
49
+
50
+ rendered-ui: {
51
+ label: "Rendered UI"
52
+ shape: rectangle
53
+ }
54
+
55
+ blocklet-yml -> blocklet-server: "1. Defines metadata"
56
+ blocklet-server -> window-blocklet: "2. Populates at runtime"
57
+ window-blocklet -> your-app: "3. Components read config"
58
+ your-app -> rendered-ui: "4. Renders configured UI"
59
+ ```
60
+
61
+ ## Key Features
62
+
63
+ - **Metadata-Driven:** Automatically configures components like `Header` and `Footer` using your blocklet's name, logo, and navigation structure defined in `blocklet.yml`.
64
+ - **Integrated Session Management:** Components seamlessly integrate with DID Connect sessions, automatically displaying user profile information, session controls, and role-based access to navigation links.
65
+ - **Responsive Layouts:** Includes powerful layout components like `Dashboard` that provide a responsive structure for administrative interfaces out of the box.
66
+ - **Component Management:** Offers tools like `ComponentInstaller` and `BlockletStudio` to help manage dependencies and resources within the Blocklet ecosystem.
67
+
68
+ ## Core Components
69
+
70
+ The library is organized into several key modules, each addressing a specific area of application UI.
71
+
72
+ <x-cards data-columns="2">
73
+ <x-card data-title="Layout" data-icon="lucide:layout-template" data-href="/components/layout">
74
+ Primary components like Header, Footer, and Dashboard that form the main structure of a blocklet application.
75
+ </x-card>
76
+ <x-card data-title="User Management" data-icon="lucide:users" data-href="/components/user-management">
77
+ A suite of components for handling user profiles, session management, and organization switching.
78
+ </x-card>
79
+ <x-card data-title="Component Management" data-icon="lucide:box" data-href="/components/component-management">
80
+ Tools for dynamically installing, publishing, and managing blocklet components within an application.
81
+ </x-card>
82
+ <x-card data-title="Utilities" data-icon="lucide:wrench" data-href="/components/utilities">
83
+ A collection of helper components and utilities, such as a versatile Icon component and theme providers.
84
+ </x-card>
85
+ </x-cards>
86
+
87
+ ## Summary
88
+
89
+ By leveraging the `@blocklet/ui-react` library, you can significantly reduce development time and focus on your application's unique features. The metadata-driven approach ensures consistency and simplifies the management of common UI elements.
90
+
91
+ To start building your application, proceed to the [Getting Started](./getting-started.md) guide for a step-by-step tutorial on installing the library and rendering your first components.