@ticatec/uniface-element 0.2.0 → 0.2.2
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 +320 -1
- package/README_CN.md +392 -0
- package/dist/accordion/Accordion.svelte +1 -1
- package/dist/action-bar/ActionBar.svelte +7 -1
- package/dist/attachment-files/FileRender.svelte +1 -1
- package/dist/attachment-files/FileUploadBar.svelte +7 -6
- package/dist/attachment-files/FileUploadPanel.svelte +2 -2
- package/dist/base-calendar/DateContext.js +5 -4
- package/dist/base-calendar/YearPickupPanel.svelte +4 -4
- package/dist/card/Card.svelte +1 -1
- package/dist/card/Card.svelte.d.ts +1 -1
- package/dist/cascade-options-select/CascadeOptionSelect.svelte +2 -3
- package/dist/cascade-options-select/CascadeOptionSelect.svelte.d.ts +46 -1
- package/dist/cascade-options-select/CascadePanel.svelte +1 -1
- package/dist/checkbox/CheckBox.svelte +1 -1
- package/dist/color-picker/ColorPicker.svelte +9 -9
- package/dist/color-picker/ColorPicker.svelte.d.ts +0 -2
- package/dist/color-picker/ColorPickerPanel.svelte +11 -15
- package/dist/color-picker/ColorPickerPanel.svelte.d.ts +1 -1
- package/dist/common/CommonPicker.svelte +2 -2
- package/dist/common/CommonPicker.svelte.d.ts +1 -1
- package/dist/common/MouseClickHandler.d.ts +1 -1
- package/dist/common/Popover.svelte +28 -6
- package/dist/common/Popover.svelte.d.ts +9 -3
- package/dist/common/uniface-utils.js +6 -4
- package/dist/common-editor/CommonEditor.svelte +1 -1
- package/dist/common-editor/CommonEditor.svelte.d.ts +1 -1
- package/dist/common-editor/NumberInput.svelte +1 -1
- package/dist/common-editor/NumberInput.svelte.d.ts +1 -1
- package/dist/concise-data-table/ConciseListTable.svelte +7 -2
- package/dist/concise-data-table/ConciseListTable.svelte.d.ts +1 -0
- package/dist/concise-data-table/DataRow.svelte +1 -1
- package/dist/concise-data-table/TableOptions.d.ts +1 -1
- package/dist/data-table/DataTable.svelte +1 -1
- package/dist/data-table/parts/ActionsPanel.svelte +4 -3
- package/dist/data-table/parts/ActionsRow.svelte +3 -3
- package/dist/data-table/parts/ContentPanel.svelte +3 -2
- package/dist/data-table/parts/FixedColumnsPanel.svelte +0 -1
- package/dist/data-table/parts/FixedColumnsPanel.svelte.d.ts +1 -2
- package/dist/data-table/parts/FixedHeaderPanel.svelte +2 -2
- package/dist/data-table/parts/FixedRow.svelte +2 -1
- package/dist/data-table/parts/FixedRow.svelte.d.ts +1 -1
- package/dist/data-table/parts/HrefCell.svelte +23 -2
- package/dist/data-table/parts/PopupMenu.svelte +25 -2
- package/dist/data-table/parts/PopupMenu.svelte.d.ts +8 -1
- package/dist/date-picker/DatePicker.svelte +0 -1
- package/dist/date-picker/DateTimePicker.svelte +3 -3
- package/dist/date-picker/ScrollBar.svelte +4 -7
- package/dist/date-range/DateRangeEditor.svelte +1 -1
- package/dist/dialog/CommonDialog.svelte +8 -5
- package/dist/dialog/CommonDialog.svelte.d.ts +2 -1
- package/dist/dialog/Dialog.svelte +37 -12
- package/dist/dialog/Dialog.svelte.d.ts +4 -3
- package/dist/dialog/DialogBoard.svelte +11 -8
- package/dist/dialog/DialogWrapper.svelte +10 -0
- package/dist/{common-editor/DateInput.svelte.d.ts → dialog/DialogWrapper.svelte.d.ts} +6 -13
- package/dist/dialog/Dialogs.js +1 -1
- package/dist/dialog/ModalResult.d.ts +5 -0
- package/dist/dialog/ModalResult.js +5 -0
- package/dist/drawer/Drawer.svelte +1 -1
- package/dist/form-field/FormField.svelte +2 -1
- package/dist/form-field/FormField.svelte.d.ts +1 -0
- package/dist/form-panel/flex-row-form/FormContainer.svelte +1 -1
- package/dist/form-panel/grid-form/EmptyCell.svelte +8 -7
- package/dist/form-panel/grid-form/EmptyCell.svelte.d.ts +2 -2
- package/dist/form-panel/grid-form/GridField.svelte +1 -1
- package/dist/i18nRes/i18nRes.d.ts +2 -0
- package/dist/i18nRes/i18nRes.js +44 -0
- package/dist/i18nRes/index.d.ts +2 -0
- package/dist/i18nRes/index.js +2 -0
- package/dist/image-files/ImageFilesField.svelte +1 -1
- package/dist/indicator/IndicatorBoard.svelte +1 -1
- package/dist/inline-cell-editor/InvalidEditor.svelte +1 -0
- package/dist/input-options-select/InputOptionsSelect.svelte +6 -6
- package/dist/input-options-select/InputOptionsSelect.svelte.d.ts +1 -1
- package/dist/layout/flex/FlexBlock.svelte +1 -1
- package/dist/lookup-editor/LookupEditor.svelte +1 -1
- package/dist/memo-editor/MemoEditor.svelte +2 -2
- package/dist/message-box/IMessageBox.d.ts +2 -4
- package/dist/message-box/IMessageBox.js +4 -6
- package/dist/message-box/MessageBoxBoard.svelte +1 -3
- package/dist/options-multi-select/OptionsMultiSelect.svelte +1 -1
- package/dist/prompts-text-editor/PromptsTextEditor.svelte +2 -2
- package/dist/prompts-text-editor/PromptsTextEditor.svelte.d.ts +1 -1
- package/dist/property-editor/PropertyEditor.svelte +3 -3
- package/dist/text-editor/PasswordEditor.svelte +1 -1
- package/dist/transfer/Transfer.svelte +17 -12
- package/dist/transfer/Transfer.svelte.d.ts +0 -1
- package/dist/unit-number-editor/UnitNumberEditor.svelte +2 -2
- package/docs/buttons/cn/ActionBar.md +459 -0
- package/docs/buttons/cn/Button.md +228 -0
- package/docs/buttons/cn/IconButton.md +294 -0
- package/docs/buttons/cn/README.md +600 -0
- package/docs/buttons/cn/TextButton.md +163 -0
- package/docs/buttons/en/ActionBar.md +459 -0
- package/docs/buttons/en/Button.md +228 -0
- package/docs/buttons/en/IconButton.md +294 -0
- package/docs/buttons/en/README.md +600 -0
- package/docs/buttons/en/TextButton.md +163 -0
- package/docs/containers/cn/accordion.md +622 -0
- package/docs/containers/cn/box.md +445 -0
- package/docs/containers/cn/card.md +404 -0
- package/docs/containers/cn/page.md +576 -0
- package/docs/containers/cn/tabs.md +686 -0
- package/docs/containers/en/accordion.md +622 -0
- package/docs/containers/en/box.md +445 -0
- package/docs/containers/en/card.md +404 -0
- package/docs/containers/en/page.md +576 -0
- package/docs/containers/en/tabs.md +686 -0
- package/docs/data-display/cn/concise-data-table.md +731 -0
- package/docs/data-display/cn/listbox.md +786 -0
- package/docs/data-display/cn/treeview.md +863 -0
- package/docs/data-display/en/concise-data-table.md +732 -0
- package/docs/data-display/en/listbox.md +786 -0
- package/docs/data-display/en/treeview.md +863 -0
- package/docs/data-table/cn/README.md +596 -0
- package/docs/data-table/en/README.md +596 -0
- package/docs/dialog/cn/README.md +767 -0
- package/docs/dialog/en/README.md +767 -0
- package/docs/form/cn/README.md +847 -0
- package/docs/form/en/README.md +847 -0
- package/docs/form-components/cn/README.md +495 -0
- package/docs/form-components/cn/attachmentfilesfield.md +757 -0
- package/docs/form-components/cn/cascade-options-select.md +374 -0
- package/docs/form-components/cn/checkbox.md +58 -0
- package/docs/form-components/cn/date-picker.md +138 -0
- package/docs/form-components/cn/datetime-picker.md +228 -0
- package/docs/form-components/cn/group-checkbox.md +405 -0
- package/docs/form-components/cn/group-radiobox.md +525 -0
- package/docs/form-components/cn/imagefilesfield.md +651 -0
- package/docs/form-components/cn/input-options-select.md +250 -0
- package/docs/form-components/cn/lookup-editor.md +406 -0
- package/docs/form-components/cn/memoeditor.md +409 -0
- package/docs/form-components/cn/number-editor.md +261 -0
- package/docs/form-components/cn/options-multi-select.md +177 -0
- package/docs/form-components/cn/options-select.md +83 -0
- package/docs/form-components/cn/passwordeditor.md +538 -0
- package/docs/form-components/cn/prompts-text-editor.md +241 -0
- package/docs/form-components/cn/radiobutton.md +84 -0
- package/docs/form-components/cn/switch.md +178 -0
- package/docs/form-components/cn/text-editor.md +142 -0
- package/docs/form-components/cn/time-editor.md +159 -0
- package/docs/form-components/cn/unit-number-editor.md +164 -0
- package/docs/form-components/en/README.md +463 -0
- package/docs/form-components/en/attachmentfilesfield.md +757 -0
- package/docs/form-components/en/cascade-options-select.md +358 -0
- package/docs/form-components/en/checkbox.md +59 -0
- package/docs/form-components/en/date-picker.md +138 -0
- package/docs/form-components/en/datetime-picker.md +228 -0
- package/docs/form-components/en/group-checkbox.md +395 -0
- package/docs/form-components/en/group-radiobox.md +498 -0
- package/docs/form-components/en/imagefilesfield.md +651 -0
- package/docs/form-components/en/input-options-select.md +239 -0
- package/docs/form-components/en/lookup-editor.md +389 -0
- package/docs/form-components/en/memoeditor.md +409 -0
- package/docs/form-components/en/number-editor.md +249 -0
- package/docs/form-components/en/options-multi-select.md +177 -0
- package/docs/form-components/en/options-select.md +83 -0
- package/docs/form-components/en/passwordeditor.md +538 -0
- package/docs/form-components/en/prompts-text-editor.md +241 -0
- package/docs/form-components/en/radiobutton.md +84 -0
- package/docs/form-components/en/switch.md +180 -0
- package/docs/form-components/en/text-editor.md +142 -0
- package/docs/form-components/en/time-editor.md +159 -0
- package/docs/form-components/en/unit-number-editor.md +164 -0
- package/docs/form-layout/cn/criteria-field.md +652 -0
- package/docs/form-layout/cn/flex-form.md +454 -0
- package/docs/form-layout/cn/flex-row-form.md +542 -0
- package/docs/form-layout/cn/form-field.md +923 -0
- package/docs/form-layout/cn/grid-form.md +676 -0
- package/docs/form-layout/en/criteria-field.md +652 -0
- package/docs/form-layout/en/flex-form.md +454 -0
- package/docs/form-layout/en/flex-row-form.md +542 -0
- package/docs/form-layout/en/form-field.md +923 -0
- package/docs/form-layout/en/grid-form.md +676 -0
- package/docs/global/cn/README.md +534 -0
- package/docs/global/en/README.md +534 -0
- package/docs/layout/cn/classiclayout.md +460 -0
- package/docs/layout/cn/headerlayout.md +524 -0
- package/docs/layout/cn/sidebarlayout.md +263 -0
- package/docs/layout/en/classiclayout.md +951 -0
- package/docs/layout/en/headerlayout.md +524 -0
- package/docs/layout/en/sidebarlayout.md +262 -0
- package/docs/misc/cn/README.md +1217 -0
- package/docs/misc/en/README.md +1217 -0
- package/docs/navigation/cn/breadcrumb.md +291 -0
- package/docs/navigation/cn/navigator.md +322 -0
- package/docs/navigation/cn/navigatormenu.md +512 -0
- package/docs/navigation/cn/progressbar.md +199 -0
- package/docs/navigation/cn/progressstepbar.md +299 -0
- package/docs/navigation/en/breadcrumb.md +291 -0
- package/docs/navigation/en/navigator.md +322 -0
- package/docs/navigation/en/navigatormenu.md +512 -0
- package/docs/navigation/en/progressbar.md +199 -0
- package/docs/navigation/en/progressstepbar.md +299 -0
- package/docs/search-filters/cn/daterange.md +1156 -0
- package/docs/search-filters/cn/numberrange.md +688 -0
- package/docs/search-filters/cn/searchbox.md +1582 -0
- package/docs/search-filters/en/daterange.md +1156 -0
- package/docs/search-filters/en/numberrange.md +688 -0
- package/docs/search-filters/en/searchbox.md +1582 -0
- package/package.json +53 -13
- package/dist/common-editor/DateInput.svelte +0 -27
- package/dist/i18n_resources/index.d.ts +0 -3
- package/dist/i18n_resources/index.js +0 -3
- /package/dist/{i18n_resources → i18nRes}/uniface_cn_resource.d.ts +0 -0
- /package/dist/{i18n_resources → i18nRes}/uniface_cn_resource.js +0 -0
- /package/dist/{i18n_resources → i18nRes}/uniface_en_resource.d.ts +0 -0
- /package/dist/{i18n_resources → i18nRes}/uniface_en_resource.js +0 -0
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
# ProgressStepBar 步骤进度条组件
|
|
2
|
+
|
|
3
|
+
ProgressStepBar 组件提供多步骤流程的可视化展示,显示每个步骤的当前状态和进度。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- **多步骤可视化**:显示多个顺序步骤的进度
|
|
8
|
+
- **状态指示器**:每个步骤的等待、处理中和已完成状态
|
|
9
|
+
- **灵活布局**:支持水平和垂直两种方向
|
|
10
|
+
- **可定制样式**:可配置背景色和样式
|
|
11
|
+
- **步骤信息**:支持标题和可选的备注说明
|
|
12
|
+
|
|
13
|
+
## 导入
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { ProgressStepBar, ProgressStep, ProgressStepStatus } from '@ticatec/uniface-element/ProgressStepBar';
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## 基本用法
|
|
20
|
+
|
|
21
|
+
### 水平步骤条
|
|
22
|
+
|
|
23
|
+
```svelte
|
|
24
|
+
<script>
|
|
25
|
+
import { ProgressStepBar, ProgressStepStatus } from '@ticatec/uniface-element/ProgressStepBar';
|
|
26
|
+
|
|
27
|
+
const steps = [
|
|
28
|
+
{
|
|
29
|
+
topic: "账户设置",
|
|
30
|
+
comment: "创建您的档案",
|
|
31
|
+
status: ProgressStepStatus.Completed
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
topic: "身份验证",
|
|
35
|
+
comment: "验证您的邮箱",
|
|
36
|
+
status: ProgressStepStatus.Processing
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
topic: "完善资料",
|
|
40
|
+
comment: "添加个人详情",
|
|
41
|
+
status: ProgressStepStatus.Pending
|
|
42
|
+
}
|
|
43
|
+
];
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<ProgressStepBar
|
|
47
|
+
{steps}
|
|
48
|
+
direction="horizontal"
|
|
49
|
+
/>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 垂直步骤条
|
|
53
|
+
|
|
54
|
+
```svelte
|
|
55
|
+
<script>
|
|
56
|
+
import { ProgressStepBar, ProgressStepStatus } from '@ticatec/uniface-element/ProgressStepBar';
|
|
57
|
+
|
|
58
|
+
const workflowSteps = [
|
|
59
|
+
{
|
|
60
|
+
topic: "审阅文档",
|
|
61
|
+
status: ProgressStepStatus.Completed
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
topic: "经理审批",
|
|
65
|
+
status: ProgressStepStatus.Processing
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
topic: "最终处理",
|
|
69
|
+
status: ProgressStepStatus.Pending
|
|
70
|
+
}
|
|
71
|
+
];
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
<ProgressStepBar
|
|
75
|
+
steps={workflowSteps}
|
|
76
|
+
direction="vertical"
|
|
77
|
+
backgroundColor="#f8f9fa"
|
|
78
|
+
/>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## API 参考
|
|
82
|
+
|
|
83
|
+
### 属性
|
|
84
|
+
|
|
85
|
+
| 属性 | 类型 | 默认值 | 描述 |
|
|
86
|
+
|------|------|--------|------|
|
|
87
|
+
| `steps` | `Array<ProgressStep>` | 必需 | 步骤对象数组 |
|
|
88
|
+
| `direction` | `'vertical' \| 'horizontal'` | `'horizontal'` | 布局方向 |
|
|
89
|
+
| `backgroundColor` | `string` | `'var(--uniface-progress-step-bar-bg, #ffffff)'` | 背景颜色 |
|
|
90
|
+
| `style` | `string` | `''` | 附加CSS样式 |
|
|
91
|
+
|
|
92
|
+
### ProgressStep 接口
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
interface ProgressStep {
|
|
96
|
+
topic: string; // 步骤标题
|
|
97
|
+
comment?: string; // 可选的步骤描述
|
|
98
|
+
status: ProgressStepStatus; // 当前状态
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### ProgressStepStatus 枚举
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
enum ProgressStepStatus {
|
|
106
|
+
Pending = 'pending', // 未开始
|
|
107
|
+
Processing = 'processing', // 当前活动
|
|
108
|
+
Completed = 'completed' // 已完成
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## 详细示例
|
|
113
|
+
|
|
114
|
+
### 电商结账流程
|
|
115
|
+
|
|
116
|
+
```svelte
|
|
117
|
+
<script>
|
|
118
|
+
import { ProgressStepBar, ProgressStepStatus } from '@ticatec/uniface-element/ProgressStepBar';
|
|
119
|
+
|
|
120
|
+
let checkoutSteps = [
|
|
121
|
+
{
|
|
122
|
+
topic: "购物车",
|
|
123
|
+
comment: "查看您的商品",
|
|
124
|
+
status: ProgressStepStatus.Completed
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
topic: "配送信息",
|
|
128
|
+
comment: "输入配送详情",
|
|
129
|
+
status: ProgressStepStatus.Completed
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
topic: "支付",
|
|
133
|
+
comment: "选择支付方式",
|
|
134
|
+
status: ProgressStepStatus.Processing
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
topic: "确认",
|
|
138
|
+
comment: "审核并完成",
|
|
139
|
+
status: ProgressStepStatus.Pending
|
|
140
|
+
}
|
|
141
|
+
];
|
|
142
|
+
|
|
143
|
+
const nextStep = () => {
|
|
144
|
+
const currentIndex = checkoutSteps.findIndex(step =>
|
|
145
|
+
step.status === ProgressStepStatus.Processing
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
if (currentIndex >= 0 && currentIndex < checkoutSteps.length - 1) {
|
|
149
|
+
checkoutSteps[currentIndex].status = ProgressStepStatus.Completed;
|
|
150
|
+
checkoutSteps[currentIndex + 1].status = ProgressStepStatus.Processing;
|
|
151
|
+
checkoutSteps = [...checkoutSteps]; // 触发响应式更新
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
</script>
|
|
155
|
+
|
|
156
|
+
<div class="checkout-container">
|
|
157
|
+
<ProgressStepBar steps={checkoutSteps} />
|
|
158
|
+
<button on:click={nextStep}>下一步</button>
|
|
159
|
+
</div>
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### 表单向导与验证
|
|
163
|
+
|
|
164
|
+
```svelte
|
|
165
|
+
<script>
|
|
166
|
+
import { ProgressStepBar, ProgressStepStatus } from '@ticatec/uniface-element/ProgressStepBar';
|
|
167
|
+
|
|
168
|
+
let formSteps = [
|
|
169
|
+
{
|
|
170
|
+
topic: "个人信息",
|
|
171
|
+
comment: "姓名、邮箱、电话",
|
|
172
|
+
status: ProgressStepStatus.Processing
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
topic: "地址详情",
|
|
176
|
+
comment: "配送和账单地址",
|
|
177
|
+
status: ProgressStepStatus.Pending
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
topic: "偏好设置",
|
|
181
|
+
comment: "通信设置",
|
|
182
|
+
status: ProgressStepStatus.Pending
|
|
183
|
+
}
|
|
184
|
+
];
|
|
185
|
+
|
|
186
|
+
let currentStepIndex = 0;
|
|
187
|
+
|
|
188
|
+
const completeCurrentStep = () => {
|
|
189
|
+
if (currentStepIndex < formSteps.length) {
|
|
190
|
+
formSteps[currentStepIndex].status = ProgressStepStatus.Completed;
|
|
191
|
+
|
|
192
|
+
if (currentStepIndex < formSteps.length - 1) {
|
|
193
|
+
currentStepIndex++;
|
|
194
|
+
formSteps[currentStepIndex].status = ProgressStepStatus.Processing;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
formSteps = [...formSteps];
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
</script>
|
|
201
|
+
|
|
202
|
+
<div class="form-wizard">
|
|
203
|
+
<ProgressStepBar
|
|
204
|
+
steps={formSteps}
|
|
205
|
+
direction="horizontal"
|
|
206
|
+
style="margin-bottom: 20px;"
|
|
207
|
+
/>
|
|
208
|
+
|
|
209
|
+
<div class="step-content">
|
|
210
|
+
<h3>{formSteps[currentStepIndex]?.topic}</h3>
|
|
211
|
+
<p>{formSteps[currentStepIndex]?.comment}</p>
|
|
212
|
+
|
|
213
|
+
{#if currentStepIndex < formSteps.length}
|
|
214
|
+
<button on:click={completeCurrentStep}>
|
|
215
|
+
完成步骤
|
|
216
|
+
</button>
|
|
217
|
+
{/if}
|
|
218
|
+
</div>
|
|
219
|
+
</div>
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### 文件上传流程
|
|
223
|
+
|
|
224
|
+
```svelte
|
|
225
|
+
<script>
|
|
226
|
+
import { ProgressStepBar, ProgressStepStatus } from '@ticatec/uniface-element/ProgressStepBar';
|
|
227
|
+
|
|
228
|
+
let uploadSteps = [
|
|
229
|
+
{
|
|
230
|
+
topic: "选择文件",
|
|
231
|
+
status: ProgressStepStatus.Completed
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
topic: "上传",
|
|
235
|
+
comment: "传输文件中...",
|
|
236
|
+
status: ProgressStepStatus.Processing
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
topic: "处理",
|
|
240
|
+
comment: "分析内容",
|
|
241
|
+
status: ProgressStepStatus.Pending
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
topic: "完成",
|
|
245
|
+
comment: "文件就绪",
|
|
246
|
+
status: ProgressStepStatus.Pending
|
|
247
|
+
}
|
|
248
|
+
];
|
|
249
|
+
|
|
250
|
+
const simulateUpload = async () => {
|
|
251
|
+
// 模拟上传过程
|
|
252
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
253
|
+
uploadSteps[1].status = ProgressStepStatus.Completed;
|
|
254
|
+
uploadSteps[2].status = ProgressStepStatus.Processing;
|
|
255
|
+
uploadSteps = [...uploadSteps];
|
|
256
|
+
|
|
257
|
+
// 模拟处理
|
|
258
|
+
await new Promise(resolve => setTimeout(resolve, 1500));
|
|
259
|
+
uploadSteps[2].status = ProgressStepStatus.Completed;
|
|
260
|
+
uploadSteps[3].status = ProgressStepStatus.Processing;
|
|
261
|
+
uploadSteps = [...uploadSteps];
|
|
262
|
+
|
|
263
|
+
// 完成
|
|
264
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
265
|
+
uploadSteps[3].status = ProgressStepStatus.Completed;
|
|
266
|
+
uploadSteps = [...uploadSteps];
|
|
267
|
+
};
|
|
268
|
+
</script>
|
|
269
|
+
|
|
270
|
+
<ProgressStepBar
|
|
271
|
+
steps={uploadSteps}
|
|
272
|
+
direction="vertical"
|
|
273
|
+
/>
|
|
274
|
+
<button on:click={simulateUpload}>开始上传</button>
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
## 最佳实践
|
|
278
|
+
|
|
279
|
+
1. **清晰的步骤名称**:使用描述性、面向操作的步骤标题
|
|
280
|
+
2. **有用的备注**:为每个步骤提供上下文说明
|
|
281
|
+
3. **逻辑进展**:确保步骤遵循自然的顺序
|
|
282
|
+
4. **状态管理**:保持状态更新与实际进度同步
|
|
283
|
+
5. **用户指导**:显示用户在每个步骤中的期望操作
|
|
284
|
+
6. **错误处理**:考虑如何处理步骤失败或验证错误
|
|
285
|
+
7. **响应式设计**:在不同屏幕尺寸上测试两种方向
|
|
286
|
+
|
|
287
|
+
## 样式提示
|
|
288
|
+
|
|
289
|
+
- 在步骤之间使用一致的间距和排版
|
|
290
|
+
- 考虑使用自定义CSS变量进行主题集成
|
|
291
|
+
- 测试状态指示器的可见性和对比度
|
|
292
|
+
- 确保移动界面有足够的触摸目标
|
|
293
|
+
|
|
294
|
+
## 无障碍访问说明
|
|
295
|
+
|
|
296
|
+
- 步骤进展提供清晰的视觉反馈
|
|
297
|
+
- 状态变化通过样式和定位表示
|
|
298
|
+
- 在实现自定义交互时考虑为屏幕阅读器添加ARIA标签
|
|
299
|
+
- 确保状态指示器有足够的颜色对比度
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
# Breadcrumb Component
|
|
2
|
+
|
|
3
|
+
The Breadcrumb component provides hierarchical navigation that shows the user's current location within the application structure and allows navigation back to parent levels.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Hierarchical Navigation**: Shows the path from root to current location
|
|
8
|
+
- **Customizable Separator**: Configurable separator character between items
|
|
9
|
+
- **Click Navigation**: Click handlers for navigating to parent levels
|
|
10
|
+
- **Flexible Data Structure**: Support for custom data objects
|
|
11
|
+
- **Styling Support**: Custom styles and CSS integration
|
|
12
|
+
|
|
13
|
+
## Import
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { Breadcrumbs, Breadcrumb } from '@ticatec/uniface-element/Breadcrumbs';
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Basic Usage
|
|
20
|
+
|
|
21
|
+
### Simple Breadcrumb
|
|
22
|
+
|
|
23
|
+
```svelte
|
|
24
|
+
<script>
|
|
25
|
+
import Breadcrumbs from '@ticatec/uniface-element/Breadcrumbs';
|
|
26
|
+
|
|
27
|
+
const breadcrumbItems = [
|
|
28
|
+
{ label: "Home", data: { route: "/" } },
|
|
29
|
+
{ label: "Products", data: { route: "/products" } },
|
|
30
|
+
{ label: "Electronics", data: { route: "/products/electronics" } },
|
|
31
|
+
{ label: "Laptops", data: { route: "/products/electronics/laptops" } }
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
const handleItemClick = (data) => (event) => {
|
|
35
|
+
console.log('Navigate to:', data.route);
|
|
36
|
+
// Handle navigation logic here
|
|
37
|
+
};
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<Breadcrumbs
|
|
41
|
+
items={breadcrumbItems}
|
|
42
|
+
onItemClick={handleItemClick}
|
|
43
|
+
/>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Custom Separator
|
|
47
|
+
|
|
48
|
+
```svelte
|
|
49
|
+
<script>
|
|
50
|
+
import Breadcrumbs from '@ticatec/uniface-element/Breadcrumbs';
|
|
51
|
+
|
|
52
|
+
const pathItems = [
|
|
53
|
+
{ label: "Dashboard", data: { id: 1 } },
|
|
54
|
+
{ label: "User Management", data: { id: 2 } },
|
|
55
|
+
{ label: "Edit Profile", data: { id: 3 } }
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
const navigate = (data) => (event) => {
|
|
59
|
+
console.log('Navigating to item:', data.id);
|
|
60
|
+
};
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<Breadcrumbs
|
|
64
|
+
items={pathItems}
|
|
65
|
+
separator=">"
|
|
66
|
+
onItemClick={navigate}
|
|
67
|
+
style="padding: 10px; background: #f5f5f5;"
|
|
68
|
+
/>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## API Reference
|
|
72
|
+
|
|
73
|
+
### Props
|
|
74
|
+
|
|
75
|
+
| Property | Type | Default | Description |
|
|
76
|
+
|----------|------|---------|-------------|
|
|
77
|
+
| `items` | `Array<Breadcrumb>` | `[]` | Array of breadcrumb items |
|
|
78
|
+
| `separator` | `string` | `"/"` | Separator character between items |
|
|
79
|
+
| `onItemClick` | `(item: any) => (event: MouseEvent) => void` | required | Click handler function |
|
|
80
|
+
| `style` | `string` | `''` | Additional CSS styles |
|
|
81
|
+
|
|
82
|
+
### Breadcrumb Interface
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
interface Breadcrumb {
|
|
86
|
+
label: string; // Display text
|
|
87
|
+
data: any; // Associated data object
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Advanced Examples
|
|
92
|
+
|
|
93
|
+
### File System Navigation
|
|
94
|
+
|
|
95
|
+
```svelte
|
|
96
|
+
<script>
|
|
97
|
+
import Breadcrumbs from '@ticatec/uniface-element/Breadcrumbs';
|
|
98
|
+
|
|
99
|
+
let currentPath = [
|
|
100
|
+
{ label: "Documents", data: { path: "/documents", type: "folder" } },
|
|
101
|
+
{ label: "Projects", data: { path: "/documents/projects", type: "folder" } },
|
|
102
|
+
{ label: "WebApp", data: { path: "/documents/projects/webapp", type: "folder" } },
|
|
103
|
+
{ label: "src", data: { path: "/documents/projects/webapp/src", type: "folder" } }
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
const navigateToPath = (data) => (event) => {
|
|
107
|
+
// Find the index of the clicked item
|
|
108
|
+
const clickedIndex = currentPath.findIndex(item => item.data.path === data.path);
|
|
109
|
+
|
|
110
|
+
if (clickedIndex >= 0) {
|
|
111
|
+
// Truncate the path to the clicked item
|
|
112
|
+
currentPath = currentPath.slice(0, clickedIndex + 1);
|
|
113
|
+
console.log('Navigated to:', data.path);
|
|
114
|
+
|
|
115
|
+
// In a real app, you'd update your file browser state here
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const addFolder = () => {
|
|
120
|
+
currentPath = [...currentPath, {
|
|
121
|
+
label: "components",
|
|
122
|
+
data: { path: currentPath[currentPath.length - 1].data.path + "/components", type: "folder" }
|
|
123
|
+
}];
|
|
124
|
+
};
|
|
125
|
+
</script>
|
|
126
|
+
|
|
127
|
+
<div class="file-navigator">
|
|
128
|
+
<Breadcrumbs
|
|
129
|
+
items={currentPath}
|
|
130
|
+
separator="/"
|
|
131
|
+
onItemClick={navigateToPath}
|
|
132
|
+
style="font-family: monospace; background: #f8f8f8; padding: 8px; border-radius: 4px;"
|
|
133
|
+
/>
|
|
134
|
+
|
|
135
|
+
<button on:click={addFolder}>Add Components Folder</button>
|
|
136
|
+
</div>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### E-commerce Category Navigation
|
|
140
|
+
|
|
141
|
+
```svelte
|
|
142
|
+
<script>
|
|
143
|
+
import Breadcrumbs from '@ticatec/uniface-element/Breadcrumbs';
|
|
144
|
+
|
|
145
|
+
let categoryPath = [
|
|
146
|
+
{ label: "All Categories", data: { categoryId: null, slug: "" } }
|
|
147
|
+
];
|
|
148
|
+
|
|
149
|
+
const categories = [
|
|
150
|
+
{ id: 1, name: "Electronics", parent: null, slug: "electronics" },
|
|
151
|
+
{ id: 2, name: "Computers", parent: 1, slug: "computers" },
|
|
152
|
+
{ id: 3, name: "Laptops", parent: 2, slug: "laptops" },
|
|
153
|
+
{ id: 4, name: "Gaming Laptops", parent: 3, slug: "gaming-laptops" }
|
|
154
|
+
];
|
|
155
|
+
|
|
156
|
+
const navigateToCategory = (data) => (event) => {
|
|
157
|
+
if (data.categoryId === null) {
|
|
158
|
+
// Navigate to root
|
|
159
|
+
categoryPath = [categoryPath[0]];
|
|
160
|
+
} else {
|
|
161
|
+
// Find the clicked category and rebuild path
|
|
162
|
+
const clickedIndex = categoryPath.findIndex(
|
|
163
|
+
item => item.data.categoryId === data.categoryId
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
if (clickedIndex >= 0) {
|
|
167
|
+
categoryPath = categoryPath.slice(0, clickedIndex + 1);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
console.log('Category path updated:', categoryPath);
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const drillDownCategory = (categoryId) => {
|
|
175
|
+
const category = categories.find(c => c.id === categoryId);
|
|
176
|
+
if (category) {
|
|
177
|
+
categoryPath = [...categoryPath, {
|
|
178
|
+
label: category.name,
|
|
179
|
+
data: { categoryId: category.id, slug: category.slug }
|
|
180
|
+
}];
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
</script>
|
|
184
|
+
|
|
185
|
+
<div class="category-navigation">
|
|
186
|
+
<Breadcrumbs
|
|
187
|
+
items={categoryPath}
|
|
188
|
+
separator="›"
|
|
189
|
+
onItemClick={navigateToCategory}
|
|
190
|
+
style="margin-bottom: 15px;"
|
|
191
|
+
/>
|
|
192
|
+
|
|
193
|
+
<div class="category-actions">
|
|
194
|
+
<button on:click={() => drillDownCategory(1)}>Go to Electronics</button>
|
|
195
|
+
<button on:click={() => drillDownCategory(2)}>Go to Computers</button>
|
|
196
|
+
<button on:click={() => drillDownCategory(3)}>Go to Laptops</button>
|
|
197
|
+
<button on:click={() => drillDownCategory(4)}>Go to Gaming</button>
|
|
198
|
+
</div>
|
|
199
|
+
</div>
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Multi-step Form Navigation
|
|
203
|
+
|
|
204
|
+
```svelte
|
|
205
|
+
<script>
|
|
206
|
+
import Breadcrumbs from '@ticatec/uniface-element/Breadcrumbs';
|
|
207
|
+
|
|
208
|
+
const formSteps = [
|
|
209
|
+
{ id: 1, name: "Account Info", completed: true },
|
|
210
|
+
{ id: 2, name: "Personal Details", completed: true },
|
|
211
|
+
{ id: 3, name: "Preferences", completed: false },
|
|
212
|
+
{ id: 4, name: "Confirmation", completed: false }
|
|
213
|
+
];
|
|
214
|
+
|
|
215
|
+
let currentStepId = 3;
|
|
216
|
+
|
|
217
|
+
// Build breadcrumb from completed steps + current step
|
|
218
|
+
$: breadcrumbItems = formSteps
|
|
219
|
+
.filter((step, index) => step.completed || step.id === currentStepId)
|
|
220
|
+
.map(step => ({
|
|
221
|
+
label: step.name,
|
|
222
|
+
data: { stepId: step.id, completed: step.completed }
|
|
223
|
+
}));
|
|
224
|
+
|
|
225
|
+
const navigateToStep = (data) => (event) => {
|
|
226
|
+
// Only allow navigation to completed steps
|
|
227
|
+
if (data.completed) {
|
|
228
|
+
currentStepId = data.stepId;
|
|
229
|
+
console.log('Navigated to step:', data.stepId);
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
const completeCurrentStep = () => {
|
|
234
|
+
const step = formSteps.find(s => s.id === currentStepId);
|
|
235
|
+
if (step) {
|
|
236
|
+
step.completed = true;
|
|
237
|
+
|
|
238
|
+
// Move to next uncompleted step
|
|
239
|
+
const nextStep = formSteps.find(s => !s.completed);
|
|
240
|
+
if (nextStep) {
|
|
241
|
+
currentStepId = nextStep.id;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
</script>
|
|
246
|
+
|
|
247
|
+
<div class="form-breadcrumb">
|
|
248
|
+
<Breadcrumbs
|
|
249
|
+
items={breadcrumbItems}
|
|
250
|
+
separator="→"
|
|
251
|
+
onItemClick={navigateToStep}
|
|
252
|
+
style="background: linear-gradient(90deg, #e3f2fd, #bbdefb); padding: 10px; border-radius: 8px;"
|
|
253
|
+
/>
|
|
254
|
+
|
|
255
|
+
<div class="form-controls">
|
|
256
|
+
<p>Current Step: {formSteps.find(s => s.id === currentStepId)?.name}</p>
|
|
257
|
+
<button on:click={completeCurrentStep}>Complete Step</button>
|
|
258
|
+
</div>
|
|
259
|
+
</div>
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## Best Practices
|
|
263
|
+
|
|
264
|
+
1. **Clear Labels**: Use descriptive, concise labels that clearly indicate the location
|
|
265
|
+
2. **Logical Hierarchy**: Ensure breadcrumbs reflect actual application structure
|
|
266
|
+
3. **Clickable Parents**: Make parent levels clickable for easy navigation
|
|
267
|
+
4. **Current Item Behavior**: The last item typically shouldn't be clickable (represents current location)
|
|
268
|
+
5. **Responsive Design**: Consider how breadcrumbs appear on mobile devices
|
|
269
|
+
6. **Consistent Separators**: Use appropriate separators for your design system
|
|
270
|
+
7. **Performance**: Avoid rebuilding breadcrumbs unnecessarily
|
|
271
|
+
|
|
272
|
+
## Styling Notes
|
|
273
|
+
|
|
274
|
+
- The component renders each item with a separator prefix
|
|
275
|
+
- The last item (current location) has click handler set to null
|
|
276
|
+
- Custom styles can be applied via the `style` prop
|
|
277
|
+
- Consider using CSS for hover effects on clickable items
|
|
278
|
+
|
|
279
|
+
## Accessibility Considerations
|
|
280
|
+
|
|
281
|
+
- Breadcrumbs provide context about page location
|
|
282
|
+
- Click handlers should provide keyboard support
|
|
283
|
+
- Consider ARIA labels for screen readers
|
|
284
|
+
- Ensure sufficient color contrast for text and separators
|
|
285
|
+
|
|
286
|
+
## Integration Tips
|
|
287
|
+
|
|
288
|
+
- Use with routing libraries to sync with URL structure
|
|
289
|
+
- Combine with page titles for better user orientation
|
|
290
|
+
- Consider auto-generating from route configurations
|
|
291
|
+
- Test truncation behavior for very long paths
|