@fibrae/semi-ui-svelte 0.9.1 → 0.10.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 (165) hide show
  1. package/README.md +8 -4
  2. package/README.zh-CN.md +8 -4
  3. package/dist/components/anchor/interface.d.ts +14 -0
  4. package/dist/components/audio-player/interface.d.ts +5 -0
  5. package/dist/components/auto-complete/interface.d.ts +29 -0
  6. package/dist/components/avatar/interface.d.ts +24 -0
  7. package/dist/components/backtop/interface.d.ts +2 -0
  8. package/dist/components/badge/interface.d.ts +7 -0
  9. package/dist/components/banner/interface.d.ts +7 -0
  10. package/dist/components/breadcrumb/interface.d.ts +10 -0
  11. package/dist/components/button/interface.d.ts +18 -0
  12. package/dist/components/calendar/interface.d.ts +16 -0
  13. package/dist/components/card/interface.d.ts +18 -0
  14. package/dist/components/carousel/interface.d.ts +16 -0
  15. package/dist/components/cascader/interface.d.ts +57 -0
  16. package/dist/components/checkbox/interface.d.ts +19 -0
  17. package/dist/components/code-highlight/interface.d.ts +3 -0
  18. package/dist/components/collapse/interface.d.ts +16 -0
  19. package/dist/components/collapsible/interface.d.ts +10 -0
  20. package/dist/components/color-picker/interface.d.ts +10 -0
  21. package/dist/components/config-provider/interface.d.ts +7 -0
  22. package/dist/components/cropper/interface.d.ts +11 -0
  23. package/dist/components/date-picker/interface.d.ts +47 -0
  24. package/dist/components/descriptions/interface.d.ts +6 -0
  25. package/dist/components/divider/interface.d.ts +4 -0
  26. package/dist/components/dropdown/interface.d.ts +8 -0
  27. package/dist/components/empty/interface.d.ts +7 -0
  28. package/dist/components/feedback/interface.d.ts +16 -0
  29. package/dist/components/float-button/interface.d.ts +14 -0
  30. package/dist/components/form/interface.d.ts +47 -0
  31. package/dist/components/grid/interface.d.ts +13 -0
  32. package/dist/components/highlight/interface.d.ts +7 -0
  33. package/dist/components/hot-keys/interface.d.ts +3 -0
  34. package/dist/components/image/interface.d.ts +59 -0
  35. package/dist/components/input/interface.d.ts +67 -0
  36. package/dist/components/input-number/interface.d.ts +24 -0
  37. package/dist/components/json-viewer/interface.d.ts +7 -0
  38. package/dist/components/layout/interface.d.ts +3 -0
  39. package/dist/components/list/interface.d.ts +18 -0
  40. package/dist/components/locale/interface.d.ts +4 -0
  41. package/dist/components/lottie/interface.d.ts +2 -0
  42. package/dist/components/markdown-render/interface.d.ts +5 -0
  43. package/dist/components/modal/interface.d.ts +29 -0
  44. package/dist/components/navigation/interface.d.ts +47 -0
  45. package/dist/components/overflow-list/interface.d.ts +11 -0
  46. package/dist/components/pagination/interface.d.ts +12 -0
  47. package/dist/components/pincode/interface.d.ts +8 -0
  48. package/dist/components/popconfirm/interface.d.ts +12 -0
  49. package/dist/components/popover/interface.d.ts +30 -0
  50. package/dist/components/progress/interface.d.ts +13 -0
  51. package/dist/components/radio/interface.d.ts +22 -0
  52. package/dist/components/rating/interface.d.ts +12 -0
  53. package/dist/components/resizable/interface.d.ts +30 -0
  54. package/dist/components/scroll-list/interface.d.ts +6 -0
  55. package/dist/components/select/interface.d.ts +63 -0
  56. package/dist/components/side-sheet/interface.d.ts +19 -0
  57. package/dist/components/skeleton/interface.d.ts +7 -0
  58. package/dist/components/slider/interface.d.ts +23 -0
  59. package/dist/components/space/interface.d.ts +4 -0
  60. package/dist/components/spin/interface.d.ts +7 -0
  61. package/dist/components/steps/interface.d.ts +9 -0
  62. package/dist/components/switch/interface.d.ts +7 -0
  63. package/dist/components/table/interface.d.ts +48 -0
  64. package/dist/components/tabs/interface.d.ts +29 -0
  65. package/dist/components/tag/interface.d.ts +22 -0
  66. package/dist/components/tag-input/interface.d.ts +29 -0
  67. package/dist/components/time-picker/interface.d.ts +31 -0
  68. package/dist/components/timeline/interface.d.ts +5 -0
  69. package/dist/components/tooltip/interface.d.ts +20 -0
  70. package/dist/components/transfer/interface.d.ts +18 -0
  71. package/dist/components/tree/interface.d.ts +45 -0
  72. package/dist/components/tree-select/interface.d.ts +55 -0
  73. package/dist/components/typography/interface.d.ts +33 -0
  74. package/dist/components/upload/interface.d.ts +64 -0
  75. package/dist/components/user-guide/interface.d.ts +15 -0
  76. package/dist/components/video-player/interface.d.ts +22 -0
  77. package/docs/advanced/dark-mode.md +288 -0
  78. package/docs/basic/button.md +605 -0
  79. package/docs/basic/divider.md +103 -0
  80. package/docs/basic/float-button.md +246 -0
  81. package/docs/basic/grid.md +427 -0
  82. package/docs/basic/layout.md +459 -0
  83. package/docs/basic/resizable.md +584 -0
  84. package/docs/basic/space.md +163 -0
  85. package/docs/basic/tokens.md +425 -0
  86. package/docs/basic/typography.md +615 -0
  87. package/docs/changes-from-semi.md +105 -0
  88. package/docs/ecosystem/tailwind.md +210 -0
  89. package/docs/experience/accessibility.md +82 -0
  90. package/docs/experience/content-guidelines.md +819 -0
  91. package/docs/experience/internationalization.md +7 -0
  92. package/docs/feedback/banner.md +198 -0
  93. package/docs/feedback/feedback.md +294 -0
  94. package/docs/feedback/notification.md +401 -0
  95. package/docs/feedback/popconfirm.md +243 -0
  96. package/docs/feedback/progress.md +389 -0
  97. package/docs/feedback/skeleton.md +388 -0
  98. package/docs/feedback/spin.md +172 -0
  99. package/docs/feedback/toast.md +393 -0
  100. package/docs/input/auto-complete.md +399 -0
  101. package/docs/input/cascader.md +1558 -0
  102. package/docs/input/checkbox.md +408 -0
  103. package/docs/input/color-picker.md +175 -0
  104. package/docs/input/date-picker.md +942 -0
  105. package/docs/input/form.md +2550 -0
  106. package/docs/input/input-number.md +451 -0
  107. package/docs/input/input.md +640 -0
  108. package/docs/input/pincode.md +191 -0
  109. package/docs/input/radio.md +337 -0
  110. package/docs/input/rating.md +214 -0
  111. package/docs/input/select.md +1230 -0
  112. package/docs/input/slider.md +347 -0
  113. package/docs/input/switch.md +206 -0
  114. package/docs/input/tag-input.md +465 -0
  115. package/docs/input/time-picker.md +358 -0
  116. package/docs/input/transfer.md +1061 -0
  117. package/docs/input/tree-select.md +1300 -0
  118. package/docs/input/upload.md +1811 -0
  119. package/docs/llms.txt +147 -0
  120. package/docs/navigation/anchor.md +377 -0
  121. package/docs/navigation/backtop.md +100 -0
  122. package/docs/navigation/breadcrumb.md +284 -0
  123. package/docs/navigation/navigation.md +851 -0
  124. package/docs/navigation/pagination.md +217 -0
  125. package/docs/navigation/steps.md +315 -0
  126. package/docs/navigation/tabs.md +754 -0
  127. package/docs/navigation/tree.md +1956 -0
  128. package/docs/other/config-provider.md +599 -0
  129. package/docs/other/locale.md +353 -0
  130. package/docs/plus/audio-player.md +155 -0
  131. package/docs/plus/code-highlight.md +150 -0
  132. package/docs/plus/drag-move.md +214 -0
  133. package/docs/plus/hot-keys.md +174 -0
  134. package/docs/plus/json-viewer.md +392 -0
  135. package/docs/plus/lottie.md +176 -0
  136. package/docs/plus/markdown-render.md +240 -0
  137. package/docs/plus/video-player.md +325 -0
  138. package/docs/show/avatar.md +475 -0
  139. package/docs/show/badge.md +276 -0
  140. package/docs/show/calendar.md +352 -0
  141. package/docs/show/card.md +485 -0
  142. package/docs/show/carousel.md +592 -0
  143. package/docs/show/collapse.md +289 -0
  144. package/docs/show/collapsible.md +216 -0
  145. package/docs/show/cropper.md +285 -0
  146. package/docs/show/descriptions.md +325 -0
  147. package/docs/show/dropdown.md +466 -0
  148. package/docs/show/empty.md +225 -0
  149. package/docs/show/highlight.md +144 -0
  150. package/docs/show/image.md +433 -0
  151. package/docs/show/list.md +927 -0
  152. package/docs/show/modal.md +517 -0
  153. package/docs/show/overflow-list.md +272 -0
  154. package/docs/show/popover.md +534 -0
  155. package/docs/show/scroll-list.md +156 -0
  156. package/docs/show/side-sheet.md +274 -0
  157. package/docs/show/table.md +5437 -0
  158. package/docs/show/tag.md +428 -0
  159. package/docs/show/timeline.md +277 -0
  160. package/docs/show/tooltip.md +442 -0
  161. package/docs/show/user-guide.md +419 -0
  162. package/docs/start/getting-started.md +234 -0
  163. package/docs/start/introduction.md +57 -0
  164. package/docs/start/overview.md +21 -0
  165. package/package.json +5 -4
