@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.
- package/README.md +8 -4
- package/README.zh-CN.md +8 -4
- package/dist/components/anchor/interface.d.ts +14 -0
- package/dist/components/audio-player/interface.d.ts +5 -0
- package/dist/components/auto-complete/interface.d.ts +29 -0
- package/dist/components/avatar/interface.d.ts +24 -0
- package/dist/components/backtop/interface.d.ts +2 -0
- package/dist/components/badge/interface.d.ts +7 -0
- package/dist/components/banner/interface.d.ts +7 -0
- package/dist/components/breadcrumb/interface.d.ts +10 -0
- package/dist/components/button/interface.d.ts +18 -0
- package/dist/components/calendar/interface.d.ts +16 -0
- package/dist/components/card/interface.d.ts +18 -0
- package/dist/components/carousel/interface.d.ts +16 -0
- package/dist/components/cascader/interface.d.ts +57 -0
- package/dist/components/checkbox/interface.d.ts +19 -0
- package/dist/components/code-highlight/interface.d.ts +3 -0
- package/dist/components/collapse/interface.d.ts +16 -0
- package/dist/components/collapsible/interface.d.ts +10 -0
- package/dist/components/color-picker/interface.d.ts +10 -0
- package/dist/components/config-provider/interface.d.ts +7 -0
- package/dist/components/cropper/interface.d.ts +11 -0
- package/dist/components/date-picker/interface.d.ts +47 -0
- package/dist/components/descriptions/interface.d.ts +6 -0
- package/dist/components/divider/interface.d.ts +4 -0
- package/dist/components/dropdown/interface.d.ts +8 -0
- package/dist/components/empty/interface.d.ts +7 -0
- package/dist/components/feedback/interface.d.ts +16 -0
- package/dist/components/float-button/interface.d.ts +14 -0
- package/dist/components/form/interface.d.ts +47 -0
- package/dist/components/grid/interface.d.ts +13 -0
- package/dist/components/highlight/interface.d.ts +7 -0
- package/dist/components/hot-keys/interface.d.ts +3 -0
- package/dist/components/image/interface.d.ts +59 -0
- package/dist/components/input/interface.d.ts +67 -0
- package/dist/components/input-number/interface.d.ts +24 -0
- package/dist/components/json-viewer/interface.d.ts +7 -0
- package/dist/components/layout/interface.d.ts +3 -0
- package/dist/components/list/interface.d.ts +18 -0
- package/dist/components/locale/interface.d.ts +4 -0
- package/dist/components/lottie/interface.d.ts +2 -0
- package/dist/components/markdown-render/interface.d.ts +5 -0
- package/dist/components/modal/interface.d.ts +29 -0
- package/dist/components/navigation/interface.d.ts +47 -0
- package/dist/components/overflow-list/interface.d.ts +11 -0
- package/dist/components/pagination/interface.d.ts +12 -0
- package/dist/components/pincode/interface.d.ts +8 -0
- package/dist/components/popconfirm/interface.d.ts +12 -0
- package/dist/components/popover/interface.d.ts +30 -0
- package/dist/components/progress/interface.d.ts +13 -0
- package/dist/components/radio/interface.d.ts +22 -0
- package/dist/components/rating/interface.d.ts +12 -0
- package/dist/components/resizable/interface.d.ts +30 -0
- package/dist/components/scroll-list/interface.d.ts +6 -0
- package/dist/components/select/interface.d.ts +63 -0
- package/dist/components/side-sheet/interface.d.ts +19 -0
- package/dist/components/skeleton/interface.d.ts +7 -0
- package/dist/components/slider/interface.d.ts +23 -0
- package/dist/components/space/interface.d.ts +4 -0
- package/dist/components/spin/interface.d.ts +7 -0
- package/dist/components/steps/interface.d.ts +9 -0
- package/dist/components/switch/interface.d.ts +7 -0
- package/dist/components/table/interface.d.ts +48 -0
- package/dist/components/tabs/interface.d.ts +29 -0
- package/dist/components/tag/interface.d.ts +22 -0
- package/dist/components/tag-input/interface.d.ts +29 -0
- package/dist/components/time-picker/interface.d.ts +31 -0
- package/dist/components/timeline/interface.d.ts +5 -0
- package/dist/components/tooltip/interface.d.ts +20 -0
- package/dist/components/transfer/interface.d.ts +18 -0
- package/dist/components/tree/interface.d.ts +45 -0
- package/dist/components/tree-select/interface.d.ts +55 -0
- package/dist/components/typography/interface.d.ts +33 -0
- package/dist/components/upload/interface.d.ts +64 -0
- package/dist/components/user-guide/interface.d.ts +15 -0
- package/dist/components/video-player/interface.d.ts +22 -0
- package/docs/advanced/dark-mode.md +288 -0
- package/docs/basic/button.md +605 -0
- package/docs/basic/divider.md +103 -0
- package/docs/basic/float-button.md +246 -0
- package/docs/basic/grid.md +427 -0
- package/docs/basic/layout.md +459 -0
- package/docs/basic/resizable.md +584 -0
- package/docs/basic/space.md +163 -0
- package/docs/basic/tokens.md +425 -0
- package/docs/basic/typography.md +615 -0
- package/docs/changes-from-semi.md +105 -0
- package/docs/ecosystem/tailwind.md +210 -0
- package/docs/experience/accessibility.md +82 -0
- package/docs/experience/content-guidelines.md +819 -0
- package/docs/experience/internationalization.md +7 -0
- package/docs/feedback/banner.md +198 -0
- package/docs/feedback/feedback.md +294 -0
- package/docs/feedback/notification.md +401 -0
- package/docs/feedback/popconfirm.md +243 -0
- package/docs/feedback/progress.md +389 -0
- package/docs/feedback/skeleton.md +388 -0
- package/docs/feedback/spin.md +172 -0
- package/docs/feedback/toast.md +393 -0
- package/docs/input/auto-complete.md +399 -0
- package/docs/input/cascader.md +1558 -0
- package/docs/input/checkbox.md +408 -0
- package/docs/input/color-picker.md +175 -0
- package/docs/input/date-picker.md +942 -0
- package/docs/input/form.md +2550 -0
- package/docs/input/input-number.md +451 -0
- package/docs/input/input.md +640 -0
- package/docs/input/pincode.md +191 -0
- package/docs/input/radio.md +337 -0
- package/docs/input/rating.md +214 -0
- package/docs/input/select.md +1230 -0
- package/docs/input/slider.md +347 -0
- package/docs/input/switch.md +206 -0
- package/docs/input/tag-input.md +465 -0
- package/docs/input/time-picker.md +358 -0
- package/docs/input/transfer.md +1061 -0
- package/docs/input/tree-select.md +1300 -0
- package/docs/input/upload.md +1811 -0
- package/docs/llms.txt +147 -0
- package/docs/navigation/anchor.md +377 -0
- package/docs/navigation/backtop.md +100 -0
- package/docs/navigation/breadcrumb.md +284 -0
- package/docs/navigation/navigation.md +851 -0
- package/docs/navigation/pagination.md +217 -0
- package/docs/navigation/steps.md +315 -0
- package/docs/navigation/tabs.md +754 -0
- package/docs/navigation/tree.md +1956 -0
- package/docs/other/config-provider.md +599 -0
- package/docs/other/locale.md +353 -0
- package/docs/plus/audio-player.md +155 -0
- package/docs/plus/code-highlight.md +150 -0
- package/docs/plus/drag-move.md +214 -0
- package/docs/plus/hot-keys.md +174 -0
- package/docs/plus/json-viewer.md +392 -0
- package/docs/plus/lottie.md +176 -0
- package/docs/plus/markdown-render.md +240 -0
- package/docs/plus/video-player.md +325 -0
- package/docs/show/avatar.md +475 -0
- package/docs/show/badge.md +276 -0
- package/docs/show/calendar.md +352 -0
- package/docs/show/card.md +485 -0
- package/docs/show/carousel.md +592 -0
- package/docs/show/collapse.md +289 -0
- package/docs/show/collapsible.md +216 -0
- package/docs/show/cropper.md +285 -0
- package/docs/show/descriptions.md +325 -0
- package/docs/show/dropdown.md +466 -0
- package/docs/show/empty.md +225 -0
- package/docs/show/highlight.md +144 -0
- package/docs/show/image.md +433 -0
- package/docs/show/list.md +927 -0
- package/docs/show/modal.md +517 -0
- package/docs/show/overflow-list.md +272 -0
- package/docs/show/popover.md +534 -0
- package/docs/show/scroll-list.md +156 -0
- package/docs/show/side-sheet.md +274 -0
- package/docs/show/table.md +5437 -0
- package/docs/show/tag.md +428 -0
- package/docs/show/timeline.md +277 -0
- package/docs/show/tooltip.md +442 -0
- package/docs/show/user-guide.md +419 -0
- package/docs/start/getting-started.md +234 -0
- package/docs/start/introduction.md +57 -0
- package/docs/start/overview.md +21 -0
- package/package.json +5 -4
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
# Pagination
|
|
2
|
+
|
|
3
|
+
> The Pager helps users navigate between multiple pages
|
|
4
|
+
|
|
5
|
+
Package: `@fibrae/semi-ui-svelte`. Web page: https://semi-design-next.pages.dev/en-US/svelte/navigation/pagination/
|
|
6
|
+
|
|
7
|
+
## Demos
|
|
8
|
+
|
|
9
|
+
### How to import
|
|
10
|
+
|
|
11
|
+
```svelte
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
import { Pagination } from '@fibrae/semi-ui-svelte';
|
|
14
|
+
</script>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Basic Usage
|
|
18
|
+
|
|
19
|
+
Set the total number via `total`, set capacity per page via `pageSize`.
|
|
20
|
+
|
|
21
|
+
```svelte
|
|
22
|
+
<script lang="ts">
|
|
23
|
+
import { Pagination } from '@fibrae/semi-ui-svelte';
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<div>
|
|
27
|
+
<Pagination style="margin-block-end: 12px" total={30} />
|
|
28
|
+
<Pagination style="margin-block-end: 12px" total={80} />
|
|
29
|
+
<Pagination style="margin-block-end: 12px" total={200} />
|
|
30
|
+
<Pagination pageSize={30} style="margin-block-end: 12px" total={80} />
|
|
31
|
+
</div>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### disabled
|
|
35
|
+
|
|
36
|
+
Disabled via the `disabled` setting
|
|
37
|
+
|
|
38
|
+
```svelte
|
|
39
|
+
<script lang="ts">
|
|
40
|
+
import { Pagination } from '@fibrae/semi-ui-svelte';
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<Pagination disabled style="margin-block-end: 12px" total={30} />
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Show total page number
|
|
47
|
+
|
|
48
|
+
Use the showTotal property to control whether the total number of pages is shown.
|
|
49
|
+
|
|
50
|
+
```svelte
|
|
51
|
+
<script lang="ts">
|
|
52
|
+
import { Pagination } from '@fibrae/semi-ui-svelte';
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<div>
|
|
56
|
+
<Pagination showTotal style="margin-block-end: 12px" total={80} />
|
|
57
|
+
<Pagination showTotal style="margin-block-end: 12px" total={200} />
|
|
58
|
+
</div>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Specify current page number
|
|
62
|
+
|
|
63
|
+
There is no `defaultCurrentPage`: pass `currentPage={3}` as the initial page. After a click the page becomes a local value of the component.
|
|
64
|
+
|
|
65
|
+
```svelte
|
|
66
|
+
<script lang="ts">
|
|
67
|
+
import { Pagination } from '@fibrae/semi-ui-svelte';
|
|
68
|
+
</script>
|
|
69
|
+
|
|
70
|
+
<div>
|
|
71
|
+
<Pagination currentPage={3} showTotal total={80} />
|
|
72
|
+
</div>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Capacity switching per page
|
|
76
|
+
|
|
77
|
+
By setting `showSizeChanger` for `true`, allowing quick switching of capacity per page via the Select component
|
|
78
|
+
|
|
79
|
+
```svelte
|
|
80
|
+
<script lang="ts">
|
|
81
|
+
import { Pagination } from '@fibrae/semi-ui-svelte';
|
|
82
|
+
</script>
|
|
83
|
+
|
|
84
|
+
<div>
|
|
85
|
+
<Pagination showSizeChanger style="margin-block-end: 12px" total={80} />
|
|
86
|
+
<Pagination showSizeChanger total={300} />
|
|
87
|
+
</div>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Jump to a page quickly
|
|
91
|
+
|
|
92
|
+
By setting `showQuickJumper` to `true`, you can enter the page number through the Input control to quickly jump\
|
|
93
|
+
When Input loses focus, if there is a valid number in Input, it will jump directly. You can also enter the page number you want to jump to when the Input is focused, and then hit enter to jump directly\
|
|
94
|
+
If you enter a page number greater than the total page number of the pager, we will automatically jump to the last page for you
|
|
95
|
+
|
|
96
|
+
```svelte
|
|
97
|
+
<script lang="ts">
|
|
98
|
+
import { Pagination } from '@fibrae/semi-ui-svelte';
|
|
99
|
+
</script>
|
|
100
|
+
|
|
101
|
+
<div>
|
|
102
|
+
<Pagination showQuickJumper style="margin-block-end: 12px" total={80} />
|
|
103
|
+
<Pagination showQuickJumper total={300} />
|
|
104
|
+
</div>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Page number controlled
|
|
108
|
+
|
|
109
|
+
Bind the page with `bind:currentPage`; `bind:currentPage={get, set}` makes the pagination fully controlled, and the setter decides whether to accept a new page. When `currentPage` is omitted the component manages the page itself.
|
|
110
|
+
|
|
111
|
+
```svelte
|
|
112
|
+
<script lang="ts">
|
|
113
|
+
import { Pagination } from '@fibrae/semi-ui-svelte';
|
|
114
|
+
|
|
115
|
+
let page = $state(3);
|
|
116
|
+
</script>
|
|
117
|
+
|
|
118
|
+
<Pagination bind:currentPage={page} total={200} />
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Preset capacity per page
|
|
122
|
+
|
|
123
|
+
Specify an optional value for switching the capacity per page by using the `pageSizeOpts` array
|
|
124
|
+
|
|
125
|
+
```svelte
|
|
126
|
+
<script lang="ts">
|
|
127
|
+
import { Pagination } from '@fibrae/semi-ui-svelte';
|
|
128
|
+
</script>
|
|
129
|
+
|
|
130
|
+
<div>
|
|
131
|
+
<Pagination pageSizeOpts={[50, 80, 90, 200]} showSizeChanger style="margin-block-end: 12px" total={300} />
|
|
132
|
+
<Pagination pageSizeOpts={[10, 20, 50, 200]} showSizeChanger total={300} />
|
|
133
|
+
</div>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Mini version
|
|
137
|
+
|
|
138
|
+
Show mini pagination via size properties.
|
|
139
|
+
|
|
140
|
+
```svelte
|
|
141
|
+
<script lang="ts">
|
|
142
|
+
import { Pagination } from '@fibrae/semi-ui-svelte';
|
|
143
|
+
</script>
|
|
144
|
+
|
|
145
|
+
<Pagination size="small" total={90} />
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Turn on `hoverShowPageSelect` to open the page list by hovering the page text and switch pages quickly
|
|
149
|
+
|
|
150
|
+
```svelte
|
|
151
|
+
<script lang="ts">
|
|
152
|
+
import { Pagination } from '@fibrae/semi-ui-svelte';
|
|
153
|
+
</script>
|
|
154
|
+
|
|
155
|
+
<Pagination hoverShowPageSelect size="small" total={90} />
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## API reference
|
|
159
|
+
|
|
160
|
+
**Props**
|
|
161
|
+
|
|
162
|
+
| Property | Description | Type | Default |
|
|
163
|
+
| - | - | - | - |
|
|
164
|
+
| currentPage | Current page, bound with `bind:currentPage`. When omitted the component manages the page itself; `bind:currentPage={get, set}` makes it fully controlled. | `number` | - |
|
|
165
|
+
| disabled | Whether disabled. | `boolean` | `false` |
|
|
166
|
+
| hideOnSinglePage | Whether to hide the pagination when there are fewer than 2 pages; has no effect while the size changer is shown. | `boolean` | `false` |
|
|
167
|
+
| hoverShowPageSelect | Only for size small: the page list opens when the page text is hovered or focused. | `boolean` | - |
|
|
168
|
+
| nextText | String or snippet that replaces the next page icon, named the same way as prevText. | `string \| Snippet` | - |
|
|
169
|
+
| onChange | Called when the page or the page size changes, with the page and the page size. | `(currentPage: number, pageSize: number) => void` | - |
|
|
170
|
+
| onPageChange | Called when the page changes. | `(currentPage: number) => void` | - |
|
|
171
|
+
| onPageSizeChange | Called when the page size changes. | `(pageSize: number) => void` | - |
|
|
172
|
+
| pageSize | Number of items per page, bound with `bind:pageSize`; the choice made in the size changer is written back. Falls back to the first item of pageSizeOpts. | `number` | - |
|
|
173
|
+
| pageSizeOpts | Options of the size changer; the current page size is inserted in order when it is not among them. | `number[]` | `[10, 20, 40, 100]` |
|
|
174
|
+
| popoverPosition | Position of the omitted pages popover and the size changer dropdown; not used by the small size. | `Position` | - |
|
|
175
|
+
| preventPageChangeOnPageSizeChange | Keeps the current page when the page size changes; the consumer picks the page in onPageSizeChange. | `boolean` | `false` |
|
|
176
|
+
| prevText | String or snippet that replaces the previous page icon. A string or a plain-text snippet names the button, and any other content (an icon, an element) keeps the locale name; an empty snippet leaves the button empty, an empty string shows the default icon. | `string \| Snippet` | - |
|
|
177
|
+
| showQuickJumper | Whether to show the quick jump input; disabled when there are fewer than 2 pages. | `boolean` | `false` |
|
|
178
|
+
| showSizeChanger | Whether to show the size changer; not rendered when size is small. | `boolean` | `false` |
|
|
179
|
+
| showTotal | Whether to show the total number of pages; not shown when size is small. | `boolean` | `false` |
|
|
180
|
+
| size | Size: default or small. | `'default' \| 'small'` | `"default"` |
|
|
181
|
+
| total | Total number of items. | `number` | `1` |
|
|
182
|
+
|
|
183
|
+
`class`, `style` and native attributes and events (such as `id`, `aria-*`, `data-*`, `onclick`) land on the root `nav`, for both the default and the small size; `onChange`, `onPageChange` and `onPageSizeChange` are component callbacks and do not land on the root element.
|
|
184
|
+
|
|
185
|
+
## Accessibility
|
|
186
|
+
|
|
187
|
+
Pagination follows the common practice of the [WAI-ARIA navigation example](https://www.w3.org/WAI/ARIA/apg/patterns/landmarks/examples/navigation.html).
|
|
188
|
+
|
|
189
|
+
### ARIA
|
|
190
|
+
|
|
191
|
+
- The root is a `nav` landmark named "Pagination" by the locale by default (an `aria-label` or `aria-labelledby` you pass takes precedence); the `ul` inside is the list, and every part (total, previous, pages, next, page size, quick jumper) is an `li` in it
|
|
192
|
+
- Previous, next, the pages and "…" are native `button`s. A page is named "Page N", "…" is named "More", and previous and next are named by the locale by default; with `prevText` or `nextText` (slots of the same name in Vue) holding plain text they are named by that text, while icons, elements and other content keep the locale name
|
|
193
|
+
- The button of the current page has `aria-current="page"`; disabled buttons use the native `disabled`
|
|
194
|
+
- The quick jumper input is named "Jump to" and is disabled when there are fewer than 2 pages
|
|
195
|
+
- When the page has several paginations, tell them apart with `aria-label`
|
|
196
|
+
|
|
197
|
+
### Keyboard and Focus
|
|
198
|
+
|
|
199
|
+
- Previous, next, the pages and "…" can be focused with `Tab`, and `Enter` or `Space` turns the page;
|
|
200
|
+
- Keyboard focus on "…", or on the page text in small mode with `hoverShowPageSelect`, opens the list of the omitted pages:
|
|
201
|
+
- `Down Arrow` focuses the first page in the list, `Up Arrow` focuses the last one;
|
|
202
|
+
- `Tab` and `Shift + Tab` move in the list, `Enter` or `Space` jumps to the page;
|
|
203
|
+
- `Esc` closes the list and returns focus to the trigger button.
|
|
204
|
+
|
|
205
|
+
## Design Tokens
|
|
206
|
+
|
|
207
|
+
The design token table of this component is on the web page: <https://semi-design-next.pages.dev/en-US/svelte/navigation/pagination/>
|
|
208
|
+
|
|
209
|
+
## Changes from Semi Design
|
|
210
|
+
|
|
211
|
+
From the project release notes (written in Chinese). Your knowledge of Semi Design does not cover these.
|
|
212
|
+
|
|
213
|
+
- 破坏性:DOM 改为 `nav > ul > li > button`:根元素是带名称的 `nav`(默认名称来自语言包 `Pagination.label`,传入 `aria-label` 时优先),`class`、`style`、`ref` 与未声明的属性落在 `nav` 上,`nav` 带 `semi-page-wrapper` 类,`semi-page`、`semi-page-small`、`semi-page-disabled` 留在内层 `ul` 上;上一页、下一页、页码、「…」是 `li` 内的原生 `button`,类名(`semi-page-item`、`semi-page-prev` 等)从 `li` 移到 button,总数、每页条数、快速跳转改为 `li`,`PaginationProps.ref` 为 `Ref<HTMLElement>`;按旧结构写的选择器需调整。删除 `popoverZIndex`。
|
|
214
|
+
- 行为变化:`prevText`、`nextText` 只有文字时以可见文字命名按钮;快速跳转的小数页码向下取整;`size="small"` 时 `showSizeChanger` 不生效;`total` 或 `currentPage` 变化不再重置用户选的页大小,`onPageSizeChange` 回写相同 `pageSize` 不再回到第 1 页;`popoverPosition` 传 `null` 与不传相同。
|
|
215
|
+
- Svelte:`currentPage`、`pageSize` 可绑定,没有 `defaultCurrentPage`、`defaultPageSize`;回调为 `onPageChange`、`onPageSizeChange`、`onChange`;未传 `currentPage` 时点击后页码成为本地值,之后 `total` 或外部 `pageSize` 变化不再回到第 1 页,绑定值写 `undefined` 才回到第 1 页;根元素是 `ul`,未声明的属性透传到 `ul`。
|
|
216
|
+
- Svelte:`prevText`、`nextText` 是 `string | Snippet`。非空字符串直接渲染并从首帧起作为按钮名称,空字符串与不传一样显示默认图标、用语言包名称;snippet 内容是单个文本节点时,按钮名称取该文本(挂载后读取,服务端首帧用语言包名称),图标或元素用语言包名称,传了空内容的 snippet 按钮是空的,不回落图标。
|
|
217
|
+
- foundation:适配器类型 `AdapterPageList` 改名 `PageListView`;`updatePage` 的页码改为必传,非受控时 `total`、`pageSize` 变化回到第 1 页的行为不变。
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
# Steps
|
|
2
|
+
|
|
3
|
+
> Decompose complex tasks or tasks with prior relationships, use step components to guide users to operate according to the prescribed process, and let them know their current progress
|
|
4
|
+
|
|
5
|
+
Package: `@fibrae/semi-ui-svelte`. Web page: https://semi-design-next.pages.dev/en-US/svelte/navigation/steps/
|
|
6
|
+
|
|
7
|
+
## Demos
|
|
8
|
+
|
|
9
|
+
### How to import
|
|
10
|
+
|
|
11
|
+
```svelte
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
import { Steps } from '@fibrae/semi-ui-svelte';
|
|
14
|
+
</script>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Svelte has no `Steps.Step`: steps are data items in `dataSource` (`StepData[]`), and each item can carry `status`, `title`, `description`, `icon` and `onClick`; other attributes land on the step's root element. For a custom title or description, use the `title` and `description` snippets of Steps, whose argument is `{ item, index }`; icons are set per item through its `icon` field.
|
|
18
|
+
|
|
19
|
+
### Default step bar(Deprecated)
|
|
20
|
+
|
|
21
|
+
It is recommended to use the simple version of steps, which will be gradually deprecated later
|
|
22
|
+
|
|
23
|
+
```svelte
|
|
24
|
+
<script lang="ts">
|
|
25
|
+
import { Steps } from '@fibrae/semi-ui-svelte';
|
|
26
|
+
|
|
27
|
+
const dataSource = [
|
|
28
|
+
{ title: 'Finished', description: 'This is a description' },
|
|
29
|
+
{ title: 'In Progress', description: 'This is a description' },
|
|
30
|
+
{ title: 'Waiting', description: 'This is a description' },
|
|
31
|
+
];
|
|
32
|
+
const log = (i: number) => console.log(i);
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<Steps current={1} {dataSource} onChange={log} />
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Basic Steps(Recommended)
|
|
39
|
+
|
|
40
|
+
Set type=`"basic"` to display a simple style step bar
|
|
41
|
+
|
|
42
|
+
```svelte
|
|
43
|
+
<script lang="ts">
|
|
44
|
+
import { Steps } from '@fibrae/semi-ui-svelte';
|
|
45
|
+
|
|
46
|
+
const dataSource = [
|
|
47
|
+
{ title: 'Finished', description: 'This is a description' },
|
|
48
|
+
{ title: 'In Progress', description: 'This is a description' },
|
|
49
|
+
{ title: 'Waiting', description: 'This is a description' },
|
|
50
|
+
];
|
|
51
|
+
const log = (i: number) => console.log(i);
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<Steps current={1} {dataSource} onChange={log} type="basic" />
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Nav Steps
|
|
58
|
+
|
|
59
|
+
You can use type="nav" to set the navigation style step bar. The navigation style step bar has the following characteristics:
|
|
60
|
+
|
|
61
|
+
1. The step bar supports interaction as well: when Steps listens for step changes or a Step has a click handler, steps are focusable and clickable, the same as the other types.
|
|
62
|
+
|
|
63
|
+
2. It is suitable when the steps are not related to each other, the content does not affect each other, and the visual elements of the page need to be highlighted.
|
|
64
|
+
|
|
65
|
+
3. The width of the step bar is opened according to the content.
|
|
66
|
+
|
|
67
|
+
4. Steps.Step only renders the title; `description`, `icon` and `status` have no effect. The other attributes and events (`aria-label`, `role`, click and keyboard handlers, class name and style, etc.) work as in the other types.
|
|
68
|
+
|
|
69
|
+
```svelte
|
|
70
|
+
<script lang="ts">
|
|
71
|
+
import { Steps } from '@fibrae/semi-ui-svelte';
|
|
72
|
+
|
|
73
|
+
const dataSource = [{ title: '注册账号' }, { title: '这个项目的文字比较多多多多' }, { title: '产品用途' }, { title: '期待尝试功能' }];
|
|
74
|
+
const log = (i: number) => console.log(i);
|
|
75
|
+
</script>
|
|
76
|
+
|
|
77
|
+
<div style="display: flex; justify-content: center">
|
|
78
|
+
<Steps current={1} {dataSource} onChange={log} style="margin: auto" type="nav" />
|
|
79
|
+
</div>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Mini size step bar
|
|
83
|
+
|
|
84
|
+
Display the mini size step bar by setting size=`"small"`
|
|
85
|
+
|
|
86
|
+
```svelte
|
|
87
|
+
<script lang="ts">
|
|
88
|
+
import { Steps } from '@fibrae/semi-ui-svelte';
|
|
89
|
+
|
|
90
|
+
const dataSource = [
|
|
91
|
+
{ title: 'Finished', description: 'This is a description' },
|
|
92
|
+
{ title: 'In Progress', description: 'This is a description' },
|
|
93
|
+
{ title: 'Waiting', description: 'This is a description' },
|
|
94
|
+
];
|
|
95
|
+
const log = (i: number) => console.log(i);
|
|
96
|
+
</script>
|
|
97
|
+
|
|
98
|
+
<Steps current={1} {dataSource} onChange={log} size="small" type="basic" />
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
```svelte
|
|
102
|
+
<script lang="ts">
|
|
103
|
+
import { Steps } from '@fibrae/semi-ui-svelte';
|
|
104
|
+
|
|
105
|
+
const dataSource = [{ title: '注册账号' }, { title: '这个项目的文字比较多多多多' }, { title: '产品用途' }, { title: '期待尝试功能' }];
|
|
106
|
+
const log = (i: number) => console.log(i);
|
|
107
|
+
</script>
|
|
108
|
+
|
|
109
|
+
<div style="display: flex; justify-content: center">
|
|
110
|
+
<Steps current={1} {dataSource} onChange={log} size="small" style="margin: auto" type="nav" />
|
|
111
|
+
</div>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Processing progress
|
|
115
|
+
|
|
116
|
+
Use with content and buttons to represent the processing progress of a process
|
|
117
|
+
|
|
118
|
+
```svelte
|
|
119
|
+
<script lang="ts">
|
|
120
|
+
import { Button, Steps } from '@fibrae/semi-ui-svelte';
|
|
121
|
+
|
|
122
|
+
const steps = [
|
|
123
|
+
{ title: 'First', content: 'First-content' },
|
|
124
|
+
{ title: 'Second', content: 'Second-content' },
|
|
125
|
+
{ title: 'Last', content: 'Last-content' },
|
|
126
|
+
];
|
|
127
|
+
let current = $state(0);
|
|
128
|
+
const next = () => {
|
|
129
|
+
current += 1;
|
|
130
|
+
};
|
|
131
|
+
const prev = () => {
|
|
132
|
+
current -= 1;
|
|
133
|
+
};
|
|
134
|
+
const log = (i: number) => console.log(i);
|
|
135
|
+
const done = () => console.log('Processing complete!');
|
|
136
|
+
</script>
|
|
137
|
+
|
|
138
|
+
<div>
|
|
139
|
+
<Steps {current} dataSource={steps} onChange={log} type="basic" />
|
|
140
|
+
<div class="steps-content" style="margin-block-start: 4px; margin-block-end: 4px">
|
|
141
|
+
{steps[current].content}
|
|
142
|
+
</div>
|
|
143
|
+
<div class="steps-action">
|
|
144
|
+
{#if current < steps.length - 1}
|
|
145
|
+
<Button type="primary" onclick={next}>Next</Button>
|
|
146
|
+
{/if}
|
|
147
|
+
{#if current === steps.length - 1}
|
|
148
|
+
<Button type="primary" onclick={done}>Done</Button>
|
|
149
|
+
{/if}
|
|
150
|
+
{#if current > 0}
|
|
151
|
+
<Button style="margin-inline-start: 8px" onclick={prev}>Previous</Button>
|
|
152
|
+
{/if}
|
|
153
|
+
</div>
|
|
154
|
+
</div>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Steps bar in vertical direction
|
|
158
|
+
|
|
159
|
+
Show steps in vertical direction by setting direction
|
|
160
|
+
|
|
161
|
+
```svelte
|
|
162
|
+
<script lang="ts">
|
|
163
|
+
import { Steps } from '@fibrae/semi-ui-svelte';
|
|
164
|
+
|
|
165
|
+
const dataSource = [
|
|
166
|
+
{ title: 'Finished', description: 'This is a description' },
|
|
167
|
+
{ title: 'In Progress', description: 'This is a description' },
|
|
168
|
+
{ title: 'Waiting', description: 'This is a description' },
|
|
169
|
+
];
|
|
170
|
+
const log = (i: number) => console.log(i);
|
|
171
|
+
</script>
|
|
172
|
+
|
|
173
|
+
<Steps current={1} {dataSource} direction="vertical" onChange={log} style="width: 300px" />
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
```svelte
|
|
177
|
+
<script lang="ts">
|
|
178
|
+
import { Steps } from '@fibrae/semi-ui-svelte';
|
|
179
|
+
|
|
180
|
+
const dataSource = [
|
|
181
|
+
{ title: 'Finished', description: 'This is a description' },
|
|
182
|
+
{ title: 'In Progress', description: 'This is a description' },
|
|
183
|
+
{ title: 'Waiting', description: 'This is a description' },
|
|
184
|
+
];
|
|
185
|
+
const log = (i: number) => console.log(i);
|
|
186
|
+
</script>
|
|
187
|
+
|
|
188
|
+
<Steps current={1} {dataSource} direction="vertical" onChange={log} type="basic" />
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Specify step status
|
|
192
|
+
|
|
193
|
+
Using Steps `status` Property to specify the state of the current step.
|
|
194
|
+
|
|
195
|
+
```svelte
|
|
196
|
+
<script lang="ts">
|
|
197
|
+
import { Steps } from '@fibrae/semi-ui-svelte';
|
|
198
|
+
|
|
199
|
+
const dataSource = [
|
|
200
|
+
{ title: 'Finished', description: 'This is a description' },
|
|
201
|
+
{ title: 'In Process', description: 'This is a description' },
|
|
202
|
+
{ title: 'Waiting', description: 'This is a description' },
|
|
203
|
+
];
|
|
204
|
+
const log = (i: number) => console.log(i);
|
|
205
|
+
</script>
|
|
206
|
+
|
|
207
|
+
<Steps current={1} {dataSource} onChange={log} status="error" type="basic" />
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Custom icons
|
|
211
|
+
|
|
212
|
+
Set the `icon` snippet of a `dataSource` item to show a custom icon for that step. Steps without `icon` keep their status icon, and `icon: false` shows no icon for that step.
|
|
213
|
+
|
|
214
|
+
By setting Steps.Step's `status` property (the `status` of a `dataSource` item in Svelte), you can customize the status of each step.
|
|
215
|
+
|
|
216
|
+
```svelte
|
|
217
|
+
<script lang="ts">
|
|
218
|
+
import { IconHome, IconLock } from '@fibrae/semi-icons-svelte';
|
|
219
|
+
import { Steps, type StepData } from '@fibrae/semi-ui-svelte';
|
|
220
|
+
|
|
221
|
+
// Steps without `icon` keep their built-in status icon
|
|
222
|
+
const dataSource: StepData[] = [
|
|
223
|
+
{ status: 'finish', title: '已完成' },
|
|
224
|
+
{ status: 'error', title: '错误' },
|
|
225
|
+
{ status: 'warning', title: '警告' },
|
|
226
|
+
{ status: 'process', title: '正在进行', icon: homeIcon },
|
|
227
|
+
{ status: 'wait', title: '等待', icon: lockIcon },
|
|
228
|
+
];
|
|
229
|
+
const log = (i: number) => console.log(i);
|
|
230
|
+
</script>
|
|
231
|
+
|
|
232
|
+
{#snippet homeIcon()}<IconHome size="extra-large" />{/snippet}
|
|
233
|
+
{#snippet lockIcon()}<IconLock size="extra-large" />{/snippet}
|
|
234
|
+
|
|
235
|
+
<Steps {dataSource} onChange={log} type="basic" />
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### onChange CallBack
|
|
239
|
+
|
|
240
|
+
Listen for step changes with `onChange`. The callback receives a number, equal to initial plus the index of the selected step; it is not called when the current step is clicked. Passing `onChange` makes every step clickable, and so is a step whose `dataSource` item has an `onClick`. `current` is not bindable: update it yourself in `onChange`.
|
|
241
|
+
|
|
242
|
+
```svelte
|
|
243
|
+
<script lang="ts">
|
|
244
|
+
import { Steps } from '@fibrae/semi-ui-svelte';
|
|
245
|
+
|
|
246
|
+
const dataSource = [{ title: 'First' }, { title: 'Second' }, { title: 'Last' }];
|
|
247
|
+
let current = $state(1);
|
|
248
|
+
</script>
|
|
249
|
+
|
|
250
|
+
<div>
|
|
251
|
+
<Steps {current} {dataSource} onChange={(next) => (current = next)} type="basic" />
|
|
252
|
+
</div>
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Accessibility
|
|
256
|
+
|
|
257
|
+
### ARIA
|
|
258
|
+
|
|
259
|
+
- Steps and Step components support `aria-label` or `aria-labelledby`. The Steps root and a Step that is not clickable have no semantic role of their own, so when a name is passed they get `role="group"` and the name reaches the accessible name; without a name no `role` is added. The fill, basic and nav types behave the same
|
|
260
|
+
- The current step has `aria-current="step"`; other steps do not
|
|
261
|
+
- When Steps listens for step changes or a Step has a click handler, steps are focusable with Tab and their `role` defaults to `button` (taking precedence over `group`; an explicit `role` wins over both). `Enter` or Space on a focused step acts like a mouse click and runs both the Step's click handler and the change callback of Steps; steps that are not clickable are not focusable
|
|
262
|
+
- A click that comes from another focusable element inside the step (`input`, `button`, a link, and so on) runs only the Step's click handler, not the change callback of Steps. A clickable step is itself `role="button"`, so a focusable control in the title or description is a nested interactive element; do not make such a step clickable
|
|
263
|
+
|
|
264
|
+
## API reference
|
|
265
|
+
|
|
266
|
+
### Steps
|
|
267
|
+
|
|
268
|
+
The whole step bar.
|
|
269
|
+
|
|
270
|
+
**Props**
|
|
271
|
+
|
|
272
|
+
| Property | Description | Type | Default |
|
|
273
|
+
| - | - | - | - |
|
|
274
|
+
| current | Current step, counting from 0; a `dataSource` item can override the state with status. Not bindable: update it yourself in `onChange`. | `number` | `0` |
|
|
275
|
+
| dataSource | Step data. Each item is a `StepData`: `status` (own status of the step; when omitted it follows current and status), `title`, `description` (not rendered by the nav type), `icon` (snippet for a custom icon of that step; `false` shows no icon; the status icon is used when omitted; not rendered by the nav type) and `onClick` (setting it makes that step clickable). Other attributes land on the step's root element. | `StepData[]` | `[]` |
|
|
276
|
+
| description | Snippet for the description of each step, with `{ item, index }`; defaults to `item.description`. Not rendered by the nav type. | `Snippet<[StepSnippetProps]>` | - |
|
|
277
|
+
| direction | Direction: horizontal or vertical. | `StepsDirection` | `"horizontal"` |
|
|
278
|
+
| hasLine | Whether the basic type shows connecting lines. | `boolean` | `true` |
|
|
279
|
+
| initial | Starting index, counting from 0. | `number` | `0` |
|
|
280
|
+
| onChange | Called when a step is selected by click or keyboard, with its number (initial plus index); not called for the current step. Passing it makes every step clickable. | `(current: number) => void` | - |
|
|
281
|
+
| size | Size of the basic and nav types: default or small. | `StepsSize` | `"default"` |
|
|
282
|
+
| status | State of the current step: wait, process, finish, error or warning. | `StepStatus` | `"process"` |
|
|
283
|
+
| title | Snippet for the title of each step, with `{ item, index }`; defaults to `item.title`. | `Snippet<[StepSnippetProps]>` | - |
|
|
284
|
+
| type | Steps type: fill, basic or nav. | `StepsType` | `"fill"` |
|
|
285
|
+
|
|
286
|
+
`class`, `style` (a string) and other native attributes land on the root element of Steps.
|
|
287
|
+
|
|
288
|
+
### Steps.Step
|
|
289
|
+
|
|
290
|
+
Step in the step bar.
|
|
291
|
+
|
|
292
|
+
Svelte has no separate Step component; the attributes of a step go in its `dataSource` item. Attributes other than `status`, `title`, `description`, `icon` and `onClick` (`aria-label`, `role`, `class`, `style`, `onkeydown` and so on) land on the step item (the root element), and `style` only accepts a string. `role` defaults to `button` when the step is clickable, and a passed `role` takes precedence; `tabindex` follows whether the step is clickable.
|
|
293
|
+
|
|
294
|
+
## Content Guidelines
|
|
295
|
+
|
|
296
|
+
- Step title
|
|
297
|
+
- title should be kept concise, avoiding truncation and line breaks
|
|
298
|
+
- use sentence capitalization
|
|
299
|
+
- do not include punctuation
|
|
300
|
+
- Step description
|
|
301
|
+
- supplementary contextual information for the title
|
|
302
|
+
- don't end with punctuation
|
|
303
|
+
|
|
304
|
+
## Design Tokens
|
|
305
|
+
|
|
306
|
+
The design token table of this component is on the web page: <https://semi-design-next.pages.dev/en-US/svelte/navigation/steps/>
|
|
307
|
+
|
|
308
|
+
## Changes from Semi Design
|
|
309
|
+
|
|
310
|
+
From the project release notes (written in Chinese). Your knowledge of Semi Design does not cover these.
|
|
311
|
+
|
|
312
|
+
- 破坏性:Steps 把每个有效子元素按顺序当作一个步骤位置(Fragment 展开后编号,文本不占位),fill 列宽与 nav 的 `total` 按它计数,原生元素只占序号、不注入步骤属性;`StepProps`、`BasicStepProps`、`FillStepProps`、`NavStepProps` 不再含 `children`(类型)。可点击(设了 `onChange` 或 `onClick`)的 Step 带 `role="button"`。
|
|
313
|
+
- Svelte 破坏性:没有 `Steps.Step`,步骤改为 `dataSource: StepData[]`(`status`、`title`、`description`、`onClick`,其余属性落在步骤根元素上),内容用 Steps 的 `title`、`description` snippet,参数 `{ item, index }`;自定义图标逐项设置:`StepData.icon?: Snippet | false`,设了 snippet 的步骤用自定义图标,`false` 时该步骤图标区为空,未设的步骤用内置状态图标,没有组件级 `icon` snippet。
|
|
314
|
+
- Svelte:`current` 不可绑定,回调 `onChange(current)`;设了 `onChange` 才让所有步骤可点击,数据项带 `onClick` 的那一步也可点击;更新 `current` 由使用方在 `onChange` 里写。
|
|
315
|
+
- 破坏性(深路径导入):React 的 `steps/basic-step` 不再导出内部常量 `stepSizeMapIconSize`。
|