@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,534 @@
|
|
|
1
|
+
# Global Components
|
|
2
|
+
|
|
3
|
+
Global components are mounted directly to the document body and can be accessed through global methods without needing to import them in each component. These provide application-wide functionality for user feedback and modal interactions.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Setup](#setup)
|
|
8
|
+
- [ToastBoard](#toastboard)
|
|
9
|
+
- [DialogBoard](#dialogboard)
|
|
10
|
+
- [IndicatorBoard](#indicatorboard)
|
|
11
|
+
- [MessageBoxBoard](#messageboxboard)
|
|
12
|
+
- [TypeScript Declarations](#typescript-declarations)
|
|
13
|
+
- [Best Practices](#best-practices)
|
|
14
|
+
|
|
15
|
+
## Setup
|
|
16
|
+
|
|
17
|
+
To use global components, you need to include them in your main application layout, typically in your root `+layout.svelte` or `app.html`:
|
|
18
|
+
|
|
19
|
+
```svelte
|
|
20
|
+
<script lang="ts">
|
|
21
|
+
import { ToastBoard } from "@ticatec/uniface-element/ToastBoard";
|
|
22
|
+
import { DialogBoard } from "@ticatec/uniface-element/DialogBoard";
|
|
23
|
+
import { IndicatorBoard } from "@ticatec/uniface-element/IndicatorBoard";
|
|
24
|
+
import { MessageBoxBoard } from "@ticatec/uniface-element/MessageBoxBoard";
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<!-- Your main application content -->
|
|
28
|
+
<main>
|
|
29
|
+
<slot />
|
|
30
|
+
</main>
|
|
31
|
+
|
|
32
|
+
<!-- Global components - these will be mounted to document.body -->
|
|
33
|
+
<ToastBoard />
|
|
34
|
+
<DialogBoard />
|
|
35
|
+
<IndicatorBoard />
|
|
36
|
+
<MessageBoxBoard />
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Once mounted, these components register themselves to the global `window` object and can be accessed anywhere in your application.
|
|
40
|
+
|
|
41
|
+
## ToastBoard
|
|
42
|
+
|
|
43
|
+
The `ToastBoard` component provides non-blocking notifications for user feedback, such as success messages, errors, or informational alerts.
|
|
44
|
+
|
|
45
|
+
### Features
|
|
46
|
+
|
|
47
|
+
- **Multiple Types**: Support for `error`, `info`, and `success` message types
|
|
48
|
+
- **Auto Dismiss**: Configurable duration with automatic dismissal
|
|
49
|
+
- **Smooth Animations**: Slide-in/slide-out transitions with customizable direction
|
|
50
|
+
- **Queue Management**: Handles multiple toast messages gracefully
|
|
51
|
+
|
|
52
|
+
### Usage
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
// Basic usage - shows error message for 3 seconds (default)
|
|
56
|
+
window.Toast.show("Operation failed");
|
|
57
|
+
|
|
58
|
+
// Specify message type and duration
|
|
59
|
+
window.Toast.show("User created successfully", "success", 2);
|
|
60
|
+
window.Toast.show("Processing your request...", "info", 5);
|
|
61
|
+
window.Toast.show("Invalid input data", "error", 4);
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### API Reference
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
interface Toast {
|
|
68
|
+
show: (message: string, type?: "error" | "info" | "success", duration?: number) => void;
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
#### Parameters
|
|
73
|
+
|
|
74
|
+
- **message** (`string`): The text to display in the toast
|
|
75
|
+
- **type** (`"error" | "info" | "success"`, optional): Visual style of the toast
|
|
76
|
+
- `"error"` (default): Red styling for error messages
|
|
77
|
+
- `"info"`: Blue styling for informational messages
|
|
78
|
+
- `"success"`: Green styling for success messages
|
|
79
|
+
- **duration** (`number`, optional): Display duration in seconds (default: 3)
|
|
80
|
+
|
|
81
|
+
### Properties
|
|
82
|
+
|
|
83
|
+
```svelte
|
|
84
|
+
<ToastBoard fromBottom={false} />
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
- **fromBottom** (`boolean`, optional): Whether toasts slide in from bottom (default: `false` - slides from top)
|
|
88
|
+
|
|
89
|
+
### Examples
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
// Common use cases
|
|
93
|
+
try {
|
|
94
|
+
await api.createUser(userData);
|
|
95
|
+
window.Toast.show("User created successfully!", "success");
|
|
96
|
+
} catch (error) {
|
|
97
|
+
window.Toast.show("Failed to create user: " + error.message, "error");
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Long-running operation
|
|
101
|
+
window.Toast.show("Uploading file... Please wait", "info", 10);
|
|
102
|
+
|
|
103
|
+
// Form validation feedback
|
|
104
|
+
if (!email.includes('@')) {
|
|
105
|
+
window.Toast.show("Please enter a valid email address", "error");
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Success confirmation
|
|
109
|
+
window.Toast.show("Settings saved successfully", "success", 2);
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## DialogBoard
|
|
113
|
+
|
|
114
|
+
The `DialogBoard` component manages modal dialogs globally, allowing you to open any Svelte component as a modal dialog from anywhere in your application.
|
|
115
|
+
|
|
116
|
+
### Features
|
|
117
|
+
|
|
118
|
+
- **Universal Modal System**: Open any Svelte component as a modal
|
|
119
|
+
- **Global Access**: Available through `window.Dialog` API
|
|
120
|
+
- **Prop Passing**: Pass props to the modal component
|
|
121
|
+
- **Context Integration**: Provides close function through context
|
|
122
|
+
|
|
123
|
+
### Usage
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
// Open a component as modal
|
|
127
|
+
window.Dialog.showModal(MyDialogComponent, {
|
|
128
|
+
title: "Edit User",
|
|
129
|
+
user: userData,
|
|
130
|
+
onSave: (result) => {
|
|
131
|
+
console.log("User saved:", result);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### API Reference
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
interface IDialog {
|
|
140
|
+
showModal<T>(component: any, props?: T): void;
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Examples
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
// Open user edit dialog
|
|
148
|
+
window.Dialog.showModal(UserEditDialog, {
|
|
149
|
+
user: selectedUser,
|
|
150
|
+
onSave: async (updatedUser) => {
|
|
151
|
+
await updateUser(updatedUser);
|
|
152
|
+
window.Toast.show("User updated successfully", "success");
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// Open confirmation dialog
|
|
157
|
+
window.Dialog.showModal(ConfirmDialog, {
|
|
158
|
+
title: "Delete Item",
|
|
159
|
+
message: "Are you sure you want to delete this item?",
|
|
160
|
+
onConfirm: () => {
|
|
161
|
+
deleteItem(itemId);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// Open complex form dialog
|
|
166
|
+
window.Dialog.showModal(ProductFormDialog, {
|
|
167
|
+
product: product,
|
|
168
|
+
categories: availableCategories,
|
|
169
|
+
onSubmit: async (productData) => {
|
|
170
|
+
try {
|
|
171
|
+
await saveProduct(productData);
|
|
172
|
+
window.Toast.show("Product saved!", "success");
|
|
173
|
+
} catch (error) {
|
|
174
|
+
window.Toast.show("Save failed: " + error.message, "error");
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## IndicatorBoard
|
|
181
|
+
|
|
182
|
+
The `IndicatorBoard` component provides a full-screen loading overlay for blocking user interactions during asynchronous operations.
|
|
183
|
+
|
|
184
|
+
### Features
|
|
185
|
+
|
|
186
|
+
- **Full-Screen Overlay**: Blocks entire application interface
|
|
187
|
+
- **Custom Messages**: Display operation status to users
|
|
188
|
+
- **Automatic Management**: Show/hide based on async operation lifecycle
|
|
189
|
+
- **Prevents User Action**: Ensures data integrity during operations
|
|
190
|
+
|
|
191
|
+
### Usage
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
// Basic loading indicator
|
|
195
|
+
try {
|
|
196
|
+
window.Indicator.show("Loading data...");
|
|
197
|
+
const data = await api.fetchData();
|
|
198
|
+
// Process data
|
|
199
|
+
} finally {
|
|
200
|
+
window.Indicator.hide();
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Multiple operations with status updates
|
|
204
|
+
window.Indicator.show("Initializing...");
|
|
205
|
+
await initializeApp();
|
|
206
|
+
|
|
207
|
+
window.Indicator.show("Loading user data...");
|
|
208
|
+
await loadUserData();
|
|
209
|
+
|
|
210
|
+
window.Indicator.show("Setting up workspace...");
|
|
211
|
+
await setupWorkspace();
|
|
212
|
+
|
|
213
|
+
window.Indicator.hide();
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### API Reference
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
interface Indicator {
|
|
220
|
+
show: (message: string) => void;
|
|
221
|
+
hide: () => void;
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Examples
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
// File upload with progress indication
|
|
229
|
+
const uploadFile = async (file) => {
|
|
230
|
+
try {
|
|
231
|
+
window.Indicator.show("Uploading file...");
|
|
232
|
+
const result = await api.uploadFile(file);
|
|
233
|
+
window.Toast.show("File uploaded successfully", "success");
|
|
234
|
+
return result;
|
|
235
|
+
} catch (error) {
|
|
236
|
+
window.Toast.show("Upload failed: " + error.message, "error");
|
|
237
|
+
throw error;
|
|
238
|
+
} finally {
|
|
239
|
+
window.Indicator.hide();
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
// Data processing workflow
|
|
244
|
+
const processData = async (data) => {
|
|
245
|
+
try {
|
|
246
|
+
window.Indicator.show("Validating data...");
|
|
247
|
+
await validateData(data);
|
|
248
|
+
|
|
249
|
+
window.Indicator.show("Processing records...");
|
|
250
|
+
const processed = await processRecords(data);
|
|
251
|
+
|
|
252
|
+
window.Indicator.show("Saving results...");
|
|
253
|
+
await saveResults(processed);
|
|
254
|
+
|
|
255
|
+
window.Toast.show("Data processed successfully", "success");
|
|
256
|
+
} catch (error) {
|
|
257
|
+
window.Toast.show("Processing failed: " + error.message, "error");
|
|
258
|
+
} finally {
|
|
259
|
+
window.Indicator.hide();
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
// Async operation with automatic cleanup
|
|
264
|
+
const performAction = async () => {
|
|
265
|
+
const cleanup = () => window.Indicator.hide();
|
|
266
|
+
|
|
267
|
+
try {
|
|
268
|
+
window.Indicator.show("Performing action...");
|
|
269
|
+
await someAsyncOperation();
|
|
270
|
+
|
|
271
|
+
// Ensure indicator is hidden even if the operation throws
|
|
272
|
+
cleanup();
|
|
273
|
+
|
|
274
|
+
window.Toast.show("Action completed", "success");
|
|
275
|
+
} catch (error) {
|
|
276
|
+
cleanup();
|
|
277
|
+
window.Toast.show("Action failed", "error");
|
|
278
|
+
throw error;
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
## MessageBoxBoard
|
|
284
|
+
|
|
285
|
+
The `MessageBoxBoard` component provides modal confirmation dialogs and message boxes for user interactions that require explicit confirmation.
|
|
286
|
+
|
|
287
|
+
### Features
|
|
288
|
+
|
|
289
|
+
- **Confirmation Dialogs**: Yes/No, OK/Cancel interactions
|
|
290
|
+
- **Information Messages**: Display important information
|
|
291
|
+
- **Promise-based**: Async/await support for dialog results
|
|
292
|
+
- **Modal Result Types**: Standard dialog result enumeration
|
|
293
|
+
|
|
294
|
+
### Usage
|
|
295
|
+
|
|
296
|
+
```typescript
|
|
297
|
+
// Confirmation dialog
|
|
298
|
+
const result = await window.MessageBox.showConfirm("Delete this item?");
|
|
299
|
+
if (result === ModalResult.MR_OK) {
|
|
300
|
+
deleteItem();
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// Information message
|
|
304
|
+
await window.MessageBox.showInfo("Operation completed successfully", "Success");
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### API Reference
|
|
308
|
+
|
|
309
|
+
```typescript
|
|
310
|
+
interface MessageBox {
|
|
311
|
+
showConfirm: (message: string, title?: string) => Promise<ModalResult>;
|
|
312
|
+
showInfo: (message: string, title?: string) => Promise<ModalResult>;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
enum ModalResult {
|
|
316
|
+
MR_OK = 1,
|
|
317
|
+
MR_CANCEL = 2
|
|
318
|
+
}
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### Examples
|
|
322
|
+
|
|
323
|
+
```typescript
|
|
324
|
+
// Delete confirmation
|
|
325
|
+
const confirmDelete = async (itemName) => {
|
|
326
|
+
const result = await window.MessageBox.showConfirm(
|
|
327
|
+
`Are you sure you want to delete "${itemName}"? This action cannot be undone.`,
|
|
328
|
+
"Confirm Delete"
|
|
329
|
+
);
|
|
330
|
+
|
|
331
|
+
if (result === ModalResult.MR_OK) {
|
|
332
|
+
try {
|
|
333
|
+
await deleteItem(itemName);
|
|
334
|
+
window.Toast.show("Item deleted successfully", "success");
|
|
335
|
+
} catch (error) {
|
|
336
|
+
window.Toast.show("Failed to delete item", "error");
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
// Save changes confirmation
|
|
342
|
+
const handlePageLeave = async () => {
|
|
343
|
+
if (hasUnsavedChanges) {
|
|
344
|
+
const result = await window.MessageBox.showConfirm(
|
|
345
|
+
"You have unsaved changes. Are you sure you want to leave?",
|
|
346
|
+
"Unsaved Changes"
|
|
347
|
+
);
|
|
348
|
+
|
|
349
|
+
return result === ModalResult.MR_OK;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
return true;
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
// Information display
|
|
356
|
+
const showWelcomeMessage = async () => {
|
|
357
|
+
await window.MessageBox.showInfo(
|
|
358
|
+
"Welcome to the application! Please take a moment to review the getting started guide.",
|
|
359
|
+
"Welcome"
|
|
360
|
+
);
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
// Error handling with confirmation
|
|
364
|
+
const handleCriticalError = async (error) => {
|
|
365
|
+
const result = await window.MessageBox.showConfirm(
|
|
366
|
+
`A critical error occurred: ${error.message}\n\nWould you like to reload the application?`,
|
|
367
|
+
"Critical Error"
|
|
368
|
+
);
|
|
369
|
+
|
|
370
|
+
if (result === ModalResult.MR_OK) {
|
|
371
|
+
window.location.reload();
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
// Batch operation confirmation
|
|
376
|
+
const processBatchOperation = async (items) => {
|
|
377
|
+
const result = await window.MessageBox.showConfirm(
|
|
378
|
+
`This will process ${items.length} items and may take several minutes. Continue?`,
|
|
379
|
+
"Batch Processing"
|
|
380
|
+
);
|
|
381
|
+
|
|
382
|
+
if (result === ModalResult.MR_OK) {
|
|
383
|
+
try {
|
|
384
|
+
window.Indicator.show("Processing items...");
|
|
385
|
+
await processBatch(items);
|
|
386
|
+
window.Toast.show(`Successfully processed ${items.length} items`, "success");
|
|
387
|
+
} catch (error) {
|
|
388
|
+
window.Toast.show("Batch processing failed", "error");
|
|
389
|
+
} finally {
|
|
390
|
+
window.Indicator.hide();
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
## TypeScript Declarations
|
|
397
|
+
|
|
398
|
+
Add these type declarations to your `src/app.d.ts` or global type definition file:
|
|
399
|
+
|
|
400
|
+
```typescript
|
|
401
|
+
import type {
|
|
402
|
+
IDialog,
|
|
403
|
+
Toast,
|
|
404
|
+
Indicator,
|
|
405
|
+
MessageBox,
|
|
406
|
+
ModalResult
|
|
407
|
+
} from '@ticatec/uniface-element';
|
|
408
|
+
|
|
409
|
+
declare global {
|
|
410
|
+
interface Window {
|
|
411
|
+
Dialog: IDialog;
|
|
412
|
+
Toast: Toast;
|
|
413
|
+
Indicator: Indicator;
|
|
414
|
+
MessageBox: MessageBox;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
// Re-export for convenience
|
|
419
|
+
export { ModalResult };
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
## Best Practices
|
|
423
|
+
|
|
424
|
+
### 1. Proper Error Handling
|
|
425
|
+
|
|
426
|
+
```typescript
|
|
427
|
+
// Always use try-finally with Indicator
|
|
428
|
+
const performOperation = async () => {
|
|
429
|
+
try {
|
|
430
|
+
window.Indicator.show("Processing...");
|
|
431
|
+
await operation();
|
|
432
|
+
window.Toast.show("Operation completed", "success");
|
|
433
|
+
} catch (error) {
|
|
434
|
+
window.Toast.show("Operation failed", "error");
|
|
435
|
+
throw error;
|
|
436
|
+
} finally {
|
|
437
|
+
window.Indicator.hide(); // Always hide, even on error
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
### 2. User-Friendly Messages
|
|
443
|
+
|
|
444
|
+
```typescript
|
|
445
|
+
// Provide clear, actionable messages
|
|
446
|
+
window.Toast.show("User created successfully", "success");
|
|
447
|
+
window.Toast.show("Please fill in all required fields", "error");
|
|
448
|
+
window.Toast.show("Saving changes... Please wait", "info", 5);
|
|
449
|
+
|
|
450
|
+
// Avoid technical jargon
|
|
451
|
+
// ❌ Bad: "HTTP 404 error occurred"
|
|
452
|
+
// ✅ Good: "The requested item could not be found"
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
### 3. Appropriate Duration
|
|
456
|
+
|
|
457
|
+
```typescript
|
|
458
|
+
// Short messages (1-3 seconds)
|
|
459
|
+
window.Toast.show("Copied to clipboard", "success", 2);
|
|
460
|
+
|
|
461
|
+
// Important messages (3-5 seconds)
|
|
462
|
+
window.Toast.show("Your password has been updated", "success", 4);
|
|
463
|
+
|
|
464
|
+
// Long operations (5+ seconds)
|
|
465
|
+
window.Toast.show("Large file upload in progress...", "info", 10);
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
### 4. Confirmation Patterns
|
|
469
|
+
|
|
470
|
+
```typescript
|
|
471
|
+
// Critical actions should always confirm
|
|
472
|
+
const deleteUser = async (user) => {
|
|
473
|
+
const result = await window.MessageBox.showConfirm(
|
|
474
|
+
`Delete user "${user.name}"? This action cannot be undone.`
|
|
475
|
+
);
|
|
476
|
+
|
|
477
|
+
if (result === ModalResult.MR_OK) {
|
|
478
|
+
// Proceed with deletion
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
|
|
482
|
+
// Non-critical actions can use toast feedback
|
|
483
|
+
const toggleUserStatus = async (user) => {
|
|
484
|
+
try {
|
|
485
|
+
await updateUserStatus(user.id, !user.active);
|
|
486
|
+
window.Toast.show(
|
|
487
|
+
`User ${user.active ? 'deactivated' : 'activated'}`,
|
|
488
|
+
"success"
|
|
489
|
+
);
|
|
490
|
+
} catch (error) {
|
|
491
|
+
window.Toast.show("Failed to update user status", "error");
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
### 5. Loading State Management
|
|
497
|
+
|
|
498
|
+
```typescript
|
|
499
|
+
// Use Indicator for operations that block the UI
|
|
500
|
+
const saveDocument = async () => {
|
|
501
|
+
window.Indicator.show("Saving document...");
|
|
502
|
+
try {
|
|
503
|
+
await api.saveDocument();
|
|
504
|
+
window.Toast.show("Document saved", "success");
|
|
505
|
+
} finally {
|
|
506
|
+
window.Indicator.hide();
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
// Use Toast for background operations
|
|
511
|
+
const autoSave = async () => {
|
|
512
|
+
try {
|
|
513
|
+
await api.autoSaveDocument();
|
|
514
|
+
window.Toast.show("Auto-saved", "info", 1);
|
|
515
|
+
} catch (error) {
|
|
516
|
+
window.Toast.show("Auto-save failed", "error", 2);
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
## Accessibility Considerations
|
|
522
|
+
|
|
523
|
+
- Toast messages should be announced by screen readers
|
|
524
|
+
- Modal dialogs should trap focus and handle escape key
|
|
525
|
+
- Provide sufficient color contrast for all message types
|
|
526
|
+
- Use semantic HTML and ARIA labels appropriately
|
|
527
|
+
- Ensure keyboard navigation works for all interactive elements
|
|
528
|
+
|
|
529
|
+
## Browser Support
|
|
530
|
+
|
|
531
|
+
- Modern browsers with ES2020+ support
|
|
532
|
+
- CSS Grid and Flexbox support for layouts
|
|
533
|
+
- DOM manipulation APIs for dynamic mounting
|
|
534
|
+
- Promise support for async dialog interactions
|