@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,600 @@
|
|
|
1
|
+
# Button Component System
|
|
2
|
+
|
|
3
|
+
The Uniface Element Button system provides a comprehensive set of interactive button components for Svelte applications. It includes standard buttons, text buttons, icon buttons, and a flexible action bar component for organizing multiple actions.
|
|
4
|
+
|
|
5
|
+
## Component Overview
|
|
6
|
+
|
|
7
|
+
The button system consists of four main components, each with specific purposes and design goals:
|
|
8
|
+
|
|
9
|
+
### [Button Component](./Button.md)
|
|
10
|
+
Full-featured button component with icon and label support, suitable for most interaction scenarios.
|
|
11
|
+
|
|
12
|
+
**Features:**
|
|
13
|
+
- Supports icon + text labels
|
|
14
|
+
- Multiple size and style variants
|
|
15
|
+
- Complete theme support
|
|
16
|
+
- Async operation handling
|
|
17
|
+
|
|
18
|
+
**Use Cases:** Primary actions, form submissions, dialog confirmations
|
|
19
|
+
|
|
20
|
+
### [TextButton Component](./TextButton.md)
|
|
21
|
+
Lightweight component optimized for text-only buttons with minimal styling.
|
|
22
|
+
|
|
23
|
+
**Features:**
|
|
24
|
+
- Text-only display
|
|
25
|
+
- Minimal visual styling
|
|
26
|
+
- Fast loading and rendering
|
|
27
|
+
- Support for custom content slots
|
|
28
|
+
|
|
29
|
+
**Use Cases:** Navigation links, inline actions, dialog cancel buttons
|
|
30
|
+
|
|
31
|
+
### [IconButton Component](./IconButton.md)
|
|
32
|
+
Icon-only button component designed for compact interfaces.
|
|
33
|
+
|
|
34
|
+
**Features:**
|
|
35
|
+
- Icon-only display
|
|
36
|
+
- Compact space usage
|
|
37
|
+
- Multiple icon library support
|
|
38
|
+
- Adaptive sizing
|
|
39
|
+
|
|
40
|
+
**Use Cases:** Toolbars, data table actions, card actions
|
|
41
|
+
|
|
42
|
+
### [ActionBar Component](./ActionBar.md)
|
|
43
|
+
Container component for organizing and managing multiple button actions.
|
|
44
|
+
|
|
45
|
+
**Features:**
|
|
46
|
+
- Unified button layout management
|
|
47
|
+
- Automatic spacing and alignment
|
|
48
|
+
- Separator support
|
|
49
|
+
- Responsive layout
|
|
50
|
+
|
|
51
|
+
**Use Cases:** Form action bars, dialog footers, toolbar layouts
|
|
52
|
+
|
|
53
|
+
## Architecture Diagram
|
|
54
|
+
|
|
55
|
+
```mermaid
|
|
56
|
+
graph TD
|
|
57
|
+
A[ActionBar Container] --> B[Button Components]
|
|
58
|
+
B --> C[Button Standard]
|
|
59
|
+
B --> D[TextButton Text-only]
|
|
60
|
+
B --> E[IconButton Icon-only]
|
|
61
|
+
F[ButtonAction Config] --> A
|
|
62
|
+
G[ButtonType Styling] --> B
|
|
63
|
+
H[MouseClickHandler Events] --> B
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Quick Start
|
|
67
|
+
|
|
68
|
+
### Installation and Import
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
// Import required components
|
|
72
|
+
import Button from '@ticatec/uniface-element/Button';
|
|
73
|
+
import TextButton from '@ticatec/uniface-element/TextButton';
|
|
74
|
+
import IconButton from '@ticatec/uniface-element/IconButton';
|
|
75
|
+
import ActionBar from '@ticatec/uniface-element/ActionBar';
|
|
76
|
+
import type { ButtonActions } from '@ticatec/uniface-element';
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Basic Examples
|
|
80
|
+
|
|
81
|
+
```svelte
|
|
82
|
+
<script lang="ts">
|
|
83
|
+
import Button from '@ticatec/uniface-element/Button';
|
|
84
|
+
import TextButton from '@ticatec/uniface-element/TextButton';
|
|
85
|
+
import IconButton from '@ticatec/uniface-element/IconButton';
|
|
86
|
+
import ActionBar from '@ticatec/uniface-element/ActionBar';
|
|
87
|
+
import type { ButtonActions } from '@ticatec/uniface-element';
|
|
88
|
+
|
|
89
|
+
const handleSave = async () => {
|
|
90
|
+
// Save operation
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const actions: ButtonActions = [
|
|
94
|
+
{ label: "Cancel", type: "secondary", handler: async () => {} },
|
|
95
|
+
{ label: "Save", type: "primary", handler: handleSave }
|
|
96
|
+
];
|
|
97
|
+
</script>
|
|
98
|
+
|
|
99
|
+
<!-- Standard button -->
|
|
100
|
+
<Button label="Save" type="primary" icon="icon_google_save" onClick={handleSave} />
|
|
101
|
+
|
|
102
|
+
<!-- Text button -->
|
|
103
|
+
<TextButton label="Cancel" type="secondary" onClick={async () => {}} />
|
|
104
|
+
|
|
105
|
+
<!-- Icon button -->
|
|
106
|
+
<IconButton icon="icon_google_edit" type="primary" onClick={async () => {}} />
|
|
107
|
+
|
|
108
|
+
<!-- Action bar -->
|
|
109
|
+
<ActionBar buttons={actions} />
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Button Types & Styling
|
|
113
|
+
|
|
114
|
+
### ButtonType Options
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
type ButtonType = 'default' | 'primary' | 'secondary' | 'third' | 'forth';
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Visual Appearance
|
|
121
|
+
|
|
122
|
+
- **default**: Standard neutral button appearance
|
|
123
|
+
- **primary**: Emphasizes primary actions (typically blue)
|
|
124
|
+
- **secondary**: Secondary actions button (typically gray)
|
|
125
|
+
- **third**: Alternative style (typically for warnings/caution)
|
|
126
|
+
- **forth**: Additional style variant
|
|
127
|
+
|
|
128
|
+
### Size Variants
|
|
129
|
+
|
|
130
|
+
- **big**: Large button size for prominent actions
|
|
131
|
+
- **medium**: Standard button size for most use cases
|
|
132
|
+
- **mini**: Small button size for compact interfaces
|
|
133
|
+
|
|
134
|
+
### Style Variants (Button only)
|
|
135
|
+
|
|
136
|
+
- **plain**: Minimalist style variant
|
|
137
|
+
- **round**: Rounded corner variant
|
|
138
|
+
- **'' (empty string)**: Standard styling
|
|
139
|
+
|
|
140
|
+
## API Reference
|
|
141
|
+
|
|
142
|
+
### ButtonAction Interface
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
interface ButtonAction {
|
|
146
|
+
/** Button label text */
|
|
147
|
+
label: string;
|
|
148
|
+
|
|
149
|
+
/** Whether button is disabled */
|
|
150
|
+
disabled?: boolean;
|
|
151
|
+
|
|
152
|
+
/** Icon class (e.g., Google Material Icons) */
|
|
153
|
+
icon?: string;
|
|
154
|
+
|
|
155
|
+
/** Button type for styling */
|
|
156
|
+
type?: ButtonType;
|
|
157
|
+
|
|
158
|
+
/** Click event handler */
|
|
159
|
+
handler?: MouseClickHandler;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
type ButtonActions = Array<ButtonAction | null>;
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### MouseClickHandler Type
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
type MouseClickHandler = (event: MouseEvent) => Promise<void>;
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Click Throttling
|
|
172
|
+
|
|
173
|
+
All button components implement automatic click throttling with a 500ms cooldown to prevent accidental double-clicks and ensure proper async operation handling.
|
|
174
|
+
|
|
175
|
+
### Icon Usage
|
|
176
|
+
|
|
177
|
+
Components use `@ticatec/uniface-google-material-icons` as the icon library. Simply pass the icon class name:
|
|
178
|
+
|
|
179
|
+
```svelte
|
|
180
|
+
<!-- Common Material Icons -->
|
|
181
|
+
<Button icon="icon_google_save" label="Save" />
|
|
182
|
+
<Button icon="icon_google_edit" label="Edit" />
|
|
183
|
+
<Button icon="icon_google_delete" label="Delete" />
|
|
184
|
+
<Button icon="icon_google_add" label="Add" />
|
|
185
|
+
<Button icon="icon_google_remove" label="Remove" />
|
|
186
|
+
<Button icon="icon_google_search" label="Search" />
|
|
187
|
+
<Button icon="icon_google_settings" label="Settings" />
|
|
188
|
+
<Button icon="icon_google_home" label="Home" />
|
|
189
|
+
<Button icon="icon_google_check" label="Confirm" />
|
|
190
|
+
<Button icon="icon_google_arrow_back" label="Back" />
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Usage Examples
|
|
194
|
+
|
|
195
|
+
### Dialog Actions
|
|
196
|
+
|
|
197
|
+
```svelte
|
|
198
|
+
<script lang="ts">
|
|
199
|
+
import ActionBar from '@ticatec/uniface-element/ActionBar';
|
|
200
|
+
import type { ButtonActions } from '@ticatec/uniface-element';
|
|
201
|
+
|
|
202
|
+
export let onSave: () => Promise<void>;
|
|
203
|
+
export let onCancel: () => void;
|
|
204
|
+
|
|
205
|
+
const dialogActions: ButtonActions = [
|
|
206
|
+
{
|
|
207
|
+
label: "Cancel",
|
|
208
|
+
type: "secondary",
|
|
209
|
+
handler: async () => {
|
|
210
|
+
onCancel();
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
label: "Save Changes",
|
|
215
|
+
type: "primary",
|
|
216
|
+
icon: "icon_google_save",
|
|
217
|
+
handler: async () => {
|
|
218
|
+
await onSave();
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
];
|
|
222
|
+
</script>
|
|
223
|
+
|
|
224
|
+
<div class="dialog-footer">
|
|
225
|
+
<ActionBar buttons={dialogActions} style="justify-content: flex-end;" />
|
|
226
|
+
</div>
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Data Table Actions
|
|
230
|
+
|
|
231
|
+
```svelte
|
|
232
|
+
<script lang="ts">
|
|
233
|
+
import IconButton from '@ticatec/uniface-element/IconButton';
|
|
234
|
+
|
|
235
|
+
export let item: any;
|
|
236
|
+
export let onEdit: (item: any) => Promise<void>;
|
|
237
|
+
export let onDelete: (item: any) => Promise<void>;
|
|
238
|
+
export let onView: (item: any) => Promise<void>;
|
|
239
|
+
</script>
|
|
240
|
+
|
|
241
|
+
<div class="table-actions">
|
|
242
|
+
<IconButton
|
|
243
|
+
icon="icon_google_visibility"
|
|
244
|
+
type="default"
|
|
245
|
+
onClick={async () => await onView(item)}
|
|
246
|
+
/>
|
|
247
|
+
<IconButton
|
|
248
|
+
icon="icon_google_edit"
|
|
249
|
+
type="primary"
|
|
250
|
+
onClick={async () => await onEdit(item)}
|
|
251
|
+
/>
|
|
252
|
+
<IconButton
|
|
253
|
+
icon="icon_google_delete"
|
|
254
|
+
type="third"
|
|
255
|
+
onClick={async () => await onDelete(item)}
|
|
256
|
+
/>
|
|
257
|
+
</div>
|
|
258
|
+
|
|
259
|
+
<style>
|
|
260
|
+
.table-actions {
|
|
261
|
+
display: flex;
|
|
262
|
+
gap: 4px;
|
|
263
|
+
}
|
|
264
|
+
</style>
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Form Buttons
|
|
268
|
+
|
|
269
|
+
```svelte
|
|
270
|
+
<script lang="ts">
|
|
271
|
+
import Button from '@ticatec/uniface-element/Button';
|
|
272
|
+
import TextButton from '@ticatec/uniface-element/TextButton';
|
|
273
|
+
|
|
274
|
+
let formData = {};
|
|
275
|
+
let isSubmitting = false;
|
|
276
|
+
let isDraft = false;
|
|
277
|
+
|
|
278
|
+
const handleSubmit = async () => {
|
|
279
|
+
isSubmitting = true;
|
|
280
|
+
try {
|
|
281
|
+
await submitForm(formData);
|
|
282
|
+
} finally {
|
|
283
|
+
isSubmitting = false;
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
const handleSaveDraft = async () => {
|
|
288
|
+
isDraft = true;
|
|
289
|
+
try {
|
|
290
|
+
await saveDraft(formData);
|
|
291
|
+
} finally {
|
|
292
|
+
isDraft = false;
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
const handleReset = async () => {
|
|
297
|
+
formData = {};
|
|
298
|
+
};
|
|
299
|
+
</script>
|
|
300
|
+
|
|
301
|
+
<form>
|
|
302
|
+
<!-- Form fields here -->
|
|
303
|
+
|
|
304
|
+
<div class="form-actions">
|
|
305
|
+
<TextButton
|
|
306
|
+
label="Reset"
|
|
307
|
+
type="default"
|
|
308
|
+
onClick={handleReset}
|
|
309
|
+
/>
|
|
310
|
+
|
|
311
|
+
<Button
|
|
312
|
+
label={isDraft ? "Saving..." : "Save Draft"}
|
|
313
|
+
type="secondary"
|
|
314
|
+
icon="icon_google_save"
|
|
315
|
+
disabled={isDraft}
|
|
316
|
+
onClick={handleSaveDraft}
|
|
317
|
+
/>
|
|
318
|
+
|
|
319
|
+
<Button
|
|
320
|
+
label={isSubmitting ? "Submitting..." : "Submit"}
|
|
321
|
+
type="primary"
|
|
322
|
+
icon="icon_google_send"
|
|
323
|
+
disabled={isSubmitting}
|
|
324
|
+
onClick={handleSubmit}
|
|
325
|
+
/>
|
|
326
|
+
</div>
|
|
327
|
+
</form>
|
|
328
|
+
|
|
329
|
+
<style>
|
|
330
|
+
.form-actions {
|
|
331
|
+
display: flex;
|
|
332
|
+
gap: 12px;
|
|
333
|
+
justify-content: flex-end;
|
|
334
|
+
margin-top: 24px;
|
|
335
|
+
}
|
|
336
|
+
</style>
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### Toolbar Implementation
|
|
340
|
+
|
|
341
|
+
```svelte
|
|
342
|
+
<script lang="ts">
|
|
343
|
+
import ActionBar from '@ticatec/uniface-element/ActionBar';
|
|
344
|
+
import type { ButtonActions } from '@ticatec/uniface-element';
|
|
345
|
+
|
|
346
|
+
let selectedItems = [];
|
|
347
|
+
|
|
348
|
+
const toolbarActions: ButtonActions = [
|
|
349
|
+
{
|
|
350
|
+
label: "Select All",
|
|
351
|
+
icon: "icon_google_check_box",
|
|
352
|
+
type: "default",
|
|
353
|
+
handler: async () => {
|
|
354
|
+
selectAll();
|
|
355
|
+
}
|
|
356
|
+
},
|
|
357
|
+
null, // Separator
|
|
358
|
+
{
|
|
359
|
+
label: "Export",
|
|
360
|
+
icon: "icon_google_download",
|
|
361
|
+
type: "secondary",
|
|
362
|
+
disabled: selectedItems.length === 0,
|
|
363
|
+
handler: async () => {
|
|
364
|
+
await exportItems(selectedItems);
|
|
365
|
+
}
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
label: "Delete Selected",
|
|
369
|
+
icon: "icon_google_delete",
|
|
370
|
+
type: "third",
|
|
371
|
+
disabled: selectedItems.length === 0,
|
|
372
|
+
handler: async () => {
|
|
373
|
+
if (confirm(`Delete ${selectedItems.length} items?`)) {
|
|
374
|
+
await deleteItems(selectedItems);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
];
|
|
379
|
+
</script>
|
|
380
|
+
|
|
381
|
+
<div class="toolbar">
|
|
382
|
+
<div class="toolbar-info">
|
|
383
|
+
{selectedItems.length} items selected
|
|
384
|
+
</div>
|
|
385
|
+
<ActionBar buttons={toolbarActions} />
|
|
386
|
+
</div>
|
|
387
|
+
|
|
388
|
+
<style>
|
|
389
|
+
.toolbar {
|
|
390
|
+
display: flex;
|
|
391
|
+
justify-content: space-between;
|
|
392
|
+
align-items: center;
|
|
393
|
+
padding: 12px;
|
|
394
|
+
border-bottom: 1px solid #eee;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
.toolbar-info {
|
|
398
|
+
color: #666;
|
|
399
|
+
font-size: 14px;
|
|
400
|
+
}
|
|
401
|
+
</style>
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
## Best Practices
|
|
405
|
+
|
|
406
|
+
### 1. Use Appropriate Button Types
|
|
407
|
+
|
|
408
|
+
Choose the correct button type based on action importance:
|
|
409
|
+
|
|
410
|
+
```svelte
|
|
411
|
+
<!-- Primary actions -->
|
|
412
|
+
<Button label="Save" type="primary" />
|
|
413
|
+
<Button label="Submit" type="primary" />
|
|
414
|
+
|
|
415
|
+
<!-- Secondary actions -->
|
|
416
|
+
<Button label="Cancel" type="secondary" />
|
|
417
|
+
<Button label="Preview" type="secondary" />
|
|
418
|
+
|
|
419
|
+
<!-- Dangerous actions -->
|
|
420
|
+
<Button label="Delete" type="third" />
|
|
421
|
+
<Button label="Remove" type="third" />
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
### 2. Handle Async Operations Properly
|
|
425
|
+
|
|
426
|
+
Always handle loading states and errors:
|
|
427
|
+
|
|
428
|
+
```svelte
|
|
429
|
+
<script lang="ts">
|
|
430
|
+
let isLoading = false;
|
|
431
|
+
let error = null;
|
|
432
|
+
|
|
433
|
+
const handleAction = async () => {
|
|
434
|
+
isLoading = true;
|
|
435
|
+
error = null;
|
|
436
|
+
|
|
437
|
+
try {
|
|
438
|
+
await performAction();
|
|
439
|
+
} catch (err) {
|
|
440
|
+
error = err.message;
|
|
441
|
+
} finally {
|
|
442
|
+
isLoading = false;
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
</script>
|
|
446
|
+
|
|
447
|
+
<Button
|
|
448
|
+
label={isLoading ? "Processing..." : "Start Process"}
|
|
449
|
+
type="primary"
|
|
450
|
+
disabled={isLoading}
|
|
451
|
+
onClick={handleAction}
|
|
452
|
+
/>
|
|
453
|
+
|
|
454
|
+
{#if error}
|
|
455
|
+
<div class="error">{error}</div>
|
|
456
|
+
{/if}
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
### 3. Use ActionBar to Group Related Actions
|
|
460
|
+
|
|
461
|
+
Group related actions together:
|
|
462
|
+
|
|
463
|
+
```svelte
|
|
464
|
+
<script lang="ts">
|
|
465
|
+
const dialogActions = [
|
|
466
|
+
{ label: "Cancel", type: "secondary", handler: cancel },
|
|
467
|
+
{ label: "Apply", type: "primary", handler: apply }
|
|
468
|
+
];
|
|
469
|
+
|
|
470
|
+
const editActions = [
|
|
471
|
+
{ label: "Undo", icon: "icon_google_undo", handler: undo },
|
|
472
|
+
{ label: "Redo", icon: "icon_google_redo", handler: redo },
|
|
473
|
+
null, // Separator
|
|
474
|
+
{ label: "Save", type: "primary", handler: save }
|
|
475
|
+
];
|
|
476
|
+
</script>
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
### 4. Provide Visual Feedback
|
|
480
|
+
|
|
481
|
+
Use icons and appropriate styling:
|
|
482
|
+
|
|
483
|
+
```svelte
|
|
484
|
+
<!-- Success actions -->
|
|
485
|
+
<Button label="Save" icon="icon_google_save" type="primary" />
|
|
486
|
+
|
|
487
|
+
<!-- Dangerous actions -->
|
|
488
|
+
<Button label="Delete" icon="icon_google_delete" type="third" />
|
|
489
|
+
|
|
490
|
+
<!-- Navigation actions -->
|
|
491
|
+
<Button label="Back" icon="icon_google_arrow_back" type="secondary" />
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
### 5. Consider Mobile Responsiveness
|
|
495
|
+
|
|
496
|
+
Use appropriate sizes for different screen sizes:
|
|
497
|
+
|
|
498
|
+
```svelte
|
|
499
|
+
<div class="responsive-buttons">
|
|
500
|
+
<!-- Desktop: normal size, Mobile: larger for touch -->
|
|
501
|
+
<Button label="Action" size="big" class="mobile-friendly" />
|
|
502
|
+
</div>
|
|
503
|
+
|
|
504
|
+
<style>
|
|
505
|
+
.responsive-buttons .mobile-friendly {
|
|
506
|
+
/* Responsive styles */
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
@media (max-width: 768px) {
|
|
510
|
+
.responsive-buttons .mobile-friendly {
|
|
511
|
+
min-height: 44px; /* iOS recommended touch target size */
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
</style>
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
## Accessibility
|
|
518
|
+
|
|
519
|
+
### Current Limitations
|
|
520
|
+
|
|
521
|
+
**⚠️ Important Note**: The current button components have the following accessibility limitations:
|
|
522
|
+
|
|
523
|
+
- **Non-semantic elements**: All buttons use `<div>` elements instead of `<button>`
|
|
524
|
+
- **Hidden from screen readers**: All buttons have `aria-hidden="true"` by default
|
|
525
|
+
- **No keyboard navigation**: Components don't support Tab navigation or Enter/Space activation
|
|
526
|
+
- **No focus management**: Components don't provide focus method or support `bind:this`
|
|
527
|
+
- **No ARIA attribute support**: Custom aria-* attributes cannot be passed
|
|
528
|
+
|
|
529
|
+
### Better Accessibility Suggestions
|
|
530
|
+
|
|
531
|
+
For production applications requiring full accessibility compliance, consider:
|
|
532
|
+
|
|
533
|
+
1. **Wrap components in proper button elements**:
|
|
534
|
+
```svelte
|
|
535
|
+
<button
|
|
536
|
+
class="custom-button-wrapper"
|
|
537
|
+
disabled={disabled}
|
|
538
|
+
aria-label="Edit user profile"
|
|
539
|
+
on:click={handleClick}
|
|
540
|
+
>
|
|
541
|
+
<IconButton
|
|
542
|
+
icon="icon_google_edit"
|
|
543
|
+
onClick={() => {}} // Handle through external button
|
|
544
|
+
/>
|
|
545
|
+
</button>
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
2. **Add keyboard event handlers**:
|
|
549
|
+
```svelte
|
|
550
|
+
<script>
|
|
551
|
+
const handleKeydown = (e) => {
|
|
552
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
553
|
+
e.preventDefault();
|
|
554
|
+
handleClick(e);
|
|
555
|
+
}
|
|
556
|
+
};
|
|
557
|
+
</script>
|
|
558
|
+
|
|
559
|
+
<div
|
|
560
|
+
class="accessible-button"
|
|
561
|
+
role="button"
|
|
562
|
+
tabindex="0"
|
|
563
|
+
aria-label="Action description"
|
|
564
|
+
on:click={handleClick}
|
|
565
|
+
on:keydown={handleKeydown}
|
|
566
|
+
>
|
|
567
|
+
<Button onClick={() => {}} label="Action" />
|
|
568
|
+
</div>
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
3. **Programmatically manage focus**:
|
|
572
|
+
```svelte
|
|
573
|
+
<script>
|
|
574
|
+
let buttonElement;
|
|
575
|
+
|
|
576
|
+
const focusButton = () => {
|
|
577
|
+
buttonElement?.focus();
|
|
578
|
+
};
|
|
579
|
+
</script>
|
|
580
|
+
|
|
581
|
+
<div
|
|
582
|
+
bind:this={buttonElement}
|
|
583
|
+
class="focusable-wrapper"
|
|
584
|
+
tabindex="0"
|
|
585
|
+
role="button"
|
|
586
|
+
on:click={handleAction}
|
|
587
|
+
>
|
|
588
|
+
<Button onClick={() => {}} label="Focusable Action" />
|
|
589
|
+
</div>
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
### Future Improvements Needed
|
|
593
|
+
|
|
594
|
+
To make these components fully accessible, the following changes are recommended:
|
|
595
|
+
|
|
596
|
+
- Replace `<div>` with `<button>` elements
|
|
597
|
+
- Remove `aria-hidden="true"` and allow ARIA attribute customization
|
|
598
|
+
- Add keyboard event handling
|
|
599
|
+
- Support focus management with `bind:this`
|
|
600
|
+
- Add proper semantic roles and states
|