@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
|
@@ -24,12 +24,11 @@ declare const LookupEditor: $$__sveltets_2_IsomorphicComponent<{
|
|
|
24
24
|
placeholder?: string;
|
|
25
25
|
displayMode?: DisplayMode;
|
|
26
26
|
text: string;
|
|
27
|
-
|
|
27
|
+
onchange?: OnChangeHandler<any>;
|
|
28
28
|
onAction?: () => void;
|
|
29
|
+
onfocus?: (event: FocusEvent) => void;
|
|
30
|
+
onblur?: (event: FocusEvent) => void;
|
|
29
31
|
}, {
|
|
30
|
-
keydown: KeyboardEvent;
|
|
31
|
-
focus: FocusEvent;
|
|
32
|
-
} & {
|
|
33
32
|
[evt: string]: CustomEvent<any>;
|
|
34
33
|
}, {}, {}, string>;
|
|
35
34
|
type LookupEditor = InstanceType<typeof LookupEditor>;
|
|
@@ -0,0 +1,684 @@
|
|
|
1
|
+
# LookupEditor
|
|
2
|
+
|
|
3
|
+
A lookup input component that provides a read-only text field with an action button to open external selection dialogs or modal windows.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Read-Only Input**: Displays selected values as text without direct editing
|
|
8
|
+
- **Action Trigger**: Built-in action button to open lookup dialogs or modal windows
|
|
9
|
+
- **Multiple Variants**: Support for plain, outlined, and filled styles
|
|
10
|
+
- **Form Integration**: Works seamlessly with forms and validation
|
|
11
|
+
- **Keyboard Support**: Handles keyboard navigation and events
|
|
12
|
+
- **Focus Events**: Supports focus and blur event handling
|
|
13
|
+
- **Clearable Values**: Optional clear functionality for non-mandatory fields
|
|
14
|
+
- **Display Modes**: Supports both edit and display modes
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @ticatec/uniface-element
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
### Basic Usage
|
|
25
|
+
|
|
26
|
+
```svelte
|
|
27
|
+
<script>
|
|
28
|
+
import LookupEditor from '@ticatec/uniface-element/lookup-editor';
|
|
29
|
+
|
|
30
|
+
let selectedValue = null;
|
|
31
|
+
let displayText = '';
|
|
32
|
+
|
|
33
|
+
function handleLookupAction() {
|
|
34
|
+
// Open your lookup dialog/modal here
|
|
35
|
+
console.log('Opening lookup dialog...');
|
|
36
|
+
|
|
37
|
+
// Example: simulate user selection
|
|
38
|
+
setTimeout(() => {
|
|
39
|
+
selectedValue = { id: 1, name: 'John Doe' };
|
|
40
|
+
displayText = 'John Doe';
|
|
41
|
+
}, 1000);
|
|
42
|
+
}
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<LookupEditor
|
|
46
|
+
bind:value={selectedValue}
|
|
47
|
+
text={displayText}
|
|
48
|
+
onAction={handleLookupAction}
|
|
49
|
+
placeholder="Click to select a user"
|
|
50
|
+
variant="outlined"
|
|
51
|
+
style="width: 300px;"
|
|
52
|
+
/>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Employee Lookup
|
|
56
|
+
|
|
57
|
+
```svelte
|
|
58
|
+
<script>
|
|
59
|
+
import LookupEditor from '@ticatec/uniface-element/lookup-editor';
|
|
60
|
+
import EmployeeLookupDialog from './EmployeeLookupDialog.svelte';
|
|
61
|
+
|
|
62
|
+
let selectedEmployee = null;
|
|
63
|
+
let employeeName = '';
|
|
64
|
+
let showLookupDialog = false;
|
|
65
|
+
|
|
66
|
+
function openEmployeeLookup() {
|
|
67
|
+
showLookupDialog = true;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function handleEmployeeSelected(employee) {
|
|
71
|
+
selectedEmployee = employee;
|
|
72
|
+
employeeName = `${employee.firstName} ${employee.lastName}`;
|
|
73
|
+
showLookupDialog = false;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function handleValueChange(value) {
|
|
77
|
+
console.log('Employee value changed:', value);
|
|
78
|
+
}
|
|
79
|
+
</script>
|
|
80
|
+
|
|
81
|
+
<LookupEditor
|
|
82
|
+
bind:value={selectedEmployee}
|
|
83
|
+
text={employeeName}
|
|
84
|
+
onAction={openEmployeeLookup}
|
|
85
|
+
onchange={handleValueChange}
|
|
86
|
+
placeholder="Select an employee"
|
|
87
|
+
variant="filled"
|
|
88
|
+
mandatory
|
|
89
|
+
/>
|
|
90
|
+
|
|
91
|
+
{#if showLookupDialog}
|
|
92
|
+
<EmployeeLookupDialog
|
|
93
|
+
on:select={handleEmployeeSelected}
|
|
94
|
+
on:close={() => showLookupDialog = false}
|
|
95
|
+
/>
|
|
96
|
+
{/if}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Customer Lookup with Focus Events
|
|
100
|
+
|
|
101
|
+
```svelte
|
|
102
|
+
<script>
|
|
103
|
+
import LookupEditor from '@ticatec/uniface-element/lookup-editor';
|
|
104
|
+
|
|
105
|
+
let selectedCustomer = null;
|
|
106
|
+
let customerDisplay = '';
|
|
107
|
+
|
|
108
|
+
function handleCustomerLookup() {
|
|
109
|
+
// Open customer selection modal
|
|
110
|
+
openCustomerModal();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function handleFocus(event) {
|
|
114
|
+
console.log('Lookup gained focus');
|
|
115
|
+
// Could highlight the field or show hints
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function handleBlur(event) {
|
|
119
|
+
console.log('Lookup lost focus');
|
|
120
|
+
// Could validate or save state
|
|
121
|
+
}
|
|
122
|
+
</script>
|
|
123
|
+
|
|
124
|
+
<LookupEditor
|
|
125
|
+
bind:value={selectedCustomer}
|
|
126
|
+
text={customerDisplay}
|
|
127
|
+
onAction={handleCustomerLookup}
|
|
128
|
+
onfocus={handleFocus}
|
|
129
|
+
onblur={handleBlur}
|
|
130
|
+
placeholder="Search customers..."
|
|
131
|
+
variant="outlined"
|
|
132
|
+
/>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Product Lookup in Form
|
|
136
|
+
|
|
137
|
+
```svelte
|
|
138
|
+
<script>
|
|
139
|
+
import LookupEditor from '@ticatec/uniface-element/lookup-editor';
|
|
140
|
+
import FormField from '@ticatec/uniface-element/form-field';
|
|
141
|
+
|
|
142
|
+
let orderData = {
|
|
143
|
+
product: null,
|
|
144
|
+
quantity: 1,
|
|
145
|
+
notes: ''
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
let productName = '';
|
|
149
|
+
let errors = {};
|
|
150
|
+
|
|
151
|
+
function openProductCatalog() {
|
|
152
|
+
// Open product selection dialog
|
|
153
|
+
console.log('Opening product catalog...');
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function validateForm() {
|
|
157
|
+
errors = {};
|
|
158
|
+
|
|
159
|
+
if (!orderData.product) {
|
|
160
|
+
errors.product = 'Please select a product';
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (!orderData.quantity || orderData.quantity < 1) {
|
|
164
|
+
errors.quantity = 'Quantity must be at least 1';
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return Object.keys(errors).length === 0;
|
|
168
|
+
}
|
|
169
|
+
</script>
|
|
170
|
+
|
|
171
|
+
<form on:submit|preventDefault={validateForm}>
|
|
172
|
+
<FormField label="Product" required error={errors.product}>
|
|
173
|
+
<LookupEditor
|
|
174
|
+
bind:value={orderData.product}
|
|
175
|
+
text={productName}
|
|
176
|
+
onAction={openProductCatalog}
|
|
177
|
+
placeholder="Select a product"
|
|
178
|
+
variant="outlined"
|
|
179
|
+
mandatory
|
|
180
|
+
/>
|
|
181
|
+
</FormField>
|
|
182
|
+
|
|
183
|
+
<FormField label="Quantity" required error={errors.quantity}>
|
|
184
|
+
<input
|
|
185
|
+
type="number"
|
|
186
|
+
bind:value={orderData.quantity}
|
|
187
|
+
min="1"
|
|
188
|
+
placeholder="Enter quantity"
|
|
189
|
+
/>
|
|
190
|
+
</FormField>
|
|
191
|
+
|
|
192
|
+
<button type="submit">Place Order</button>
|
|
193
|
+
</form>
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## API Reference
|
|
197
|
+
|
|
198
|
+
### Props
|
|
199
|
+
|
|
200
|
+
| Prop | Type | Default | Description |
|
|
201
|
+
|------|------|---------|-------------|
|
|
202
|
+
| `value` | `any` | `null` | The selected value/object |
|
|
203
|
+
| `text` | `string` | `''` | Display text shown in the input field |
|
|
204
|
+
| `variant` | `'' \| 'plain' \| 'outlined' \| 'filled'` | `''` | Visual style variant |
|
|
205
|
+
| `placeholder` | `string` | `''` | Placeholder text when no value is selected |
|
|
206
|
+
| `disabled` | `boolean` | `false` | Whether the component is disabled |
|
|
207
|
+
| `readonly` | `boolean` | `false` | Whether the component is read-only |
|
|
208
|
+
| `mandatory` | `boolean` | `false` | Whether a value is required (affects clear button) |
|
|
209
|
+
| `compact` | `boolean` | `false` | Whether to use compact styling |
|
|
210
|
+
| `style` | `string` | `''` | Custom CSS styles |
|
|
211
|
+
| `displayMode` | `DisplayMode` | `DisplayMode.Edit` | Display mode (edit or display) |
|
|
212
|
+
|
|
213
|
+
### Events
|
|
214
|
+
|
|
215
|
+
| Event | Type | Description |
|
|
216
|
+
|-------|------|-------------|
|
|
217
|
+
| `onAction` | `() => void` | Fired when the action button is clicked |
|
|
218
|
+
| `onchange` | `(value: any) => void` | Fired when the value changes |
|
|
219
|
+
| `onfocus` | `(event: FocusEvent) => void` | Fired when the input gains focus |
|
|
220
|
+
| `onblur` | `(event: FocusEvent) => void` | Fired when the input loses focus |
|
|
221
|
+
|
|
222
|
+
### Keyboard Events
|
|
223
|
+
|
|
224
|
+
The component also forwards these keyboard events:
|
|
225
|
+
|
|
226
|
+
- `on:keydown` - Keyboard key press events
|
|
227
|
+
|
|
228
|
+
## Advanced Usage
|
|
229
|
+
|
|
230
|
+
### Multi-Step Lookup
|
|
231
|
+
|
|
232
|
+
```svelte
|
|
233
|
+
<script>
|
|
234
|
+
import LookupEditor from '@ticatec/uniface-element/lookup-editor';
|
|
235
|
+
|
|
236
|
+
let selectedLocation = null;
|
|
237
|
+
let locationText = '';
|
|
238
|
+
let currentStep = 'country'; // 'country' -> 'state' -> 'city'
|
|
239
|
+
|
|
240
|
+
function handleLocationLookup() {
|
|
241
|
+
switch (currentStep) {
|
|
242
|
+
case 'country':
|
|
243
|
+
openCountrySelector();
|
|
244
|
+
break;
|
|
245
|
+
case 'state':
|
|
246
|
+
openStateSelector();
|
|
247
|
+
break;
|
|
248
|
+
case 'city':
|
|
249
|
+
openCitySelector();
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function handleLocationChange(location) {
|
|
255
|
+
selectedLocation = location;
|
|
256
|
+
if (location) {
|
|
257
|
+
locationText = `${location.city}, ${location.state}, ${location.country}`;
|
|
258
|
+
} else {
|
|
259
|
+
locationText = '';
|
|
260
|
+
currentStep = 'country';
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
</script>
|
|
264
|
+
|
|
265
|
+
<LookupEditor
|
|
266
|
+
bind:value={selectedLocation}
|
|
267
|
+
text={locationText}
|
|
268
|
+
onAction={handleLocationLookup}
|
|
269
|
+
onchange={handleLocationChange}
|
|
270
|
+
placeholder="Select location (Country � State � City)"
|
|
271
|
+
variant="outlined"
|
|
272
|
+
/>
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### Lookup with Validation
|
|
276
|
+
|
|
277
|
+
```svelte
|
|
278
|
+
<script>
|
|
279
|
+
import LookupEditor from '@ticatec/uniface-element/lookup-editor';
|
|
280
|
+
|
|
281
|
+
let selectedItem = null;
|
|
282
|
+
let itemText = '';
|
|
283
|
+
let isValid = true;
|
|
284
|
+
let validationMessage = '';
|
|
285
|
+
|
|
286
|
+
function validateSelection(item) {
|
|
287
|
+
if (!item) {
|
|
288
|
+
isValid = false;
|
|
289
|
+
validationMessage = 'Selection is required';
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (item.status === 'inactive') {
|
|
294
|
+
isValid = false;
|
|
295
|
+
validationMessage = 'Selected item is inactive';
|
|
296
|
+
return false;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
isValid = true;
|
|
300
|
+
validationMessage = '';
|
|
301
|
+
return true;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function handleSelectionChange(value) {
|
|
305
|
+
validateSelection(value);
|
|
306
|
+
}
|
|
307
|
+
</script>
|
|
308
|
+
|
|
309
|
+
<div class="lookup-container">
|
|
310
|
+
<LookupEditor
|
|
311
|
+
bind:value={selectedItem}
|
|
312
|
+
text={itemText}
|
|
313
|
+
onAction={openLookupDialog}
|
|
314
|
+
onchange={handleSelectionChange}
|
|
315
|
+
placeholder="Select an item"
|
|
316
|
+
variant="outlined"
|
|
317
|
+
style={isValid ? '' : 'border-color: #f44336;'}
|
|
318
|
+
/>
|
|
319
|
+
|
|
320
|
+
{#if !isValid}
|
|
321
|
+
<div class="error-message">{validationMessage}</div>
|
|
322
|
+
{/if}
|
|
323
|
+
</div>
|
|
324
|
+
|
|
325
|
+
<style>
|
|
326
|
+
.lookup-container {
|
|
327
|
+
position: relative;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
.error-message {
|
|
331
|
+
color: #f44336;
|
|
332
|
+
font-size: 0.875rem;
|
|
333
|
+
margin-top: 4px;
|
|
334
|
+
}
|
|
335
|
+
</style>
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### Lookup with Recent Selections
|
|
339
|
+
|
|
340
|
+
```svelte
|
|
341
|
+
<script>
|
|
342
|
+
import LookupEditor from '@ticatec/uniface-element/lookup-editor';
|
|
343
|
+
|
|
344
|
+
let selectedUser = null;
|
|
345
|
+
let userDisplayName = '';
|
|
346
|
+
let recentSelections = [];
|
|
347
|
+
let showRecentMenu = false;
|
|
348
|
+
|
|
349
|
+
function handleUserLookup() {
|
|
350
|
+
// Show recent selections first, then full lookup
|
|
351
|
+
if (recentSelections.length > 0) {
|
|
352
|
+
showRecentMenu = true;
|
|
353
|
+
} else {
|
|
354
|
+
openFullUserLookup();
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function handleUserSelected(user) {
|
|
359
|
+
selectedUser = user;
|
|
360
|
+
userDisplayName = user.displayName;
|
|
361
|
+
|
|
362
|
+
// Add to recent selections
|
|
363
|
+
recentSelections = [
|
|
364
|
+
user,
|
|
365
|
+
...recentSelections.filter(u => u.id !== user.id)
|
|
366
|
+
].slice(0, 5); // Keep only 5 recent items
|
|
367
|
+
|
|
368
|
+
showRecentMenu = false;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function handleFocus() {
|
|
372
|
+
// Could show recent selections on focus
|
|
373
|
+
if (recentSelections.length > 0 && !selectedUser) {
|
|
374
|
+
showRecentMenu = true;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
function handleBlur() {
|
|
379
|
+
// Hide recent menu when focus is lost
|
|
380
|
+
setTimeout(() => {
|
|
381
|
+
showRecentMenu = false;
|
|
382
|
+
}, 200); // Delay to allow clicking on menu items
|
|
383
|
+
}
|
|
384
|
+
</script>
|
|
385
|
+
|
|
386
|
+
<div class="lookup-with-recent">
|
|
387
|
+
<LookupEditor
|
|
388
|
+
bind:value={selectedUser}
|
|
389
|
+
text={userDisplayName}
|
|
390
|
+
onAction={handleUserLookup}
|
|
391
|
+
onfocus={handleFocus}
|
|
392
|
+
onblur={handleBlur}
|
|
393
|
+
placeholder="Select a user"
|
|
394
|
+
variant="outlined"
|
|
395
|
+
/>
|
|
396
|
+
|
|
397
|
+
{#if showRecentMenu}
|
|
398
|
+
<div class="recent-menu">
|
|
399
|
+
<div class="recent-header">Recent Selections</div>
|
|
400
|
+
{#each recentSelections as user}
|
|
401
|
+
<button
|
|
402
|
+
class="recent-item"
|
|
403
|
+
on:click={() => handleUserSelected(user)}
|
|
404
|
+
>
|
|
405
|
+
{user.displayName}
|
|
406
|
+
</button>
|
|
407
|
+
{/each}
|
|
408
|
+
<button
|
|
409
|
+
class="recent-item show-all"
|
|
410
|
+
on:click={openFullUserLookup}
|
|
411
|
+
>
|
|
412
|
+
Show All Users...
|
|
413
|
+
</button>
|
|
414
|
+
</div>
|
|
415
|
+
{/if}
|
|
416
|
+
</div>
|
|
417
|
+
|
|
418
|
+
<style>
|
|
419
|
+
.lookup-with-recent {
|
|
420
|
+
position: relative;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
.recent-menu {
|
|
424
|
+
position: absolute;
|
|
425
|
+
top: 100%;
|
|
426
|
+
left: 0;
|
|
427
|
+
right: 0;
|
|
428
|
+
background: white;
|
|
429
|
+
border: 1px solid #ddd;
|
|
430
|
+
border-radius: 4px;
|
|
431
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
432
|
+
z-index: 1000;
|
|
433
|
+
max-height: 200px;
|
|
434
|
+
overflow-y: auto;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
.recent-header {
|
|
438
|
+
padding: 8px 12px;
|
|
439
|
+
font-size: 0.875rem;
|
|
440
|
+
font-weight: 600;
|
|
441
|
+
color: #666;
|
|
442
|
+
border-bottom: 1px solid #eee;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
.recent-item {
|
|
446
|
+
display: block;
|
|
447
|
+
width: 100%;
|
|
448
|
+
padding: 8px 12px;
|
|
449
|
+
border: none;
|
|
450
|
+
background: white;
|
|
451
|
+
text-align: left;
|
|
452
|
+
cursor: pointer;
|
|
453
|
+
transition: background-color 0.2s;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
.recent-item:hover {
|
|
457
|
+
background-color: #f5f5f5;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
.recent-item.show-all {
|
|
461
|
+
font-style: italic;
|
|
462
|
+
color: #666;
|
|
463
|
+
border-top: 1px solid #eee;
|
|
464
|
+
}
|
|
465
|
+
</style>
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
## Styling
|
|
469
|
+
|
|
470
|
+
### CSS Variables
|
|
471
|
+
|
|
472
|
+
The LookupEditor component inherits styling from the CommonPicker component and supports these CSS variables:
|
|
473
|
+
|
|
474
|
+
```css
|
|
475
|
+
:root {
|
|
476
|
+
--uniface-picker-border-color: #d1d5db;
|
|
477
|
+
--uniface-picker-focus-border-color: #3b82f6;
|
|
478
|
+
--uniface-picker-background: white;
|
|
479
|
+
--uniface-picker-text-color: #374151;
|
|
480
|
+
--uniface-picker-placeholder-color: #9ca3af;
|
|
481
|
+
}
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
### Custom Styling
|
|
485
|
+
|
|
486
|
+
```css
|
|
487
|
+
.custom-lookup {
|
|
488
|
+
--uniface-picker-border-color: #e2e8f0;
|
|
489
|
+
--uniface-picker-focus-border-color: #2563eb;
|
|
490
|
+
border-radius: 8px;
|
|
491
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
.custom-lookup input {
|
|
495
|
+
font-weight: 500;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
.custom-lookup .action-button {
|
|
499
|
+
color: #2563eb;
|
|
500
|
+
}
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
### Variant Styles
|
|
504
|
+
|
|
505
|
+
```svelte
|
|
506
|
+
<!-- Outlined variant -->
|
|
507
|
+
<LookupEditor variant="outlined" />
|
|
508
|
+
|
|
509
|
+
<!-- Filled variant -->
|
|
510
|
+
<LookupEditor variant="filled" />
|
|
511
|
+
|
|
512
|
+
<!-- Plain variant -->
|
|
513
|
+
<LookupEditor variant="plain" />
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
## Integration Patterns
|
|
517
|
+
|
|
518
|
+
### With Modal Dialogs
|
|
519
|
+
|
|
520
|
+
```svelte
|
|
521
|
+
<script>
|
|
522
|
+
import LookupEditor from '@ticatec/uniface-element/lookup-editor';
|
|
523
|
+
import Modal from '@ticatec/uniface-element/modal';
|
|
524
|
+
|
|
525
|
+
let showModal = false;
|
|
526
|
+
let selectedItem = null;
|
|
527
|
+
let itemDisplay = '';
|
|
528
|
+
|
|
529
|
+
function openLookup() {
|
|
530
|
+
showModal = true;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
function handleItemSelected(item) {
|
|
534
|
+
selectedItem = item;
|
|
535
|
+
itemDisplay = item.name;
|
|
536
|
+
showModal = false;
|
|
537
|
+
}
|
|
538
|
+
</script>
|
|
539
|
+
|
|
540
|
+
<LookupEditor
|
|
541
|
+
bind:value={selectedItem}
|
|
542
|
+
text={itemDisplay}
|
|
543
|
+
onAction={openLookup}
|
|
544
|
+
placeholder="Select an item"
|
|
545
|
+
variant="outlined"
|
|
546
|
+
/>
|
|
547
|
+
|
|
548
|
+
<Modal bind:show={showModal} title="Select Item">
|
|
549
|
+
<!-- Your lookup/selection content here -->
|
|
550
|
+
<ItemSelectionList on:select={handleItemSelected} />
|
|
551
|
+
</Modal>
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
### With External APIs
|
|
555
|
+
|
|
556
|
+
```svelte
|
|
557
|
+
<script>
|
|
558
|
+
import LookupEditor from '@ticatec/uniface-element/lookup-editor';
|
|
559
|
+
|
|
560
|
+
let selectedRecord = null;
|
|
561
|
+
let recordDisplay = '';
|
|
562
|
+
let isLoading = false;
|
|
563
|
+
|
|
564
|
+
async function handleLookup() {
|
|
565
|
+
isLoading = true;
|
|
566
|
+
|
|
567
|
+
try {
|
|
568
|
+
// Open external lookup system
|
|
569
|
+
const result = await openExternalLookup();
|
|
570
|
+
|
|
571
|
+
if (result) {
|
|
572
|
+
selectedRecord = result;
|
|
573
|
+
recordDisplay = result.displayName;
|
|
574
|
+
}
|
|
575
|
+
} catch (error) {
|
|
576
|
+
console.error('Lookup failed:', error);
|
|
577
|
+
} finally {
|
|
578
|
+
isLoading = false;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
</script>
|
|
582
|
+
|
|
583
|
+
<LookupEditor
|
|
584
|
+
bind:value={selectedRecord}
|
|
585
|
+
text={recordDisplay}
|
|
586
|
+
onAction={handleLookup}
|
|
587
|
+
disabled={isLoading}
|
|
588
|
+
placeholder={isLoading ? 'Loading...' : 'Select a record'}
|
|
589
|
+
variant="outlined"
|
|
590
|
+
/>
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
## Best Practices
|
|
594
|
+
|
|
595
|
+
### 1. Clear Value Display
|
|
596
|
+
|
|
597
|
+
Always provide meaningful display text:
|
|
598
|
+
|
|
599
|
+
```svelte
|
|
600
|
+
<script>
|
|
601
|
+
// Good: Clear, descriptive display
|
|
602
|
+
$: displayText = selectedCustomer ?
|
|
603
|
+
`${selectedCustomer.name} (${selectedCustomer.code})` : '';
|
|
604
|
+
|
|
605
|
+
// Avoid: Just showing IDs or unclear text
|
|
606
|
+
// $: displayText = selectedCustomer?.id;
|
|
607
|
+
</script>
|
|
608
|
+
```
|
|
609
|
+
|
|
610
|
+
### 2. Handle Loading States
|
|
611
|
+
|
|
612
|
+
Show appropriate feedback during lookup operations:
|
|
613
|
+
|
|
614
|
+
```svelte
|
|
615
|
+
<script>
|
|
616
|
+
let isLookupOpen = false;
|
|
617
|
+
|
|
618
|
+
function handleLookup() {
|
|
619
|
+
isLookupOpen = true;
|
|
620
|
+
// Open lookup dialog
|
|
621
|
+
}
|
|
622
|
+
</script>
|
|
623
|
+
|
|
624
|
+
<LookupEditor
|
|
625
|
+
disabled={isLookupOpen}
|
|
626
|
+
placeholder={isLookupOpen ? 'Lookup in progress...' : 'Select item'}
|
|
627
|
+
onAction={handleLookup}
|
|
628
|
+
/>
|
|
629
|
+
```
|
|
630
|
+
|
|
631
|
+
### 3. Validate Selections
|
|
632
|
+
|
|
633
|
+
Always validate lookup selections:
|
|
634
|
+
|
|
635
|
+
```svelte
|
|
636
|
+
<script>
|
|
637
|
+
function handleSelectionChange(value) {
|
|
638
|
+
if (value && !value.isActive) {
|
|
639
|
+
// Clear invalid selections
|
|
640
|
+
selectedItem = null;
|
|
641
|
+
displayText = '';
|
|
642
|
+
showError('Selected item is not active');
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
</script>
|
|
646
|
+
```
|
|
647
|
+
|
|
648
|
+
### 4. Provide Context
|
|
649
|
+
|
|
650
|
+
Help users understand what they're selecting:
|
|
651
|
+
|
|
652
|
+
```svelte
|
|
653
|
+
<LookupEditor
|
|
654
|
+
placeholder="Select employee (use employee search)"
|
|
655
|
+
text={selectedEmployee ?
|
|
656
|
+
`${selectedEmployee.name} - ${selectedEmployee.department}` :
|
|
657
|
+
''
|
|
658
|
+
}
|
|
659
|
+
/>
|
|
660
|
+
```
|
|
661
|
+
|
|
662
|
+
## Accessibility Features
|
|
663
|
+
|
|
664
|
+
- **Keyboard Navigation**: Full keyboard support with tab and enter keys
|
|
665
|
+
- **Screen Reader Support**: Proper labeling and announcements
|
|
666
|
+
- **Focus Management**: Clear focus indicators and logical tab order
|
|
667
|
+
- **ARIA Attributes**: Appropriate roles and properties for assistive technology
|
|
668
|
+
|
|
669
|
+
## Browser Support
|
|
670
|
+
|
|
671
|
+
- **Modern Browsers**: Chrome, Firefox, Safari, Edge (latest versions)
|
|
672
|
+
- **Mobile Browsers**: iOS Safari, Chrome Mobile, Firefox Mobile
|
|
673
|
+
- **Keyboard Navigation**: Full support across all platforms
|
|
674
|
+
|
|
675
|
+
## Related Components
|
|
676
|
+
|
|
677
|
+
- **CommonPicker**: Base picker component used internally
|
|
678
|
+
- **FormField**: Form field wrapper for labels and validation
|
|
679
|
+
- **Modal**: Modal dialogs for lookup interfaces
|
|
680
|
+
- **ListBox**: List selection component for lookup dialogs
|
|
681
|
+
|
|
682
|
+
## License
|
|
683
|
+
|
|
684
|
+
MIT License - see LICENSE file for details.
|