@blocklet/ui-react 3.1.48 → 3.1.50

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,76 @@
1
+ # 使用者管理
2
+
3
+ 使用者管理套件提供了一系列預先建置的 React 元件,專為處理基本的使用者相關功能而設計。這些元件簡化了在您的應用程式中實現使用者個人資料、會話管理和組織切換的過程,確保提供一致且可靠的使用者體驗。
4
+
5
+ 本節概述了此套件中可用的主要元件。有關詳細的實作指南和 API 參考,請參閱下方連結的特定元件文件。
6
+
7
+ ```d2
8
+ direction: down
9
+
10
+ User: {
11
+ shape: c4-person
12
+ }
13
+
14
+ Application: {
15
+ label: "Blocklet 應用程式"
16
+ shape: rectangle
17
+ grid-columns: 1
18
+ grid-gap: 100
19
+
20
+ UserCenter: {
21
+ label: "UserCenter\n(個人資料與設定)"
22
+ }
23
+
24
+ UserSessions: {
25
+ label: "UserSessions\n(登入活動)"
26
+ }
27
+
28
+ OrgsSwitch: {
29
+ label: "OrgsSwitch\n(團隊情境)"
30
+ }
31
+ }
32
+
33
+ User -> Application.UserCenter: "管理個人資料"
34
+ User -> Application.UserSessions: "檢視會話"
35
+ User -> Application.OrgsSwitch: "切換組織"
36
+ ```
37
+
38
+ ## 核心元件
39
+
40
+ 此套件由幾個關鍵元件組成,每個元件都處理使用者管理的特定方面。
41
+
42
+ <x-cards>
43
+ <x-card data-title="UserCenter" data-icon="lucide:user-cog" data-href="/components/user-management/user-center">
44
+ 一個用於顯示和管理使用者個人資料的全面元件。它包含處理使用者設定、通行證管理以及如追蹤其他使用者等社交互動的功能。
45
+ </x-card>
46
+ <x-card data-title="UserSessions" data-icon="lucide:smartphone-nfc" data-href="/components/user-management/user-sessions">
47
+ 一個注重安全性的元件,允許使用者查看和管理他們在不同裝置上的有效和過去的登入會話,從而增強帳戶安全性。
48
+ </x-card>
49
+ </x-cards>
50
+
51
+ ### 組織切換
52
+
53
+ `OrgsSwitch` 元件為屬於多個組織的使用者提供了一個下拉式選單介面。它允許無縫的情境切換,這對於具有團隊或多租戶功能的應用程式至關重要。
54
+
55
+ **主要功能:**
56
+
57
+ * **目前組織顯示:**清楚地顯示使用者目前的組織情境。
58
+ * **組織列表:**列出使用者可以切換的所有可用組織,並具備無限滾動功能以提升效能。
59
+ * **搜尋功能:**包含一個搜尋欄,可快速篩選和尋找特定組織。
60
+ * **建立與導覽:**提供建立新組織的選項,以及一個連結到管理所有組織的專屬頁面。
61
+
62
+ ### 用於使用者互動的 Hooks
63
+
64
+ 為方便開發社交功能,此函式庫還包含自訂的 hooks 和 contexts,用以抽象化複雜的邏輯。
65
+
66
+ * **`useFollow` hook**:此 hook 管理追蹤和取消追蹤其他使用者的完整邏輯。它處理 API 請求和狀態變更,並返回目前的追蹤狀態(`followed`)以及 `followUser` 和 `unfollowUser` 函式。
67
+ * **`UserFollowersProvider` context**:對於需要在多個元件中存取追蹤狀態的應用程式,此提供者會包覆您的元件樹的一部分,並透過 `useUserFollowersContext` hook 提供追蹤狀態和操作。
68
+
69
+ ## 總結
70
+
71
+ 這套元件為任何使用此函式庫建置的應用程式提供了強健使用者管理的必要建構區塊。透過使用這些元件,您可以加速開發,並確保您的應用程式遵循使用者帳戶管理和安全性的最佳實踐。
72
+
73
+ 有關詳細的實作指南,請繼續參閱特定元件的文件。
74
+
75
+ * **下一步:** [UserCenter](./components-user-management-user-center.md)
76
+ * **另請參閱:** [UserSessions](./components-user-management-user-sessions.md)
@@ -0,0 +1,76 @@
1
+ # 用户管理
2
+
3
+ 用户管理套件提供了一系列预构建的 React 组件,旨在处理与用户相关的基本功能。这些组件简化了在您的应用中实现用户个人资料、会话管理和组织切换的过程,确保了用户体验的一致性和可靠性。
4
+
5
+ 本节概述了该套件中可用的主要组件。有关详细的实现指南和 API 参考,请参阅下方链接的特定组件文档。
6
+
7
+ ```d2
8
+ direction: down
9
+
10
+ User: {
11
+ shape: c4-person
12
+ }
13
+
14
+ Application: {
15
+ label: "Blocklet 应用"
16
+ shape: rectangle
17
+ grid-columns: 1
18
+ grid-gap: 100
19
+
20
+ UserCenter: {
21
+ label: "UserCenter\n(个人资料与设置)"
22
+ }
23
+
24
+ UserSessions: {
25
+ label: "UserSessions\n(登录活动)"
26
+ }
27
+
28
+ OrgsSwitch: {
29
+ label: "OrgsSwitch\n(团队上下文)"
30
+ }
31
+ }
32
+
33
+ User -> Application.UserCenter: "管理个人资料"
34
+ User -> Application.UserSessions: "查看会话"
35
+ User -> Application.OrgsSwitch: "切换组织"
36
+ ```
37
+
38
+ ## 核心组件
39
+
40
+ 该套件由几个关键组件组成,每个组件都针对用户管理的特定方面。
41
+
42
+ <x-cards>
43
+ <x-card data-title="UserCenter" data-icon="lucide:user-cog" data-href="/components/user-management/user-center">
44
+ 一个用于显示和管理用户个人资料的综合性组件。它包含处理用户设置、通行证管理以及关注其他用户等社交互动的功能。
45
+ </x-card>
46
+ <x-card data-title="UserSessions" data-icon="lucide:smartphone-nfc" data-href="/components/user-management/user-sessions">
47
+ 一个注重安全的组件,允许用户查看和管理他们在不同设备上的活动和历史登录会话,从而增强账户安全性。
48
+ </x-card>
49
+ </x-cards>
50
+
51
+ ### 组织切换
52
+
53
+ `OrgsSwitch` 组件为属于多个组织的用户提供了一个下拉菜单界面。它支持无缝的上下文切换,这对于具有基于团队或多租户功能的应用至关重要。
54
+
55
+ **主要功能:**
56
+
57
+ * **当前组织显示:** 清晰地显示用户当前的组织上下文。
58
+ * **组织列表:** 列出用户可以切换到的所有可用组织,并支持无限滚动以提高性能。
59
+ * **搜索功能:** 包含一个搜索栏,用于快速筛选和查找特定组织。
60
+ * **创建与导航:** 提供创建新组织的选项,以及一个用于管理所有组织的专用页面链接。
61
+
62
+ ### 用于用户交互的钩子 (Hooks)
63
+
64
+ 为便于开发社交功能,该库还包含了自定义钩子 (hooks) 和上下文 (contexts),用以抽象复杂的逻辑。
65
+
66
+ * **`useFollow` 钩子 (hook)**:此钩子管理关注和取消关注其他用户的完整逻辑。它处理 API 请求和状态变更,返回当前的关注状态(`followed`)以及 `followUser` 和 `unfollowUser` 函数。
67
+ * **`UserFollowersProvider` 上下文 (context)**:对于需要在多个组件之间访问关注状态的应用,此提供程序 (provider) 会包装您的组件树的一部分,并通过 `useUserFollowersContext` 钩子 (hook) 使关注状态和操作可用。
68
+
69
+ ## 总结
70
+
71
+ 这套组件为任何使用该库构建的应用提供了实现强大用户管理的必要构建块。通过使用这些组件,您可以加速开发,并确保您的应用遵循用户账户管理和安全方面的最佳实践。
72
+
73
+ 有关详细的实现指南,请继续阅读特定组件的文档。
74
+
75
+ * **下一步:** [UserCenter](./components-user-management-user-center.md)
76
+ * **另请参阅:** [UserSessions](./components-user-management-user-sessions.md)
@@ -0,0 +1,106 @@
1
+ # Icon
2
+
3
+ `Icon` コンポーネントは、Material-UI の `Avatar` コンポーネントを基に構築された柔軟なユーティリティです。[Iconify](https://iconify.design/) のアイコン文字列、画像 URL、文字ベースの「レターアバター」など、複数のソースからアイコンをレンダリングするように設計されています。この汎用性により、アプリケーション内のほとんどのアイコンやアバターの表示ニーズに対応するための標準化されたコンポーネントとなっています。
4
+
5
+ ## Props
6
+
7
+ `Icon` コンポーネントは以下の props を受け入れます:
8
+
9
+ <x-field-group>
10
+ <x-field data-name="icon" data-type="string" data-required="true">
11
+ <x-field-desc markdown>アイコンの主要な識別子。コンポーネントは文字列の形式に基づいてレンダリング方法を賢く決定します。Iconify 文字列(例:`mdi:home`)、直接の画像 URL、またはレターアバターを生成するための単純な文字列(例:「U」)を指定できます。</x-field-desc>
12
+ </x-field>
13
+ <x-field data-name="size" data-type="number" data-required="false">
14
+ <x-field-desc markdown>アイコンコンテナの `width` と `height` をピクセル単位で均一に設定します。</x-field-desc>
15
+ </x-field>
16
+ <x-field data-name="sx" data-type="BoxProps['sx']" data-required="false">
17
+ <x-field-desc markdown>Material-UI のシステムと一貫性のあるカスタムスタイリングのための `sx` prop。</x-field-desc>
18
+ </x-field>
19
+ <x-field data-name="..." data-type="AvatarProps" data-required="false">
20
+ <x-field-desc markdown>このコンポーネントは、Material-UI の [Avatar](https://mui.com/material-ui/react-avatar/) コンポーネントでサポートされている他のすべての props(`variant`、`alt`、`onClick` など)も受け入れます。</x-field-desc>
21
+ </x-field>
22
+ </x-field-group>
23
+
24
+ ## 使用例
25
+
26
+ `Icon` コンポーネントのさまざまな使用方法を示す実践的な例を以下に示します。
27
+
28
+ ### Iconify アイコン
29
+
30
+ Iconify エコシステムからアイコンを表示するには、その一意の文字列識別子を `icon` prop に指定します。コンポーネントは対応する SVG を動的に読み込み、レンダリングします。
31
+
32
+ ```jsx Displaying an Iconify icon icon=mdi:react
33
+ import Icon from '@blocklet/ui-react/lib/Icon';
34
+
35
+ export default function IconifyExample() {
36
+ return <Icon icon="mdi:react" size={48} />;
37
+ }
38
+ ```
39
+
40
+ この例では、Material Design Icons コレクションの「react」アイコンをレンダリングします。
41
+
42
+ ### 画像 URL
43
+
44
+ URL を `icon` prop に渡すことで、画像を直接レンダリングできます。コンポーネントは URL 形式を検出し、それを Avatar 内の `<img>` タグの `src` として使用します。
45
+
46
+ ```jsx Rendering an icon from a URL icon=mdi:image
47
+ import Icon from '@blocklet/ui-react/lib/Icon';
48
+
49
+ export default function ImageUrlExample() {
50
+ return <Icon icon="https://www.arcblock.io/image-bin/uploads/eb1cf5d60cd85c42362920c49e3768cb.svg" size={48} />;
51
+ }
52
+ ```
53
+
54
+ ### レターアバター
55
+
56
+ `icon` prop が有効な Iconify アイコンでも URL でもない文字列を受け取った場合、その文字列の最初の文字を使用してレターアバターをレンダリングします。これはユーザープロファイルのプレースホルダーとして便利です。
57
+
58
+ ```jsx Creating a letter avatar icon=mdi:format-letter-case
59
+ import Icon from '@blocklet/ui-react/lib/Icon';
60
+
61
+ export default function LetterAvatarExample() {
62
+ return <Icon icon="Blocklet" size={48} variant="rounded" sx={{ bgcolor: 'primary.main', color: 'primary.contrastText' }} />;
63
+ }
64
+ ```
65
+
66
+ この場合、コンポーネントは文字「B」を表示します。`variant` と `sx` prop の使用に注意してください。これらは基盤となる Material-UI Avatar に直接渡されます。
67
+
68
+ ### カスタムサイズ
69
+
70
+ `size` prop を使用すると、アイコンの寸法を簡単に制御できます。
71
+
72
+ ```jsx Adjusting the icon size icon=mdi:ruler
73
+ import Icon from '@blocklet/ui-react/lib/Icon';
74
+
75
+ export default function SizingExample() {
76
+ return (
77
+ <div>
78
+ <Icon icon="mdi:home" size={24} />
79
+ <Icon icon="mdi:home" size={32} />
80
+ <Icon icon="mdi:home" size={48} />
81
+ </div>
82
+ );
83
+ }
84
+ ```
85
+
86
+ この例では、同じアイコンを3つの異なるサイズでレンダリングしています。
87
+
88
+ ### Avatar Props の使用
89
+
90
+ `Icon` コンポーネントは Material-UI の `Avatar` のラッパーであるため、任意の `Avatar` prop を使用してその外観をカスタマイズできます。たとえば、`variant` prop を使用して形状を変更できます。
91
+
92
+ ```jsx Customizing with Avatar props icon=mdi:shape
93
+ import Icon from '@blocklet/ui-react/lib/Icon';
94
+
95
+ export default function AvatarPropsExample() {
96
+ return (
97
+ <div>
98
+ <Icon icon="B" variant="circular" size={48} sx={{ bgcolor: 'secondary.main' }} />
99
+ <Icon icon="L" variant="rounded" size={48} sx={{ bgcolor: 'success.main' }} />
100
+ <Icon icon="T" variant="square" size={48} sx={{ bgcolor: 'info.main' }} />
101
+ </div>
102
+ );
103
+ }
104
+ ```
105
+
106
+ これは、円形、角丸、四角形のアバターを作成する方法を示しています。
@@ -0,0 +1,106 @@
1
+ # Icon
2
+
3
+ The `Icon` component is a flexible utility built upon Material-UI's `Avatar` component. It is designed to render icons from multiple sources, including [Iconify](https://iconify.design/) icon strings, image URLs, and character-based "letter avatars". This versatility makes it a standardized component for handling most icon and avatar display needs within an application.
4
+
5
+ ## Props
6
+
7
+ The `Icon` component accepts the following props:
8
+
9
+ <x-field-group>
10
+ <x-field data-name="icon" data-type="string" data-required="true">
11
+ <x-field-desc markdown>The primary identifier for the icon. The component intelligently determines how to render it based on the string's format. It can be an Iconify string (e.g., `mdi:home`), a direct image URL, or a simple string to generate a letter avatar (e.g., "U").</x-field-desc>
12
+ </x-field>
13
+ <x-field data-name="size" data-type="number" data-required="false">
14
+ <x-field-desc markdown>Sets a uniform `width` and `height` for the icon container in pixels.</x-field-desc>
15
+ </x-field>
16
+ <x-field data-name="sx" data-type="BoxProps['sx']" data-required="false">
17
+ <x-field-desc markdown>The `sx` prop for custom styling, consistent with Material-UI's system.</x-field-desc>
18
+ </x-field>
19
+ <x-field data-name="..." data-type="AvatarProps" data-required="false">
20
+ <x-field-desc markdown>The component also accepts any other props supported by the Material-UI [Avatar](https://mui.com/material-ui/react-avatar/) component, such as `variant`, `alt`, and `onClick`.</x-field-desc>
21
+ </x-field>
22
+ </x-field-group>
23
+
24
+ ## Usage Examples
25
+
26
+ Here are practical examples demonstrating the different ways to use the `Icon` component.
27
+
28
+ ### Iconify Icon
29
+
30
+ To display an icon from the Iconify ecosystem, provide its unique string identifier to the `icon` prop. The component will dynamically load and render the corresponding SVG.
31
+
32
+ ```jsx Displaying an Iconify icon icon=mdi:react
33
+ import Icon from '@blocklet/ui-react/lib/Icon';
34
+
35
+ export default function IconifyExample() {
36
+ return <Icon icon="mdi:react" size={48} />;
37
+ }
38
+ ```
39
+
40
+ This example renders the "react" icon from the Material Design Icons collection.
41
+
42
+ ### Image URL
43
+
44
+ You can render an image directly by passing its URL to the `icon` prop. The component will detect the URL format and use it as the `src` for an `<img>` tag within the Avatar.
45
+
46
+ ```jsx Rendering an icon from a URL icon=mdi:image
47
+ import Icon from '@blocklet/ui-react/lib/Icon';
48
+
49
+ export default function ImageUrlExample() {
50
+ return <Icon icon="https://www.arcblock.io/image-bin/uploads/eb1cf5d60cd85c42362920c49e3768cb.svg" size={48} />;
51
+ }
52
+ ```
53
+
54
+ ### Letter Avatar
55
+
56
+ If the `icon` prop receives a string that is neither a valid Iconify icon nor a URL, it will render a letter avatar using the first character of the string. This is useful for user profile placeholders.
57
+
58
+ ```jsx Creating a letter avatar icon=mdi:format-letter-case
59
+ import Icon from '@blocklet/ui-react/lib/Icon';
60
+
61
+ export default function LetterAvatarExample() {
62
+ return <Icon icon="Blocklet" size={48} variant="rounded" sx={{ bgcolor: 'primary.main', color: 'primary.contrastText' }} />;
63
+ }
64
+ ```
65
+
66
+ In this case, the component will display the letter "B". Note the use of the `variant` and `sx` props, which are passed directly to the underlying Material-UI Avatar.
67
+
68
+ ### Custom Size
69
+
70
+ The `size` prop provides a convenient way to control the icon's dimensions.
71
+
72
+ ```jsx Adjusting the icon size icon=mdi:ruler
73
+ import Icon from '@blocklet/ui-react/lib/Icon';
74
+
75
+ export default function SizingExample() {
76
+ return (
77
+ <div>
78
+ <Icon icon="mdi:home" size={24} />
79
+ <Icon icon="mdi:home" size={32} />
80
+ <Icon icon="mdi:home" size={48} />
81
+ </div>
82
+ );
83
+ }
84
+ ```
85
+
86
+ This example shows the same icon rendered at three different sizes.
87
+
88
+ ### Using Avatar Props
89
+
90
+ Since the `Icon` component is a wrapper around Material-UI's `Avatar`, you can use any `Avatar` prop to customize its appearance. For instance, you can change the shape using the `variant` prop.
91
+
92
+ ```jsx Customizing with Avatar props icon=mdi:shape
93
+ import Icon from '@blocklet/ui-react/lib/Icon';
94
+
95
+ export default function AvatarPropsExample() {
96
+ return (
97
+ <div>
98
+ <Icon icon="B" variant="circular" size={48} sx={{ bgcolor: 'secondary.main' }} />
99
+ <Icon icon="L" variant="rounded" size={48} sx={{ bgcolor: 'success.main' }} />
100
+ <Icon icon="T" variant="square" size={48} sx={{ bgcolor: 'info.main' }} />
101
+ </div>
102
+ );
103
+ }
104
+ ```
105
+
106
+ This demonstrates how to create circular, rounded, and square avatars.
@@ -0,0 +1,106 @@
1
+ # Icon
2
+
3
+ `Icon` 元件是一個基於 Material-UI 的 `Avatar` 元件所建構的靈活工具。它旨在渲染來自多種來源的圖示,包括 [Iconify](https://iconify.design/) 圖示字串、圖片 URL 以及基於字元的「字母頭像」。這種多功能性使其成為一個標準化元件,可滿足應用程式中大多數圖示和頭像的顯示需求。
4
+
5
+ ## 屬性
6
+
7
+ `Icon` 元件接受以下屬性:
8
+
9
+ <x-field-group>
10
+ <x-field data-name="icon" data-type="string" data-required="true">
11
+ <x-field-desc markdown>圖示的主要識別碼。元件會根據字串的格式智慧地決定如何渲染它。它可以是 Iconify 字串(例如 `mdi:home`)、直接的圖片 URL,或用於產生字母頭像的簡單字串(例如 "U")。</x-field-desc>
12
+ </x-field>
13
+ <x-field data-name="size" data-type="number" data-required="false">
14
+ <x-field-desc markdown>設定圖示容器的統一 `width` 和 `height`(以像素為單位)。</x-field-desc>
15
+ </x-field>
16
+ <x-field data-name="sx" data-type="BoxProps['sx']" data-required="false">
17
+ <x-field-desc markdown>用於自訂樣式的 `sx` 屬性,與 Material-UI 的系統一致。</x-field-desc>
18
+ </x-field>
19
+ <x-field data-name="..." data-type="AvatarProps" data-required="false">
20
+ <x-field-desc markdown>該元件也接受 Material-UI [Avatar](https://mui.com/material-ui/react-avatar/) 元件支援的任何其他屬性,例如 `variant`、`alt` 和 `onClick`。</x-field-desc>
21
+ </x-field>
22
+ </x-field-group>
23
+
24
+ ## 使用範例
25
+
26
+ 以下是展示 `Icon` 元件不同使用方式的實際範例。
27
+
28
+ ### Iconify 圖示
29
+
30
+ 要顯示來自 Iconify 生態系統的圖示,請將其唯一的字串識別碼提供給 `icon` 屬性。元件將動態載入並渲染對應的 SVG。
31
+
32
+ ```jsx Displaying an Iconify icon icon=mdi:react
33
+ import Icon from '@blocklet/ui-react/lib/Icon';
34
+
35
+ export default function IconifyExample() {
36
+ return <Icon icon="mdi:react" size={48} />;
37
+ }
38
+ ```
39
+
40
+ 此範例渲染了 Material Design Icons 集合中的 "react" 圖示。
41
+
42
+ ### 圖片 URL
43
+
44
+ 您可以透過將圖片的 URL 傳遞給 `icon` 屬性來直接渲染圖片。元件將偵測 URL 格式,並將其用作 Avatar 內 `<img>` 標籤的 `src`。
45
+
46
+ ```jsx Rendering an icon from a URL icon=mdi:image
47
+ import Icon from '@blocklet/ui-react/lib/Icon';
48
+
49
+ export default function ImageUrlExample() {
50
+ return <Icon icon="https://www.arcblock.io/image-bin/uploads/eb1cf5d60cd85c42362920c49e3768cb.svg" size={48} />;
51
+ }
52
+ ```
53
+
54
+ ### 字母頭像
55
+
56
+ 如果 `icon` 屬性收到的字串既不是有效的 Iconify 圖示也不是 URL,它將使用字串的第一個字元渲染一個字母頭像。這對於使用者個人資料的預留位置很有用。
57
+
58
+ ```jsx Creating a letter avatar icon=mdi:format-letter-case
59
+ import Icon from '@blocklet/ui-react/lib/Icon';
60
+
61
+ export default function LetterAvatarExample() {
62
+ return <Icon icon="Blocklet" size={48} variant="rounded" sx={{ bgcolor: 'primary.main', color: 'primary.contrastText' }} />;
63
+ }
64
+ ```
65
+
66
+ 在這種情況下,元件將顯示字母 "B"。請注意 `variant` 和 `sx` 屬性的使用,它們會直接傳遞給底層的 Material-UI Avatar。
67
+
68
+ ### 自訂尺寸
69
+
70
+ `size` 屬性提供了一種方便的方式來控制圖示的尺寸。
71
+
72
+ ```jsx Adjusting the icon size icon=mdi:ruler
73
+ import Icon from '@blocklet/ui-react/lib/Icon';
74
+
75
+ export default function SizingExample() {
76
+ return (
77
+ <div>
78
+ <Icon icon="mdi:home" size={24} />
79
+ <Icon icon="mdi:home" size={32} />
80
+ <Icon icon="mdi:home" size={48} />
81
+ </div>
82
+ );
83
+ }
84
+ ```
85
+
86
+ 此範例展示了以三種不同尺寸渲染的同一個圖示。
87
+
88
+ ### 使用 Avatar 屬性
89
+
90
+ 由於 `Icon` 元件是 Material-UI 的 `Avatar` 的封裝,您可以使用任何 `Avatar` 屬性來自訂其外觀。例如,您可以使用 `variant` 屬性來改變形狀。
91
+
92
+ ```jsx Customizing with Avatar props icon=mdi:shape
93
+ import Icon from '@blocklet/ui-react/lib/Icon';
94
+
95
+ export default function AvatarPropsExample() {
96
+ return (
97
+ <div>
98
+ <Icon icon="B" variant="circular" size={48} sx={{ bgcolor: 'secondary.main' }} />
99
+ <Icon icon="L" variant="rounded" size={48} sx={{ bgcolor: 'success.main' }} />
100
+ <Icon icon="T" variant="square" size={48} sx={{ bgcolor: 'info.main' }} />
101
+ </div>
102
+ );
103
+ }
104
+ ```
105
+
106
+ 這展示了如何創建圓形、圓角和方形的頭像。
@@ -0,0 +1,106 @@
1
+ # Icon
2
+
3
+ `Icon` 组件是一个基于 Material-UI 的 `Avatar` 组件构建的灵活实用工具。它旨在从多种来源渲染图标,包括 [Iconify](https://iconify.design/) 图标字符串、图像 URL 和基于字符的“字母头像”。这种多功能性使其成为一个标准化组件,可用于处理应用程序中的大多数图标和头像显示需求。
4
+
5
+ ## Props
6
+
7
+ `Icon` 组件接受以下 props:
8
+
9
+ <x-field-group>
10
+ <x-field data-name="icon" data-type="string" data-required="true">
11
+ <x-field-desc markdown>图标的主要标识符。组件会根据字符串的格式智能地确定如何渲染它。它可以是 Iconify 字符串(例如 `mdi:home`)、直接的图像 URL 或用于生成字母头像的简单字符串(例如 “U”)。</x-field-desc>
12
+ </x-field>
13
+ <x-field data-name="size" data-type="number" data-required="false">
14
+ <x-field-desc markdown>以像素为单位,为图标容器设置统一的 `width` 和 `height`。</x-field-desc>
15
+ </x-field>
16
+ <x-field data-name="sx" data-type="BoxProps['sx']" data-required="false">
17
+ <x-field-desc markdown>用于自定义样式的 `sx` prop,与 Material-UI 的系统一致。</x-field-desc>
18
+ </x-field>
19
+ <x-field data-name="..." data-type="AvatarProps" data-required="false">
20
+ <x-field-desc markdown>该组件也接受 Material-UI [Avatar](https://mui.com/material-ui/react-avatar/) 组件支持的任何其他 props,例如 `variant`、`alt` 和 `onClick`。</x-field-desc>
21
+ </x-field>
22
+ </x-field-group>
23
+
24
+ ## 用法示例
25
+
26
+ 以下是演示 `Icon` 组件不同使用方式的实际示例。
27
+
28
+ ### Iconify 图标
29
+
30
+ 要显示来自 Iconify 生态系统的图标,请将其唯一的字符串标识符提供给 `icon` prop。该组件将动态加载并渲染相应的 SVG。
31
+
32
+ ```jsx 显示 Iconify 图标 icon=mdi:react
33
+ import Icon from '@blocklet/ui-react/lib/Icon';
34
+
35
+ export default function IconifyExample() {
36
+ return <Icon icon="mdi:react" size={48} />;
37
+ }
38
+ ```
39
+
40
+ 此示例渲染了 Material Design Icons 集合中的 “react” 图标。
41
+
42
+ ### 图像 URL
43
+
44
+ 您可以通过将其 URL 传递给 `icon` prop 来直接渲染图像。该组件将检测 URL 格式,并将其用作 Avatar 内 `<img>` 标签的 `src`。
45
+
46
+ ```jsx 从 URL 渲染图标 icon=mdi:image
47
+ import Icon from '@blocklet/ui-react/lib/Icon';
48
+
49
+ export default function ImageUrlExample() {
50
+ return <Icon icon="https://www.arcblock.io/image-bin/uploads/eb1cf5d60cd85c42362920c49e3768cb.svg" size={48} />;
51
+ }
52
+ ```
53
+
54
+ ### 字母头像
55
+
56
+ 如果 `icon` prop 接收到的字符串既不是有效的 Iconify 图标也不是 URL,它将使用该字符串的第一个字符渲染一个字母头像。这对于用户个人资料的占位符很有用。
57
+
58
+ ```jsx 创建字母头像 icon=mdi:format-letter-case
59
+ import Icon from '@blocklet/ui-react/lib/Icon';
60
+
61
+ export default function LetterAvatarExample() {
62
+ return <Icon icon="Blocklet" size={48} variant="rounded" sx={{ bgcolor: 'primary.main', color: 'primary.contrastText' }} />;
63
+ }
64
+ ```
65
+
66
+ 在这种情况下,组件将显示字母 “B”。请注意 `variant` 和 `sx` props 的使用,它们被直接传递给底层的 Material-UI Avatar。
67
+
68
+ ### 自定义尺寸
69
+
70
+ `size` prop 提供了一种便捷的方式来控制图标的尺寸。
71
+
72
+ ```jsx 调整图标尺寸 icon=mdi:ruler
73
+ import Icon from '@blocklet/ui-react/lib/Icon';
74
+
75
+ export default function SizingExample() {
76
+ return (
77
+ <div>
78
+ <Icon icon="mdi:home" size={24} />
79
+ <Icon icon="mdi:home" size={32} />
80
+ <Icon icon="mdi:home" size={48} />
81
+ </div>
82
+ );
83
+ }
84
+ ```
85
+
86
+ 此示例展示了以三种不同尺寸渲染的同一个图标。
87
+
88
+ ### 使用 Avatar Props
89
+
90
+ 由于 `Icon` 组件是 Material-UI 的 `Avatar` 的包装器,您可以使用任何 `Avatar` prop 来自定义其外观。例如,您可以使用 `variant` prop 来改变形状。
91
+
92
+ ```jsx 使用 Avatar props 进行自定义 icon=mdi:shape
93
+ import Icon from '@blocklet/ui-react/lib/Icon';
94
+
95
+ export default function AvatarPropsExample() {
96
+ return (
97
+ <div>
98
+ <Icon icon="B" variant="circular" size={48} sx={{ bgcolor: 'secondary.main' }} />
99
+ <Icon icon="L" variant="rounded" size={48} sx={{ bgcolor: 'success.main' }} />
100
+ <Icon icon="T" variant="square" size={48} sx={{ bgcolor: 'info.main' }} />
101
+ </div>
102
+ );
103
+ }
104
+ ```
105
+
106
+ 这演示了如何创建圆形、圆角和方形的头像。