@fibrae/semi-ui-svelte 0.9.0 → 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/cascader.svelte +1 -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/form/label.svelte +2 -2
- 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/tooltip/tooltip.svelte +3 -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/dist/styles.css +1 -1
- 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,7 @@
|
|
|
1
|
+
# Internationalization
|
|
2
|
+
|
|
3
|
+
> Global design is not targeted at a certain market, but is based on commonalities, looking for differences, and creating an inclusive design so that different users in different countries and regions can understand the same design language and ensure the basic experience of the interface.
|
|
4
|
+
|
|
5
|
+
Package: `@fibrae/semi-ui-svelte`. Web page: https://semi-design-next.pages.dev/en-US/svelte/experience/internationalization/
|
|
6
|
+
|
|
7
|
+
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# Banner
|
|
2
|
+
|
|
3
|
+
> The Banner component is usually used to identify the status or notification of the full page. It is usually resident and requires the user to close it initiatively.
|
|
4
|
+
|
|
5
|
+
Package: `@fibrae/semi-ui-svelte`. Web page: https://semi-design-next.pages.dev/en-US/svelte/feedback/banner/
|
|
6
|
+
|
|
7
|
+
## Demos
|
|
8
|
+
|
|
9
|
+
### How to import
|
|
10
|
+
|
|
11
|
+
```svelte
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
import { Banner } from '@fibrae/semi-ui-svelte';
|
|
14
|
+
</script>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Basic Usage
|
|
18
|
+
|
|
19
|
+
```svelte
|
|
20
|
+
<script lang="ts">
|
|
21
|
+
import { Banner, Button, Layout } from '@fibrae/semi-ui-svelte';
|
|
22
|
+
|
|
23
|
+
let visible = $state(false);
|
|
24
|
+
const toggle = () => {
|
|
25
|
+
visible = !visible;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const commonStyle = 'height: 64px; line-height: 64px; background: var(--semi-color-fill-0)';
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<Layout class="components-layout-demo banner-basic">
|
|
32
|
+
<Layout.Header style={commonStyle}>Header</Layout.Header>
|
|
33
|
+
{#if visible}
|
|
34
|
+
<Banner onClose={toggle}>
|
|
35
|
+
{#snippet description()}一套组件,四个框架原生可用,随时查阅对应的前端代码{/snippet}
|
|
36
|
+
</Banner>
|
|
37
|
+
{/if}
|
|
38
|
+
<Layout.Content style="height: 300px; line-height: 300px">Content</Layout.Content>
|
|
39
|
+
<Layout.Footer style={commonStyle}>Footer</Layout.Footer>
|
|
40
|
+
</Layout>
|
|
41
|
+
<Button style="display: block; width: 120px; margin: 0 auto" onclick={toggle}>
|
|
42
|
+
{visible ? 'Hide Banner' : 'Show Banner'}
|
|
43
|
+
</Button>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Types
|
|
47
|
+
|
|
48
|
+
The `type` prop supports one of: `default`(default),`danger`,`warning`, `success`.
|
|
49
|
+
|
|
50
|
+
```svelte
|
|
51
|
+
<script lang="ts">
|
|
52
|
+
import { Banner } from '@fibrae/semi-ui-svelte';
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<Banner type="info">
|
|
56
|
+
{#snippet description()}一套组件,四个框架原生可用,随时查阅对应的前端代码{/snippet}
|
|
57
|
+
</Banner>
|
|
58
|
+
<br />
|
|
59
|
+
<Banner type="warning">
|
|
60
|
+
{#snippet description()}当前使用的 UI Kit 为旧版,可能无法支持完整的组件能力{/snippet}
|
|
61
|
+
</Banner>
|
|
62
|
+
<br />
|
|
63
|
+
<Banner type="danger">
|
|
64
|
+
{#snippet description()}当前使用 API 已过期,请尽快升级{/snippet}
|
|
65
|
+
</Banner>
|
|
66
|
+
<br />
|
|
67
|
+
<Banner type="success">
|
|
68
|
+
{#snippet description()}Semi Design Next themes through --semi-* variables{/snippet}
|
|
69
|
+
</Banner>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Use in Container
|
|
73
|
+
|
|
74
|
+
You could set `fullMode={false}` to use style for non-fullscreen mode. Also, use `bordered` for bordered style. `icon={null}` and `closeIcon={null}` hide the icon and the close button.
|
|
75
|
+
|
|
76
|
+
```svelte
|
|
77
|
+
<script lang="ts">
|
|
78
|
+
import { Banner, Typography } from '@fibrae/semi-ui-svelte';
|
|
79
|
+
|
|
80
|
+
const types = ['info', 'warning', 'danger', 'success'] as const;
|
|
81
|
+
</script>
|
|
82
|
+
|
|
83
|
+
<div class="components-banner-demo" style="width: 640px">
|
|
84
|
+
{#each types as type, index (type)}
|
|
85
|
+
{#if index > 0}
|
|
86
|
+
<br />
|
|
87
|
+
{/if}
|
|
88
|
+
<Banner bordered closeIcon={null} fullMode={false} icon={null} {type}>
|
|
89
|
+
{#snippet title()}
|
|
90
|
+
<div style="font-weight: 600; font-size: 14px; line-height: 20px">不知道 AppKey?</div>
|
|
91
|
+
{/snippet}
|
|
92
|
+
{#snippet description()}
|
|
93
|
+
<div>
|
|
94
|
+
你可先联系对应的研发同学,确认是否已在
|
|
95
|
+
<Typography.Text link={{ href: 'https://semi-design-next.pages.dev/' }}>应用云平台</Typography.Text>
|
|
96
|
+
申请了应用,并填写对应的信息。
|
|
97
|
+
</div>
|
|
98
|
+
{/snippet}
|
|
99
|
+
</Banner>
|
|
100
|
+
{/each}
|
|
101
|
+
</div>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
```css
|
|
105
|
+
.components-banner-demo {
|
|
106
|
+
.semi-banner-info.semi-banner-bordered {
|
|
107
|
+
border: 1px solid var(--semi-color-primary-disabled);
|
|
108
|
+
}
|
|
109
|
+
.semi-banner-warning.semi-banner-bordered {
|
|
110
|
+
border: 1px solid var(--semi-color-warning-light-active);
|
|
111
|
+
}
|
|
112
|
+
.semi-banner-danger.semi-banner-bordered {
|
|
113
|
+
border: 1px solid var(--semi-color-danger-light-active);
|
|
114
|
+
}
|
|
115
|
+
.semi-banner-success.semi-banner-bordered {
|
|
116
|
+
border: 1px solid var(--semi-color-success-light-active);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Customized Content
|
|
122
|
+
|
|
123
|
+
Write the content directly inside the Banner tag (the `children` snippet) to create customized content.
|
|
124
|
+
|
|
125
|
+
```svelte
|
|
126
|
+
<script lang="ts">
|
|
127
|
+
import { Banner } from '@fibrae/semi-ui-svelte';
|
|
128
|
+
</script>
|
|
129
|
+
|
|
130
|
+
<div style="width: 500px; padding: 20px; border: 1px solid var(--semi-color-border)">
|
|
131
|
+
<Banner bordered fullMode={false} title="Title" type="warning">
|
|
132
|
+
{#snippet description()}
|
|
133
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat
|
|
134
|
+
{/snippet}
|
|
135
|
+
<div class="semi-modal-footer">
|
|
136
|
+
<button class="semi-button semi-button-tertiary semi-button-light" type="button">No, thanks.</button>
|
|
137
|
+
<button class="semi-button semi-button-warning" type="button">Sounds great!</button>
|
|
138
|
+
</div>
|
|
139
|
+
</Banner>
|
|
140
|
+
<br />
|
|
141
|
+
</div>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## API Reference
|
|
145
|
+
|
|
146
|
+
**Props**
|
|
147
|
+
|
|
148
|
+
| Property | Description | Type | Default |
|
|
149
|
+
| - | - | - | - |
|
|
150
|
+
| bordered | Whether to show a border. Only takes effect in non-full mode. | `boolean` | `false` |
|
|
151
|
+
| children | Custom content below the message. | `Snippet` | - |
|
|
152
|
+
| closeIcon | Snippet that replaces the icon in the close button. Pass `null` to remove the button. | `Snippet \| null` | - |
|
|
153
|
+
| description | Snippet for the description content. | `Snippet` | - |
|
|
154
|
+
| fullMode | Whether the banner is in full mode. | `boolean` | `true` |
|
|
155
|
+
| icon | Snippet that replaces the icon of the type. Pass `null` to hide the icon. | `Snippet \| null` | - |
|
|
156
|
+
| onClose | Called when the close button is clicked, with its native click event. The banner hides once the callback returns. | `(event: MouseEvent) => void` | - |
|
|
157
|
+
| title | Title, a string or a snippet. | `string \| Snippet` | - |
|
|
158
|
+
| type | Type: info, success, danger or warning. | `BannerType` | `"info"` |
|
|
159
|
+
|
|
160
|
+
`class`, `style` (a string) and native attributes and events (such as `aria-*` and `onclick`) land on the root element. `title` can be a string or a snippet, and `description`, `icon` and `closeIcon` are snippets. The closed state lives inside the component and there is no `bind:`; unmount with `{#if}` and mount again to show it again.
|
|
161
|
+
|
|
162
|
+
## Accessibility
|
|
163
|
+
|
|
164
|
+
### ARIA
|
|
165
|
+
|
|
166
|
+
- The root has no `role` by default, so a note that stays on the page is not announced as an alert. For a message that appears dynamically and must be announced at once, such as a failed operation, pass `role="alert"`.
|
|
167
|
+
- The close button's `aria-label` comes from the current locale ('Close' in English, '关闭' in Simplified Chinese).
|
|
168
|
+
|
|
169
|
+
### Keyboard and Focus
|
|
170
|
+
|
|
171
|
+
- The close button of the Banner can be focused with the `Tab` key. After the button is focused, hit the `Enter` key or the `Space` key to close the banner.
|
|
172
|
+
|
|
173
|
+
## Content Guidelines
|
|
174
|
+
|
|
175
|
+
- Full screen Banner
|
|
176
|
+
- Try to keep the content displayed completely on one line
|
|
177
|
+
- Use correct punctuation, commas within sentences and periods between sentences
|
|
178
|
+
- Non-fullscreen Banner
|
|
179
|
+
- title
|
|
180
|
+
- Instructions in condensed language
|
|
181
|
+
- Try to avoid using commas, periods and other punctuation marks in the title, and support the use of question marks at the end when there are and only interrogative sentences
|
|
182
|
+
- text
|
|
183
|
+
- On the premise of complete information transmission, try to compress the text to 1-2 sentences
|
|
184
|
+
- A detailed description or explanation of the title, rather than a repetition of the title
|
|
185
|
+
- Use correct punctuation, commas within sentences and periods between sentences
|
|
186
|
+
|
|
187
|
+
## Design Tokens
|
|
188
|
+
|
|
189
|
+
The design token table of this component is on the web page: <https://semi-design-next.pages.dev/en-US/svelte/feedback/banner/>
|
|
190
|
+
|
|
191
|
+
## Changes from Semi Design
|
|
192
|
+
|
|
193
|
+
From the project release notes (written in Chinese). Your knowledge of Semi Design does not cover these.
|
|
194
|
+
|
|
195
|
+
- 破坏性:根元素不再固定 `role="alert"`,默认不设 `role`,传入的 `role` 落在根元素上。依赖读屏立即播报的场景要自己传 `role="alert"`。
|
|
196
|
+
- 删除已废弃的 `target` 属性,传入时作为未声明属性落到根 DOM。
|
|
197
|
+
- Vue、Solid:关闭按钮的点击不冒泡,祖先元素的原生监听也收不到(React 只拦住 React 处理函数)。
|
|
198
|
+
- Svelte:`onClose(event)` 是回调 prop;`title` 是 `string | Snippet`,`description`、`children` 是 snippet;`icon`、`closeIcon` 传 snippet 替换默认图标,传 `null` 隐藏图标或去掉关闭按钮(传渲染为空的 snippet 不会隐藏);关闭按钮的点击不冒泡。
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
# Feedback
|
|
2
|
+
|
|
3
|
+
> Quick feedback component
|
|
4
|
+
|
|
5
|
+
Package: `@fibrae/semi-ui-svelte`. Web page: https://semi-design-next.pages.dev/en-US/svelte/feedback/feedback/
|
|
6
|
+
|
|
7
|
+
## Demos
|
|
8
|
+
|
|
9
|
+
### How to import
|
|
10
|
+
|
|
11
|
+
```svelte
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
import { Feedback } from '@fibrae/semi-ui-svelte';
|
|
14
|
+
</script>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Basic usage
|
|
18
|
+
|
|
19
|
+
Use `bind:visible` to set whether to display or not. Cancel, close and Esc write `false` back to it, while the submit button only calls `onOk` and the caller closes the feedback. The default feedback display content is in emoji form. The currently selected content can be obtained through `onValueChange`.
|
|
20
|
+
|
|
21
|
+
```svelte
|
|
22
|
+
<script lang="ts">
|
|
23
|
+
import { Button, Feedback, type FeedbackValue } from '@fibrae/semi-ui-svelte';
|
|
24
|
+
|
|
25
|
+
let visible = $state(false);
|
|
26
|
+
const onOk = () => {
|
|
27
|
+
visible = false;
|
|
28
|
+
};
|
|
29
|
+
const onValueChange = (value: FeedbackValue) => {
|
|
30
|
+
console.log('emoji value', value);
|
|
31
|
+
};
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<Button onclick={() => (visible = !visible)}>展示反馈: Popup, emoji</Button>
|
|
35
|
+
<Feedback bind:visible {onOk} {onValueChange} title="您对本产品的评分是?" />
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Text type
|
|
39
|
+
|
|
40
|
+
Set `type` to `text` to get feedback in the form of a multi-line input box, and set the parameters of the multi-line input box through `textAreaProps`.
|
|
41
|
+
|
|
42
|
+
```svelte
|
|
43
|
+
<script lang="ts">
|
|
44
|
+
import { Button, Feedback } from '@fibrae/semi-ui-svelte';
|
|
45
|
+
|
|
46
|
+
let visible = $state(false);
|
|
47
|
+
const onOk = () => {
|
|
48
|
+
visible = false;
|
|
49
|
+
};
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<Button onclick={() => (visible = !visible)}>展示反馈: Popup, text</Button>
|
|
53
|
+
<Feedback bind:visible {onOk} textAreaProps={{ maxCount: 200 }} title="您对本产品的建议是?" type="text" />
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Single choice feedback
|
|
57
|
+
|
|
58
|
+
Set `type` to `radio` to get feedback in the form of a single selection, and set the parameters of the radio selection through `radioGroupProps`. The option group has no accessible name by default; name it with `aria-label` in `radioGroupProps`.
|
|
59
|
+
|
|
60
|
+
```svelte
|
|
61
|
+
<script lang="ts">
|
|
62
|
+
import { Button, Feedback } from '@fibrae/semi-ui-svelte';
|
|
63
|
+
|
|
64
|
+
let visible = $state(false);
|
|
65
|
+
const onOk = () => {
|
|
66
|
+
visible = false;
|
|
67
|
+
};
|
|
68
|
+
</script>
|
|
69
|
+
|
|
70
|
+
<Button onclick={() => (visible = !visible)}>展示反馈: Popup, radio</Button>
|
|
71
|
+
<Feedback bind:visible {onOk} radioGroupProps={{ options: ['访客', '开发者', '维护者'] }} title="您的身份是" type="radio" />
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Multiple choice feedback
|
|
75
|
+
|
|
76
|
+
Set `type` to `checkbox` to obtain feedback in the form of multiple selections, and set the parameters of the multi selection through `checkboxGroupProps`. The option group has no accessible name by default; name it with `aria-label` in `checkboxGroupProps`.
|
|
77
|
+
|
|
78
|
+
```svelte
|
|
79
|
+
<script lang="ts">
|
|
80
|
+
import { Button, Feedback } from '@fibrae/semi-ui-svelte';
|
|
81
|
+
|
|
82
|
+
let visible = $state(false);
|
|
83
|
+
const onOk = () => {
|
|
84
|
+
visible = false;
|
|
85
|
+
};
|
|
86
|
+
</script>
|
|
87
|
+
|
|
88
|
+
<Button onclick={() => (visible = !visible)}>展示反馈: Popup, checkbox</Button>
|
|
89
|
+
<Feedback bind:visible checkboxGroupProps={{ options: ['短视频', '直播', '资讯'] }} {onOk} title="您最常使用以下哪些产品?" type="checkbox" />
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Customized feedback content
|
|
93
|
+
|
|
94
|
+
Set `type` to `custom` to obtain feedback with customized content, and write the feedback content inside the tag (`children`). When using custom feedback, you need to control whether the submit button is disabled or not. Users can set it through `okButtonProps`.
|
|
95
|
+
|
|
96
|
+
```svelte
|
|
97
|
+
<script lang="ts">
|
|
98
|
+
import { Button, Feedback, TextArea } from '@fibrae/semi-ui-svelte';
|
|
99
|
+
|
|
100
|
+
let visible = $state(false);
|
|
101
|
+
let value = $state('');
|
|
102
|
+
const onOk = () => {
|
|
103
|
+
visible = false;
|
|
104
|
+
};
|
|
105
|
+
</script>
|
|
106
|
+
|
|
107
|
+
<Button onclick={() => (visible = !visible)}>展示反馈: Popup, custom</Button>
|
|
108
|
+
<Feedback bind:visible okButtonProps={{ disabled: !value }} {onOk} title="您对本产品的建议是?" type="custom">
|
|
109
|
+
<span>这是一段自定义的内容</span>
|
|
110
|
+
<TextArea bind:value />
|
|
111
|
+
</Feedback>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Modal
|
|
115
|
+
|
|
116
|
+
The form of feedback can be passed through `mode`, the default is `popup`, set to `modal` to get the display in the form of modal dialog box.
|
|
117
|
+
|
|
118
|
+
```svelte
|
|
119
|
+
<script lang="ts">
|
|
120
|
+
import { Button, Feedback, type FeedbackValue } from '@fibrae/semi-ui-svelte';
|
|
121
|
+
|
|
122
|
+
let visible = $state(false);
|
|
123
|
+
const onOk = () => {
|
|
124
|
+
visible = false;
|
|
125
|
+
};
|
|
126
|
+
const onValueChange = (value: FeedbackValue) => {
|
|
127
|
+
console.log('emoji value', value);
|
|
128
|
+
};
|
|
129
|
+
</script>
|
|
130
|
+
|
|
131
|
+
<Button onclick={() => (visible = !visible)}>展示反馈: Modal, emoji</Button>
|
|
132
|
+
<Feedback bind:visible mode="modal" {onOk} {onValueChange} title="Why did you choose this rating?" />
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Feedback completion tips
|
|
136
|
+
|
|
137
|
+
After the feedback is completed, you can switch to display information to remind the user that the feedback has been completed.
|
|
138
|
+
|
|
139
|
+
```svelte
|
|
140
|
+
<script lang="ts">
|
|
141
|
+
import { IllustrationSuccess, IllustrationSuccessDark } from '@fibrae/semi-icons-svelte/illustrations';
|
|
142
|
+
import { Button, Empty, Feedback, TextArea } from '@fibrae/semi-ui-svelte';
|
|
143
|
+
|
|
144
|
+
const createState = () => ({ visible: false, value: '', showThanks: false });
|
|
145
|
+
const popup = $state(createState());
|
|
146
|
+
const modal = $state(createState());
|
|
147
|
+
const showThankProps = { title: ' ', footer: null };
|
|
148
|
+
|
|
149
|
+
// The thanks view stays 200ms past the close so the exit animation still shows it.
|
|
150
|
+
const handleOk = (state: ReturnType<typeof createState>) => {
|
|
151
|
+
state.showThanks = true;
|
|
152
|
+
setTimeout(() => {
|
|
153
|
+
state.visible = false;
|
|
154
|
+
setTimeout(() => {
|
|
155
|
+
state.showThanks = false;
|
|
156
|
+
}, 200);
|
|
157
|
+
}, 1500);
|
|
158
|
+
};
|
|
159
|
+
</script>
|
|
160
|
+
|
|
161
|
+
{#snippet thanks()}
|
|
162
|
+
<Empty style="padding: 30px">
|
|
163
|
+
{#snippet image()}
|
|
164
|
+
<IllustrationSuccess style="width: 150px; height: 150px" />
|
|
165
|
+
{/snippet}
|
|
166
|
+
{#snippet darkModeImage()}
|
|
167
|
+
<IllustrationSuccessDark style="width: 150px; height: 150px" />
|
|
168
|
+
{/snippet}
|
|
169
|
+
{#snippet description()}感谢您的反馈{/snippet}
|
|
170
|
+
</Empty>
|
|
171
|
+
{/snippet}
|
|
172
|
+
|
|
173
|
+
<div>
|
|
174
|
+
<Button onclick={() => (popup.visible = !popup.visible)}>Open Feedback: Popup, Custom</Button>
|
|
175
|
+
<Feedback bind:visible={popup.visible} okButtonProps={{ disabled: !popup.value }} onOk={() => handleOk(popup)} title="What is your feedback on this product?" type="custom" {...popup.showThanks ? showThankProps : {}}>
|
|
176
|
+
{#if popup.showThanks}
|
|
177
|
+
{@render thanks()}
|
|
178
|
+
{:else}
|
|
179
|
+
<span>这是一段自定义的内容</span>
|
|
180
|
+
<TextArea bind:value={popup.value} />
|
|
181
|
+
{/if}
|
|
182
|
+
</Feedback>
|
|
183
|
+
<br />
|
|
184
|
+
<br />
|
|
185
|
+
<Button onclick={() => (modal.visible = !modal.visible)}>Open Feedback: Modal, Custom</Button>
|
|
186
|
+
<Feedback bind:visible={modal.visible} mode="modal" okButtonProps={{ disabled: !modal.value }} onOk={() => handleOk(modal)} title="What is your feedback on this product?" type="custom" {...modal.showThanks ? showThankProps : {}}>
|
|
187
|
+
{#if modal.showThanks}
|
|
188
|
+
{@render thanks()}
|
|
189
|
+
{:else}
|
|
190
|
+
<span>这是一段自定义的内容</span>
|
|
191
|
+
<TextArea bind:value={modal.value} />
|
|
192
|
+
{/if}
|
|
193
|
+
</Feedback>
|
|
194
|
+
</div>
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## API reference
|
|
198
|
+
|
|
199
|
+
### FeedbackProps
|
|
200
|
+
|
|
201
|
+
In addition to the parameters listed below, when `mode` is `modal`, FeedbackProps also supports the parameters in [ModalProps](../show/modal.md#Modal). When `mode` is `popup`, FeedbackProps also supports the parameters in [SideSheetProps](../show/side-sheet.md#API%20reference)
|
|
202
|
+
|
|
203
|
+
**Props**
|
|
204
|
+
|
|
205
|
+
| Property | Description | Type | Default |
|
|
206
|
+
| - | - | - | - |
|
|
207
|
+
| afterClose | Called after the panel has fully closed, in both modes. | `() => void` | - |
|
|
208
|
+
| afterVisibleChange | Called once the shown state has changed and the animation has ended. Only popup mode calls it. | `(visible: boolean) => void` | - |
|
|
209
|
+
| cancelButtonProps | Props of the cancel button. It is loading when either the built-in pending state or your loading says so. onclick runs before the built-in handling, which still runs. | `FeedbackButtonProps` | - |
|
|
210
|
+
| cancelLoading | Modal mode only: whether the cancel button is loading. When omitted it follows the Promise returned by onCancel; pass false to turn that off. | `boolean` | - |
|
|
211
|
+
| cancelText | Modal mode only: cancel button text. Defaults to the locale entry Modal.cancel. | `string` | - |
|
|
212
|
+
| canVerticalSetWidth | Popup mode only: whether width applies when placement is top or bottom. By default those sheets span the full width. | `boolean` | - |
|
|
213
|
+
| centered | Modal mode only: whether the dialog is vertically centered. | `boolean` | - |
|
|
214
|
+
| checkboxExtra | Snippet for the extra text of each item in checkboxGroupProps.options, with `{ option, index }` as its argument. | `Snippet<[FeedbackCheckboxSnippetProps]>` | - |
|
|
215
|
+
| checkboxGroupProps | Props of the checkbox group for the checkbox type, written as the props of CheckboxGroup. The group has no accessible name by default; name it with aria-label. | `FeedbackCheckboxGroupProps` | - |
|
|
216
|
+
| checkboxLabel | Snippet for the label of each item in checkboxGroupProps.options, with `{ option, index }` as its argument. | `Snippet<[FeedbackCheckboxSnippetProps]>` | - |
|
|
217
|
+
| children | Feedback content for type custom. | `Snippet` | - |
|
|
218
|
+
| classNames | Class names of the inner parts, keyed by mask, header and body; values take anything class takes (string, array or object) and merge with the built-in classes. Passed to the Modal or SideSheet of the current mode. | `Partial<Record<FeedbackPart, ClassValue>>` | - |
|
|
219
|
+
| closable | Whether the close button in the corner is shown. | `boolean` | - |
|
|
220
|
+
| closeIcon | Icon inside the close button. | `Snippet` | - |
|
|
221
|
+
| closeOnEsc | Whether Esc cancels the feedback. | `boolean` | - |
|
|
222
|
+
| confirmLoading | Modal mode only: whether the ok button is loading. When omitted it follows the Promise returned by onOk; pass false to turn that off. | `boolean` | - |
|
|
223
|
+
| content | Snippet that wraps or replaces the built-in content for any type. Its argument `{ content }` is the built-in content; place it with `{@render content()}`. | `Snippet<[FeedbackContentSnippetProps]>` | - |
|
|
224
|
+
| disableScroll | Popup mode only: whether body scrolling is locked while a masked sheet is rendered in document.body. | `boolean` | - |
|
|
225
|
+
| footer | Replaces the default cancel and submit buttons; `null` renders no footer area. | `Snippet \| null` | - |
|
|
226
|
+
| footerFill | Modal mode only: whether the two buttons of the default footer fill the row. | `boolean` | - |
|
|
227
|
+
| fullScreen | Modal mode only: whether the dialog fills the screen. width and height are ignored. | `boolean` | - |
|
|
228
|
+
| getPopupContainer | Parent element the layer is rendered into. A custom container needs position: relative. | `() => HTMLElement` | - |
|
|
229
|
+
| hasCancel | Modal mode only: whether the default footer shows the cancel button. | `boolean` | - |
|
|
230
|
+
| header | Modal mode only: replaces the whole default header; `null` renders no header. | `Snippet \| null` | - |
|
|
231
|
+
| height | Height. A number is in pixels; a string is any valid CSS length. In popup mode it applies only when placement is top or bottom. | `string \| number` | - |
|
|
232
|
+
| icon | Modal mode only: icon before the title. | `Snippet` | - |
|
|
233
|
+
| keepDOM | Whether the content stays mounted while closed. | `boolean` | - |
|
|
234
|
+
| lazyRender | Modal mode only: used with keepDOM. When true, the dialog is not rendered until it is first shown. | `boolean` | - |
|
|
235
|
+
| mask | Whether the mask is shown; in popup mode there is no mask by default and the rest of the page stays usable. | `boolean` | - |
|
|
236
|
+
| maskClosable | Whether a click on the mask cancels the feedback. | `boolean` | - |
|
|
237
|
+
| maskFixed | Modal mode only: whether a mask confined to a custom container still covers the viewport with fixed positioning and is treated as modal. | `boolean` | - |
|
|
238
|
+
| modal | Modal mode only: custom rendering of the dialog itself. Its argument `{ modal }` is the `role="dialog"` element; place it with `{@render modal()}`. | `Snippet<[{ modal: Snippet }]>` | - |
|
|
239
|
+
| modalContentClass | Modal mode only: class name of the dialog content element. | `string` | - |
|
|
240
|
+
| mode | Display mode: popup is a non-modal panel at the bottom without a mask (SideSheet); modal is a modal dialog (Modal). Attributes Feedback does not declare go to the SideSheet or Modal of the current mode. | `FeedbackMode` | `"popup"` |
|
|
241
|
+
| motion | Whether the enter and leave animations run. | `boolean` | - |
|
|
242
|
+
| okButtonProps | Props of the submit button. Without disabled, it is disabled while the value is empty; a disabled you give wins, which is how the custom type controls submission. It is loading when either the built-in pending state or your loading says so. onclick runs before the built-in handling, which still runs. | `FeedbackButtonProps` | - |
|
|
243
|
+
| okText | Modal mode only: ok button text. Defaults to the locale entry Modal.confirm. | `string` | - |
|
|
244
|
+
| okType | Modal mode only: type of the ok button. | `OKType` | - |
|
|
245
|
+
| onCancel | Called by the cancel button, the close button, Esc and, in modal mode, a click on the mask; the argument is a native KeyboardEvent for Esc. Once it returns, the filled-in value is cleared and visible is written back as false. A returned Promise keeps the cancel button loading; both happen only once it fulfills, and a rejection keeps the feedback open. | `(event: MouseEvent \| KeyboardEvent) => unknown` | - |
|
|
246
|
+
| onOk | Called when the submit button is clicked; the filled-in value is cleared once it returns. A returned Promise keeps the button loading and the value is cleared only once it fulfills, and kept when it rejects. The component never closes itself on submit; the caller sets visible to false. | `(event: MouseEvent) => unknown` | - |
|
|
247
|
+
| onValueChange | Called when the feedback content changes, with the current value: a string for text, `{ emoji, text }` for emoji (text is the reason filled in after choosing the bad face), the value of the chosen option for radio, and an array of chosen values for checkbox. | `(value: FeedbackValue) => void` | - |
|
|
248
|
+
| placement | Popup mode only: edge the sheet slides in from. | `Placement` | - |
|
|
249
|
+
| preventScroll | Modal mode only: whether the focus calls made by the component avoid scrolling the focused element into view. | `boolean` | - |
|
|
250
|
+
| radioExtra | Snippet for the extra text of each item in radioGroupProps.options, with `{ option, index }` as its argument. | `Snippet<[FeedbackRadioSnippetProps]>` | - |
|
|
251
|
+
| radioGroupProps | Props of the radio group for the radio type, written as the props of RadioGroup. The group has no accessible name by default; name it with aria-label. | `FeedbackRadioGroupProps` | - |
|
|
252
|
+
| radioLabel | Snippet for the label of each item in radioGroupProps.options, with `{ option, index }` as its argument. | `Snippet<[FeedbackRadioSnippetProps]>` | - |
|
|
253
|
+
| role | Modal mode only: role of the dialog, dialog or alertdialog. | `'alertdialog' \| 'dialog'` | - |
|
|
254
|
+
| size | Width preset: small is 448px, medium 684px, large 920px. In popup mode it applies only when placement is left or right. | `Size` | - |
|
|
255
|
+
| style | Style string; see the note below for where it lands. | `string` | - |
|
|
256
|
+
| styles | Inline styles of the inner parts, keyed like classNames; every value is a style string. Passed to the Modal or SideSheet of the current mode. | `Partial<Record<FeedbackPart, string>>` | - |
|
|
257
|
+
| textAreaProps | Props of the multi-line input for the text and emoji types; its onChange is called as usual and does not replace the built-in handling. | `FeedbackTextAreaProps` | - |
|
|
258
|
+
| title | Title, a string or a snippet, which also names the dialog. | `string \| Snippet` | - |
|
|
259
|
+
| type | Type of the feedback content. For custom, the content goes in the children. | `FeedbackType` | `"emoji"` |
|
|
260
|
+
| visible | Whether the feedback is shown; bind it with `bind:visible`. A cancel path (cancel button, close button, Esc, and the mask in modal mode) writes `false` back; the submit button never closes it. | `boolean` | - |
|
|
261
|
+
| width | Width. A number is in pixels; a string is any valid CSS length. When omitted, size decides. | `string \| number` | - |
|
|
262
|
+
| zIndex | z-index of the layer. | `number` | - |
|
|
263
|
+
|
|
264
|
+
**Methods**
|
|
265
|
+
|
|
266
|
+
| Method | Description | Type |
|
|
267
|
+
| - | - | - |
|
|
268
|
+
| getRoot | The outermost element of the Modal or SideSheet inside the portal, or null while nothing is rendered. | `() => any` |
|
|
269
|
+
|
|
270
|
+
Undeclared attributes go to the Modal or SideSheet of the current `mode` and land where they do there: all `aria-*` attributes land on the `role="dialog"` element; `style` lands on the `.semi-modal` dialog box in `modal` mode and on the `role="dialog"` element in `popup` mode; `class`, the other undeclared attributes and native events land on the outermost element inside the portal. `textAreaProps`, `radioGroupProps` and `checkboxGroupProps` are written as the props of the matching component without `value`, as Feedback owns the value; their `onChange` is called after Feedback handles the change; the `bind:this` instance provides `getRoot()`.
|
|
271
|
+
|
|
272
|
+
## Accessibility
|
|
273
|
+
|
|
274
|
+
### ARIA
|
|
275
|
+
|
|
276
|
+
- The faces of the emoji type are native `input type="radio"` elements inside a `role="radiogroup"` (named by the locale entry `Feedback.rating`), each named by `Feedback.bad`, `Feedback.normal` or `Feedback.good`. The selected state is expressed by the native `checked`, following the [APG Radio Group](https://www.w3.org/WAI/ARIA/apg/patterns/radio/)
|
|
277
|
+
- The option groups of the radio and checkbox types have no accessible name by default; name them with `aria-label` in `radioGroupProps` or `checkboxGroupProps`
|
|
278
|
+
- `modal` mode follows the [APG Dialog (Modal)](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/), see [Modal](../show/modal.md#Accessibility) for details. `popup` mode is a SideSheet without a mask and is treated as a non-modal dialog, so `aria-modal` is not set
|
|
279
|
+
|
|
280
|
+
### Keyboard and focus
|
|
281
|
+
|
|
282
|
+
- The emoji group has a single Tab stop and the arrow keys move the selected face; a face shows the theme focus ring when focused with the keyboard. The radio and checkbox types follow the keyboard behavior of [RadioGroup](../input/radio.md) and [CheckboxGroup](../input/checkbox.md)
|
|
283
|
+
- In `popup` mode, focus moves into the panel on open but Tab is not trapped and the rest of the page stays usable; Esc triggers cancel. On close, focus returns to the element focused before opening only if it is still inside the panel or has fallen to the body; focus the user has moved elsewhere on the page is left alone
|
|
284
|
+
- In `modal` mode, focus moves into the dialog on open, Tab cycles within the dialog and the page behind is not interactive; focus returns to the previously focused element on close, and Esc triggers cancel
|
|
285
|
+
|
|
286
|
+
## Changes from Semi Design
|
|
287
|
+
|
|
288
|
+
From the project release notes (written in Chinese). Your knowledge of Semi Design does not cover these.
|
|
289
|
+
|
|
290
|
+
- 破坏性:删除 `bodyStyle`、`maskStyle`(Svelte 另有 `headerStyle`),改用 `classNames`、`styles` 的 `mask`、`header`、`body` 键,转发给当前模式的 Modal 或 SideSheet。
|
|
291
|
+
- 破坏性(类型):`FeedbackProps` 按 `mode` 判别(`FeedbackModalProps` 的 `mode` 必填为 `'modal'`,`FeedbackSideSheetProps` 为可选 `'popup'`),popup 下传 Modal 专属属性报类型错误;`onCancel` 参数为 `React.MouseEvent | KeyboardEvent`;checkbox 的 `onValueChange` 值为 `(string | number | boolean)[]`;popup 模式默认开启 `closeOnEsc`,按 Esc 触发 `onCancel`(原不响应);表情选择改为 `role="radiogroup"` 的原生 radio,外层 `span` 改为 `label`;radio、checkbox 选项组需用 `radioGroupProps`、`checkboxGroupProps` 的 `aria-label` 命名。
|
|
292
|
+
- 破坏性(类型):`textAreaProps`、`radioGroupProps`、`checkboxGroupProps` 去掉 `value`(Vue 为 `modelValue`),传入也不再覆盖 Feedback 的值;其中的 `onChange` 仍在 Feedback 处理后调用。
|
|
293
|
+
- Svelte:Feedback 的 `visible` 可绑定;`title` 是字符串或 snippet,`content`(参数含 `content`)、`footer`、`closeIcon`、`children` 是 snippet,单选、多选的选项文字用 RadioGroup、CheckboxGroup 的选项 snippet;回调为 `onOk`、`onCancel`、`onValueChange`、`afterClose`、`afterVisibleChange`;`okButtonProps`、`cancelButtonProps` 的点击用原生 `onclick`;根元素经 `bind:this` 后调用 `getRoot()` 获取。
|
|
294
|
+
- Svelte:`FeedbackProps` 是 Feedback 自身属性与 Modal、SideSheet 属性的合并类型,另导出 `FeedbackModalProps`、`FeedbackSideSheetProps`。
|