@ticatec/uniface-element 0.2.3 → 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/DialogBoard.svelte +1 -1
- 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/ticatec-uniface-web.css +1 -0
- 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,632 @@
|
|
|
1
|
+
# OptionsSelect
|
|
2
|
+
|
|
3
|
+
A single-selection dropdown component that allows users to select one option from a predefined list with customizable styling and behavior.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Single Selection**: Select one option from a dropdown list
|
|
8
|
+
- **Custom Field Mapping**: Configure which object properties to use for keys and display text
|
|
9
|
+
- **Option Control**: Hide or disable specific options
|
|
10
|
+
- **Custom Rendering**: Use custom components to render dropdown items
|
|
11
|
+
- **Mandatory Mode**: Prevent clearing of selected values
|
|
12
|
+
- **Search Integration**: Works with CommonPicker for consistent behavior
|
|
13
|
+
- **Focus Management**: Proper focus handling and keyboard navigation
|
|
14
|
+
- **Display Modes**: Support for edit and view modes
|
|
15
|
+
- **Empty State Handling**: Customizable placeholder and empty text
|
|
16
|
+
- **Event Callbacks**: Rich event handling for selection, focus, and blur
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @ticatec/uniface-element
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Basic Usage
|
|
25
|
+
|
|
26
|
+
```svelte
|
|
27
|
+
<script>
|
|
28
|
+
import OptionsSelect from '@ticatec/uniface-element/OptionsSelect';
|
|
29
|
+
|
|
30
|
+
let selectedValue = null;
|
|
31
|
+
let options = [
|
|
32
|
+
{ code: 'JS', text: 'JavaScript' },
|
|
33
|
+
{ code: 'TS', text: 'TypeScript' },
|
|
34
|
+
{ code: 'PY', text: 'Python' }
|
|
35
|
+
];
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<OptionsSelect
|
|
39
|
+
{options}
|
|
40
|
+
bind:value={selectedValue}
|
|
41
|
+
/>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## API Reference
|
|
45
|
+
|
|
46
|
+
### Props
|
|
47
|
+
|
|
48
|
+
| Prop | Type | Default | Description |
|
|
49
|
+
|------|------|---------|-------------|
|
|
50
|
+
| `value` | `any` | `null` | Selected option key/value |
|
|
51
|
+
| `options` | `Array<any>` | `[]` | Array of option objects |
|
|
52
|
+
| `keyField` | `string` | `'code'` | Property name for option keys |
|
|
53
|
+
| `textField` | `string` | `'text'` | Property name for option display text |
|
|
54
|
+
| `variant` | `'' \| 'plain' \| 'outlined' \| 'filled'` | `''` | Visual style variant |
|
|
55
|
+
| `compact` | `boolean` | `false` | Enables compact display mode |
|
|
56
|
+
| `disabled` | `boolean` | `false` | Disables the component |
|
|
57
|
+
| `readonly` | `boolean` | `false` | Makes the component read-only |
|
|
58
|
+
| `mandatory` | `boolean` | `false` | Prevents clearing selected value |
|
|
59
|
+
| `style` | `string` | `''` | Custom CSS styles |
|
|
60
|
+
| `placeholder` | `string` | `''` | Placeholder text when no option selected |
|
|
61
|
+
| `emptyText` | `string` | `null` | Text to show when no option selected (overrides placeholder) |
|
|
62
|
+
| `disableOptions` | `Array<string>` | `[]` | Keys of options to disable |
|
|
63
|
+
| `hideOptions` | `Array<string>` | `[]` | Keys of options to hide |
|
|
64
|
+
| `displayMode` | `DisplayMode` | `DisplayMode.Edit` | Edit or view mode |
|
|
65
|
+
| `menu$height` | `number` | `0` | Maximum height of dropdown menu |
|
|
66
|
+
| `itemRender` | `any` | `null` | Custom component for rendering items |
|
|
67
|
+
| `onchange` | `OnChangeHandler<any>` | `null` | Change event handler |
|
|
68
|
+
| `onfocus` | `(() => void) \| null` | `null` | Focus event handler |
|
|
69
|
+
| `onblur` | `(() => void) \| null` | `null` | Blur event handler |
|
|
70
|
+
| `onSelected` | `OnSelectedHandler` | `null` | Selection event handler with full item data |
|
|
71
|
+
|
|
72
|
+
### Methods
|
|
73
|
+
|
|
74
|
+
| Method | Description |
|
|
75
|
+
|--------|-------------|
|
|
76
|
+
| `setFocus()` | Programmatically focus the component |
|
|
77
|
+
|
|
78
|
+
## Examples
|
|
79
|
+
|
|
80
|
+
### Currency Selector
|
|
81
|
+
|
|
82
|
+
```svelte
|
|
83
|
+
<script>
|
|
84
|
+
import OptionsSelect from '@ticatec/uniface-element/OptionsSelect';
|
|
85
|
+
import FormField from '@ticatec/uniface-element/FormField';
|
|
86
|
+
|
|
87
|
+
let selectedCurrency = 'USD';
|
|
88
|
+
let currencies = [
|
|
89
|
+
{ code: 'USD', text: 'US Dollar' },
|
|
90
|
+
{ code: 'EUR', text: 'Euro' },
|
|
91
|
+
{ code: 'GBP', text: 'British Pound' },
|
|
92
|
+
{ code: 'JPY', text: 'Japanese Yen' },
|
|
93
|
+
{ code: 'CNY', text: 'Chinese Yuan' }
|
|
94
|
+
];
|
|
95
|
+
|
|
96
|
+
function handleCurrencyChange(currency) {
|
|
97
|
+
console.log('Currency changed to:', currency);
|
|
98
|
+
}
|
|
99
|
+
</script>
|
|
100
|
+
|
|
101
|
+
<FormField label="Currency">
|
|
102
|
+
<OptionsSelect
|
|
103
|
+
options={currencies}
|
|
104
|
+
bind:value={selectedCurrency}
|
|
105
|
+
variant="outlined"
|
|
106
|
+
placeholder="Select currency"
|
|
107
|
+
onchange={handleCurrencyChange}
|
|
108
|
+
/>
|
|
109
|
+
</FormField>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Country Selector with Custom Fields
|
|
113
|
+
|
|
114
|
+
```svelte
|
|
115
|
+
<script>
|
|
116
|
+
import OptionsSelect from '@ticatec/uniface-element/OptionsSelect';
|
|
117
|
+
|
|
118
|
+
let selectedCountry = null;
|
|
119
|
+
let countries = [
|
|
120
|
+
{ id: 'US', name: 'United States' },
|
|
121
|
+
{ id: 'CA', name: 'Canada' },
|
|
122
|
+
{ id: 'UK', name: 'United Kingdom' },
|
|
123
|
+
{ id: 'DE', name: 'Germany' },
|
|
124
|
+
{ id: 'JP', name: 'Japan' }
|
|
125
|
+
];
|
|
126
|
+
|
|
127
|
+
function handleCountrySelection(countryItem) {
|
|
128
|
+
console.log('Selected country object:', countryItem);
|
|
129
|
+
}
|
|
130
|
+
</script>
|
|
131
|
+
|
|
132
|
+
<OptionsSelect
|
|
133
|
+
options={countries}
|
|
134
|
+
keyField="id"
|
|
135
|
+
textField="name"
|
|
136
|
+
bind:value={selectedCountry}
|
|
137
|
+
variant="filled"
|
|
138
|
+
placeholder="Choose your country"
|
|
139
|
+
onSelected={handleCountrySelection}
|
|
140
|
+
/>
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Status Selector with Disabled Options
|
|
144
|
+
|
|
145
|
+
```svelte
|
|
146
|
+
<script>
|
|
147
|
+
import OptionsSelect from '@ticatec/uniface-element/OptionsSelect';
|
|
148
|
+
|
|
149
|
+
let taskStatus = 'PENDING';
|
|
150
|
+
let statusOptions = [
|
|
151
|
+
{ code: 'PENDING', text: 'Pending' },
|
|
152
|
+
{ code: 'IN_PROGRESS', text: 'In Progress' },
|
|
153
|
+
{ code: 'REVIEW', text: 'Under Review' },
|
|
154
|
+
{ code: 'COMPLETED', text: 'Completed' },
|
|
155
|
+
{ code: 'CANCELLED', text: 'Cancelled' },
|
|
156
|
+
{ code: 'ARCHIVED', text: 'Archived' }
|
|
157
|
+
];
|
|
158
|
+
|
|
159
|
+
let disabledStatuses = ['ARCHIVED']; // Archive status not available
|
|
160
|
+
let hiddenStatuses = ['CANCELLED']; // Hide cancelled option
|
|
161
|
+
</script>
|
|
162
|
+
|
|
163
|
+
<div class="status-selector">
|
|
164
|
+
<label>Task Status</label>
|
|
165
|
+
<OptionsSelect
|
|
166
|
+
options={statusOptions}
|
|
167
|
+
bind:value={taskStatus}
|
|
168
|
+
variant="outlined"
|
|
169
|
+
disableOptions={disabledStatuses}
|
|
170
|
+
hideOptions={hiddenStatuses}
|
|
171
|
+
mandatory
|
|
172
|
+
emptyText="No status set"
|
|
173
|
+
/>
|
|
174
|
+
</div>
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Language Preference
|
|
178
|
+
|
|
179
|
+
```svelte
|
|
180
|
+
<script>
|
|
181
|
+
import OptionsSelect from '@ticatec/uniface-element/OptionsSelect';
|
|
182
|
+
|
|
183
|
+
let preferredLanguage = null;
|
|
184
|
+
let languages = [
|
|
185
|
+
{ locale: 'en', display: 'English' },
|
|
186
|
+
{ locale: 'es', display: 'Espa�ol' },
|
|
187
|
+
{ locale: 'fr', display: 'Fran�ais' },
|
|
188
|
+
{ locale: 'de', display: 'Deutsch' },
|
|
189
|
+
{ locale: 'zh', display: '-�' },
|
|
190
|
+
{ locale: 'ja', display: '�,�' }
|
|
191
|
+
];
|
|
192
|
+
|
|
193
|
+
function handleLanguageChange(locale) {
|
|
194
|
+
console.log('Language changed to:', locale);
|
|
195
|
+
// Update application language
|
|
196
|
+
updateAppLanguage(locale);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function handleFocus() {
|
|
200
|
+
console.log('Language selector focused');
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function handleBlur() {
|
|
204
|
+
console.log('Language selector blurred');
|
|
205
|
+
}
|
|
206
|
+
</script>
|
|
207
|
+
|
|
208
|
+
<div class="language-settings">
|
|
209
|
+
<OptionsSelect
|
|
210
|
+
options={languages}
|
|
211
|
+
keyField="locale"
|
|
212
|
+
textField="display"
|
|
213
|
+
bind:value={preferredLanguage}
|
|
214
|
+
variant="filled"
|
|
215
|
+
placeholder="Select your language"
|
|
216
|
+
onchange={handleLanguageChange}
|
|
217
|
+
onfocus={handleFocus}
|
|
218
|
+
onblur={handleBlur}
|
|
219
|
+
/>
|
|
220
|
+
</div>
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Priority Selector with Custom Styling
|
|
224
|
+
|
|
225
|
+
```svelte
|
|
226
|
+
<script>
|
|
227
|
+
import OptionsSelect from '@ticatec/uniface-element/OptionsSelect';
|
|
228
|
+
import PriorityItem from './PriorityItem.svelte'; // Custom component
|
|
229
|
+
|
|
230
|
+
let priority = 'MEDIUM';
|
|
231
|
+
let priorities = [
|
|
232
|
+
{ level: 'LOW', label: 'Low Priority', color: '#4caf50' },
|
|
233
|
+
{ level: 'MEDIUM', label: 'Medium Priority', color: '#ff9800' },
|
|
234
|
+
{ level: 'HIGH', label: 'High Priority', color: '#f44336' },
|
|
235
|
+
{ level: 'URGENT', label: 'Urgent', color: '#9c27b0' }
|
|
236
|
+
];
|
|
237
|
+
|
|
238
|
+
const priorityRenderer = {
|
|
239
|
+
component: PriorityItem,
|
|
240
|
+
props: {
|
|
241
|
+
showIcon: true
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
</script>
|
|
245
|
+
|
|
246
|
+
<div class="priority-selector">
|
|
247
|
+
<label>Task Priority</label>
|
|
248
|
+
<OptionsSelect
|
|
249
|
+
options={priorities}
|
|
250
|
+
keyField="level"
|
|
251
|
+
textField="label"
|
|
252
|
+
bind:value={priority}
|
|
253
|
+
variant="outlined"
|
|
254
|
+
itemRender={priorityRenderer}
|
|
255
|
+
mandatory
|
|
256
|
+
/>
|
|
257
|
+
</div>
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### Theme Selector
|
|
261
|
+
|
|
262
|
+
```svelte
|
|
263
|
+
<script>
|
|
264
|
+
import OptionsSelect from '@ticatec/uniface-element/OptionsSelect';
|
|
265
|
+
|
|
266
|
+
let currentTheme = 'light';
|
|
267
|
+
let themes = [
|
|
268
|
+
{ code: 'light', text: 'Light Theme' },
|
|
269
|
+
{ code: 'dark', text: 'Dark Theme' },
|
|
270
|
+
{ code: 'auto', text: 'System Default' },
|
|
271
|
+
{ code: 'high-contrast', text: 'High Contrast' }
|
|
272
|
+
];
|
|
273
|
+
|
|
274
|
+
function applyTheme(themeCode) {
|
|
275
|
+
console.log('Applying theme:', themeCode);
|
|
276
|
+
document.documentElement.setAttribute('data-theme', themeCode);
|
|
277
|
+
}
|
|
278
|
+
</script>
|
|
279
|
+
|
|
280
|
+
<div class="theme-settings">
|
|
281
|
+
<h3>Appearance</h3>
|
|
282
|
+
<OptionsSelect
|
|
283
|
+
options={themes}
|
|
284
|
+
bind:value={currentTheme}
|
|
285
|
+
variant="outlined"
|
|
286
|
+
mandatory
|
|
287
|
+
onchange={applyTheme}
|
|
288
|
+
style="width: 200px;"
|
|
289
|
+
/>
|
|
290
|
+
</div>
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### Form with Multiple Selectors
|
|
294
|
+
|
|
295
|
+
```svelte
|
|
296
|
+
<script>
|
|
297
|
+
import OptionsSelect from '@ticatec/uniface-element/OptionsSelect';
|
|
298
|
+
import FormField from '@ticatec/uniface-element/FormField';
|
|
299
|
+
|
|
300
|
+
let userProfile = {
|
|
301
|
+
gender: null,
|
|
302
|
+
country: null,
|
|
303
|
+
timezone: null,
|
|
304
|
+
currency: 'USD'
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
let genders = [
|
|
308
|
+
{ code: 'M', text: 'Male' },
|
|
309
|
+
{ code: 'F', text: 'Female' },
|
|
310
|
+
{ code: 'O', text: 'Other' },
|
|
311
|
+
{ code: 'N', text: 'Prefer not to say' }
|
|
312
|
+
];
|
|
313
|
+
|
|
314
|
+
let countries = [
|
|
315
|
+
{ id: 'US', name: 'United States' },
|
|
316
|
+
{ id: 'CA', name: 'Canada' },
|
|
317
|
+
{ id: 'UK', name: 'United Kingdom' },
|
|
318
|
+
{ id: 'AU', name: 'Australia' }
|
|
319
|
+
];
|
|
320
|
+
|
|
321
|
+
let timezones = [
|
|
322
|
+
{ code: 'UTC', text: 'UTC' },
|
|
323
|
+
{ code: 'EST', text: 'Eastern Time' },
|
|
324
|
+
{ code: 'PST', text: 'Pacific Time' },
|
|
325
|
+
{ code: 'GMT', text: 'Greenwich Mean Time' }
|
|
326
|
+
];
|
|
327
|
+
|
|
328
|
+
let currencies = [
|
|
329
|
+
{ code: 'USD', text: 'US Dollar' },
|
|
330
|
+
{ code: 'EUR', text: 'Euro' },
|
|
331
|
+
{ code: 'GBP', text: 'British Pound' },
|
|
332
|
+
{ code: 'CAD', text: 'Canadian Dollar' }
|
|
333
|
+
];
|
|
334
|
+
|
|
335
|
+
function saveProfile() {
|
|
336
|
+
console.log('Saving profile:', userProfile);
|
|
337
|
+
}
|
|
338
|
+
</script>
|
|
339
|
+
|
|
340
|
+
<div class="profile-form">
|
|
341
|
+
<h3>User Profile</h3>
|
|
342
|
+
|
|
343
|
+
<FormField label="Gender">
|
|
344
|
+
<OptionsSelect
|
|
345
|
+
options={genders}
|
|
346
|
+
bind:value={userProfile.gender}
|
|
347
|
+
variant="outlined"
|
|
348
|
+
placeholder="Select gender"
|
|
349
|
+
/>
|
|
350
|
+
</FormField>
|
|
351
|
+
|
|
352
|
+
<FormField label="Country">
|
|
353
|
+
<OptionsSelect
|
|
354
|
+
options={countries}
|
|
355
|
+
keyField="id"
|
|
356
|
+
textField="name"
|
|
357
|
+
bind:value={userProfile.country}
|
|
358
|
+
variant="outlined"
|
|
359
|
+
placeholder="Select country"
|
|
360
|
+
mandatory
|
|
361
|
+
/>
|
|
362
|
+
</FormField>
|
|
363
|
+
|
|
364
|
+
<FormField label="Timezone">
|
|
365
|
+
<OptionsSelect
|
|
366
|
+
options={timezones}
|
|
367
|
+
bind:value={userProfile.timezone}
|
|
368
|
+
variant="outlined"
|
|
369
|
+
placeholder="Select timezone"
|
|
370
|
+
/>
|
|
371
|
+
</FormField>
|
|
372
|
+
|
|
373
|
+
<FormField label="Currency">
|
|
374
|
+
<OptionsSelect
|
|
375
|
+
options={currencies}
|
|
376
|
+
bind:value={userProfile.currency}
|
|
377
|
+
variant="outlined"
|
|
378
|
+
mandatory
|
|
379
|
+
/>
|
|
380
|
+
</FormField>
|
|
381
|
+
|
|
382
|
+
<button on:click={saveProfile}>Save Profile</button>
|
|
383
|
+
</div>
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
### Compact Table Usage
|
|
387
|
+
|
|
388
|
+
```svelte
|
|
389
|
+
<script>
|
|
390
|
+
import OptionsSelect from '@ticatec/uniface-element/OptionsSelect';
|
|
391
|
+
|
|
392
|
+
let statusOptions = [
|
|
393
|
+
{ code: 'ACTIVE', text: 'Active' },
|
|
394
|
+
{ code: 'INACTIVE', text: 'Inactive' },
|
|
395
|
+
{ code: 'PENDING', text: 'Pending' }
|
|
396
|
+
];
|
|
397
|
+
|
|
398
|
+
let users = [
|
|
399
|
+
{ id: 1, name: 'John Doe', status: 'ACTIVE' },
|
|
400
|
+
{ id: 2, name: 'Jane Smith', status: 'INACTIVE' },
|
|
401
|
+
{ id: 3, name: 'Bob Wilson', status: 'PENDING' }
|
|
402
|
+
];
|
|
403
|
+
|
|
404
|
+
function updateUserStatus(userId, newStatus) {
|
|
405
|
+
const user = users.find(u => u.id === userId);
|
|
406
|
+
if (user) {
|
|
407
|
+
user.status = newStatus;
|
|
408
|
+
users = [...users];
|
|
409
|
+
console.log(`User ${user.name} status updated to ${newStatus}`);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
</script>
|
|
413
|
+
|
|
414
|
+
<table class="user-table">
|
|
415
|
+
<thead>
|
|
416
|
+
<tr>
|
|
417
|
+
<th>Name</th>
|
|
418
|
+
<th>Status</th>
|
|
419
|
+
</tr>
|
|
420
|
+
</thead>
|
|
421
|
+
<tbody>
|
|
422
|
+
{#each users as user}
|
|
423
|
+
<tr>
|
|
424
|
+
<td>{user.name}</td>
|
|
425
|
+
<td>
|
|
426
|
+
<OptionsSelect
|
|
427
|
+
options={statusOptions}
|
|
428
|
+
value={user.status}
|
|
429
|
+
compact
|
|
430
|
+
variant="outlined"
|
|
431
|
+
onchange={(status) => updateUserStatus(user.id, status)}
|
|
432
|
+
/>
|
|
433
|
+
</td>
|
|
434
|
+
</tr>
|
|
435
|
+
{/each}
|
|
436
|
+
</tbody>
|
|
437
|
+
</table>
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
### Dynamic Options Loading
|
|
441
|
+
|
|
442
|
+
```svelte
|
|
443
|
+
<script>
|
|
444
|
+
import OptionsSelect from '@ticatec/uniface-element/OptionsSelect';
|
|
445
|
+
|
|
446
|
+
let selectedCategory = null;
|
|
447
|
+
let selectedProduct = null;
|
|
448
|
+
let categories = [
|
|
449
|
+
{ id: 'electronics', name: 'Electronics' },
|
|
450
|
+
{ id: 'clothing', name: 'Clothing' },
|
|
451
|
+
{ id: 'books', name: 'Books' }
|
|
452
|
+
];
|
|
453
|
+
let products = [];
|
|
454
|
+
|
|
455
|
+
async function loadProducts(categoryId) {
|
|
456
|
+
if (!categoryId) {
|
|
457
|
+
products = [];
|
|
458
|
+
selectedProduct = null;
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// Simulate API call
|
|
463
|
+
const productData = {
|
|
464
|
+
'electronics': [
|
|
465
|
+
{ sku: 'E001', name: 'Laptop' },
|
|
466
|
+
{ sku: 'E002', name: 'Smartphone' }
|
|
467
|
+
],
|
|
468
|
+
'clothing': [
|
|
469
|
+
{ sku: 'C001', name: 'T-Shirt' },
|
|
470
|
+
{ sku: 'C002', name: 'Jeans' }
|
|
471
|
+
],
|
|
472
|
+
'books': [
|
|
473
|
+
{ sku: 'B001', name: 'Programming Guide' },
|
|
474
|
+
{ sku: 'B002', name: 'Design Patterns' }
|
|
475
|
+
]
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
products = productData[categoryId] || [];
|
|
479
|
+
selectedProduct = null;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
$: loadProducts(selectedCategory);
|
|
483
|
+
</script>
|
|
484
|
+
|
|
485
|
+
<div class="product-selector">
|
|
486
|
+
<div class="selector-row">
|
|
487
|
+
<label>Category</label>
|
|
488
|
+
<OptionsSelect
|
|
489
|
+
options={categories}
|
|
490
|
+
keyField="id"
|
|
491
|
+
textField="name"
|
|
492
|
+
bind:value={selectedCategory}
|
|
493
|
+
variant="outlined"
|
|
494
|
+
placeholder="Select category"
|
|
495
|
+
/>
|
|
496
|
+
</div>
|
|
497
|
+
|
|
498
|
+
<div class="selector-row">
|
|
499
|
+
<label>Product</label>
|
|
500
|
+
<OptionsSelect
|
|
501
|
+
options={products}
|
|
502
|
+
keyField="sku"
|
|
503
|
+
textField="name"
|
|
504
|
+
bind:value={selectedProduct}
|
|
505
|
+
variant="outlined"
|
|
506
|
+
placeholder={selectedCategory ? 'Select product' : 'Select category first'}
|
|
507
|
+
disabled={!selectedCategory}
|
|
508
|
+
/>
|
|
509
|
+
</div>
|
|
510
|
+
</div>
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
## Custom Item Rendering
|
|
514
|
+
|
|
515
|
+
You can provide a custom component to render dropdown items:
|
|
516
|
+
|
|
517
|
+
```svelte
|
|
518
|
+
<!-- CustomItemRenderer.svelte -->
|
|
519
|
+
<script>
|
|
520
|
+
export let item;
|
|
521
|
+
export let disabled = false;
|
|
522
|
+
|
|
523
|
+
import { createEventDispatcher } from 'svelte';
|
|
524
|
+
const dispatch = createEventDispatcher();
|
|
525
|
+
|
|
526
|
+
function handleClick() {
|
|
527
|
+
if (!disabled) {
|
|
528
|
+
dispatch('click');
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
</script>
|
|
532
|
+
|
|
533
|
+
<div class="custom-item" class:disabled on:click={handleClick}>
|
|
534
|
+
<div class="item-icon"><�</div>
|
|
535
|
+
<div class="item-content">
|
|
536
|
+
<div class="item-title">{item.title}</div>
|
|
537
|
+
<div class="item-description">{item.description}</div>
|
|
538
|
+
</div>
|
|
539
|
+
</div>
|
|
540
|
+
|
|
541
|
+
<style>
|
|
542
|
+
.custom-item {
|
|
543
|
+
display: flex;
|
|
544
|
+
align-items: center;
|
|
545
|
+
padding: 12px;
|
|
546
|
+
cursor: pointer;
|
|
547
|
+
border-bottom: 1px solid #eee;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
.custom-item:hover:not(.disabled) {
|
|
551
|
+
background-color: #f5f5f5;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
.custom-item.disabled {
|
|
555
|
+
opacity: 0.5;
|
|
556
|
+
cursor: not-allowed;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
.item-icon {
|
|
560
|
+
margin-right: 12px;
|
|
561
|
+
font-size: 18px;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
.item-title {
|
|
565
|
+
font-weight: 600;
|
|
566
|
+
margin-bottom: 4px;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
.item-description {
|
|
570
|
+
font-size: 12px;
|
|
571
|
+
color: #666;
|
|
572
|
+
}
|
|
573
|
+
</style>
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
## Best Practices
|
|
577
|
+
|
|
578
|
+
1. **Option Management**: Keep option lists focused and relevant
|
|
579
|
+
2. **Performance**: Consider virtualizing for very large option lists
|
|
580
|
+
3. **Accessibility**: Provide clear labels and meaningful option text
|
|
581
|
+
4. **User Experience**: Use appropriate variants and sizing for your design
|
|
582
|
+
5. **Data Validation**: Handle edge cases like missing options
|
|
583
|
+
6. **Loading States**: Show loading indicators for dynamic options
|
|
584
|
+
7. **Error Handling**: Gracefully handle API failures for dynamic options
|
|
585
|
+
|
|
586
|
+
## Styling
|
|
587
|
+
|
|
588
|
+
```css
|
|
589
|
+
.options-popover {
|
|
590
|
+
max-height: 300px;
|
|
591
|
+
overflow-y: auto;
|
|
592
|
+
border: 1px solid #e0e0e0;
|
|
593
|
+
border-radius: 4px;
|
|
594
|
+
background: white;
|
|
595
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
.option-item {
|
|
599
|
+
padding: 8px 12px;
|
|
600
|
+
cursor: pointer;
|
|
601
|
+
border-bottom: 1px solid #f0f0f0;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
.option-item:hover:not(.disabled) {
|
|
605
|
+
background-color: #f5f5f5;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
.option-item.disabled {
|
|
609
|
+
opacity: 0.5;
|
|
610
|
+
cursor: not-allowed;
|
|
611
|
+
background-color: #fafafa;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
.option-item:last-child {
|
|
615
|
+
border-bottom: none;
|
|
616
|
+
}
|
|
617
|
+
```
|
|
618
|
+
|
|
619
|
+
## Accessibility
|
|
620
|
+
|
|
621
|
+
- Full keyboard navigation support (Arrow keys, Enter, Escape)
|
|
622
|
+
- ARIA labels and roles for screen readers
|
|
623
|
+
- Focus management and visual indicators
|
|
624
|
+
- High contrast mode compatibility
|
|
625
|
+
- Proper labeling for form associations
|
|
626
|
+
|
|
627
|
+
## Related Components
|
|
628
|
+
|
|
629
|
+
- [OptionsMultiSelect](../options-multi-select/README.md) - For multiple option selection
|
|
630
|
+
- [FormField](../form-field/README.md) - For form layout and labels
|
|
631
|
+
- [CommonPicker](../common/README.md) - Base picker functionality
|
|
632
|
+
- [LookupEditor](../lookup-editor/README.md) - For dynamic data lookup
|