@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,599 @@
1
+ # ConfigProvider
2
+
3
+ > Provide a unified global configuration for components.
4
+
5
+ Package: `@fibrae/semi-ui-svelte`. Web page: https://semi-design-next.pages.dev/en-US/svelte/other/config-provider/
6
+
7
+ ## Scenes to be used
8
+
9
+ Coverage configuration is divided into two scenarios
10
+
11
+ - When you need to override the public Props configuration of multiple components (such as `timezone`, `rtl`), use ConfigProvider
12
+ - When the ConfigProvider props are not enough and you want to modify a certain type of Props of a certain component globally (for example, set the `theme` of all `Button`s to `solid`, or the `position` of all `Popover`s), use semiGlobal
13
+
14
+ ## ConfigProvider
15
+
16
+ ConfigProvider is built on Svelte context, so it affects the child components in the component tree. ConfigProvider and ConfigConsumer render no element of their own (a `div` carrying `dir` is added only when the direction changes), and undeclared attributes are discarded, so they never reach the DOM.
17
+
18
+ ## Demos
19
+
20
+ ### How to import
21
+
22
+ ```svelte
23
+ <script lang="ts">
24
+ import { ConfigProvider, ConfigConsumer, useConfig } from '@fibrae/semi-ui-svelte';
25
+ </script>
26
+ ```
27
+
28
+ ### Basic Usage
29
+
30
+ By passing in the timeZone parameter, users can configure the time zone for the time components:
31
+
32
+ ```svelte
33
+ <script lang="ts">
34
+ import { ConfigProvider, DatePicker, Select, TimePicker } from '@fibrae/semi-ui-svelte';
35
+
36
+ let timeZone = $state('GMT+08:00');
37
+ const defaultTimestamp = 1581599305265;
38
+ const gmtList: string[] = [];
39
+ for (let hourOffset = -11; hourOffset <= 14; hourOffset++) {
40
+ const prefix = hourOffset >= 0 ? '+' : '-';
41
+ gmtList.push(`GMT${prefix}${String(Math.abs(hourOffset)).padStart(2, '0')}:00`);
42
+ }
43
+ // fractional offsets stay fixed all year; an IANA name follows its daylight saving time
44
+ gmtList.push('GMT-03:30', 'GMT+05:45', 'GMT+13:45', 'America/New_York');
45
+ const optionList = gmtList.map((gmt) => ({ value: gmt, label: gmt }));
46
+ </script>
47
+
48
+ <ConfigProvider {timeZone}>
49
+ <div style="width: 300px">
50
+ <h5 style="margin: 10px">Select Time Zone:</h5>
51
+ <Select aria-label="时区" onSelect={(value) => (timeZone = String(value))} {optionList} placeholder="请选择时区" showClear style="width: 300px" value={timeZone} />
52
+ <br />
53
+ <br />
54
+ <DatePicker onChange={(date, dateString) => console.log('DatePicker changed: ', date, dateString)} type="dateTime" value={defaultTimestamp} />
55
+ <br />
56
+ <br />
57
+ <TimePicker onChange={(date, dateString) => console.log('DatePicker changed: ', date, dateString)} value={defaultTimestamp} />
58
+ </div>
59
+ </ConfigProvider>
60
+ ```
61
+
62
+ ### Manually obtain values
63
+
64
+ Usually, the value of ConfigProvider is automatically obtained and consumed within the component, so you don't need to worry about it. However, in some special scenarios, you may need to manually obtain the value to perform other operations.
65
+
66
+ Use the `children` snippet of ConfigConsumer to obtain the value of ConfigProvider; its argument is the effective configuration. A child component can also call `useConfig()` during initialization, which returns the same configuration object, and it is an empty object without a ConfigProvider. The fields of the object are getters evaluated on read, so read them as `config.xxx` instead of destructuring and holding them, which would not follow changes.
67
+
68
+ ```svelte
69
+ <script lang="ts">
70
+ import { ConfigConsumer, ConfigProvider, Typography } from '@fibrae/semi-ui-svelte';
71
+ </script>
72
+
73
+ <ConfigProvider timeZone="GMT+08:00">
74
+ <ConfigConsumer>
75
+ {#snippet children(value)}
76
+ <Typography.Text ellipsis={{ showTooltip: { opts: { style: 'min-width: 1200px' } } }} style="width: 600px">
77
+ {JSON.stringify(value)}
78
+ </Typography.Text>
79
+ {/snippet}
80
+ </ConfigConsumer>
81
+ </ConfigProvider>
82
+ ```
83
+
84
+ ### Responsive breakpoints
85
+
86
+ ConfigProvider supports responsive breakpoint configuration and subscriptions to breakpoint changes.
87
+
88
+ > **Notes**
89
+ >
90
+ > - For performance reasons, `responsiveObserve` is `false` by default. When disabled, ConfigProvider will not register any `matchMedia` listeners.
91
+ > - `onBreakpoint` / `screens` are not ConfigProvider props. Please access them via `ConfigConsumer` (in Vue, `useConfig()` works too).
92
+ > - Each subscription **fires the callback once immediately** with the current breakpoint matches, so you don't need to call `window.matchMedia` yourself on mount.
93
+ > - `responsiveMap` is compared by content: an inline object whose content does not change does not re-register listeners when re-rendered.
94
+
95
+ #### Enable observing & custom breakpoints
96
+
97
+ - Use `responsiveObserve` to enable breakpoint observing (recommended only when you really need subscriptions)
98
+ - Use `responsiveMap` to customize breakpoints (falls back to default map when not provided)
99
+
100
+ ```svelte
101
+ <!-- breakpoint-subscriber.svelte -->
102
+ <script lang="ts">
103
+ import { onMount } from 'svelte';
104
+ import { Typography, useConfig } from '@fibrae/semi-ui-svelte';
105
+
106
+ const config = useConfig();
107
+ let screens = $state(config.screens);
108
+
109
+ onMount(() => config.onBreakpoint?.((next) => (screens = next)));
110
+ </script>
111
+
112
+ <Typography.Text>{JSON.stringify(screens)}</Typography.Text>
113
+ ```
114
+
115
+ ```svelte
116
+ <script lang="ts">
117
+ import { ConfigProvider } from '@fibrae/semi-ui-svelte';
118
+ import BreakpointSubscriber from './breakpoint-subscriber.svelte';
119
+
120
+ const responsiveMap = {
121
+ xs: '(max-width: 575px)',
122
+ sm: '(min-width: 576px)',
123
+ md: '(min-width: 768px)',
124
+ lg: '(min-width: 992px)',
125
+ xl: '(min-width: 1200px)',
126
+ xxl: '(min-width: 1600px)',
127
+ };
128
+ </script>
129
+
130
+ <ConfigProvider responsiveObserve {responsiveMap}>
131
+ <BreakpointSubscriber />
132
+ </ConfigProvider>
133
+ ```
134
+
135
+ #### Subscription API
136
+
137
+ `onBreakpoint` supports two overloads (both return an unsubscribe function):
138
+
139
+ - `onBreakpoint((screens) => void)`: callback receives the full screens map
140
+ - `onBreakpoint(['md', 'lg'], (screen, match) => void)`: listen to specific breakpoints only
141
+
142
+ ### RTL/LTR
143
+
144
+ Global configuration `direction` can change the text direction of components. `rtl` means right to left (similar to Hebrew or Arabic), `ltr` means left to right (similar to most languages such as English). When an explicitly passed `direction` differs from the outer one, including at the outermost level, ConfigProvider wraps its content in a `div` carrying the `dir` attribute. The RTL styles of components match `:dir(rtl)` and follow the nearest ancestor `dir` attribute; popup roots carry a `dir` from the ConfigProvider `direction`. When the page sets `dir="rtl"` itself, for example on `<html>`, components in the page look RTL, but their logic such as arrow-key direction and popup placement only reads the ConfigProvider `direction`, and popups and Table inside a ConfigProvider follow its `direction` (`ltr` by default), so set `direction="rtl"` as well.
145
+
146
+ Special components:
147
+
148
+ - Command call of Modal, Notification and Toast needs to be passed to 'direction' through prop.
149
+ - If you want to internationalize the directional icon, you need to handle it on your own. We think RTL for icon will make it difficult to understand and maintain. Semi has adapted the icons in other components.
150
+ - The tree data of Table does not support RTL ([Chrome, Safari have different behave with Firefox](https://codesandbox.io/s/table-rtl-treedata-uy7gzl?file=/src/App.jsx)), and fixed column supports RTL.
151
+
152
+ Imperative calls (`Modal.success()`, `Toast.info()`, `Notification.info()` and the like) render outside the ConfigProvider and cannot read its direction. To follow the direction, pass `direction` in the options, or use `Modal.useModal()`, `Toast.useToast()` and `Notification.useNotification()`. `Modal.useModal()` inherits the ConfigProvider at the position of the component that calls it; `useToast()` and `useNotification()` return `[api, Holder]` and inherit the ConfigProvider wherever the Holder component is rendered.
153
+
154
+ ```svelte
155
+ <script lang="ts">
156
+ import { IconCamera, IconChevronDown, IconEdit, IconList, IconSidebar, IconVigoLogo } from '@fibrae/semi-icons-svelte';
157
+ import {
158
+ Avatar,
159
+ Badge,
160
+ Breadcrumb,
161
+ Button,
162
+ ButtonGroup,
163
+ Cascader,
164
+ Checkbox,
165
+ Col,
166
+ ConfigProvider,
167
+ DatePicker,
168
+ Input,
169
+ Modal,
170
+ Nav,
171
+ Notification,
172
+ Pagination,
173
+ Popover,
174
+ Radio,
175
+ Rating,
176
+ Row,
177
+ Select,
178
+ Spin,
179
+ Steps,
180
+ Switch,
181
+ Tag,
182
+ TextArea,
183
+ TimePicker,
184
+ Timeline,
185
+ Toast,
186
+ Tooltip,
187
+ Typography,
188
+ type NavItems,
189
+ type TimelineData,
190
+ } from '@fibrae/semi-ui-svelte';
191
+
192
+ let direction = $state<'ltr' | 'rtl'>();
193
+ const flexStyle = 'display: flex; margin-block-end: 32px; flex-wrap: wrap';
194
+ const titleStyle = 'margin: 50px 0 16px 0';
195
+ const rowStyle = 'margin: 16px 10px';
196
+ const badgeStyle = 'width: 42px; height: 42px; border-radius: 4px; display: inline-block';
197
+ const tagStyle = 'margin-inline-end: 8px; margin-block-end: 8px';
198
+ const buttonStyle = tagStyle;
199
+ const opts = () => ({
200
+ title: 'Hi,semi',
201
+ content: 'Semi Design Next',
202
+ duration: 3,
203
+ direction,
204
+ });
205
+ const optionList = [
206
+ { value: 'video', label: '短视频' },
207
+ { value: 'live', label: '直播' },
208
+ { value: 'community', label: '社区', disabled: true },
209
+ { value: 'movie', label: '长视频' },
210
+ ];
211
+ const treeData = [
212
+ {
213
+ label: '浙江省',
214
+ value: 'zhejiang',
215
+ children: [
216
+ {
217
+ label: '杭州市',
218
+ value: 'hangzhou',
219
+ children: [
220
+ { label: '西湖区', value: 'xihu' },
221
+ { label: '萧山区', value: 'xiaoshan' },
222
+ { label: '临安区', value: 'linan' },
223
+ ],
224
+ },
225
+ {
226
+ label: '宁波市',
227
+ value: 'ningbo',
228
+ children: [
229
+ { label: '海曙区', value: 'haishu' },
230
+ { label: '江北区', value: 'jiangbei' },
231
+ ],
232
+ },
233
+ ],
234
+ },
235
+ ];
236
+ const navItems: NavItems = [
237
+ { itemKey: 'user', text: 'Option1' },
238
+ { itemKey: 'union', text: 'Option2' },
239
+ { itemKey: 'approve-management', text: 'Group3', items: ['3-1', '3-2'] },
240
+ ];
241
+ const navIcons = { user: IconEdit, union: IconCamera, 'approve-management': IconList };
242
+ const steps = [
243
+ { title: 'Finished', description: 'This is a description.' },
244
+ { title: 'In Progress', description: 'This is a description.' },
245
+ { title: 'Waiting', description: 'This is a description.' },
246
+ ];
247
+ const timeline: TimelineData[] = [
248
+ { type: 'ongoing', time: '2019-07-14 10:35', content: '审核中' },
249
+ { type: 'success', time: '2019-06-13 16:17', content: '发布成功' },
250
+ { type: 'error', time: '2019-05-14 18:34', content: '审核失败' },
251
+ ];
252
+ </script>
253
+
254
+ {#snippet vigo()}<IconVigoLogo />{/snippet}
255
+ {#snippet pinkVigo()}<IconVigoLogo style="color: pink" />{/snippet}
256
+
257
+ <div>
258
+ <div style="margin-block-end: 20px">
259
+ <ButtonGroup>
260
+ <Button onclick={() => (direction = 'ltr')}>LTR</Button>
261
+ <Button onclick={() => (direction = 'rtl')}>RTL</Button>
262
+ </ButtonGroup>
263
+ </div>
264
+ <ConfigProvider {direction}>
265
+ <div>
266
+ <h3 style={titleStyle}>Buttons</h3>
267
+ </div>
268
+ <div style={rowStyle}>
269
+ <Button loading style="margin-inline-end: 8px" theme="solid">加载</Button>
270
+ <Button style="margin-inline-end: 8px" theme="solid">
271
+ {#snippet icon()}
272
+ <IconSidebar />
273
+ {/snippet}
274
+ 收起
275
+ </Button>
276
+ <Button iconPosition="right" style="margin-inline-end: 8px" theme="solid">
277
+ {#snippet icon()}
278
+ <IconChevronDown />
279
+ {/snippet}
280
+ 展开选项
281
+ </Button>
282
+ <br />
283
+ <br />
284
+ <ButtonGroup>
285
+ <Button>拷贝</Button>
286
+ <Button>查询</Button>
287
+ <Button>剪切</Button>
288
+ </ButtonGroup>
289
+ </div>
290
+ <div>
291
+ <h3 style={titleStyle}>Input</h3>
292
+ </div>
293
+ <Row gutter={16} style={rowStyle}>
294
+ <Col span={12}>
295
+ <Input aria-label="输入框" placeholder="输入框" />
296
+ <br />
297
+ <br />
298
+ <Input aria-label="禁用的输入框" disabled placeholder="输入框" />
299
+ <br />
300
+ <br />
301
+ <Input aria-label="带前缀的输入框" showClear>
302
+ {#snippet prefix()}Prefix{/snippet}
303
+ </Input>
304
+ <br />
305
+ <br />
306
+ <Input aria-label="带后缀的输入框" showClear>
307
+ {#snippet suffix()}
308
+ <Typography.Text strong style="margin: 0 8px" type="secondary">Suffix</Typography.Text>
309
+ {/snippet}
310
+ </Input>
311
+ <br />
312
+ <br />
313
+ <TextArea aria-label="文本框" maxCount={100} placeholder="文本框" />
314
+ <br />
315
+ <br />
316
+ <div style={flexStyle}>
317
+ <Switch aria-label="已开启的开关" checked style="margin-inline-end: 8px" />
318
+ <Switch aria-label="已关闭的开关" style="margin-inline-end: 8px" />
319
+ <Switch aria-label="禁用的开关" checked disabled style="margin-inline-end: 8px" />
320
+ </div>
321
+ <div style={flexStyle}>
322
+ <Checkbox checked style="margin-inline-end: 8px">多选框</Checkbox>
323
+ <Checkbox checked disabled style="margin-inline-end: 8px">禁用的多选框</Checkbox>
324
+ <Checkbox disabled style="margin-inline-end: 8px">禁用的多选框</Checkbox>
325
+ </div>
326
+ <div style="{flexStyle}; margin-block-end: 0">
327
+ <Radio checked style="margin-inline-end: 8px">单选框</Radio>
328
+ <Radio checked disabled style="margin-inline-end: 8px">禁用的单选框</Radio>
329
+ <Radio disabled style="margin-inline-end: 8px">禁用的单选框</Radio>
330
+ </div>
331
+ </Col>
332
+ <Col span={12}>
333
+ <DatePicker onChange={(_date, dateString) => console.log(dateString)} style="width: 100%" />
334
+ <br />
335
+ <br />
336
+ <TimePicker style="width: 100%" />
337
+ <br />
338
+ <br />
339
+ <Select aria-label="选择器-单选" {optionList} placeholder="选择器-单选" style="width: 100%" />
340
+ <br />
341
+ <br />
342
+ <Select aria-label="选择器-禁用" disabled {optionList} placeholder="选择器-禁用" style="width: 100%" />
343
+ <br />
344
+ <br />
345
+ <Select aria-label="选择器-多选" multiple {optionList} placeholder="选择器-多选" style="width: 100%" />
346
+ <br />
347
+ <br />
348
+ <Cascader placeholder="级联选择器" style="width: 100%" {treeData} />
349
+ </Col>
350
+ </Row>
351
+ <div>
352
+ <h3 style={titleStyle}>Navigation</h3>
353
+ </div>
354
+ <div style={rowStyle}>
355
+ <Breadcrumb routes={['Semi-ui', 'Breadcrumb', 'Default']} />
356
+ <Nav items={navItems} mode="horizontal">
357
+ {#snippet icon({ item, size })}
358
+ {@const Icon = navIcons[item.itemKey as keyof typeof navIcons]}
359
+ {#if Icon}
360
+ <Icon {size} />
361
+ {/if}
362
+ {/snippet}
363
+ </Nav>
364
+ <br />
365
+ <br />
366
+ <Pagination showSizeChanger total={80} />
367
+ <br />
368
+ <Steps current={1} dataSource={steps} />
369
+ <br />
370
+ <Steps current={1} dataSource={steps} status="error" />
371
+ </div>
372
+ <div>
373
+ <h3 style={titleStyle}>Display</h3>
374
+ </div>
375
+ <div style={rowStyle}>
376
+ <div style="display: flex">
377
+ <div style="padding: 8px">
378
+ <Badge count={5} theme="solid">
379
+ <Avatar color="blue" shape="square" style={badgeStyle}>XZ</Avatar>
380
+ </Badge>
381
+ </div>
382
+ <div style="padding: 8px">
383
+ <Badge count={5} theme="light">
384
+ <Avatar color="cyan" shape="square" style={badgeStyle}>YB</Avatar>
385
+ </Badge>
386
+ </div>
387
+ <div style="padding: 8px">
388
+ <Badge count={5} theme="inverted">
389
+ <Avatar color="indigo" shape="square" style={badgeStyle}>LX</Avatar>
390
+ </Badge>
391
+ </div>
392
+ <div style="padding: 8px">
393
+ <Badge dot theme="solid">
394
+ <Avatar color="light-blue" shape="square" style={badgeStyle}>YZ</Avatar>
395
+ </Badge>
396
+ </div>
397
+ <div style="padding: 8px">
398
+ <Badge dot theme="light">
399
+ <Avatar color="teal" shape="square" style={badgeStyle}>HW</Avatar>
400
+ </Badge>
401
+ </div>
402
+ <div style="padding: 8px; border-radius: 4px; background-color: var(--semi-color-fill-0)">
403
+ <Badge dot theme="inverted">
404
+ <Avatar color="green" shape="square" style={badgeStyle}>XM</Avatar>
405
+ </Badge>
406
+ </div>
407
+ </div>
408
+ <br />
409
+ <div>
410
+ <Tag color="grey" style={tagStyle}>grey tag</Tag>
411
+ <Tag color="blue" style={tagStyle}>blue tag</Tag>
412
+ <Tag color="blue" style={tagStyle} type="ghost">ghost tag</Tag>
413
+ <Tag color="blue" style={tagStyle} type="solid">solid tag</Tag>
414
+ <Tag color="red" style={tagStyle}>red tag</Tag>
415
+ <Tag color="green" style={tagStyle}>green tag</Tag>
416
+ <Tag color="orange" style={tagStyle}>orange tag</Tag>
417
+ <Tag color="teal" style={tagStyle}>teal tag</Tag>
418
+ <Tag color="violet" style={tagStyle}>violet tag</Tag>
419
+ <Tag color="white" style={tagStyle}>white tag</Tag>
420
+ </div>
421
+ <br />
422
+ <div style="display: flex; align-items: center">
423
+ <Popover style="padding: 8px">
424
+ {#snippet content()}hi semi-design{/snippet}
425
+ <Tag style="margin-inline-end: 8px">I am Popover</Tag>
426
+ </Popover>
427
+ <Tooltip>
428
+ {#snippet content()}hi semi-design{/snippet}
429
+ <Tag style="margin-inline-end: 8px">I am Tooltip</Tag>
430
+ </Tooltip>
431
+ <Rating size="small" style="margin-inline-end: 8px" value={3} />
432
+ </div>
433
+ <br />
434
+ <Timeline dataSource={timeline} />
435
+ </div>
436
+ <div>
437
+ <h3 style={titleStyle}>Feedback</h3>
438
+ </div>
439
+ <div style={rowStyle}>
440
+ <Button style={buttonStyle} type="primary" onclick={() => Notification.success(opts())}>成功信息的通知</Button>
441
+ <Button style={buttonStyle} onclick={() => Notification.info(opts())}>提示信息的通知</Button>
442
+ <Button style={buttonStyle} type="warning" onclick={() => Notification.warning(opts())}>警告信息的通知</Button>
443
+ <Button style={buttonStyle} type="danger" onclick={() => Notification.error(opts())}>失败信息的通知</Button>
444
+ <Button aria-label="Vigo 图标通知" style={buttonStyle} onclick={() => Notification.info({ ...opts(), icon: vigo })}>
445
+ {#snippet icon()}
446
+ <IconVigoLogo />
447
+ {/snippet}
448
+ </Button>
449
+ <Button aria-label="粉色 Vigo 图标通知" style={buttonStyle} onclick={() => Notification.info({ ...opts(), icon: pinkVigo })}>
450
+ {#snippet icon()}
451
+ <IconVigoLogo />
452
+ {/snippet}
453
+ </Button>
454
+ <br />
455
+ <Button style={buttonStyle} type="primary" onclick={() => Modal.success(opts())}>成功信息的弹窗</Button>
456
+ <Button style={buttonStyle} onclick={() => Modal.info(opts())}>提示信息的弹窗</Button>
457
+ <Button style={buttonStyle} type="warning" onclick={() => Modal.warning(opts())}>警告信息的弹窗</Button>
458
+ <Button style={buttonStyle} type="danger" onclick={() => Modal.error(opts())}>失败信息的弹窗</Button>
459
+ <br />
460
+ <Button style={buttonStyle} type="primary" onclick={() => Toast.success(opts())}>成功信息的提示</Button>
461
+ <Button style={buttonStyle} onclick={() => Toast.info(opts())}>提示信息的提示</Button>
462
+ <Button style={buttonStyle} type="warning" onclick={() => Toast.warning(opts())}>警告信息的提示</Button>
463
+ <Button style={buttonStyle} type="danger" onclick={() => Toast.error(opts())}>失败信息的提示</Button>
464
+ <br />
465
+ <br />
466
+ <Spin>
467
+ {#snippet tip()}I am loading...{/snippet}
468
+ <div style="background-color: var(--semi-color-primary-light-default); border: 1px solid var(--semi-color-primary); border-radius: 4px; padding: 16px 10px">
469
+ <p>Here are some texts.</p>
470
+ <p>And more texts on the way.</p>
471
+ </div>
472
+ </Spin>
473
+ </div>
474
+ </ConfigProvider>
475
+ </div>
476
+ ```
477
+
478
+ ### Nesting
479
+
480
+ `ConfigProvider` can be nested. The inner one overrides only the props it is given; props it does not pass (`direction`, `locale`, `dateFnsLocale`, `timeZone`, `getPopupContainer`, `responsiveObserve`, `responsiveMap`) are inherited from the outer one. A prop set to `undefined` counts as not passed; `locale={null}` is explicit, so it clears the outer `locale` and leaves it to the `LocaleProvider` inside, or the default language.
481
+
482
+ An inner `direction="ltr"` switches a subtree inside an `rtl` ConfigProvider back to left to right, for both the logic and the styles of its components.
483
+
484
+ ```svelte
485
+ <script lang="ts">
486
+ import { ConfigConsumer, ConfigProvider } from '@fibrae/semi-ui-svelte';
487
+ import { en_US } from '@fibrae/semi-ui-svelte/locale';
488
+ </script>
489
+
490
+ {#snippet show(title: string)}
491
+ <ConfigConsumer>
492
+ {#snippet children(config)}
493
+ <div style="margin: 8px">{title}:locale = {config.locale?.code ?? '未设置'},timeZone = {String(config.timeZone)},direction = {config.direction}</div>
494
+ {/snippet}
495
+ </ConfigConsumer>
496
+ {/snippet}
497
+
498
+ <ConfigProvider direction="ltr" locale={en_US} timeZone="Asia/Tokyo">
499
+ {@render show('外层')}
500
+ <ConfigProvider timeZone={8}>
501
+ {@render show('内层只传 timeZone,其余继承外层')}
502
+ </ConfigProvider>
503
+ </ConfigProvider>
504
+ ```
505
+
506
+ ## API Reference
507
+
508
+ ### ConfigProvider
509
+
510
+ **Props**
511
+
512
+ | Property | Description | Type | Default |
513
+ | - | - | - | - |
514
+ | children | Content affected by the configuration. When an explicitly passed direction differs from the outer one, including at the outermost level, the content is wrapped in a div carrying the dir attribute. | `Snippet` | - |
515
+ | dateFnsLocale | date-fns locale that DatePicker, TimePicker and Calendar use to format and parse dates. Inherited from the outer ConfigProvider when omitted; without one, the built-in zh-CN or en-US is picked by the current locale's code, and other languages fall back to enUS. For other languages, import the locale from date-fns/locale and pass it. | `DateFnsLocale` | - |
516
+ | direction | Text direction: ltr or rtl. Inherited from the outer ConfigProvider when omitted, and ltr at the outermost level. | `'ltr' \| 'rtl'` | - |
517
+ | getPopupContainer | Function returning the popup container. It only affects Modal, SideSheet and ImagePreview, which still render through a Portal; the container needs position: relative. Inherited from the outer ConfigProvider when omitted, and document.body at the outermost level. | `() => HTMLElement` | - |
518
+ | locale | Locale configuration, which takes precedence over LocaleProvider. Inherited from the outer ConfigProvider when omitted; when no ConfigProvider sets it, LocaleProvider decides, and zh\_CN is used without either. Pass null to clear the outer locale. Takes the built-in zh\_CN or en\_US, or a custom pack with at least code, whose missing text and currency fall back to en\_US. | `LocaleInput \| null` | - |
519
+ | responsiveMap | Custom responsive breakpoints: keys are xs, sm, md, lg, xl and xxl, values are media query strings. Compared by content, so an inline object does not re-register listeners. Inherited from the outer ConfigProvider when omitted, and defaultResponsiveMap at the outermost level. | `ResponsiveMap` | - |
520
+ | responsiveObserve | Whether to observe responsive breakpoints. When off, no matchMedia listener is registered; when on, listeners are registered on the first subscription and removed when none remain. Inherited from the outer ConfigProvider when omitted, and false at the outermost level. | `boolean` | - |
521
+ | timeZone | Time zone for time components: a number (hour offset from UTC), a GMT±HH:MM string or an IANA identifier. Numbers and GMT strings are fixed offsets all year. Inherited from the outer ConfigProvider when omitted. | `string \| number` | - |
522
+
523
+ `defaultResponsiveMap` is the default breakpoint map, a named export of `@fibrae/semi-ui-svelte`. `locale` works like the `locale` parameter of `LocaleProvider`, see its [usage](../other/locale.md). ConfigProvider does not accept `class`, `style` or native attributes, and they do not land on the DOM.
524
+
525
+ ### ConfigConsumer
526
+
527
+ **Props**
528
+
529
+ | Property | Description | Type | Default |
530
+ | - | - | - | - |
531
+ | children | Snippet receiving the effective configuration (ContextValue). Inside a ConfigProvider it also holds screens and onBreakpoint; without a ConfigProvider it is an empty object. | `Snippet<[config: ContextValue]>` | - |
532
+
533
+ ConfigConsumer renders no element either, so undeclared attributes are discarded.
534
+
535
+ ### useConfig
536
+
537
+ `useConfig(): ContextValue` returns the effective configuration object, an empty object without a ConfigProvider; call it during component initialization. `ContextValue` holds `direction`, `timeZone`, `locale`, `dateFnsLocale`, `getPopupContainer`, `responsiveObserve` and `responsiveMap` from the table above, plus the read-only `screens` (which breakpoints match) and `onBreakpoint` (the subscribe function, see "Subscription API" above). The fields are getters, which return the current value when read.
538
+
539
+ ### Time Zone Identifier
540
+
541
+ - Numbers, such as `1`,`-9.5`, represent the time offset from UTC, the unit is hour, and it can be negative or decimal;
542
+ - A string, such as `"GMT-09:30"`,`"GMT+08:00"`, which is a characterization offset string starting with `"GMT"`, or [IANA](https://time.is/time_zones), such as `"Asia/Shanghai"`,`"America/Los_Angeles"`, etc.
543
+
544
+ A number or a string like `GMT-09:30` is a fixed offset all year round and never shifts for daylight saving time. For example, `-3.5` and `GMT-03:30` are UTC-03:30 in every season, and the time zone name (`z`) in a format shows `GMT-03:30`.
545
+
546
+ To follow the daylight saving time of a region, use an IANA identifier. Here you can check the [IANA list](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones), and whether the time zone has daylight saving time.
547
+
548
+ ### FAQ
549
+
550
+ - The ConfigProvider does not provide the function of global custom prefix classname. How to achieve similar requirements (for example, Semi is used in the SDK, and it is expected that the packaged dom style does not have the .semi-xx prefix, so as not to be affected by the host's global CSS)?
551
+ - Since prefixCls needs to be consumed by the js/css of the component layer at the same time, Semi put this switch in the configuration item of webpack plugin, rather than as a configuration item of ConfigProvider.
552
+ - If you use webpack, please configure it in the parameters of `SemiWebpackPlugin`
553
+
554
+ ```diff
555
+ # webpack config example: webpack.config.js
556
+ const SemiWebpackPlugin = require('@fibrae/semi-webpack-plugin').default;
557
+ module.exports = {
558
+ + plugins: [new SemiWebpackPlugin({ prefixCls: 'imes' })],
559
+ }
560
+ ```
561
+
562
+ ## semiGlobal
563
+
564
+ You can override the default Props of global components.
565
+
566
+ In `semiGlobal.config.overrideDefaultProps` you can configure the component default Props. A component reads the global configuration once when it is created, so changes made afterwards do not update components that already exist. Set it before the application mounts, at the entrance of the entire site. A prop whose value is `undefined` counts as not passed and takes the default. To give one app its own configuration, create a `SemiGlobal` instance and pass it with `mount(App, { context: new Map([[semiGlobalKey, semi]]) })`; `SemiGlobal` and `semiGlobalKey` are also exported from `@fibrae/semi-ui-svelte`.
567
+
568
+ Properties that are unique to each instance, such as `id`, `insetLabelId`, `wrapperId`, `addonId` and `extraId`, cannot be set through the global defaults: the types have no such keys, and they are ignored at runtime.
569
+
570
+ > **Notes**
571
+ >
572
+ > semiGlobal is a singleton mode that affects the entire site. If you only want to cover certain components in certain places, it is recommended not to use semiGlobal. Instead, encapsulate the corresponding components that need to be covered and pass in the modified default props.
573
+
574
+ For example, the configuration below sets all Buttons to warning by default, and filter of Select to enabled by default, etc.
575
+
576
+ ```ts
577
+ import { semiGlobal } from '@fibrae/semi-ui-svelte';
578
+
579
+ semiGlobal.config.overrideDefaultProps = {
580
+ Button: {
581
+ type: 'warning',
582
+ },
583
+ Select: {
584
+ filter: true,
585
+ },
586
+ Tooltip: {
587
+ trigger: 'click',
588
+ },
589
+ };
590
+ ```
591
+
592
+ ## Changes from Semi Design
593
+
594
+ From the project release notes (written in Chinese). Your knowledge of Semi Design does not cover these.
595
+
596
+ - 新增 `dateFnsLocale`:DatePicker、TimePicker、Calendar 使用的 date-fns 语言,未传时继承外层,再按语言包的 `code` 取内置语言。
597
+ - `getPopupContainer` 只作用于 Modal、SideSheet、ImagePreview。嵌套时内层只覆盖显式传入的属性,其余继承外层;`locale={null}` 清除继承的语言,不传 `locale` 时不再注入 zh_CN。
598
+ - 数字和 `GMT±HH:MM` 形式的 `timeZone` 按固定 UTC 偏移换算,不再映射为 IANA 时区,格式 token `z` 显示偏移;删除 `IANAOffsetMap` 导出,需要夏令时请传 IANA 名称。
599
+ - Svelte:`useConfig()` 返回随配置更新的对象,按属性读取保持响应,解构只得到当前值;`ConfigConsumer` 的内容写在 `children` snippet 中,参数是配置对象。