@blocklet/ui-react 3.4.14 → 3.5.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 (256) hide show
  1. package/lib/common/org-switch/use-org.d.ts +4 -4
  2. package/lib/common/ws.d.ts +22 -1
  3. package/package.json +10 -7
  4. package/.aigne/doc-smith/.local/afs-storage.sqlite3 +0 -0
  5. package/.aigne/doc-smith/config.yaml +0 -78
  6. package/.aigne/doc-smith/history.yaml +0 -14
  7. package/.aigne/doc-smith/media-description.yaml +0 -11
  8. package/.aigne/doc-smith/output/structure-plan.json +0 -255
  9. package/.aigne/doc-smith/translation-cache.yaml +0 -11
  10. package/.aigne/doc-smith/upload-cache.yaml +0 -528
  11. package/build.config.ts +0 -24
  12. package/docs/_sidebar.md +0 -19
  13. package/docs/assets/diagram/component-installer-diagram-0.ja.jpg +0 -0
  14. package/docs/assets/diagram/component-installer-diagram-0.jpg +0 -0
  15. package/docs/assets/diagram/component-installer-diagram-0.zh-TW.jpg +0 -0
  16. package/docs/assets/diagram/component-installer-diagram-0.zh.jpg +0 -0
  17. package/docs/assets/diagram/component-management-diagram-0.ja.jpg +0 -0
  18. package/docs/assets/diagram/component-management-diagram-0.jpg +0 -0
  19. package/docs/assets/diagram/component-management-diagram-0.zh-TW.jpg +0 -0
  20. package/docs/assets/diagram/component-management-diagram-0.zh.jpg +0 -0
  21. package/docs/assets/diagram/core-concepts-diagram-0.ja.jpg +0 -0
  22. package/docs/assets/diagram/core-concepts-diagram-0.jpg +0 -0
  23. package/docs/assets/diagram/core-concepts-diagram-0.zh-TW.jpg +0 -0
  24. package/docs/assets/diagram/core-concepts-diagram-0.zh.jpg +0 -0
  25. package/docs/assets/diagram/dashboard-diagram-0.ja.jpg +0 -0
  26. package/docs/assets/diagram/dashboard-diagram-0.jpg +0 -0
  27. package/docs/assets/diagram/dashboard-diagram-0.zh-TW.jpg +0 -0
  28. package/docs/assets/diagram/dashboard-diagram-0.zh.jpg +0 -0
  29. package/docs/assets/diagram/header-diagram-0.ja.jpg +0 -0
  30. package/docs/assets/diagram/header-diagram-0.jpg +0 -0
  31. package/docs/assets/diagram/header-diagram-0.zh-TW.jpg +0 -0
  32. package/docs/assets/diagram/header-diagram-0.zh.jpg +0 -0
  33. package/docs/assets/diagram/layout-diagram-0.ja.jpg +0 -0
  34. package/docs/assets/diagram/layout-diagram-0.jpg +0 -0
  35. package/docs/assets/diagram/layout-diagram-0.zh-TW.jpg +0 -0
  36. package/docs/assets/diagram/layout-diagram-0.zh.jpg +0 -0
  37. package/docs/assets/diagram/notifications-diagram-0.ja.jpg +0 -0
  38. package/docs/assets/diagram/notifications-diagram-0.jpg +0 -0
  39. package/docs/assets/diagram/notifications-diagram-0.zh-TW.jpg +0 -0
  40. package/docs/assets/diagram/notifications-diagram-0.zh.jpg +0 -0
  41. package/docs/assets/diagram/overview-diagram-0.ja.jpg +0 -0
  42. package/docs/assets/diagram/overview-diagram-0.jpg +0 -0
  43. package/docs/assets/diagram/overview-diagram-0.zh-TW.jpg +0 -0
  44. package/docs/assets/diagram/overview-diagram-0.zh.jpg +0 -0
  45. package/docs/assets/diagram/user-center-diagram-0.ja.jpg +0 -0
  46. package/docs/assets/diagram/user-center-diagram-0.jpg +0 -0
  47. package/docs/assets/diagram/user-center-diagram-0.zh-TW.jpg +0 -0
  48. package/docs/assets/diagram/user-center-diagram-0.zh.jpg +0 -0
  49. package/docs/assets/diagram/user-management-diagram-0.ja.jpg +0 -0
  50. package/docs/assets/diagram/user-management-diagram-0.jpg +0 -0
  51. package/docs/assets/diagram/user-management-diagram-0.zh-TW.jpg +0 -0
  52. package/docs/assets/diagram/user-management-diagram-0.zh.jpg +0 -0
  53. package/docs/assets/diagram/user-sessions-diagram-0.ja.jpg +0 -0
  54. package/docs/assets/diagram/user-sessions-diagram-0.jpg +0 -0
  55. package/docs/assets/diagram/user-sessions-diagram-0.zh-TW.jpg +0 -0
  56. package/docs/assets/diagram/user-sessions-diagram-0.zh.jpg +0 -0
  57. package/docs/components-component-management-blocklet-studio.ja.md +0 -194
  58. package/docs/components-component-management-blocklet-studio.md +0 -194
  59. package/docs/components-component-management-blocklet-studio.zh-TW.md +0 -194
  60. package/docs/components-component-management-blocklet-studio.zh.md +0 -194
  61. package/docs/components-component-management-component-installer.ja.md +0 -182
  62. package/docs/components-component-management-component-installer.md +0 -182
  63. package/docs/components-component-management-component-installer.zh-TW.md +0 -182
  64. package/docs/components-component-management-component-installer.zh.md +0 -182
  65. package/docs/components-component-management.ja.md +0 -30
  66. package/docs/components-component-management.md +0 -30
  67. package/docs/components-component-management.zh-TW.md +0 -30
  68. package/docs/components-component-management.zh.md +0 -30
  69. package/docs/components-layout-dashboard.ja.md +0 -185
  70. package/docs/components-layout-dashboard.md +0 -187
  71. package/docs/components-layout-dashboard.zh-TW.md +0 -185
  72. package/docs/components-layout-dashboard.zh.md +0 -185
  73. package/docs/components-layout-footer.ja.md +0 -165
  74. package/docs/components-layout-footer.md +0 -165
  75. package/docs/components-layout-footer.zh-TW.md +0 -165
  76. package/docs/components-layout-footer.zh.md +0 -165
  77. package/docs/components-layout-header.ja.md +0 -183
  78. package/docs/components-layout-header.md +0 -183
  79. package/docs/components-layout-header.zh-TW.md +0 -183
  80. package/docs/components-layout-header.zh.md +0 -183
  81. package/docs/components-layout.ja.md +0 -31
  82. package/docs/components-layout.md +0 -31
  83. package/docs/components-layout.zh-TW.md +0 -31
  84. package/docs/components-layout.zh.md +0 -31
  85. package/docs/components-notifications.ja.md +0 -125
  86. package/docs/components-notifications.md +0 -125
  87. package/docs/components-notifications.zh-TW.md +0 -125
  88. package/docs/components-notifications.zh.md +0 -125
  89. package/docs/components-user-management-user-center.ja.md +0 -148
  90. package/docs/components-user-management-user-center.md +0 -147
  91. package/docs/components-user-management-user-center.zh-TW.md +0 -148
  92. package/docs/components-user-management-user-center.zh.md +0 -148
  93. package/docs/components-user-management-user-sessions.ja.md +0 -121
  94. package/docs/components-user-management-user-sessions.md +0 -123
  95. package/docs/components-user-management-user-sessions.zh-TW.md +0 -121
  96. package/docs/components-user-management-user-sessions.zh.md +0 -121
  97. package/docs/components-user-management.ja.md +0 -49
  98. package/docs/components-user-management.md +0 -51
  99. package/docs/components-user-management.zh-TW.md +0 -49
  100. package/docs/components-user-management.zh.md +0 -49
  101. package/docs/components-utilities-icon.ja.md +0 -106
  102. package/docs/components-utilities-icon.md +0 -106
  103. package/docs/components-utilities-icon.zh-TW.md +0 -106
  104. package/docs/components-utilities-icon.zh.md +0 -106
  105. package/docs/components-utilities.ja.md +0 -136
  106. package/docs/components-utilities.md +0 -136
  107. package/docs/components-utilities.zh-TW.md +0 -136
  108. package/docs/components-utilities.zh.md +0 -136
  109. package/docs/components.ja.md +0 -27
  110. package/docs/components.md +0 -27
  111. package/docs/components.zh-TW.md +0 -27
  112. package/docs/components.zh.md +0 -27
  113. package/docs/core-concepts.ja.md +0 -134
  114. package/docs/core-concepts.md +0 -135
  115. package/docs/core-concepts.zh-TW.md +0 -134
  116. package/docs/core-concepts.zh.md +0 -134
  117. package/docs/getting-started.ja.md +0 -132
  118. package/docs/getting-started.md +0 -132
  119. package/docs/getting-started.zh-TW.md +0 -132
  120. package/docs/getting-started.zh.md +0 -132
  121. package/docs/hooks-api.ja.md +0 -214
  122. package/docs/hooks-api.md +0 -214
  123. package/docs/hooks-api.zh-TW.md +0 -214
  124. package/docs/hooks-api.zh.md +0 -214
  125. package/docs/how-to-guides.ja.md +0 -413
  126. package/docs/how-to-guides.md +0 -413
  127. package/docs/how-to-guides.zh-TW.md +0 -413
  128. package/docs/how-to-guides.zh.md +0 -413
  129. package/docs/overview.ja.md +0 -51
  130. package/docs/overview.md +0 -51
  131. package/docs/overview.zh-TW.md +0 -51
  132. package/docs/overview.zh.md +0 -51
  133. package/glossary.md +0 -12
  134. package/src/@types/index.ts +0 -230
  135. package/src/@types/shims.d.ts +0 -18
  136. package/src/BlockletStudio/README.md +0 -116
  137. package/src/BlockletStudio/index.tsx +0 -145
  138. package/src/ComponentInstaller/ComponentInstaller.stories.jsx +0 -16
  139. package/src/ComponentInstaller/index.jsx +0 -207
  140. package/src/ComponentInstaller/installer-item.jsx +0 -129
  141. package/src/ComponentInstaller/locales.js +0 -22
  142. package/src/ComponentInstaller/use-component-installed.js +0 -88
  143. package/src/ComponentManager/components/add-component.tsx +0 -136
  144. package/src/ComponentManager/components/check-component.tsx +0 -3
  145. package/src/ComponentManager/components/publish-component.tsx +0 -90
  146. package/src/ComponentManager/components/resource-dialog.tsx +0 -91
  147. package/src/ComponentManager/index.tsx +0 -3
  148. package/src/ComponentManager/libs/locales.ts +0 -15
  149. package/src/Dashboard/Dashboard.stories.jsx +0 -20
  150. package/src/Dashboard/app-shell/app-badge.stories.tsx +0 -64
  151. package/src/Dashboard/app-shell/app-badge.tsx +0 -94
  152. package/src/Dashboard/app-shell/app-header.tsx +0 -104
  153. package/src/Dashboard/app-shell/app-info-context.tsx +0 -182
  154. package/src/Dashboard/app-shell/badges/app-badge-default.tsx +0 -130
  155. package/src/Dashboard/app-shell/badges/app-badge-did.tsx +0 -28
  156. package/src/Dashboard/app-shell/badges/app-badge-state.tsx +0 -40
  157. package/src/Dashboard/app-shell/badges/app-badge-switch.tsx +0 -72
  158. package/src/Dashboard/app-shell/badges/app-badge-version.tsx +0 -60
  159. package/src/Dashboard/app-shell/index.ts +0 -5
  160. package/src/Dashboard/index.jsx +0 -184
  161. package/src/Footer/Footer.stories.jsx +0 -33
  162. package/src/Footer/brand.jsx +0 -81
  163. package/src/Footer/copyright.jsx +0 -22
  164. package/src/Footer/index.jsx +0 -111
  165. package/src/Footer/internal-footer.jsx +0 -139
  166. package/src/Footer/layout/plain.jsx +0 -55
  167. package/src/Footer/layout/row.jsx +0 -43
  168. package/src/Footer/layout/standard.jsx +0 -114
  169. package/src/Footer/links.jsx +0 -321
  170. package/src/Footer/social-media.jsx +0 -55
  171. package/src/Header/Header.stories.jsx +0 -30
  172. package/src/Header/index.tsx +0 -259
  173. package/src/Icon/Icon.stories.jsx +0 -12
  174. package/src/Icon/index.tsx +0 -87
  175. package/src/Notifications/Snackbar.tsx +0 -261
  176. package/src/Notifications/hooks/use-title.tsx +0 -254
  177. package/src/Notifications/hooks/use-width.tsx +0 -16
  178. package/src/Notifications/utils.ts +0 -246
  179. package/src/UserCenter/assets/banner.png +0 -0
  180. package/src/UserCenter/components/config-inviter.tsx +0 -48
  181. package/src/UserCenter/components/config-profile.tsx +0 -99
  182. package/src/UserCenter/components/danger-zone.tsx +0 -82
  183. package/src/UserCenter/components/editable-field.tsx +0 -273
  184. package/src/UserCenter/components/fallback.tsx +0 -57
  185. package/src/UserCenter/components/nft-preview.tsx +0 -84
  186. package/src/UserCenter/components/nft.tsx +0 -279
  187. package/src/UserCenter/components/notification.tsx +0 -319
  188. package/src/UserCenter/components/passport.tsx +0 -107
  189. package/src/UserCenter/components/privacy.tsx +0 -120
  190. package/src/UserCenter/components/settings.tsx +0 -170
  191. package/src/UserCenter/components/status-dialog/date-picker.tsx +0 -77
  192. package/src/UserCenter/components/status-dialog/index.tsx +0 -293
  193. package/src/UserCenter/components/status-selector/duration-menu.tsx +0 -90
  194. package/src/UserCenter/components/status-selector/index.tsx +0 -58
  195. package/src/UserCenter/components/status-selector/menu-item.tsx +0 -56
  196. package/src/UserCenter/components/storage/action.tsx +0 -49
  197. package/src/UserCenter/components/storage/connected.tsx +0 -61
  198. package/src/UserCenter/components/storage/delete.tsx +0 -72
  199. package/src/UserCenter/components/storage/disconnect.tsx +0 -40
  200. package/src/UserCenter/components/storage/icons/empty-spaces-nft.svg +0 -1
  201. package/src/UserCenter/components/storage/icons/long-arrow.svg +0 -5
  202. package/src/UserCenter/components/storage/icons/space-connected.svg +0 -3
  203. package/src/UserCenter/components/storage/icons/space-disconnect.svg +0 -3
  204. package/src/UserCenter/components/storage/index.tsx +0 -41
  205. package/src/UserCenter/components/storage/preview-nft.tsx +0 -72
  206. package/src/UserCenter/components/third-party-login/index.tsx +0 -199
  207. package/src/UserCenter/components/third-party-login/third-party-item.tsx +0 -296
  208. package/src/UserCenter/components/user-center.tsx +0 -787
  209. package/src/UserCenter/components/user-info/address.tsx +0 -143
  210. package/src/UserCenter/components/user-info/index.tsx +0 -4
  211. package/src/UserCenter/components/user-info/link-preview-input.tsx +0 -274
  212. package/src/UserCenter/components/user-info/metadata.tsx +0 -658
  213. package/src/UserCenter/components/user-info/social-actions/chat.tsx +0 -43
  214. package/src/UserCenter/components/user-info/social-actions/follow.tsx +0 -23
  215. package/src/UserCenter/components/user-info/social-actions/index.tsx +0 -17
  216. package/src/UserCenter/components/user-info/switch-role.tsx +0 -42
  217. package/src/UserCenter/components/user-info/timezone-select.tsx +0 -119
  218. package/src/UserCenter/components/user-info/user-basic-info.tsx +0 -292
  219. package/src/UserCenter/components/user-info/user-info-item.tsx +0 -54
  220. package/src/UserCenter/components/user-info/user-info.tsx +0 -91
  221. package/src/UserCenter/components/user-info/user-status.tsx +0 -234
  222. package/src/UserCenter/components/user-info/utils.ts +0 -320
  223. package/src/UserCenter/components/webhook-item.tsx +0 -248
  224. package/src/UserCenter/index.tsx +0 -1
  225. package/src/UserCenter/libs/locales.ts +0 -378
  226. package/src/UserCenter/libs/utils.ts +0 -30
  227. package/src/UserSessions/components/user-session-info.tsx +0 -78
  228. package/src/UserSessions/components/user-sessions.tsx +0 -545
  229. package/src/UserSessions/index.tsx +0 -1
  230. package/src/UserSessions/libs/locales.ts +0 -60
  231. package/src/UserSessions/libs/utils.ts +0 -82
  232. package/src/blocklets.js +0 -195
  233. package/src/common/domain-warning.jsx +0 -178
  234. package/src/common/header-addons.jsx +0 -119
  235. package/src/common/link-blocker.jsx +0 -20
  236. package/src/common/notification-addon.jsx +0 -135
  237. package/src/common/org-switch/avatar-uploader.jsx +0 -271
  238. package/src/common/org-switch/create.jsx +0 -267
  239. package/src/common/org-switch/index.jsx +0 -407
  240. package/src/common/org-switch/locales.js +0 -52
  241. package/src/common/org-switch/use-org.jsx +0 -79
  242. package/src/common/overridable-theme-provider.jsx +0 -17
  243. package/src/common/wallet-hidden-topbar.js +0 -14
  244. package/src/common/wizard-modal.jsx +0 -200
  245. package/src/common/ws.js +0 -68
  246. package/src/contexts/config-user-space.tsx +0 -88
  247. package/src/contexts/user-followers.tsx +0 -54
  248. package/src/hooks/use-follow.tsx +0 -75
  249. package/src/hooks/use-mobile.tsx +0 -6
  250. package/src/index.ts +0 -16
  251. package/src/libs/constant.ts +0 -1
  252. package/src/libs/spaces.tsx +0 -18
  253. package/src/libs/with-hide-when-embed.tsx +0 -24
  254. package/src/types.js +0 -45
  255. package/src/utils.js +0 -161
  256. package/vite.config.mjs +0 -34
