@ticatec/uniface-element 0.2.4 → 0.3.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/dist/accordion/README.md +169 -0
- package/dist/accordion/README_CN.md +176 -0
- package/dist/action-bar/README.md +275 -0
- package/dist/action-bar/README_CN.md +285 -0
- package/dist/app-layout/README.md +374 -0
- package/dist/app-layout/README_CN.md +381 -0
- package/dist/app-top-bar/README.md +357 -0
- package/dist/app-top-bar/README_CN.md +365 -0
- package/dist/attachment-files/AttachmentFilesField.svelte +67 -1
- package/dist/attachment-files/AttachmentFilesField.svelte.d.ts +8 -1
- package/dist/base-calendar/CalendarBase.svelte +0 -3
- package/dist/box/README.md +385 -0
- package/dist/box/README_CN.md +393 -0
- package/dist/breadcrumbs/README.md +442 -0
- package/dist/breadcrumbs/README_CN.md +442 -0
- package/dist/button/Button.svelte +27 -7
- package/dist/button/Button.svelte.d.ts +3 -1
- package/dist/button/IconButton.svelte +26 -6
- package/dist/button/IconButton.svelte.d.ts +3 -1
- package/dist/button/IconButton_README.md +513 -0
- package/dist/button/IconButton_README_CN.md +513 -0
- package/dist/button/README.md +428 -0
- package/dist/button/README_CN.md +428 -0
- package/dist/button/TextButton.svelte +26 -6
- package/dist/button/TextButton.svelte.d.ts +3 -1
- package/dist/button/TextButton_README.md +571 -0
- package/dist/button/TextButton_README_CN.md +571 -0
- package/dist/card/README.md +666 -0
- package/dist/card/README_CN.md +666 -0
- package/dist/cascade-options-select/CascadeOptionSelect.svelte +43 -7
- package/dist/cascade-options-select/CascadeOptionSelect.svelte.d.ts +3 -4
- package/dist/cascade-options-select/README.md +663 -2
- package/dist/cascade-options-select/README_CN.md +664 -0
- package/dist/checkbox/CheckBox.svelte +20 -6
- package/dist/checkbox/CheckBox.svelte.d.ts +4 -2
- package/dist/checkbox/README.md +562 -0
- package/dist/checkbox/README_CN.md +727 -0
- package/dist/common-editor/NumberInput.svelte +39 -26
- package/dist/common-editor/NumberInput.svelte.d.ts +5 -1
- package/dist/concise-data-table/ConciseListTable.svelte +133 -36
- package/dist/concise-data-table/ConciseListTable.svelte.d.ts +8 -1
- package/dist/concise-data-table/DataCell.svelte +5 -6
- package/dist/concise-data-table/DataRow.svelte +22 -2
- package/dist/concise-data-table/DataRow.svelte.d.ts +1 -0
- package/dist/concise-data-table/README.md +606 -0
- package/dist/concise-data-table/README_CN.md +611 -0
- package/dist/context-menu/ContextMenu.svelte +138 -21
- package/dist/context-menu/ContextMenu.svelte.d.ts +5 -0
- package/dist/context-menu/ContextMenuItem.d.ts +20 -4
- package/dist/context-menu/README.md +551 -0
- package/dist/context-menu/README_CN.md +551 -0
- package/dist/criteria-field/CriteriaField.svelte +3 -5
- package/dist/criteria-field/README.md +532 -0
- package/dist/criteria-field/README_CN.md +532 -0
- package/dist/data-table/README.md +712 -0
- package/dist/data-table/README_CN.md +712 -0
- package/dist/date-picker/DatePicker.svelte +44 -7
- package/dist/date-picker/DatePicker.svelte.d.ts +3 -4
- package/dist/date-picker/DateTimePicker.svelte +32 -8
- package/dist/date-picker/DateTimePicker.svelte.d.ts +3 -4
- package/dist/date-picker/README.md +326 -0
- package/dist/date-picker/README_CN.md +316 -0
- package/dist/date-picker/ScrollBar.svelte +18 -8
- package/dist/date-picker/ScrollBar.svelte.d.ts +1 -1
- package/dist/date-picker/TimePanel.svelte +5 -5
- package/dist/date-picker/TimePanel.svelte.d.ts +1 -1
- package/dist/date-range/README.md +374 -0
- package/dist/date-range/README_CN.md +374 -0
- package/dist/dialog/README.md +596 -0
- package/dist/dialog/README_CN.md +596 -0
- package/dist/drawer/README.md +679 -1
- package/dist/drawer/README_CN.md +679 -0
- package/dist/group-box/group-check-box/GroupCheckBox.svelte +62 -5
- package/dist/group-box/group-check-box/GroupCheckBox.svelte.d.ts +7 -2
- package/dist/group-box/group-check-box/README.md +749 -0
- package/dist/group-box/group-check-box/README_CN.md +750 -0
- package/dist/group-box/group-radio-box/GroupRadioBox.svelte +69 -4
- package/dist/group-box/group-radio-box/GroupRadioBox.svelte.d.ts +8 -2
- package/dist/group-box/group-radio-box/README.md +920 -0
- package/dist/group-box/group-radio-box/README_CN.md +920 -0
- package/dist/image-files/README.md +1346 -0
- package/dist/image-files/README_CN.md +1346 -0
- package/dist/input-options-select/InputOptionsSelect.svelte +161 -65
- package/dist/input-options-select/InputOptionsSelect.svelte.d.ts +4 -1
- package/dist/lib/forwardAllEvents.d.ts +3 -0
- package/dist/lib/forwardAllEvents.js +24 -0
- package/dist/list-box/README.md +579 -0
- package/dist/list-box/README_CN.md +682 -0
- package/dist/lookup-editor/LookupEditor.svelte +15 -3
- package/dist/lookup-editor/LookupEditor.svelte.d.ts +3 -4
- package/dist/lookup-editor/README.md +684 -0
- package/dist/lookup-editor/README_CN.md +684 -0
- package/dist/memo-editor/MemoEditor.svelte +77 -27
- package/dist/memo-editor/MemoEditor.svelte.d.ts +6 -3
- package/dist/memo-editor/README.md +819 -0
- package/dist/memo-editor/README_CN.md +819 -0
- package/dist/message-box/README.md +398 -0
- package/dist/message-box/README_CN.md +398 -0
- package/dist/number-editor/NumberEditor.svelte +2 -2
- package/dist/number-editor/NumberEditor.svelte.d.ts +1 -1
- package/dist/number-editor/README.md +353 -22
- package/dist/number-editor/README_CN.md +357 -0
- package/dist/number-range/README.md +443 -0
- package/dist/number-range/README_CN.md +443 -0
- package/dist/options-multi-select/OptionsMultiSelect.svelte +87 -12
- package/dist/options-multi-select/OptionsMultiSelect.svelte.d.ts +3 -1
- package/dist/options-multi-select/README.md +480 -0
- package/dist/options-multi-select/README_CN.md +480 -0
- package/dist/options-select/OptionsSelect.svelte +36 -5
- package/dist/options-select/OptionsSelect.svelte.d.ts +3 -4
- package/dist/options-select/README.md +632 -0
- package/dist/options-select/README_CN.md +632 -0
- package/dist/page/README.md +605 -0
- package/dist/page/README_CN.md +605 -0
- package/dist/pagination/README.md +946 -0
- package/dist/pagination/README_CN.md +946 -0
- package/dist/pagination-panel/README.md +1075 -0
- package/dist/pagination-panel/README_CN.md +1075 -0
- package/dist/popup-hint/README.md +841 -0
- package/dist/popup-hint/README_CN.md +840 -0
- package/dist/progress-bar/README.md +242 -0
- package/dist/progress-bar/README_CN.md +242 -0
- package/dist/progress-step-bar/README.md +316 -0
- package/dist/progress-step-bar/README_CN.md +316 -0
- package/dist/prompts-text-editor/PromptsTextEditor.svelte +6 -3
- package/dist/prompts-text-editor/PromptsTextEditor.svelte.d.ts +3 -1
- package/dist/prompts-text-editor/README.md +329 -0
- package/dist/prompts-text-editor/README_CN.md +329 -0
- package/dist/property-editor/README.md +969 -0
- package/dist/property-editor/README_CN.md +969 -0
- package/dist/radio-button/README.md +372 -0
- package/dist/radio-button/README_CN.md +372 -0
- package/dist/radio-button/RadioButton.svelte +32 -3
- package/dist/radio-button/RadioButton.svelte.d.ts +12 -1
- package/dist/search-box/README.md +425 -0
- package/dist/search-box/README_CN.md +424 -0
- package/dist/search-box/SearchBox.svelte +22 -6
- package/dist/search-box/SearchBox.svelte.d.ts +4 -1
- package/dist/tabs/README.md +919 -0
- package/dist/tabs/README_CN.md +920 -0
- package/dist/tag/README.md +922 -0
- package/dist/tag/README_CN.md +922 -0
- package/dist/text-editor/PasswordEditor.svelte +17 -2
- package/dist/text-editor/PasswordEditor.svelte.d.ts +3 -3
- package/dist/text-editor/PasswordEditor_README.md +551 -0
- package/dist/text-editor/PasswordEditor_README_CN.md +551 -0
- package/dist/text-editor/README.md +466 -0
- package/dist/text-editor/README_CN.md +466 -0
- package/dist/text-editor/TextEditor.svelte +51 -19
- package/dist/text-editor/TextEditor.svelte.d.ts +0 -1
- package/dist/time-editor/README.md +498 -24
- package/dist/time-editor/README_CN.md +498 -0
- package/dist/time-editor/TimeEditor.svelte +7 -3
- package/dist/time-editor/TimeEditor.svelte.d.ts +3 -1
- package/dist/toast/README.md +667 -0
- package/dist/toast/README_CN.md +667 -0
- package/dist/transfer/README.md +795 -0
- package/dist/transfer/Transfer.svelte +6 -4
- package/dist/transfer/Transfer.svelte.d.ts +3 -1
- package/dist/tree-view/README.md +761 -0
- package/dist/tree-view/README_CN.md +761 -0
- package/dist/tree-view/TreeView.svelte +5 -3
- package/dist/tree-view/TreeView.svelte.d.ts +3 -1
- package/dist/unit-number-editor/README.md +546 -20
- package/dist/unit-number-editor/README_CN.md +525 -0
- package/dist/unit-number-editor/UnitNumberEditor.svelte +62 -8
- package/dist/unit-number-editor/UnitNumberEditor.svelte.d.ts +5 -1
- package/docs/form-field/cn/README_CN.md +364 -0
- package/docs/form-field/en/README.md +364 -0
- package/docs/form-panel/flex-form/cn/README_CN.md +586 -0
- package/docs/form-panel/flex-form/en/README.md +586 -0
- package/docs/form-panel/flex-row-form/cn/README_CN.md +787 -0
- package/docs/form-panel/flex-row-form/en/README.md +787 -0
- package/docs/form-panel/grid-form/en/README.md +744 -0
- package/package.json +1 -1
- package/dist/drawer/README-CN.md +0 -1
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
# MessageBox
|
|
2
|
+
|
|
3
|
+
A global modal dialog system for displaying informational messages, confirmations, and user interactions with customizable buttons and styling.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Global Access**: Available throughout the application via `window.MessageBox`
|
|
8
|
+
- **Multiple Types**: Support for info, warning, and custom message types
|
|
9
|
+
- **Confirmation Dialogs**: Built-in confirm/cancel functionality
|
|
10
|
+
- **Draggable**: Users can drag the message box around the screen
|
|
11
|
+
- **Custom Buttons**: Configure custom button sets with different actions
|
|
12
|
+
- **HTML Content**: Support for both plain text and HTML content
|
|
13
|
+
- **Promise-based**: Returns promises for easy async handling
|
|
14
|
+
- **Auto-positioning**: Automatically centers on screen with drag support
|
|
15
|
+
- **Internationalization**: Built-in i18n support for button labels
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @ticatec/uniface-element
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Setup
|
|
24
|
+
|
|
25
|
+
First, add the MessageBoxBoard to your root layout or app component:
|
|
26
|
+
|
|
27
|
+
```svelte
|
|
28
|
+
<script>
|
|
29
|
+
import MessageBoxBoard from '@ticatec/uniface-element/MessageBox';
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<!-- Your app content -->
|
|
33
|
+
<main>
|
|
34
|
+
<!-- Your components -->
|
|
35
|
+
</main>
|
|
36
|
+
|
|
37
|
+
<!-- MessageBox Board - Global instance -->
|
|
38
|
+
<MessageBoxBoard appTitle="My Application" />
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Basic Usage
|
|
42
|
+
|
|
43
|
+
Once the MessageBoxBoard is mounted, you can use the global MessageBox instance:
|
|
44
|
+
|
|
45
|
+
```javascript
|
|
46
|
+
// Show an information message
|
|
47
|
+
await window.MessageBox.showInfo('Operation completed successfully!', 'Success');
|
|
48
|
+
|
|
49
|
+
// Show a confirmation dialog
|
|
50
|
+
const result = await window.MessageBox.showConfirm(
|
|
51
|
+
'Are you sure you want to delete this item?',
|
|
52
|
+
'Confirm Delete'
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
if (result === ModalResult.MR_OK) {
|
|
56
|
+
// User confirmed
|
|
57
|
+
console.log('User confirmed the action');
|
|
58
|
+
} else {
|
|
59
|
+
// User cancelled
|
|
60
|
+
console.log('User cancelled the action');
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## API Reference
|
|
65
|
+
|
|
66
|
+
### MessageBoxBoard Props
|
|
67
|
+
|
|
68
|
+
| Prop | Type | Default | Description |
|
|
69
|
+
|------|------|---------|-------------|
|
|
70
|
+
| `appTitle` | `string` | `null` | Default title for message boxes when no title is provided |
|
|
71
|
+
|
|
72
|
+
### Global Methods
|
|
73
|
+
|
|
74
|
+
#### `window.MessageBox.showInfo(message, title?, escapeHTML?)`
|
|
75
|
+
|
|
76
|
+
Shows an informational message with a close button.
|
|
77
|
+
|
|
78
|
+
**Parameters:**
|
|
79
|
+
- `message` (string): The message to display
|
|
80
|
+
- `title` (string, optional): Dialog title
|
|
81
|
+
- `escapeHTML` (boolean, optional): Whether to escape HTML content (default: true)
|
|
82
|
+
|
|
83
|
+
**Returns:** `Promise<void>`
|
|
84
|
+
|
|
85
|
+
#### `window.MessageBox.showConfirm(message, title?, escapeHTML?, type?)`
|
|
86
|
+
|
|
87
|
+
Shows a confirmation dialog with OK/Cancel buttons.
|
|
88
|
+
|
|
89
|
+
**Parameters:**
|
|
90
|
+
- `message` (string): The message to display
|
|
91
|
+
- `title` (string, optional): Dialog title
|
|
92
|
+
- `escapeHTML` (boolean, optional): Whether to escape HTML content (default: true)
|
|
93
|
+
- `type` ('info' | 'warning', optional): Icon type to display (default: 'info')
|
|
94
|
+
|
|
95
|
+
**Returns:** `Promise<ModalResult>`
|
|
96
|
+
|
|
97
|
+
### ModalResult Enum
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
enum ModalResult {
|
|
101
|
+
MR_OK = 1, // User clicked OK/Confirm
|
|
102
|
+
MR_CANCEL = 2, // User clicked Cancel
|
|
103
|
+
MR_CLOSE = 3 // User clicked Close/X button
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Examples
|
|
108
|
+
|
|
109
|
+
### Basic Information Message
|
|
110
|
+
|
|
111
|
+
```javascript
|
|
112
|
+
// Simple info message
|
|
113
|
+
await window.MessageBox.showInfo('Your changes have been saved successfully.');
|
|
114
|
+
|
|
115
|
+
// Info message with custom title
|
|
116
|
+
await window.MessageBox.showInfo(
|
|
117
|
+
'The operation completed without any errors.',
|
|
118
|
+
'Operation Complete'
|
|
119
|
+
);
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Confirmation Dialogs
|
|
123
|
+
|
|
124
|
+
```javascript
|
|
125
|
+
// Basic confirmation
|
|
126
|
+
const result = await window.MessageBox.showConfirm(
|
|
127
|
+
'Do you want to save your changes before closing?',
|
|
128
|
+
'Unsaved Changes'
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
if (result === ModalResult.MR_OK) {
|
|
132
|
+
// Save changes
|
|
133
|
+
saveChanges();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Warning confirmation
|
|
137
|
+
const result = await window.MessageBox.showConfirm(
|
|
138
|
+
'This action cannot be undone. Continue?',
|
|
139
|
+
'Permanent Action',
|
|
140
|
+
false,
|
|
141
|
+
'warning'
|
|
142
|
+
);
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### HTML Content
|
|
146
|
+
|
|
147
|
+
```javascript
|
|
148
|
+
// Display HTML content (escapeHTML = false)
|
|
149
|
+
await window.MessageBox.showInfo(
|
|
150
|
+
'<strong>Important:</strong> Please check your <em>email</em> for verification.',
|
|
151
|
+
'Email Verification',
|
|
152
|
+
false
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
// Safe HTML escaping (default behavior)
|
|
156
|
+
await window.MessageBox.showInfo(
|
|
157
|
+
'User input: <script>alert("xss")</script>', // Will be escaped
|
|
158
|
+
'User Data'
|
|
159
|
+
);
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Error Handling
|
|
163
|
+
|
|
164
|
+
```javascript
|
|
165
|
+
try {
|
|
166
|
+
const result = await window.MessageBox.showConfirm(
|
|
167
|
+
'Delete all selected items?',
|
|
168
|
+
'Bulk Delete'
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
if (result === ModalResult.MR_OK) {
|
|
172
|
+
await deleteItems();
|
|
173
|
+
await window.MessageBox.showInfo('Items deleted successfully.', 'Success');
|
|
174
|
+
}
|
|
175
|
+
} catch (error) {
|
|
176
|
+
await window.MessageBox.showInfo(
|
|
177
|
+
'An error occurred. Please try again.',
|
|
178
|
+
'Error',
|
|
179
|
+
false,
|
|
180
|
+
'warning'
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Form Validation Example
|
|
186
|
+
|
|
187
|
+
```svelte
|
|
188
|
+
<script>
|
|
189
|
+
import { ModalResult } from '@ticatec/uniface-element/MessageBox';
|
|
190
|
+
|
|
191
|
+
async function handleSubmit() {
|
|
192
|
+
if (!formData.name) {
|
|
193
|
+
await window.MessageBox.showInfo(
|
|
194
|
+
'Please enter your name before submitting.',
|
|
195
|
+
'Required Field'
|
|
196
|
+
);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const result = await window.MessageBox.showConfirm(
|
|
201
|
+
'Submit the form with the provided information?',
|
|
202
|
+
'Confirm Submission'
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
if (result === ModalResult.MR_OK) {
|
|
206
|
+
try {
|
|
207
|
+
await submitForm(formData);
|
|
208
|
+
await window.MessageBox.showInfo(
|
|
209
|
+
'Form submitted successfully!',
|
|
210
|
+
'Success'
|
|
211
|
+
);
|
|
212
|
+
} catch (error) {
|
|
213
|
+
await window.MessageBox.showInfo(
|
|
214
|
+
'Failed to submit form. Please try again.',
|
|
215
|
+
'Submission Error',
|
|
216
|
+
false,
|
|
217
|
+
'warning'
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
</script>
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Async Operations
|
|
226
|
+
|
|
227
|
+
```javascript
|
|
228
|
+
async function performAsyncOperation() {
|
|
229
|
+
// Show loading state (could be implemented with a custom dialog)
|
|
230
|
+
const confirmed = await window.MessageBox.showConfirm(
|
|
231
|
+
'This operation may take several minutes. Continue?',
|
|
232
|
+
'Long Running Operation'
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
if (confirmed === ModalResult.MR_OK) {
|
|
236
|
+
try {
|
|
237
|
+
await longRunningTask();
|
|
238
|
+
await window.MessageBox.showInfo(
|
|
239
|
+
'Operation completed successfully!',
|
|
240
|
+
'Success'
|
|
241
|
+
);
|
|
242
|
+
} catch (error) {
|
|
243
|
+
await window.MessageBox.showInfo(
|
|
244
|
+
`Operation failed: ${error.message}`,
|
|
245
|
+
'Error',
|
|
246
|
+
false,
|
|
247
|
+
'warning'
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Dialog Chain Example
|
|
255
|
+
|
|
256
|
+
```javascript
|
|
257
|
+
async function handleDataLoss() {
|
|
258
|
+
const saveFirst = await window.MessageBox.showConfirm(
|
|
259
|
+
'You have unsaved changes. Would you like to save them first?',
|
|
260
|
+
'Unsaved Changes'
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
if (saveFirst === ModalResult.MR_OK) {
|
|
264
|
+
try {
|
|
265
|
+
await saveData();
|
|
266
|
+
await window.MessageBox.showInfo('Data saved successfully.', 'Saved');
|
|
267
|
+
} catch (error) {
|
|
268
|
+
const retry = await window.MessageBox.showConfirm(
|
|
269
|
+
'Failed to save data. Try again?',
|
|
270
|
+
'Save Error',
|
|
271
|
+
false,
|
|
272
|
+
'warning'
|
|
273
|
+
);
|
|
274
|
+
|
|
275
|
+
if (retry === ModalResult.MR_OK) {
|
|
276
|
+
return handleDataLoss(); // Recursive retry
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// Proceed with the original action
|
|
282
|
+
proceedWithAction();
|
|
283
|
+
}
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### Multiple MessageBox Prevention
|
|
287
|
+
|
|
288
|
+
```javascript
|
|
289
|
+
let messageBoxActive = false;
|
|
290
|
+
|
|
291
|
+
async function safeShowMessage(message, title) {
|
|
292
|
+
if (messageBoxActive) {
|
|
293
|
+
console.warn('MessageBox already active');
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
messageBoxActive = true;
|
|
298
|
+
try {
|
|
299
|
+
await window.MessageBox.showInfo(message, title);
|
|
300
|
+
} finally {
|
|
301
|
+
messageBoxActive = false;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
## Styling
|
|
307
|
+
|
|
308
|
+
The MessageBox uses CSS classes that can be customized:
|
|
309
|
+
|
|
310
|
+
```css
|
|
311
|
+
.uniface-message-board {
|
|
312
|
+
/* Overlay background */
|
|
313
|
+
position: fixed;
|
|
314
|
+
top: 0;
|
|
315
|
+
left: 0;
|
|
316
|
+
width: 100%;
|
|
317
|
+
height: 100%;
|
|
318
|
+
background: rgba(0, 0, 0, 0.5);
|
|
319
|
+
z-index: 9999;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.uniface-message-box {
|
|
323
|
+
/* Dialog container */
|
|
324
|
+
position: fixed;
|
|
325
|
+
top: 50%;
|
|
326
|
+
left: 50%;
|
|
327
|
+
transform: translate(-50%, -50%);
|
|
328
|
+
background: white;
|
|
329
|
+
border-radius: 8px;
|
|
330
|
+
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.title-bar {
|
|
334
|
+
/* Draggable title area */
|
|
335
|
+
cursor: move;
|
|
336
|
+
padding: 8px;
|
|
337
|
+
border-bottom: 1px solid #eee;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.box-content {
|
|
341
|
+
/* Message content area */
|
|
342
|
+
padding: 20px;
|
|
343
|
+
display: flex;
|
|
344
|
+
align-items: center;
|
|
345
|
+
gap: 16px;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
.control-bar {
|
|
349
|
+
/* Button area */
|
|
350
|
+
padding: 16px 20px;
|
|
351
|
+
text-align: right;
|
|
352
|
+
border-top: 1px solid #eee;
|
|
353
|
+
}
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
## Best Practices
|
|
357
|
+
|
|
358
|
+
1. **Use Meaningful Titles**: Provide clear, descriptive titles for better UX
|
|
359
|
+
2. **Keep Messages Concise**: Short, clear messages are more effective
|
|
360
|
+
3. **Handle Promises Properly**: Always await MessageBox calls or handle rejections
|
|
361
|
+
4. **Consider User Context**: Use appropriate message types (info vs warning)
|
|
362
|
+
5. **Avoid Message Spam**: Prevent multiple MessageBoxes from showing simultaneously
|
|
363
|
+
6. **Test HTML Content**: When using HTML, ensure content is safe and properly formatted
|
|
364
|
+
7. **Provide Context**: Include relevant information to help users make decisions
|
|
365
|
+
|
|
366
|
+
## TypeScript Support
|
|
367
|
+
|
|
368
|
+
The MessageBox includes full TypeScript definitions:
|
|
369
|
+
|
|
370
|
+
```typescript
|
|
371
|
+
import { ModalResult, type IMessageBox } from '@ticatec/uniface-element/MessageBox';
|
|
372
|
+
|
|
373
|
+
declare global {
|
|
374
|
+
interface Window {
|
|
375
|
+
MessageBox: IMessageBox;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// Usage with type safety
|
|
380
|
+
const result: ModalResult = await window.MessageBox.showConfirm(
|
|
381
|
+
'Delete this item?',
|
|
382
|
+
'Confirm Delete'
|
|
383
|
+
);
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
## Accessibility
|
|
387
|
+
|
|
388
|
+
- Proper ARIA labels and roles
|
|
389
|
+
- Keyboard navigation support (ESC to close)
|
|
390
|
+
- Focus management
|
|
391
|
+
- Screen reader compatibility
|
|
392
|
+
- High contrast mode support
|
|
393
|
+
|
|
394
|
+
## Related Components
|
|
395
|
+
|
|
396
|
+
- [Dialog](../dialog/README.md) - For custom modal dialogs
|
|
397
|
+
- [Toast](../toast/README.md) - For non-blocking notifications
|
|
398
|
+
- [Button](../button/README.md) - For dialog actions
|