@@ -0,0 +1,475 @@
1
+ # Avatar
2
+
3
+ > Avatar, used for image or text display.
4
+
5
+ Package: `@fibrae/semi-ui-svelte`. Web page: https://semi-design-next.pages.dev/en-US/svelte/show/avatar/
6
+
7
+ ## Demos
8
+
9
+ ### How to import
10
+
11
+ ```svelte
12
+ <script lang="ts">
13
+ import { Avatar, AvatarGroup } from '@fibrae/semi-ui-svelte';
14
+ </script>
15
+ ```
16
+
17
+ ### Size
18
+
19
+ You can change the size of the avatars with `size` property. The following sizes are supported: `extra-extra-small`, `extra-small`,`small`, `default`, `medium`, `large`, `extra-large`.
20
+
21
+ ```svelte
22
+ <script lang="ts">
23
+ import { Avatar } from '@fibrae/semi-ui-svelte';
24
+ </script>
25
+
26
+ <div>
27
+ <Avatar alt="用户" size="extra-extra-small" style="margin: 4px">U</Avatar>
28
+ <Avatar alt="用户" size="extra-small" style="margin: 4px">U</Avatar>
29
+ <Avatar alt="用户" size="small" style="margin: 4px">U</Avatar>
30
+ <Avatar alt="用户" size="default" style="margin: 4px">U</Avatar>
31
+ <Avatar alt="用户" style="margin: 4px">U</Avatar>
32
+ <Avatar alt="用户" size="large" style="margin: 4px">U</Avatar>
33
+ <Avatar alt="用户" size="extra-large" style="margin: 4px">U</Avatar>
34
+ </div>
35
+ ```
36
+
37
+ ### Color
38
+
39
+ Avatars support 16 colors including `white`, `amber`, `blue`, `cyan`, `green`, `grey`, `indigo`, `light-blue`, `light-green`, `lime`, `orange`, `pink`, `purple`, `red`, `teal`, `violet`, and `yellow`. You can also use the `style` prop to customize styles. The default color is`grey`.
40
+
41
+ ```svelte
42
+ <script lang="ts">
43
+ import { Avatar } from '@fibrae/semi-ui-svelte';
44
+ </script>
45
+
46
+ <div>
47
+ <Avatar alt="Alice Swift" style="margin: 4px">AS</Avatar>
48
+ <Avatar alt="Bob Matteo" color="red" style="margin: 4px">BM</Avatar>
49
+ <Avatar alt="Taylor Joy" color="light-blue" style="margin: 4px">TJ</Avatar>
50
+ <Avatar alt="Zank Lance" style="color: #f56a00; background-color: #fde3cf; margin: 4px">ZL</Avatar>
51
+ <Avatar alt="Youself Zhang" style="background-color: #87d068; margin: 4px">YZ</Avatar>
52
+ </div>
53
+ ```
54
+
55
+ ### Adaptive character size
56
+
57
+ For the avatar of the character type, the font size will be adjusted adaptively according to the width of the avatar. Use `gap` to adjust the pixel size on the left and right sides of the character avatar distance.
58
+
59
+ ```svelte
60
+ <script lang="ts">
61
+ import { Avatar } from '@fibrae/semi-ui-svelte';
62
+ </script>
63
+
64
+ <div>
65
+ <Avatar style="margin: 4px">AS</Avatar>
66
+ <Avatar gap={4} style="margin: 4px">Semi</Avatar>
67
+ <Avatar gap={10} style="margin: 4px">Semi</Avatar>
68
+ </div>
69
+ ```
70
+
71
+ ### Image
72
+
73
+ Image avatars can be created by using the `src` or `srcSet` prop.
74
+
75
+ ```svelte
76
+ <script lang="ts">
77
+ import { Avatar } from '@fibrae/semi-ui-svelte';
78
+ </script>
79
+
80
+ <div>
81
+ <Avatar alt="漂亮的猫咪" src="/assets/placeholder/avatar-a.svg" style="margin: 4px" />
82
+ <Avatar alt="可爱的猫咪" size="small" src="/assets/placeholder/avatar-a.svg" style="margin: 4px" />
83
+ </div>
84
+ ```
85
+
86
+ ### Shape
87
+
88
+ Avatars support two shapes: `circle` and `square`. The shape is default to `circle`.
89
+
90
+ ```svelte
91
+ <script lang="ts">
92
+ import { Avatar } from '@fibrae/semi-ui-svelte';
93
+ </script>
94
+
95
+ <div>
96
+ <Avatar alt="用户" style="margin: 4px">U</Avatar>
97
+ <Avatar alt="用户" shape="square" style="margin: 4px">U</Avatar>
98
+ </div>
99
+ ```
100
+
101
+ ### Event
102
+
103
+ Avatars support `onclick`, `onMouseEnter` and `onMouseLeave`; only an avatar given `onclick` becomes a focusable button. Pass hover overlay content through the `hoverMask` snippet, written as `{#snippet hoverMask()}...{/snippet}` inside the Avatar tag. The overlay has no default style.
104
+
105
+ ```svelte
106
+ <script lang="ts">
107
+ import { IconCamera } from '@fibrae/semi-icons-svelte';
108
+ import { Avatar } from '@fibrae/semi-ui-svelte';
109
+
110
+ const overlayStyle = 'background-color: var(--semi-color-overlay-bg); height: 100%; width: 100%; display: flex; align-items: center; justify-content: center';
111
+ </script>
112
+
113
+ <Avatar alt="Bob Downton" color="red">
114
+ BD
115
+ {#snippet hoverMask()}
116
+ <div style={overlayStyle}>
117
+ <IconCamera />
118
+ </div>
119
+ {/snippet}
120
+ </Avatar>
121
+ ```
122
+
123
+ ### Top and Bottom Slot
124
+
125
+ Use the `topSlot` and `bottomSlot` props to configure badge appearance, and the `topSlotText` and `bottomSlotText` snippets for badge content. A snippet as `topSlot.render` or `bottomSlot.render` replaces the entire badge; `topSlot.style` and `bottomSlot.style` are strings.
126
+
127
+ ```svelte
128
+ <script lang="ts">
129
+ import { IconPlus } from '@fibrae/semi-icons-svelte';
130
+ import { Avatar } from '@fibrae/semi-ui-svelte';
131
+ </script>
132
+
133
+ <Avatar alt="漂亮的猫咪" border={{ color: '#FE2C55', motion: true }} bottomSlot={{ shape: 'circle', bgColor: '#FE2C55' }} contentMotion size="large" src="/assets/placeholder/avatar-a.svg" style="margin: 4px" topSlot={{ gradientStart: 'rgb(255,23,100)', gradientEnd: 'rgb(237,52,148)' }}>
134
+ {#snippet topSlotText()}直播{/snippet}
135
+ {#snippet bottomSlotText()}
136
+ <IconPlus />
137
+ {/snippet}
138
+ </Avatar>
139
+ ```
140
+
141
+ #### Top
142
+
143
+ ```svelte
144
+ <script lang="ts">
145
+ import { Avatar } from '@fibrae/semi-ui-svelte';
146
+ </script>
147
+
148
+ <div>
149
+ <Avatar color="amber" topSlot={{ gradientStart: 'rgb(255,23,100)', gradientEnd: 'rgb(237,52,148)' }}>
150
+ T
151
+ {#snippet topSlotText()}直播{/snippet}
152
+ </Avatar>
153
+
154
+ <Avatar color="amber" size="large" topSlot={{ gradientStart: 'rgb(255,23,100)', gradientEnd: 'rgb(237,52,148)' }}>
155
+ T
156
+ {#snippet topSlotText()}直播{/snippet}
157
+ </Avatar>
158
+
159
+ <Avatar color="amber" size="extra-large" topSlot={{ gradientStart: 'rgb(255,23,100)', gradientEnd: 'rgb(237,52,148)' }}>
160
+ T
161
+ {#snippet topSlotText()}直播{/snippet}
162
+ </Avatar>
163
+ </div>
164
+ ```
165
+
166
+ #### Bottom
167
+
168
+ ```svelte
169
+ <script lang="ts">
170
+ import { IconPlus } from '@fibrae/semi-icons-svelte';
171
+ import { Avatar } from '@fibrae/semi-ui-svelte';
172
+ </script>
173
+
174
+ <div>
175
+ <Avatar bottomSlot={{ shape: 'square', bgColor: '#FE2C55' }} color="amber">
176
+ T
177
+ {#snippet bottomSlotText()}直播中{/snippet}
178
+ </Avatar>
179
+
180
+ <Avatar bottomSlot={{ shape: 'square', bgColor: '#FE2C55' }} color="amber" size="large">
181
+ T
182
+ {#snippet bottomSlotText()}直播中{/snippet}
183
+ </Avatar>
184
+
185
+ <Avatar bottomSlot={{ shape: 'square', bgColor: '#FE2C55' }} color="amber" size="extra-large">
186
+ T
187
+ {#snippet bottomSlotText()}直播中{/snippet}
188
+ </Avatar>
189
+ <br />
190
+ <br />
191
+ <br />
192
+ <Avatar bottomSlot={{ shape: 'circle', bgColor: '#FE2C55' }} color="amber">
193
+ T
194
+ {#snippet bottomSlotText()}
195
+ <IconPlus />
196
+ {/snippet}
197
+ </Avatar>
198
+
199
+ <Avatar bottomSlot={{ shape: 'circle', bgColor: '#FE2C55' }} color="amber" size="large">
200
+ T
201
+ {#snippet bottomSlotText()}
202
+ <IconPlus />
203
+ {/snippet}
204
+ </Avatar>
205
+
206
+ <Avatar bottomSlot={{ shape: 'circle', bgColor: '#FE2C55' }} color="amber" size="extra-large">
207
+ T
208
+ {#snippet bottomSlotText()}
209
+ <IconPlus />
210
+ {/snippet}
211
+ </Avatar>
212
+ </div>
213
+ ```
214
+
215
+ ### Additional border
216
+
217
+ ```svelte
218
+ <script lang="ts">
219
+ import { Avatar } from '@fibrae/semi-ui-svelte';
220
+ </script>
221
+
222
+ <div>
223
+ <Avatar border color="amber" style="margin-inline-end: 8px">T</Avatar>
224
+
225
+ <Avatar border color="amber" style="margin-inline-end: 8px">T</Avatar>
226
+
227
+ <Avatar border color="amber" style="margin-inline-end: 8px">T</Avatar>
228
+ </div>
229
+ ```
230
+
231
+ ### Additional Animation
232
+
233
+ Enable additional border and content animation through the `motion` field of `border` and the `contentMotion` prop.
234
+
235
+ ```svelte
236
+ <script lang="ts">
237
+ import { Avatar } from '@fibrae/semi-ui-svelte';
238
+ </script>
239
+
240
+ <div>
241
+ <Avatar border={{ motion: true }} color="amber" contentMotion style="margin-inline-end: 8px">T</Avatar>
242
+
243
+ <Avatar border={{ motion: true }} color="amber" contentMotion size="large" style="margin-inline-end: 8px">T</Avatar>
244
+
245
+ <Avatar border={{ motion: true }} color="amber" contentMotion size="extra-large" style="margin-inline-end: 8px">T</Avatar>
246
+ </div>
247
+ ```
248
+
249
+ ### AvatarGroup
250
+
251
+ You can use `AvatarGroup` component to display avatars as a group.
252
+
253
+ In Svelte, `AvatarGroup` takes the props of each avatar through `items` and the text inside an avatar through the `item` snippet (parameter `{ item, index }`); it does not accept `Avatar` children.
254
+
255
+ ```svelte
256
+ <script lang="ts">
257
+ import { AvatarGroup } from '@fibrae/semi-ui-svelte';
258
+
259
+ const items = [{ alt: 'Lisa LeBlanc', color: 'red' as const }, { alt: 'Caroline Xiao' }, { alt: 'Rafal Matin', color: 'amber' as const }, { alt: 'Zank Lance', style: 'color: #f56a00; background-color: #fde3cf' }, { alt: 'Youself Zhang', style: 'background-color: #87d068' }];
260
+
261
+ const initials = (alt = '') =>
262
+ alt
263
+ .split(' ')
264
+ .map((word) => word[0])
265
+ .join('');
266
+ </script>
267
+
268
+ <div>
269
+ <AvatarGroup {items}>
270
+ {#snippet item(context)}
271
+ {initials(context.item.alt)}
272
+ {/snippet}
273
+ </AvatarGroup>
274
+ </div>
275
+ ```
276
+
277
+ You can set the number of avatars to display with `maxCount` property.
278
+
279
+ ```svelte
280
+ <script lang="ts">
281
+ import { AvatarGroup } from '@fibrae/semi-ui-svelte';
282
+
283
+ const items = [{ alt: 'Lisa LeBlanc', color: 'red' as const }, { alt: 'Caroline Xiao' }, { alt: 'Rafal Matin', color: 'amber' as const }, { alt: 'Zank Lance', style: 'color: #f56a00; background-color: #fde3cf' }, { alt: 'Youself Zhang', style: 'background-color: #87d068' }];
284
+
285
+ const initials = (alt = '') =>
286
+ alt
287
+ .split(' ')
288
+ .map((word) => word[0])
289
+ .join('');
290
+ </script>
291
+
292
+ <div>
293
+ <AvatarGroup {items} maxCount={3}>
294
+ {#snippet item(context)}
295
+ {initials(context.item.alt)}
296
+ {/snippet}
297
+ </AvatarGroup>
298
+ </div>
299
+ ```
300
+
301
+ Customize the more label with the `more` snippet, whose parameter is `{ restNumber, restAvatars }`. `restAvatars` holds the hidden items of `items` as given; the text inside an avatar comes from the `item` snippet, not from the data.
302
+
303
+ ```svelte
304
+ <script lang="ts">
305
+ import { Avatar, AvatarGroup, Popover } from '@fibrae/semi-ui-svelte';
306
+
307
+ const items = [{ alt: 'Lisa LeBlanc', color: 'red' as const }, { alt: 'Caroline Xiao' }, { alt: 'Rafal Matin', color: 'amber' as const }, { alt: 'Zank Lance', style: 'color: #f56a00; background-color: #fde3cf' }, { alt: 'Youself Zhang', style: 'background-color: #87d068' }];
308
+
309
+ const initials = (alt = '') =>
310
+ alt
311
+ .split(' ')
312
+ .map((word) => word[0])
313
+ .join('');
314
+ </script>
315
+
316
+ <AvatarGroup {items} maxCount={3}>
317
+ {#snippet item(context)}
318
+ {initials(context.item.alt)}
319
+ {/snippet}
320
+ {#snippet more(context)}
321
+ <Popover autoAdjustOverflow={false} position="bottomRight" style="padding: 12px 8px; padding-bottom: 0">
322
+ <!-- the trigger props go on the avatar itself: a wrapper span would put a non-listitem tab stop inside the group's list -->
323
+ {#snippet child(trigger)}
324
+ <Avatar {...trigger.props}>{`+${context.restNumber}`}</Avatar>
325
+ {/snippet}
326
+ {#snippet content()}
327
+ {#each context.restAvatars as avatar (avatar.alt)}
328
+ <div style="padding-bottom: 12px">
329
+ <Avatar {...avatar} size="extra-small">{initials(avatar.alt)}</Avatar>
330
+ <span style="margin-inline-start: 8px; font-size: 14px">这是段文字描述</span>
331
+ </div>
332
+ {/each}
333
+ {/snippet}
334
+ </Popover>
335
+ {/snippet}
336
+ </AvatarGroup>
337
+ ```
338
+
339
+ You can set the coverage direction of the avatars with `overlapFrom`. It has two optional values A and B. The default value is `start`.
340
+
341
+ ```svelte
342
+ <script lang="ts">
343
+ import { AvatarGroup } from '@fibrae/semi-ui-svelte';
344
+
345
+ const items = [{ alt: 'Lisa LeBlanc', color: 'red' as const }, { alt: 'Caroline Xiao' }, { alt: 'Rafal Matin', color: 'amber' as const }, { alt: 'Zank Lance', style: 'color: #f56a00; background-color: #fde3cf' }, { alt: 'Youself Zhang', style: 'background-color: #87d068' }];
346
+
347
+ const initials = (alt = '') =>
348
+ alt
349
+ .split(' ')
350
+ .map((word) => word[0])
351
+ .join('');
352
+ </script>
353
+
354
+ <div>
355
+ <div>
356
+ <AvatarGroup {items} overlapFrom="start">
357
+ {#snippet item(context)}
358
+ {initials(context.item.alt)}
359
+ {/snippet}
360
+ </AvatarGroup>
361
+ </div>
362
+ <div>
363
+ <AvatarGroup {items} overlapFrom="end">
364
+ {#snippet item(context)}
365
+ {initials(context.item.alt)}
366
+ {/snippet}
367
+ </AvatarGroup>
368
+ </div>
369
+ </div>
370
+ ```
371
+
372
+ ## API Reference
373
+
374
+ ---
375
+
376
+ ### Avatar
377
+
378
+ **Props**
379
+
380
+ | Property | Description | Type | Default |
381
+ | - | - | - | - |
382
+ | alt | Alternative text for the avatar image or text. | `string` | - |
383
+ | border | Additional border, with optional color and animation. | `boolean \| { color?: string; motion?: boolean }` | - |
384
+ | bottomSlot | Shape, background color, text color, class and style string of the bottom badge; use the bottomSlotText snippet for its content. A `render` snippet replaces the whole badge. | `AvatarBottomSlot` | - |
385
+ | bottomSlotText | Snippet for the text or nodes inside the preset bottom badge. | `Snippet` | - |
386
+ | children | Snippet for the avatar text or custom content. | `Snippet` | - |
387
+ | color | Preset background color of the avatar. | `AvatarColor` | `"grey"` |
388
+ | contentMotion | Enables animation in the avatar content area. | `boolean` | - |
389
+ | gap | Space in pixels between the text and either side of the avatar. | `number` | `3` |
390
+ | hoverMask | Snippet for the overlay shown on hover, with styles supplied by the caller. | `Snippet` | - |
391
+ | imgAttr | Native attributes applied to the inner img element. | `HTMLImgAttributes` | - |
392
+ | onError | Called when the image fails to load. Return false to prevent the default fallback. | `(event: Event) => boolean \| void` | - |
393
+ | onMouseEnter | Called when the pointer enters the avatar. | `(event: MouseEvent) => void` | - |
394
+ | onMouseLeave | Called when the pointer leaves the avatar. | `(event: MouseEvent) => void` | - |
395
+ | shape | Avatar shape: circle or square. | `AvatarShape` | - |
396
+ | size | Avatar size, as a preset name or a valid CSS size. | `string` | - |
397
+ | src | Image source URL. | `string` | - |
398
+ | srcSet | Responsive image sources. | `string` | - |
399
+ | topSlot | Gradient, text color, class and style string of the top badge; use the topSlotText snippet for its content. A `render` snippet replaces the whole badge. | `AvatarTopSlot` | - |
400
+ | topSlotText | Snippet for the text or nodes inside the preset top badge. | `Snippet` | - |
401
+
402
+ `class`, `style`, `id` and other native attributes are applied to the avatar `span`. With `border`, `topSlot` or `bottomSlot`, `style` goes to the outer wrapper, while `class` and the other native attributes stay on the avatar `span`. A clickable avatar applies `tabindex` and `aria-*` to its single inner focus target.
403
+
404
+ ### AvatarGroup
405
+
406
+ **Props**
407
+
408
+ | Property | Description | Type | Default |
409
+ | - | - | - | - |
410
+ | item | Snippet for the content of every avatar, with the parameter `{ item, index }`; it takes precedence over the item's own `children`. | `Snippet<[AvatarGroupItemContext]>` | - |
411
+ | items | Data of the avatars in the group; each item holds the props of an Avatar, and the group's `size` and `shape` override the item's own. | `AvatarGroupItem[]` | `[]` |
412
+ | maxCount | Maximum number of visible avatars; overflow is shown as +N. | `number` | - |
413
+ | more | Snippet for a custom overflow label, with the parameter `{ restNumber, restAvatars }`: the remaining count and the hidden items. | `Snippet<[AvatarGroupMoreContext]>` | - |
414
+ | overlapFrom | Avatar overlap direction: start or end. | `AvatarGroupOverlapFrom` | `"start"` |
415
+ | shape | Shape of the avatars in the group. | `AvatarGroupShape` | `"circle"` |
416
+ | size | Size of the avatars in the group. | `string` | `"medium"` |
417
+
418
+ `class`, `style` and native attributes, including `aria-*`, are applied to the group root element, not to the avatars inside it.
419
+
420
+ ## Accessibility
421
+
422
+ - Avatars are generally not used for operations and do not need to be focused. But when the Avatar can be clicked (such as the avatar on the Semi official website), it needs to be focused and respond to the keyboard `Enter` and `Space` events.
423
+ - A clickable Avatar with an image or text has a single Tab stop, the image or the text label. Its focus order and `aria-*` attributes, including those injected by Tooltip, are applied to that element.
424
+ - When Avatar is used in combination with other components, also check the accessibility guidelines for that component.
425
+ - Avatar's `alt` attribute can be read by screen readers, when using the avatar component, please use the `alt` attribute to explain the content of the image.
426
+
427
+ ```svelte
428
+ <script lang="ts">
429
+ import { Avatar } from '@fibrae/semi-ui-svelte';
430
+
431
+ const src = '/assets/placeholder/avatar-a.svg';
432
+ </script>
433
+
434
+ <Avatar alt="A cute cat" {src} />
435
+ <Avatar alt="Jiang Pengzhi" {src} />
436
+ ```
437
+
438
+ Describe the avatar content with alternative text. Avoid empty text and redundant words such as "picture". Declare an action with `onclick`; the component supplies a Tab stop and activates the click on `Enter` and `Space`.
439
+
440
+ ## Design Tokens
441
+
442
+ The design token table of this component is on the web page: <https://semi-design-next.pages.dev/en-US/svelte/show/avatar/>
443
+
444
+ ## Changes from Semi Design
445
+
446
+ From the project release notes (written in Chinese). Your knowledge of Semi Design does not cover these.
447
+
448
+ - 破坏性:AutoComplete 删除 `dropdownClassName`、`dropdownStyle`,改用 `classNames.dropdown`、`styles.dropdown`,落在 `role="listbox"` 元素上,样式与 `maxHeight` 合并且 `styles.dropdown` 优先。
449
+ - PinCode:格子间距改为逻辑属性;ConfigProvider 的 `direction` 为 `rtl` 时左右方向键反向(ArrowLeft 移到下一格)。
450
+ - 破坏性:AutoComplete 删除 `getPopupContainer`、`zIndex`、`AutoComplete.Option` 与 `children`(改用 `Select.Option`),删除深路径 `@fibrae/semi-ui-react/auto-complete/option`、`@fibrae/semi-foundation/auto-complete/optionFoundation`;`style.width` 不再复制为下拉最小宽度。
451
+ - 破坏性(类型):AutoComplete 的 `defaultValue` 收窄为 `string | number`,`onKeyDown` 参数改为 `KeyboardEvent<HTMLDivElement>`,删除 `mouseEnterDelay`、`mouseLeaveDelay`、`tabIndex`;输入框角色改为 combobox(按 textbox 查询的测试需改为 combobox),`id` 落在输入框上。
452
+ - 破坏性(类型):TagInput 的 `onFocus`、`onBlur` 参数改为 `React.FocusEvent<HTMLDivElement>`,`onInputChange` 第二个参数改为 `React.SyntheticEvent`,`value` 为 `string[] | null`,ref 为 `TagInputHandle { focus, blur }`;`AvatarState.hoverContent` 改为 `hovered: boolean`。
453
+ - 破坏性(类型):`@fibrae/semi-foundation/components/tag-input/foundation` 删除 `any` 别名 `TagInputCursorEvent`、`TagInputKeyboardEvent`、`TagInputMouseEvent`,改为 `TagInputKeyEvent`、`TagInputFocusEvent`、`TagInputClearEvent`;`TagInputFoundation`、`TagInputAdapter` 新增按键与焦点事件的类型参数 `KE`、`FE`,`notifyKeyDown`、`notifyFocus`、`notifyBlur` 的参数随之收窄。
454
+ - TagInput:`+N` 浮层、`suffix` 中的 Popover 等内部弹层里的按下、焦点与点击不结束也不进入激活状态,`+N` 浮层里的标签可以直接关闭(四个框架一致)。
455
+ - AutoComplete:对象数据项缺 `label` 时候选行显示 `value`(四个框架一致);数据项带 `show: false` 时,高亮项与 Enter 选中项是同一个可见项。`defaultActiveFirstOption` 高亮第一个可用项,首项禁用时不再停在禁用项上(与 Select 一致,四个框架一致)。
456
+ - 破坏性(样式钩子):TagInput 悬停改由 CSS `:hover` 提供,不再加 `semi-tagInput-hover` 类;删除 `semi-tagInput-clearBtn-invisible` 与 `semi-avatar-focus`。TagInput 清除按钮与拖拽句柄改为带名称(`TagInput.clear`、`TagInput.dragSort`)的原生 button,`onFocus`、`onBlur` 以整个组件为界。
457
+ - Avatar:可点击头像的焦点目标为 `role="button"`(按 `img` 查询的测试需改为 button),不再加语言包 `Avatar.clickable` 前缀(键已删除);AvatarGroup 未声明属性落在根 div,`size`、`shape` 经 context 下发到被 Tooltip、Popover 包住的头像。PinCode:`autoFocus` 默认值由 `true` 改为 `false`,需要时显式传 `autoFocus` 或用 `PinCodeHandle.focus(0)`;`onFocus`、`onBlur` 按整组计,焦点从外部进入整个 PinCode 时触发一次 `onFocus`,格子之间移动不触发。
458
+ - Avatar:`bottomSlot` 方形标签不换行,比头像宽时向两侧超出。
459
+ - Avatar:`border.motion` 的外圈动画只放大并淡出,边框粗细不再随动画变细到 0(原来每帧触发布局与重绘);删除 Sass 变量 `$animation_width-additionalBorder-end`。
460
+ - React、Vue、Solid:服务端渲染的 Avatar 图片在 hydration 前已加载失败时,hydration 后调用 `onError` 并显示文字(原来保留破图)。
461
+ - AutoComplete:受控值回显但没有匹配项时保留已输入的文本(四个框架一致)。
462
+ - AutoComplete:下拉中有可聚焦元素(`renderItem`、`emptyContent` 里的按钮或链接)时,方向键只移动高亮,焦点不再移入下拉。
463
+ - Solid 破坏性:AvatarGroup 的 `renderMore` 签名为 `(restNumber: number, restAvatars: ((props?: AvatarProps) => JSX.Element)[]) => JSX.Element`。超出 `maxCount` 的头像在组内不创建,`restAvatars` 的每一项是渲染函数,在调用处才创建该头像(独立头像,不是列表项,不取组的 `size`、`shape`),传入的属性覆盖头像自身的属性(如 `avatar({ size: 'extra-small' })`,对应 React 的 `cloneElement`);`maxCount` 与 React 一样按子节点计数,包装元素(如 Tooltip)里的头像随包装元素整体隐藏,不单独隐藏,`maxCount` 变化或增删子节点时由后面的子节点补位。默认 `+N` 头像的名称只列被隐藏头像的 `alt`。
464
+ - Solid 破坏性(类型):Avatar 的 `topSlot.text`、`bottomSlot.text` 改为 `AvatarSlotText`(`string | number | (() => JSX.Element)`,从包入口导出),自定义内容写成函数 `text: () => <IconPlus />`,只在标记实际显示时(预设尺寸,topSlot 另需圆形)调用;`render` 仍完全替换标记。
465
+ - Svelte:Avatar 的 `class`、`style`、`id` 等属性落在头像 span,存在包装层时 `style` 落在包装层;传了 `onclick` 才成为可聚焦的 button;`hoverMask`、`topSlotText`、`bottomSlotText` 是 snippet,整块替换写 `topSlot.render`、`bottomSlot.render`,`topSlot.style`、`bottomSlot.style` 是字符串;内容是文字还是元素在挂载后判定,服务端首帧一律按文字结构输出。
466
+ - Svelte 破坏性:AvatarGroup 不接受 Avatar 子节点,改用 `items`(每项是 Avatar 的属性,类型 `AvatarGroupItem`)加 `item` snippet(参数 `{ item, index }`,提供头像内的文字),组的 `size`、`shape` 覆盖数据项自己的值;`maxCount` 截断、`+N` 与其可访问名称在服务端首帧同步算出,默认 `+N` 的名称只列被隐藏项的 `alt`。`more` snippet 参数为 `{ restNumber, restAvatars }`,`restAvatars` 是被隐藏的完整数据项。不能再用 Tooltip 等包裹组内的单个头像,需要时在 `item` snippet 里包裹内容。
467
+ - Svelte:PinCode 的 `value` 可绑定,没有 `defaultValue`;回调为 `onChange`、`onComplete`、`onFocus`、`onBlur`;`autofocus` 默认 `false`;实例方法为 `focus(index)`、`blur(index)`;`id` 落在第一格,`name`、`insetLabel`、`insetLabelId` 被丢弃。
468
+ - Svelte:头像内容里弹层中的 Avatar 不继承 AvatarGroup 的 `size`、`shape`,也不是列表项。
469
+ - Svelte:TagInput 的 `value`、`inputValue` 可绑定,没有 `defaultValue`,把它们绑成 `undefined` 会清空内部状态(表单重置);回调是 `onChange`、`onInputChange(value, event)`、`onAdd`、`onRemove(value, index)`、`onExceed`、`onInputExceed`、`onFocus`、`onBlur`、`onKeyDown`。
470
+ - Svelte:snippet 有 `prefix`、`suffix`、`insetLabel`、`clearIcon`、`tag({ value, index, onClose })`,`tag` 返回空内容就不渲染该标签,不回落默认标签;`focus()`、`blur()` 经 `bind:this` 调用,没有 `TagInputHandle` 类型;`restTagsPopoverProps` 的类型去掉了 `content`、`child`、`children`。
471
+ - Svelte:`id`、`name`、`role`、`tabindex` 与全部 `aria-*` 落在内部 `<input>`(根元素是 `role="group"`),根元素上的 `onclick` 与组件自己的点击处理组合调用。
472
+ - Svelte:AutoComplete 的 `value` 可绑定,没有 `defaultValue`;`renderItem`、`triggerRender` 改为 `item`、`trigger` snippet(`trigger` 参数不含 `componentProps`),`prefix`、`suffix`、`insetLabel`、`clearIcon`、`emptyContent` 为 snippet,`insetLabel` 只要传了 snippet 就当作有内容。
473
+ - Svelte:回调为 `onChange`、`onSearch`、`onSelect`、`onClear`、`onFocus`、`onBlur`、`onDropdownVisibleChange`;`focus()`、`blur()`、`getNativeElement()` 经 `bind:this` 调用;数据项的 `class` 接受 clsx 值,`style` 与 `styles` 的值只接受字符串;`id`、`name`、`aria-*` 落在输入框,用 `trigger` 时 `id` 落在根元素。
474
+ - Avatar:`size`、`gap` 变化后重算文字缩放。
475
+ - 破坏性(类型):Avatar 图片加载失败时 `onError` 收到 error 事件,返回 `false` 保留破图:React 为 `(event: SyntheticEvent<HTMLImageElement>) => boolean | void`,Vue、Svelte 为 `(event: Event) => boolean | void`,Solid 的事件带 `currentTarget: HTMLImageElement`。