@@ -1,136 +0,0 @@
1
- # Utilities
2
-
3
- This section provides documentation for a collection of helper components, Higher-Order Components (HOCs), and utility functions. These tools are designed to simplify common development tasks, manage application themes, and handle complex data structures.
4
-
5
- The primary utilities available are:
6
-
7
- <x-cards data-columns="2">
8
- <x-card data-title="Icon Component" data-icon="lucide:image" data-href="/components/utilities/icon">
9
- A versatile component for displaying icons from various sources, including Iconify, image URLs, or as letter avatars.
10
- </x-card>
11
- <x-card data-title="OverridableThemeProvider" data-icon="lucide:palette">
12
- A theme provider that allows developers to supply their own theme object to override the default Blocklet UI theme.
13
- </x-card>
14
- <x-card data-title="withHideWhenEmbed HOC" data-icon="lucide:eye-off">
15
- A Higher-Order Component that conditionally renders a component, hiding it when the application is in an embedded mode.
16
- </x-card>
17
- <x-card data-title="JavaScript Helpers" data-icon="lucide:function-square">
18
- A suite of standalone functions for tasks such as recursive array manipulation, URL validation, and path matching.
19
- </x-card>
20
- </x-cards>
21
-
22
- For a detailed guide on the `Icon` component, please see its dedicated documentation page. The other utilities are documented below.
23
-
24
- ## OverridableThemeProvider
25
-
26
- This component is a wrapper around Material-UI's `ThemeProvider`. It allows you to apply a consistent theme to its child components. By default, it uses the standard Blocklet UI theme, but you can provide a custom theme object via the `theme` prop to override the default styles.
27
-
28
- ### Usage
29
-
30
- To apply a custom theme, pass a theme object to the `theme` prop. The component will merge your overrides with the default theme.
31
-
32
- ```javascript Theme Provider Example icon=logos:javascript
33
- import OverridableThemeProvider from '@blocklet/ui-react/lib/common/overridable-theme-provider';
34
- import { Button } from '@mui/material';
35
-
36
- const customTheme = {
37
- palette: {
38
- primary: {
39
- main: '#ff5722',
40
- },
41
- },
42
- };
43
-
44
- function App() {
45
- return (
46
- <OverridableThemeProvider theme={customTheme}>
47
- <Button color="primary" variant="contained">
48
- Custom Themed Button
49
- </Button>
50
- </OverridableThemeProvider>
51
- );
52
- }
53
- ```
54
-
55
- ## withHideWhenEmbed
56
-
57
- `withHideWhenEmbed` is a Higher-Order Component (HOC) that prevents a component from rendering if the application is in "embed mode." It checks a session storage key (`EMBED_MODE_KEY`) to determine the current mode. If the value is `1`, the wrapped component will return `null`.
58
-
59
- This is useful for hiding elements like headers or footers in an embedded context where they are not needed.
60
-
61
- ### Usage
62
-
63
- Wrap the component you wish to conditionally hide with the `withHideWhenEmbed` HOC.
64
-
65
- ```javascript HOC Example icon=logos:javascript
66
- import withHideWhenEmbed from '@blocklet/ui-react/lib/libs/with-hide-when-embed';
67
-
68
- function PageHeader() {
69
- return (
70
- <header>
71
- <h1>My Application</h1>
72
- </header>
73
- );
74
- }
75
-
76
- const MaybeHiddenHeader = withHideWhenEmbed(PageHeader);
77
-
78
- function App() {
79
- return (
80
- <div>
81
- <MaybeHiddenHeader />
82
- <main>
83
- {/* Main content goes here */}
84
- </main>
85
- </div>
86
- );
87
- }
88
- ```
89
-
90
- ## Helper Functions
91
-
92
- A set of pure JavaScript functions are available for common data manipulation and validation tasks. These can be imported directly from the library's utility module.
93
-
94
- ### Array Manipulation
95
-
96
- These functions are designed to work with arrays of nested objects, such as navigation menus or file trees.
97
-
98
- | Function | Description |
99
- | --- | --- |
100
- | `mapRecursive(array, fn, childrenKey = 'children')` | Recursively applies a function to each item in a nested array. |
101
- | `flatRecursive(array, childrenKey = 'children')` | Flattens a nested array into a single-level array. |
102
- | `countRecursive(array, childrenKey = 'children')` | Counts the total number of items in a nested array. |
103
- | `filterRecursive(array, predicate, childrenKey = 'children')` | Recursively filters a nested array based on a predicate function, preserving parent structure if children match. |
104
-
105
- ### String & URL Validation
106
-
107
- Simple helpers for checking string formats.
108
-
109
- | Function | Description |
110
- | --- | --- |
111
- | `isUrl(str)` | Returns `true` if the string starts with `http://` or `https://`. |
112
- | `isMailProtocol(str)` | Returns `true` if the string starts with `mailto:`. |
113
-
114
- ### Routing
115
-
116
- Utilities to assist with client-side routing logic.
117
-
118
- | Function | Description |
119
- | --- | --- |
120
- | `matchPath(path)` | Checks if a given path matches the current `window.location.pathname`. |
121
- | `matchPaths(paths)` | Finds the best matching path from an array of paths against the current location. |
122
-
123
- ### Layout
124
-
125
- | Function | Description |
126
- | --- | --- |
127
- | `splitNavColumns(items, options)` | Splits a list of navigation items into a specified number of columns, useful for creating mega menus. |
128
-
129
- ---
130
-
131
- ### Summary
132
-
133
- This section provided an overview of the general-purpose utilities included in the library. For more powerful, specialized functionality, proceed to the detailed documentation for individual components.
134
-
135
- For a comprehensive guide on using the flexible `Icon` component, please refer to the next section.
136
- - **[Icon](./components-utilities-icon.md)**
@@ -1,136 +0,0 @@
1
- # 工具
2
-
3
- 本節提供了一系列輔助元件、高階元件 (HOCs) 和工具函式的說明文件。這些工具旨在簡化常見的開發任務、管理應用程式主題以及處理複雜的資料結構。
4
-
5
- 可用的主要工具有:
6
-
7
- <x-cards data-columns="2">
8
- <x-card data-title="圖示元件" data-icon="lucide:image" data-href="/components/utilities/icon">
9
- 一個多功能的元件,可用於顯示來自各種來源的圖示,包括 Iconify、圖片 URL 或字母頭像。
10
- </x-card>
11
- <x-card data-title="OverridableThemeProvider" data-icon="lucide:palette">
12
- 一個主題提供者,允許開發人員提供自己的主題物件來覆寫預設的 Blocklet UI 主題。
13
- </x-card>
14
- <x-card data-title="withHideWhenEmbed HOC" data-icon="lucide:eye-off">
15
- 一個高階元件,可根據條件渲染元件,當應用程式處於嵌入模式時將其隱藏。
16
- </x-card>
17
- <x-card data-title="JavaScript 輔助函式" data-icon="lucide:function-square">
18
- 一套獨立的函式,用於遞迴陣列操作、URL 驗證和路徑匹配等任務。
19
- </x-card>
20
- </x-cards>
21
-
22
- 有關 `Icon` 元件的詳細指南,請參閱其專門的文件頁面。其他工具的說明文件如下。
23
-
24
- ## OverridableThemeProvider
25
-
26
- 此元件是 Material-UI `ThemeProvider` 的一個封裝。它允許您將一致的主題應用於其子元件。預設情況下,它使用標準的 Blocklet UI 主題,但您可以透過 `theme` 屬性提供一個自訂的主題物件來覆寫預設樣式。
27
-
28
- ### 使用方法
29
-
30
- 若要應用自訂主題,請將一個主題物件傳遞給 `theme` 屬性。該元件會將您的覆寫與預設主題合併。
31
-
32
- ```javascript Theme Provider Example icon=logos:javascript
33
- import OverridableThemeProvider from '@blocklet/ui-react/lib/common/overridable-theme-provider';
34
- import { Button } from '@mui/material';
35
-
36
- const customTheme = {
37
- palette: {
38
- primary: {
39
- main: '#ff5722',
40
- },
41
- },
42
- };
43
-
44
- function App() {
45
- return (
46
- <OverridableThemeProvider theme={customTheme}>
47
- <Button color="primary" variant="contained">
48
- Custom Themed Button
49
- </Button>
50
- </OverridableThemeProvider>
51
- );
52
- }
53
- ```
54
-
55
- ## withHideWhenEmbed
56
-
57
- `withHideWhenEmbed` 是一個高階元件 (HOC),如果應用程式處於「嵌入模式」,它會防止元件被渲染。它會檢查一個 session storage 的鍵 (`EMBED_MODE_KEY`) 來確定當前模式。如果該值為 `1`,被封裝的元件將返回 `null`。
58
-
59
- 這對於在嵌入式情境中隱藏不需要的元素(如頁首或頁尾)非常有用。
60
-
61
- ### 使用方法
62
-
63
- 用 `withHideWhenEmbed` HOC 封裝您希望有條件地隱藏的元件。
64
-
65
- ```javascript HOC Example icon=logos:javascript
66
- import withHideWhenEmbed from '@blocklet/ui-react/lib/libs/with-hide-when-embed';
67
-
68
- function PageHeader() {
69
- return (
70
- <header>
71
- <h1>My Application</h1>
72
- </header>
73
- );
74
- }
75
-
76
- const MaybeHiddenHeader = withHideWhenEmbed(PageHeader);
77
-
78
- function App() {
79
- return (
80
- <div>
81
- <MaybeHiddenHeader />
82
- <main>
83
- {/* 主要內容放置於此 */}
84
- </main>
85
- </div>
86
- );
87
- }
88
- ```
89
-
90
- ## 輔助函式
91
-
92
- 提供了一組純 JavaScript 函式,用於常見的資料操作和驗證任務。這些函式可以直接從函式庫的工具模組中匯入。
93
-
94
- ### 陣列操作
95
-
96
- 這些函式設計用於處理巢狀物件的陣列,例如導覽選單或檔案樹。
97
-
98
- | 函式 | 說明 |
99
- | --- | --- |
100
- | `mapRecursive(array, fn, childrenKey = 'children')` | 遞迴地將一個函式應用於巢狀陣列中的每個項目。 |
101
- | `flatRecursive(array, childrenKey = 'children')` | 將巢狀陣列扁平化為單層陣列。 |
102
- | `countRecursive(array, childrenKey = 'children')` | 計算巢狀陣列中項目的總數。 |
103
- | `filterRecursive(array, predicate, childrenKey = 'children')` | 根據一個斷言函式遞迴地篩選巢狀陣列,如果子項目匹配,則保留父結構。 |
104
-
105
- ### 字串與 URL 驗證
106
-
107
- 用於檢查字串格式的簡單輔助函式。
108
-
109
- | 函式 | 說明 |
110
- | --- | --- |
111
- | `isUrl(str)` | 如果字串以 `http://` 或 `https://` 開頭,則返回 `true`。 |
112
- | `isMailProtocol(str)` | 如果字串以 `mailto:` 開頭,則返回 `true`。 |
113
-
114
- ### 路由
115
-
116
- 協助客戶端路由邏輯的工具。
117
-
118
- | 函式 | 說明 |
119
- | --- | --- |
120
- | `matchPath(path)` | 檢查給定路徑是否與當前的 `window.location.pathname` 匹配。 |
121
- | `matchPaths(paths)` | 從一個路徑陣列中,找到與當前位置最佳匹配的路徑。 |
122
-
123
- ### 版面配置
124
-
125
- | 函式 | 說明 |
126
- | --- | --- |
127
- | `splitNavColumns(items, options)` | 將導覽項目列表分割成指定數量的欄,對於建立大型選單很有用。 |
128
-
129
- ---
130
-
131
- ### 總結
132
-
133
- 本節概述了函式庫中包含的通用工具。若需更強大、更專業的功能,請繼續閱讀各個元件的詳細文件。
134
-
135
- 有關使用靈活的 `Icon` 元件的全面指南,請參閱下一節。
136
- - **[圖示](./components-utilities-icon.md)**
@@ -1,136 +0,0 @@
1
- # 工具
2
-
3
- 本节提供了关于一系列辅助组件、高阶组件 (HOC) 和实用函数的文档。这些工具旨在简化常见的开发任务、管理应用程序主题和处理复杂的数据结构。
4
-
5
- 可用的主要工具有:
6
-
7
- <x-cards data-columns="2">
8
- <x-card data-title="Icon 组件" data-icon="lucide:image" data-href="/components/utilities/icon">
9
- 一个多功能组件,用于显示来自各种来源的图标,包括 Iconify、图片 URL 或字母头像。
10
- </x-card>
11
- <x-card data-title="OverridableThemeProvider" data-icon="lucide:palette">
12
- 一个主题提供程序,允许开发者提供自己的主题对象来覆盖默认的 Blocklet UI 主题。
13
- </x-card>
14
- <x-card data-title="withHideWhenEmbed HOC" data-icon="lucide:eye-off">
15
- 一个高阶组件,可有条件地渲染组件,在应用程序处于嵌入模式时将其隐藏。
16
- </x-card>
17
- <x-card data-title="JavaScript 辅助函数" data-icon="lucide:function-square">
18
- 一套用于执行递归数组操作、URL 验证和路径匹配等任务的独立函数。
19
- </x-card>
20
- </x-cards>
21
-
22
- 有关 `Icon` 组件的详细指南,请参阅其专门的文档页面。其他工具的文档如下。
23
-
24
- ## OverridableThemeProvider
25
-
26
- 该组件是 Material-UI `ThemeProvider` 的一个包装器。它允许您将一致的主题应用于其子组件。默认情况下,它使用标准的 Blocklet UI 主题,但您可以通过 `theme` 属性提供一个自定义主题对象来覆盖默认样式。
27
-
28
- ### 用法
29
-
30
- 要应用自定义主题,请将一个主题对象传递给 `theme` 属性。该组件会将您的覆盖项与默认主题合并。
31
-
32
- ```javascript Theme Provider Example icon=logos:javascript
33
- import OverridableThemeProvider from '@blocklet/ui-react/lib/common/overridable-theme-provider';
34
- import { Button } from '@mui/material';
35
-
36
- const customTheme = {
37
- palette: {
38
- primary: {
39
- main: '#ff5722',
40
- },
41
- },
42
- };
43
-
44
- function App() {
45
- return (
46
- <OverridableThemeProvider theme={customTheme}>
47
- <Button color="primary" variant="contained">
48
- Custom Themed Button
49
- </Button>
50
- </OverridableThemeProvider>
51
- );
52
- }
53
- ```
54
-
55
- ## withHideWhenEmbed
56
-
57
- `withHideWhenEmbed` 是一个高阶组件 (HOC),如果应用程序处于“嵌入模式”,它会阻止组件渲染。它会检查一个会话存储键 (`EMBED_MODE_KEY`) 来确定当前模式。如果值为 `1`,被包装的组件将返回 `null`。
58
-
59
- 这在嵌入式上下文中非常有用,可以隐藏不需要的元素,如页眉或页脚。
60
-
61
- ### 用法
62
-
63
- 用 `withHideWhenEmbed` HOC 包装您希望有条件隐藏的组件。
64
-
65
- ```javascript HOC Example icon=logos:javascript
66
- import withHideWhenEmbed from '@blocklet/ui-react/lib/libs/with-hide-when-embed';
67
-
68
- function PageHeader() {
69
- return (
70
- <header>
71
- <h1>My Application</h1>
72
- </header>
73
- );
74
- }
75
-
76
- const MaybeHiddenHeader = withHideWhenEmbed(PageHeader);
77
-
78
- function App() {
79
- return (
80
- <div>
81
- <MaybeHiddenHeader />
82
- <main>
83
- {/* 主内容放在这里 */}
84
- </main>
85
- </div>
86
- );
87
- }
88
- ```
89
-
90
- ## 辅助函数
91
-
92
- 提供了一组纯 JavaScript 函数,用于常见的数据操作和验证任务。这些函数可以直接从库的实用工具模块中导入。
93
-
94
- ### 数组操作
95
-
96
- 这些函数设计用于处理嵌套对象的数组,例如导航菜单或文件树。
97
-
98
- | 函数 | 描述 |
99
- | --- | --- |
100
- | `mapRecursive(array, fn, childrenKey = 'children')` | 递归地将一个函数应用于嵌套数组中的每一项。 |
101
- | `flatRecursive(array, childrenKey = 'children')` | 将嵌套数组扁平化为单层数组。 |
102
- | `countRecursive(array, childrenKey = 'children')` | 计算嵌套数组中项目的总数。 |
103
- | `filterRecursive(array, predicate, childrenKey = 'children')` | 根据谓词函数递归过滤嵌套数组,如果子项匹配,则保留父结构。 |
104
-
105
- ### 字符串和 URL 验证
106
-
107
- 用于检查字符串格式的简单辅助函数。
108
-
109
- | 函数 | 描述 |
110
- | --- | --- |
111
- | `isUrl(str)` | 如果字符串以 `http://` 或 `https://` 开头,则返回 `true`。 |
112
- | `isMailProtocol(str)` | 如果字符串以 `mailto:` 开头,则返回 `true`。 |
113
-
114
- ### 路由
115
-
116
- 用于辅助客户端路由逻辑的工具。
117
-
118
- | 函数 | 描述 |
119
- | --- | --- |
120
- | `matchPath(path)` | 检查给定路径是否与当前的 `window.location.pathname` 匹配。 |
121
- | `matchPaths(paths)` | 从一个路径数组中找到与当前位置最佳匹配的路径。 |
122
-
123
- ### 布局
124
-
125
- | 函数 | 描述 |
126
- | --- | --- |
127
- | `splitNavColumns(items, options)` | 将导航项列表拆分为指定数量的列,可用于创建大型菜单。 |
128
-
129
- ---
130
-
131
- ### 总结
132
-
133
- 本节概述了库中包含的通用工具。要了解更强大、更专业的功能,请继续阅读各个组件的详细文档。
134
-
135
- 有关使用灵活的 `Icon` 组件的全面指南,请参阅下一节。
136
- - **[Icon](./components-utilities-icon.md)**
@@ -1,27 +0,0 @@
1
- # コンポーネント
2
-
3
- このセクションでは、Blocklet UI React ライブラリで利用可能なすべてのUIコンポーネントに関する包括的なリファレンスを提供します。各コンポーネントには、アプリケーションへのスムーズな統合を保証するために、そのプロパティ(props)、実践的な使用例、およびベストプラクティスが記載されています。
4
-
5
- コンポーネントは、ナビゲーションと検索を容易にするために、論理的なカテゴリに分類されています。以下のカテゴリを選択して、その中のコンポーネントをご覧ください。
6
-
7
- <x-cards data-columns="3">
8
- <x-card data-title="レイアウト" data-icon="lucide:layout-template" data-href="/components/layout">
9
- Header、Footer、Dashboard のような、blocklet アプリケーションの主要な構造を形成するプライマリコンポーネント。
10
- </x-card>
11
- <x-card data-title="ユーザー管理" data-icon="lucide:users" data-href="/components/user-management">
12
- ユーザープロファイル、セッション管理、組織の切り替えを処理するための一連のコンポーネント。
13
- </x-card>
14
- <x-card data-title="コンポーネント管理" data-icon="lucide:package" data-href="/components/component-management">
15
- アプリケーション内で blocklet コンポーネントを動的にインストール、公開、管理するためのツール。
16
- </x-card>
17
- <x-card data-title="通知" data-icon="lucide:bell" data-href="/components/notifications">
18
- リアルタイムのユーザー通知システムを実装するためのコンポーネントとユーティリティを提供します。
19
- </x-card>
20
- <x-card data-title="ユーティリティ" data-icon="lucide:wrench" data-href="/components/utilities">
21
- 多用途なアイコンコンポーネントやテーマプロバイダーなど、ヘルパーコンポーネントとユーティリティのコレクション。
22
- </x-card>
23
- </x-cards>
24
-
25
- ---
26
-
27
- アプリケーションの構造の構築を開始するには、[レイアウトコンポーネント](./components-layout.md) セクションに進んでください。
@@ -1,27 +0,0 @@
1
- # Components
2
-
3
- This section provides a comprehensive reference for all available UI components in the Blocklet UI React library. Each component is documented with its properties (props), practical usage examples, and best practices to ensure seamless integration into your application.
4
-
5
- The components are organized into logical categories to facilitate navigation and discovery. Select a category below to explore the components within it.
6
-
7
- <x-cards data-columns="3">
8
- <x-card data-title="Layout" data-icon="lucide:layout-template" data-href="/components/layout">
9
- Primary components like Header, Footer, and Dashboard that form the main structure of a blocklet application.
10
- </x-card>
11
- <x-card data-title="User Management" data-icon="lucide:users" data-href="/components/user-management">
12
- A suite of components for handling user profiles, session management, and organization switching.
13
- </x-card>
14
- <x-card data-title="Component Management" data-icon="lucide:package" data-href="/components/component-management">
15
- Tools for dynamically installing, publishing, and managing blocklet components within an application.
16
- </x-card>
17
- <x-card data-title="Notifications" data-icon="lucide:bell" data-href="/components/notifications">
18
- Provides components and utilities for implementing a real-time user notification system.
19
- </x-card>
20
- <x-card data-title="Utilities" data-icon="lucide:wrench" data-href="/components/utilities">
21
- A collection of helper components and utilities, such as a versatile Icon component and theme providers.
22
- </x-card>
23
- </x-cards>
24
-
25
- ---
26
-
27
- To begin building your application's structure, proceed to the [Layout Components](./components-layout.md) section.
@@ -1,27 +0,0 @@
1
- # 元件
2
-
3
- 本節為 Blocklet UI React 函式庫中所有可用的 UI 元件提供了詳盡的參考文件。每個元件都附有其屬性(props)、實際用法範例和最佳實踐的說明,以確保能順利地整合到您的應用程式中。
4
-
5
- 元件被組織成邏輯分類,以便於導覽和查找。請在下方選擇一個類別,以探索其中的元件。
6
-
7
- <x-cards data-columns="3">
8
- <x-card data-title="版面配置" data-icon="lucide:layout-template" data-href="/components/layout">
9
- 像 Header、Footer 和 Dashboard 這樣構成 blocklet 應用程式主要結構的核心元件。
10
- </x-card>
11
- <x-card data-title="使用者管理" data-icon="lucide:users" data-href="/components/user-management">
12
- 一套用於處理使用者個人資料、會話管理和組織切換的元件。
13
- </x-card>
14
- <x-card data-title="元件管理" data-icon="lucide:package" data-href="/components/component-management">
15
- 用於在應用程式中動態安裝、發布和管理 blocklet 元件的工具。
16
- </x-card>
17
- <x-card data-title="通知" data-icon="lucide:bell" data-href="/components/notifications">
18
- 提供用於實作即時使用者通知系統的元件和工具程式。
19
- </x-card>
20
- <x-card data-title="工具程式" data-icon="lucide:wrench" data-href="/components/utilities">
21
- 一系列輔助元件和工具程式,例如多功能的圖示元件和主題提供者。
22
- </x-card>
23
- </x-cards>
24
-
25
- ---
26
-
27
- 若要開始建構您的應用程式結構,請前往 [版面配置元件](./components-layout.md) 章節。
@@ -1,27 +0,0 @@
1
- # 组件
2
-
3
- 本节为 Blocklet UI React 库中所有可用的 UI 组件提供了全面的参考文档。每个组件都附有其属性 (props)、实际使用示例和最佳实践的文档,以确保能无缝集成到您的应用程序中。
4
-
5
- 这些组件按逻辑类别进行组织,以方便导航和查找。请在下方选择一个类别,以浏览其中的组件。
6
-
7
- <x-cards data-columns="3">
8
- <x-card data-title="布局" data-icon="lucide:layout-template" data-href="/components/layout">
9
- 构成 Blocklet 应用主要结构的主要组件,例如 Header、Footer 和 Dashboard。
10
- </x-card>
11
- <x-card data-title="用户管理" data-icon="lucide:users" data-href="/components/user-management">
12
- 一套用于处理用户个人资料、会话管理和组织切换的组件。
13
- </x-card>
14
- <x-card data-title="组件管理" data-icon="lucide:package" data-href="/components/component-management">
15
- 用于在应用程序内动态安装、发布和管理 Blocklet 组件的工具。
16
- </x-card>
17
- <x-card data-title="通知" data-icon="lucide:bell" data-href="/components/notifications">
18
- 提供用于实现实时用户通知系统的组件和实用工具。
19
- </x-card>
20
- <x-card data-title="实用工具" data-icon="lucide:wrench" data-href="/components/utilities">
21
- 一系列辅助组件和实用工具,例如多功能的图标组件和主题提供程序。
22
- </x-card>
23
- </x-cards>
24
-
25
- ---
26
-
27
- 要开始构建您的应用结构,请前往 [布局组件](./components-layout.md) 部分。
@@ -1,134 +0,0 @@
1
- # コアコンセプト
2
-
3
- このドキュメントでは、Blocklet UI React ライブラリの基本原則について説明します。中心的な設計思想は**メタデータ駆動アプローチ**であり、`Header`、`Footer`、`Dashboard` などの UI コンポーネントは、blocklet のメタデータに基づいて自動的に設定・レンダリングされます。この戦略により、一貫性が確保され、定型的なコードが削減され、ユーザーの役割や言語設定に適応する動的な UI が可能になります。
4
-
5
- 中心的な考え方は、単一の設定ファイル(通常は `blocklet.yml`)が、アプリケーションの全体的な構造と外観に関する信頼できる唯一の情報源として機能するということです。ライブラリはこのメタデータを読み取り、処理し、それを使用して適切な UI 要素を構築します。
6
-
7
- ## メタデータ駆動の原則
8
-
9
- ライブラリの動作は、単純なデータフローとして視覚化できます。blocklet のメタデータがライブラリへの入力として提供され、ライブラリはそれをパイプラインを通じて処理し、完全にレンダリングされた UI コンポーネントを生成します。これにより、開発者がアプリケーションごとに共通のレイアウト要素を手動で構築・設定する必要がなくなります。
10
-
11
- <!-- DIAGRAM_IMAGE_START:flowchart:16:9:1765962229 -->
12
- ![Core Concepts](assets/diagram/core-concepts-diagram-0.ja.jpg)
13
- <!-- DIAGRAM_IMAGE_END -->
14
-
15
- この自動化されたプロセスは、明確に定義されたメタデータ構造に依存しており、それについては次のセクションで詳しく説明します。
16
-
17
- ## Blocklet メタデータの構造
18
-
19
- ライブラリは、UI のレンダリングに必要なすべての情報を含む `BlockletMetaProps` と呼ばれる特定のオブジェクト構造を想定しています。以下に、この構造の詳細な内訳を示します。
20
-
21
- <x-field-group>
22
- <x-field data-name="appName" data-type="string" data-required="false" data-desc="アプリケーション名。通常は Header に表示されます。"></x-field>
23
- <x-field data-name="appLogo" data-type="React.ReactNode" data-required="false" data-desc="アプリケーションのロゴ用の React ノード。これも Header に表示されます。"></x-field>
24
- <x-field data-name="enableConnect" data-type="boolean" data-required="false" data-desc="DID Connect ボタンを表示するかどうかを決定します。"></x-field>
25
- <x-field data-name="enableLocale" data-type="boolean" data-required="false" data-desc="言語選択コンポーネントを表示するかどうかを決定します。"></x-field>
26
- <x-field data-name="theme" data-type="object" data-required="false">
27
- <x-field-desc markdown>アプリケーションレイアウトのカラースキームを定義します。</x-field-desc>
28
- <x-field data-name="background" data-type="string" data-required="false" data-desc="Header や Footer などのレイアウトコンポーネントの背景色を設定します。"></x-field>
29
- </x-field>
30
- <x-field data-name="navigation" data-type="array" data-required="false">
31
- <x-field-desc markdown>アプリケーション全体のリンクとメニューを定義するナビゲーション項目オブジェクトの配列です。</x-field-desc>
32
- <x-field data-name="title" data-type="string | object" data-required="true" data-desc="ナビゲーション項目の表示テキスト。i18n のためにオブジェクトにすることも可能です。"></x-field>
33
- <x-field data-name="link" data-type="string | object" data-required="false" data-desc="ナビゲーション項目の URL。i18n のためにオブジェクトにすることも可能です。"></x-field>
34
- <x-field data-name="icon" data-type="string" data-required="false" data-desc="タイトルの横に表示するアイコン用の Iconify 互換文字列です。"></x-field>
35
- <x-field data-name="section" data-type="string | array" data-required="false" data-desc="項目が表示される場所を指定します。例:'header'、'footer'、'dashboard'。"></x-field>
36
- <x-field data-name="role" data-type="string | array" data-required="false" data-desc="この項目を閲覧できるユーザーロールを定義します。例:'admin'、'guest'。"></x-field>
37
- <x-field data-name="items" data-type="array" data-required="false" data-desc="ドロップダウンメニューやサブメニューを作成するための、ネストされたナビゲーション項目の配列です。"></x-field>
38
- </x-field>
39
- </x-field-group>
40
-
41
- ### ナビゲーション設定の例
42
-
43
- `navigation` 配列は、メタデータの最も重要な部分です。すべてのリンク、メニュー、およびその配置を構造化された方法で定義する手段を提供します。
44
-
45
- ```yaml blocklet.yml でのナビゲーション設定 icon=mdi:code-braces
46
- # blocklet.yml
47
- navigation:
48
- - title: 機能
49
- link: /features
50
- - title:
51
- en: About Us
52
- ja: 私たちについて
53
- link:
54
- en: /about
55
- ja: /about-us
56
- section: footer
57
- - title: 管理ダッシュボード
58
- link: /admin
59
- section: dashboard
60
- role: admin
61
- - title: ソーシャル
62
- section: social
63
- items:
64
- - title: Twitter
65
- link: https://twitter.com/arcblock
66
- icon: mdi:twitter
67
- - title: GitHub
68
- link: https://github.com/arcblock
69
- icon: mdi:github
70
- ```
71
-
72
- この例は、いくつかの主要な機能を示しています:
73
- - シンプルなヘッダーリンク(「機能」)。
74
- - 多言語対応のフッターリンク(「私たちについて」)。
75
- - ダッシュボード用の管理者専用リンク。
76
- - フッター向けのソーシャルメディアリンクのグループ。
77
-
78
- ## データ処理パイプライン
79
-
80
- レンダリングの前に、ライブラリは生のメタデータを一連のステップで処理し、UI コンポーネント用に準備します。
81
-
82
- ### 1. パースとセクション分割
83
-
84
- 最初のステップは、`navigation` 配列をパースし、項目を `section` プロパティに基づいてグループ化することです。単一のナビゲーション項目は、`section` の値に配列を使用することで、複数のセクションに割り当てることができます。
85
-
86
- `parseNavigation` ユーティリティは、各項目を事前に定義されたセクションに分類します:
87
- - `header`: メインアプリケーションのヘッダー用。
88
- - `footer`: フッターの主要なリンク用。
89
- - `social`: 通常はフッターに配置されるソーシャルメディアアイコン用。
90
- - `bottom`: フッターの最下部にある法的または二次的なリンク用。
91
- - `dashboard`: ダッシュボードレイアウトのサイドバーナビゲーション用。
92
- - `sessionManager`: ユーザーセッションコンポーネント内のメニュー用。
93
- - `userCenter`: ユーザープロファイルエリア内のタブまたはリンク用。
94
-
95
- 項目に `section` プロパティがない場合、デフォルトで `header` になります。
96
-
97
- ### 2. 国際化 (i18n)
98
-
99
- ライブラリは、複数の言語を組み込みでサポートしています。ナビゲーション項目の `title` または `link` プロパティが言語キー(例:`en`、`ja`)を持つオブジェクトである場合、`getLocalizedNavigation` 関数はユーザーの現在のロケールに基づいて正しい文字列を自動的に選択します。
100
-
101
- ```javascript i18n オブジェクトの例 icon=logos:javascript
102
- // 多言語サポートを持つナビゲーション項目
103
- {
104
- title: {
105
- en: 'Home',
106
- ja: 'ホームページ'
107
- },
108
- link: {
109
- en: '/home',
110
- ja: '/ja/home'
111
- }
112
- }
113
- ```
114
-
115
- ### 3. ロールベースのフィルタリング
116
-
117
- 動的なユーザーエクスペリエンスを作成するために、ナビゲーション項目を特定のユーザーロールに制限することができます。`filterNavByRole` 関数は、各項目の `role` プロパティを現在のセッションの `user.role` と比較してナビゲーションリストをフィルタリングします。
118
-
119
- - 項目に `role` プロパティがない場合、それは全員に表示されます。
120
- - 項目に `role` プロパティ(例:`['admin', 'editor']`)がある場合、そのロールが配列に含まれるユーザーにのみ表示されます。
121
- - `guest` ロールは、未認証のユーザーに適用される特別な値です。
122
-
123
- このメカニズムにより、メタデータで包括的なナビゲーション構造を定義し、ログインしているユーザーの権限に基づいて UI を自動的に適応させることができます。
124
-
125
- ## まとめ
126
-
127
- Blocklet UI React ライブラリのコアコンセプトは、一元化されたメタデータオブジェクトを活用して、共通の UI コンポーネントの設定とレンダリングを駆動することです。このメタデータ駆動アプローチは、いくつかの利点を提供します:
128
-
129
- - **信頼できる唯一の情報源**:アプリケーションの構造、ブランディング、ナビゲーションが 1 か所で定義されます。
130
- - **一貫性**:アプリケーションのさまざまな部分で一貫したルックアンドフィールを保証します。
131
- - **ボイラープレートの削減**:ヘッダーやフッターのような共通のレイアウト要素を手動でコーディングする必要がなくなります。
132
- - **動的 UI**:国際化とロールベースのアクセス制御をネイティブでサポートし、UI がユーザーとその権限に応じて動的に適応できるようにします。
133
-
134
- これらの原則を明確に理解することで、ライブラリのコンポーネントを効果的に活用できます。特定のコンポーネントとその使用方法に関する詳細については、[コンポーネント](./components.md)セクションを参照してください。