@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,241 @@
|
|
|
1
|
+
# PromptsTextEditor Component
|
|
2
|
+
|
|
3
|
+
Text input component with auto-complete suggestions.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
| Property | Type | Default | Description |
|
|
8
|
+
|----------|------|---------|-------------|
|
|
9
|
+
| `variant` | `'' \| 'plain' \| 'outlined' \| 'filled'` | `''` | Appearance variant |
|
|
10
|
+
| `disabled` | `boolean` | `false` | Whether disabled |
|
|
11
|
+
| `readonly` | `boolean` | `false` | Whether read-only |
|
|
12
|
+
| `compact` | `boolean` | `false` | Whether compact mode |
|
|
13
|
+
| `value` | `string` | `''` | Input value |
|
|
14
|
+
| `placeholder` | `string` | `''` | Placeholder text |
|
|
15
|
+
| `displayMode` | `DisplayMode` | `DisplayMode.Edit` | Display mode |
|
|
16
|
+
| `prompts` | `Array<string>` | `[]` | Array of suggestion options |
|
|
17
|
+
| `maxPrompts` | `number` | `10` | Maximum number of suggestions to display |
|
|
18
|
+
| `minChars` | `number` | `1` | Minimum characters to trigger suggestions |
|
|
19
|
+
| `caseSensitive` | `boolean` | `false` | Whether case sensitive |
|
|
20
|
+
| `style` | `string` | `''` | Custom styles |
|
|
21
|
+
| `onChange` | `OnChangeHandler<string>` | - | Value change callback |
|
|
22
|
+
|
|
23
|
+
## Usage Examples
|
|
24
|
+
|
|
25
|
+
```svelte
|
|
26
|
+
<script lang="ts">
|
|
27
|
+
import PromptsTextEditor from '@ticatec/uniface-element/PromptsTextEditor';
|
|
28
|
+
|
|
29
|
+
// Email domain suggestions
|
|
30
|
+
const emailDomains: string[] = [
|
|
31
|
+
'gmail.com',
|
|
32
|
+
'outlook.com',
|
|
33
|
+
'yahoo.com',
|
|
34
|
+
'hotmail.com',
|
|
35
|
+
'icloud.com',
|
|
36
|
+
'protonmail.com',
|
|
37
|
+
'company.com',
|
|
38
|
+
'example.org'
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
// City name suggestions
|
|
42
|
+
const cities: string[] = [
|
|
43
|
+
'New York',
|
|
44
|
+
'Los Angeles',
|
|
45
|
+
'Chicago',
|
|
46
|
+
'Houston',
|
|
47
|
+
'Phoenix',
|
|
48
|
+
'Philadelphia',
|
|
49
|
+
'San Antonio',
|
|
50
|
+
'San Diego',
|
|
51
|
+
'Dallas',
|
|
52
|
+
'San Jose'
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
let email: string = '';
|
|
56
|
+
let city: string = '';
|
|
57
|
+
|
|
58
|
+
const handleEmailChange = (value: string): void => {
|
|
59
|
+
email = value;
|
|
60
|
+
console.log('Email:', value);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const handleCityChange = (value: string): void => {
|
|
64
|
+
city = value;
|
|
65
|
+
console.log('City:', value);
|
|
66
|
+
};
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<!-- Email input (domain suggestions) -->
|
|
70
|
+
<PromptsTextEditor
|
|
71
|
+
placeholder="Enter email address"
|
|
72
|
+
prompts={emailDomains}
|
|
73
|
+
bind:value={email}
|
|
74
|
+
onChange={handleEmailChange}
|
|
75
|
+
/>
|
|
76
|
+
|
|
77
|
+
<!-- City input (auto-complete) -->
|
|
78
|
+
<PromptsTextEditor
|
|
79
|
+
placeholder="Enter city name"
|
|
80
|
+
prompts={cities}
|
|
81
|
+
minChars={1}
|
|
82
|
+
maxPrompts={5}
|
|
83
|
+
bind:value={city}
|
|
84
|
+
onChange={handleCityChange}
|
|
85
|
+
/>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Advanced Usage
|
|
89
|
+
|
|
90
|
+
### Dynamic Suggestions
|
|
91
|
+
```svelte
|
|
92
|
+
<script lang="ts">
|
|
93
|
+
import { onMount } from 'svelte';
|
|
94
|
+
|
|
95
|
+
let searchValue: string = '';
|
|
96
|
+
let dynamicPrompts: string[] = [];
|
|
97
|
+
let isLoading: boolean = false;
|
|
98
|
+
|
|
99
|
+
// Fetch suggestions from API
|
|
100
|
+
const fetchPrompts = async (query: string): Promise<string[]> => {
|
|
101
|
+
if (query.length < 2) return [];
|
|
102
|
+
|
|
103
|
+
isLoading = true;
|
|
104
|
+
try {
|
|
105
|
+
const response = await fetch(`/api/suggestions?q=${encodeURIComponent(query)}`);
|
|
106
|
+
const data = await response.json();
|
|
107
|
+
return data.suggestions || [];
|
|
108
|
+
} catch (error) {
|
|
109
|
+
console.error('Failed to fetch suggestions:', error);
|
|
110
|
+
return [];
|
|
111
|
+
} finally {
|
|
112
|
+
isLoading = false;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// Debounced prompt updates
|
|
117
|
+
let debounceTimeout: number;
|
|
118
|
+
const updatePrompts = (value: string): void => {
|
|
119
|
+
clearTimeout(debounceTimeout);
|
|
120
|
+
debounceTimeout = setTimeout(async () => {
|
|
121
|
+
dynamicPrompts = await fetchPrompts(value);
|
|
122
|
+
}, 300);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const handleSearchChange = (value: string): void => {
|
|
126
|
+
searchValue = value;
|
|
127
|
+
updatePrompts(value);
|
|
128
|
+
};
|
|
129
|
+
</script>
|
|
130
|
+
|
|
131
|
+
<PromptsTextEditor
|
|
132
|
+
placeholder="Search products..."
|
|
133
|
+
prompts={dynamicPrompts}
|
|
134
|
+
minChars={2}
|
|
135
|
+
maxPrompts={8}
|
|
136
|
+
bind:value={searchValue}
|
|
137
|
+
onChange={handleSearchChange}
|
|
138
|
+
/>
|
|
139
|
+
|
|
140
|
+
{#if isLoading}
|
|
141
|
+
<div class="loading-hint">Loading suggestions...</div>
|
|
142
|
+
{/if}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Tag Input
|
|
146
|
+
```svelte
|
|
147
|
+
<script lang="ts">
|
|
148
|
+
const availableTags: string[] = [
|
|
149
|
+
'JavaScript',
|
|
150
|
+
'TypeScript',
|
|
151
|
+
'Svelte',
|
|
152
|
+
'Vue.js',
|
|
153
|
+
'React',
|
|
154
|
+
'Node.js',
|
|
155
|
+
'Python',
|
|
156
|
+
'Java',
|
|
157
|
+
'Go',
|
|
158
|
+
'Rust'
|
|
159
|
+
];
|
|
160
|
+
|
|
161
|
+
let tagInput: string = '';
|
|
162
|
+
let selectedTags: string[] = [];
|
|
163
|
+
|
|
164
|
+
const handleTagInput = (value: string): void => {
|
|
165
|
+
tagInput = value;
|
|
166
|
+
|
|
167
|
+
// Check for delimiter input
|
|
168
|
+
if (value.includes(',') || value.includes(';')) {
|
|
169
|
+
const newTags = value.split(/[,;]/).map(tag => tag.trim()).filter(Boolean);
|
|
170
|
+
|
|
171
|
+
newTags.forEach(tag => {
|
|
172
|
+
if (tag && !selectedTags.includes(tag)) {
|
|
173
|
+
selectedTags = [...selectedTags, tag];
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
tagInput = ''; // Clear input
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const removeTag = (tagToRemove: string): void => {
|
|
182
|
+
selectedTags = selectedTags.filter(tag => tag !== tagToRemove);
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
// Filter out already selected tags
|
|
186
|
+
$: filteredPrompts = availableTags.filter(tag =>
|
|
187
|
+
!selectedTags.includes(tag) &&
|
|
188
|
+
tag.toLowerCase().includes(tagInput.toLowerCase())
|
|
189
|
+
);
|
|
190
|
+
</script>
|
|
191
|
+
|
|
192
|
+
<div class="tag-input-container">
|
|
193
|
+
<!-- Selected tags -->
|
|
194
|
+
<div class="selected-tags">
|
|
195
|
+
{#each selectedTags as tag}
|
|
196
|
+
<span class="tag">
|
|
197
|
+
{tag}
|
|
198
|
+
<button type="button" on:click={() => removeTag(tag)}>×</button>
|
|
199
|
+
</span>
|
|
200
|
+
{/each}
|
|
201
|
+
</div>
|
|
202
|
+
|
|
203
|
+
<!-- Tag input -->
|
|
204
|
+
<PromptsTextEditor
|
|
205
|
+
placeholder="Enter tag name..."
|
|
206
|
+
prompts={filteredPrompts}
|
|
207
|
+
bind:value={tagInput}
|
|
208
|
+
onChange={handleTagInput}
|
|
209
|
+
minChars={1}
|
|
210
|
+
maxPrompts={6}
|
|
211
|
+
/>
|
|
212
|
+
|
|
213
|
+
<div class="tag-hint">Use comma or semicolon to separate multiple tags</div>
|
|
214
|
+
</div>
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Best Practices
|
|
218
|
+
|
|
219
|
+
### 1. Set Reasonable Trigger Conditions
|
|
220
|
+
```svelte
|
|
221
|
+
<!-- Short words: 1 character trigger -->
|
|
222
|
+
<PromptsTextEditor minChars={1} prompts={shortWords} />
|
|
223
|
+
|
|
224
|
+
<!-- Long words or search: 2-3 characters trigger -->
|
|
225
|
+
<PromptsTextEditor minChars={2} prompts={searchTerms} />
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### 2. Limit Number of Suggestions
|
|
229
|
+
```svelte
|
|
230
|
+
<!-- Avoid showing too many suggestions -->
|
|
231
|
+
<PromptsTextEditor maxPrompts={6} prompts={largeDataset} />
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### 3. Case Sensitivity Handling
|
|
235
|
+
```svelte
|
|
236
|
+
<!-- Code or technical terms: case sensitive -->
|
|
237
|
+
<PromptsTextEditor caseSensitive={true} prompts={codeSnippets} />
|
|
238
|
+
|
|
239
|
+
<!-- General text: case insensitive -->
|
|
240
|
+
<PromptsTextEditor caseSensitive={false} prompts={commonWords} />
|
|
241
|
+
```
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# RadioButton Component
|
|
2
|
+
|
|
3
|
+
Radio button component for selecting one option from multiple choices.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
| Property | Type | Default | Description |
|
|
8
|
+
|----------|------|---------|-------------|
|
|
9
|
+
| `variant` | `'' \| 'plain' \| 'outlined' \| 'filled'` | `''` | Appearance variant |
|
|
10
|
+
| `disabled` | `boolean` | `false` | Whether disabled |
|
|
11
|
+
| `readonly` | `boolean` | `false` | Whether read-only |
|
|
12
|
+
| `value` | `any` | `null` | Selected value |
|
|
13
|
+
| `groupValue` | `any` | `null` | Current value of the radio group |
|
|
14
|
+
| `label` | `string` | `''` | Label text |
|
|
15
|
+
| `displayMode` | `DisplayMode` | `DisplayMode.Edit` | Display mode |
|
|
16
|
+
| `style` | `string` | `''` | Custom styles |
|
|
17
|
+
| `onChange` | `OnChangeHandler<any>` | - | Value change callback |
|
|
18
|
+
|
|
19
|
+
## Usage Examples
|
|
20
|
+
|
|
21
|
+
```svelte
|
|
22
|
+
<script lang="ts">
|
|
23
|
+
import RadioButton from '@ticatec/uniface-element/RadioButton';
|
|
24
|
+
|
|
25
|
+
let selectedPayment: string = 'credit';
|
|
26
|
+
let selectedSize: string = 'M';
|
|
27
|
+
|
|
28
|
+
const handlePaymentChange = (value: string): void => {
|
|
29
|
+
selectedPayment = value;
|
|
30
|
+
console.log('Payment method:', value);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const handleSizeChange = (value: string): void => {
|
|
34
|
+
selectedSize = value;
|
|
35
|
+
console.log('Size:', value);
|
|
36
|
+
};
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<!-- Payment method selection -->
|
|
40
|
+
<div>
|
|
41
|
+
<h4>Please select payment method:</h4>
|
|
42
|
+
<RadioButton
|
|
43
|
+
label="Credit Card"
|
|
44
|
+
value="credit"
|
|
45
|
+
groupValue={selectedPayment}
|
|
46
|
+
onChange={handlePaymentChange}
|
|
47
|
+
/>
|
|
48
|
+
<RadioButton
|
|
49
|
+
label="PayPal"
|
|
50
|
+
value="paypal"
|
|
51
|
+
groupValue={selectedPayment}
|
|
52
|
+
onChange={handlePaymentChange}
|
|
53
|
+
/>
|
|
54
|
+
<RadioButton
|
|
55
|
+
label="Apple Pay"
|
|
56
|
+
value="applepay"
|
|
57
|
+
groupValue={selectedPayment}
|
|
58
|
+
onChange={handlePaymentChange}
|
|
59
|
+
/>
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
<!-- Size selection -->
|
|
63
|
+
<div>
|
|
64
|
+
<h4>Please select size:</h4>
|
|
65
|
+
<RadioButton
|
|
66
|
+
label="Small (S)"
|
|
67
|
+
value="S"
|
|
68
|
+
groupValue={selectedSize}
|
|
69
|
+
onChange={handleSizeChange}
|
|
70
|
+
/>
|
|
71
|
+
<RadioButton
|
|
72
|
+
label="Medium (M)"
|
|
73
|
+
value="M"
|
|
74
|
+
groupValue={selectedSize}
|
|
75
|
+
onChange={handleSizeChange}
|
|
76
|
+
/>
|
|
77
|
+
<RadioButton
|
|
78
|
+
label="Large (L)"
|
|
79
|
+
value="L"
|
|
80
|
+
groupValue={selectedSize}
|
|
81
|
+
onChange={handleSizeChange}
|
|
82
|
+
/>
|
|
83
|
+
</div>
|
|
84
|
+
```
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# Switch Component
|
|
2
|
+
|
|
3
|
+
Switch component providing visual toggle for boolean values.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
| Property | Type | Default | Description |
|
|
8
|
+
|----------|------|---------|-------------|
|
|
9
|
+
| `variant` | `'' \| 'plain' \| 'outlined' \| 'filled'` | `''` | Appearance variant |
|
|
10
|
+
| `disabled` | `boolean` | `false` | Whether disabled |
|
|
11
|
+
| `readonly` | `boolean` | `false` | Whether read-only |
|
|
12
|
+
| `value` | `boolean` | `false` | Switch state |
|
|
13
|
+
| `label` | `string` | `''` | Label text |
|
|
14
|
+
| `size` | `'small' \| 'medium' \| 'large'` | `'medium'` | Switch size |
|
|
15
|
+
| `displayMode` | `DisplayMode` | `DisplayMode.Edit` | Display mode |
|
|
16
|
+
| `style` | `string` | `''` | Custom styles |
|
|
17
|
+
| `onChange` | `OnChangeHandler<boolean>` | - | Value change callback |
|
|
18
|
+
|
|
19
|
+
## Usage Examples
|
|
20
|
+
|
|
21
|
+
```svelte
|
|
22
|
+
<script lang="ts">
|
|
23
|
+
import Switch from '@ticatec/uniface-element/Switch';
|
|
24
|
+
|
|
25
|
+
let darkMode: boolean = false;
|
|
26
|
+
let notifications: boolean = true;
|
|
27
|
+
let autoSave: boolean = false;
|
|
28
|
+
|
|
29
|
+
const handleDarkModeChange = (enabled: boolean): void => {
|
|
30
|
+
darkMode = enabled;
|
|
31
|
+
// Apply dark theme logic
|
|
32
|
+
document.body.classList.toggle('dark-theme', enabled);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const handleNotificationChange = (enabled: boolean): void => {
|
|
36
|
+
notifications = enabled;
|
|
37
|
+
console.log('Notification setting:', enabled);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const handleAutoSaveChange = (enabled: boolean): void => {
|
|
41
|
+
autoSave = enabled;
|
|
42
|
+
console.log('Auto-save:', enabled);
|
|
43
|
+
};
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<!-- Dark mode switch -->
|
|
47
|
+
<Switch
|
|
48
|
+
label="Dark Mode"
|
|
49
|
+
bind:value={darkMode}
|
|
50
|
+
onChange={handleDarkModeChange}
|
|
51
|
+
/>
|
|
52
|
+
|
|
53
|
+
<!-- Notification switch (large size) -->
|
|
54
|
+
<Switch
|
|
55
|
+
label="Push Notifications"
|
|
56
|
+
size="large"
|
|
57
|
+
bind:value={notifications}
|
|
58
|
+
onChange={handleNotificationChange}
|
|
59
|
+
/>
|
|
60
|
+
|
|
61
|
+
<!-- Auto-save switch (small size) -->
|
|
62
|
+
<Switch
|
|
63
|
+
label="Auto Save"
|
|
64
|
+
size="small"
|
|
65
|
+
bind:value={autoSave}
|
|
66
|
+
onChange={handleAutoSaveChange}
|
|
67
|
+
/>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Advanced Usage
|
|
71
|
+
|
|
72
|
+
### Settings Panel
|
|
73
|
+
```svelte
|
|
74
|
+
<script lang="ts">
|
|
75
|
+
import { onMount } from 'svelte';
|
|
76
|
+
|
|
77
|
+
interface AppSettings {
|
|
78
|
+
darkMode: boolean;
|
|
79
|
+
notifications: boolean;
|
|
80
|
+
autoSave: boolean;
|
|
81
|
+
showPreview: boolean;
|
|
82
|
+
enableShortcuts: boolean;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
let settings: AppSettings = {
|
|
86
|
+
darkMode: false,
|
|
87
|
+
notifications: true,
|
|
88
|
+
autoSave: true,
|
|
89
|
+
showPreview: true,
|
|
90
|
+
enableShortcuts: true
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const updateSetting = (key: keyof AppSettings) => (value: boolean): void => {
|
|
94
|
+
settings = { ...settings, [key]: value };
|
|
95
|
+
localStorage.setItem('app-settings', JSON.stringify(settings));
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// Restore settings on page load
|
|
99
|
+
onMount(() => {
|
|
100
|
+
const savedSettings = localStorage.getItem('app-settings');
|
|
101
|
+
if (savedSettings) {
|
|
102
|
+
settings = { ...settings, ...JSON.parse(savedSettings) };
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
</script>
|
|
106
|
+
|
|
107
|
+
<div class="settings-panel">
|
|
108
|
+
<h3>Application Settings</h3>
|
|
109
|
+
|
|
110
|
+
<div class="setting-group">
|
|
111
|
+
<Switch
|
|
112
|
+
label="Dark Mode"
|
|
113
|
+
bind:value={settings.darkMode}
|
|
114
|
+
onChange={updateSetting('darkMode')}
|
|
115
|
+
/>
|
|
116
|
+
<p class="setting-description">Enable dark theme to reduce eye strain</p>
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
<div class="setting-group">
|
|
120
|
+
<Switch
|
|
121
|
+
label="Desktop Notifications"
|
|
122
|
+
bind:value={settings.notifications}
|
|
123
|
+
onChange={updateSetting('notifications')}
|
|
124
|
+
/>
|
|
125
|
+
<p class="setting-description">Allow desktop notifications</p>
|
|
126
|
+
</div>
|
|
127
|
+
|
|
128
|
+
<div class="setting-group">
|
|
129
|
+
<Switch
|
|
130
|
+
label="Auto Save"
|
|
131
|
+
size="small"
|
|
132
|
+
bind:value={settings.autoSave}
|
|
133
|
+
onChange={updateSetting('autoSave')}
|
|
134
|
+
/>
|
|
135
|
+
<p class="setting-description">Automatically save your work</p>
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Best Practices
|
|
141
|
+
|
|
142
|
+
### 1. Provide Immediate Feedback
|
|
143
|
+
```svelte
|
|
144
|
+
<script lang="ts">
|
|
145
|
+
let isOnline: boolean = true;
|
|
146
|
+
|
|
147
|
+
const toggleOnlineStatus = (status: boolean): void => {
|
|
148
|
+
isOnline = status;
|
|
149
|
+
|
|
150
|
+
// Show status change notification
|
|
151
|
+
const message = status ? 'Online' : 'Offline';
|
|
152
|
+
showToast(message);
|
|
153
|
+
};
|
|
154
|
+
</script>
|
|
155
|
+
|
|
156
|
+
<Switch
|
|
157
|
+
label={`Status: ${isOnline ? 'Online' : 'Offline'}`}
|
|
158
|
+
bind:value={isOnline}
|
|
159
|
+
onChange={toggleOnlineStatus}
|
|
160
|
+
/>
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### 2. Conditional Disabling
|
|
164
|
+
```svelte
|
|
165
|
+
<script lang="ts">
|
|
166
|
+
let isPremiumUser: boolean = false;
|
|
167
|
+
let advancedFeatures: boolean = false;
|
|
168
|
+
|
|
169
|
+
$: canUseAdvancedFeatures = isPremiumUser;
|
|
170
|
+
</script>
|
|
171
|
+
|
|
172
|
+
<Switch
|
|
173
|
+
label="Advanced Features"
|
|
174
|
+
disabled={!canUseAdvancedFeatures}
|
|
175
|
+
bind:value={advancedFeatures}
|
|
176
|
+
/>
|
|
177
|
+
{#if !canUseAdvancedFeatures}
|
|
178
|
+
<p class="upgrade-hint">Upgrade to premium to use this feature</p>
|
|
179
|
+
{/if}
|
|
180
|
+
```
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# TextEditor Component
|
|
2
|
+
|
|
3
|
+
Basic text input component supporting single-line and multi-line text input.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
| Property | Type | Default | Description |
|
|
8
|
+
|----------|------|---------|-------------|
|
|
9
|
+
| `variant` | `'' \| 'plain' \| 'outlined' \| 'filled'` | `''` | Appearance variant |
|
|
10
|
+
| `disabled` | `boolean` | `false` | Whether disabled |
|
|
11
|
+
| `readonly` | `boolean` | `false` | Whether read-only |
|
|
12
|
+
| `compact` | `boolean` | `false` | Whether compact mode |
|
|
13
|
+
| `value` | `string` | `''` | Input value |
|
|
14
|
+
| `suffix` | `string` | `''` | Text suffix |
|
|
15
|
+
| `prefix` | `string` | `''` | Text prefix |
|
|
16
|
+
| `removable` | `boolean` | `true` | Show clear button |
|
|
17
|
+
| `displayMode` | `DisplayMode` | `DisplayMode.Edit` | Display mode |
|
|
18
|
+
| `style` | `string` | `''` | Custom styles |
|
|
19
|
+
| `onChange` | `(value: string) => void` | - | Value change callback |
|
|
20
|
+
|
|
21
|
+
## Events
|
|
22
|
+
|
|
23
|
+
- `onChange(value: string)` - Triggered when input value changes
|
|
24
|
+
|
|
25
|
+
## Usage Examples
|
|
26
|
+
|
|
27
|
+
```svelte
|
|
28
|
+
<script lang="ts">
|
|
29
|
+
import TextEditor from '@ticatec/uniface-element/TextEditor';
|
|
30
|
+
|
|
31
|
+
let inputValue = '';
|
|
32
|
+
|
|
33
|
+
const handleChange = (value: string) => {
|
|
34
|
+
console.log('Input value:', value);
|
|
35
|
+
inputValue = value;
|
|
36
|
+
};
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<!-- Basic input -->
|
|
40
|
+
<TextEditor
|
|
41
|
+
placeholder="Enter text"
|
|
42
|
+
onChange={handleChange}
|
|
43
|
+
bind:value={inputValue}
|
|
44
|
+
/>
|
|
45
|
+
|
|
46
|
+
<!-- Input with prefix and suffix -->
|
|
47
|
+
<TextEditor
|
|
48
|
+
prefix="$"
|
|
49
|
+
suffix=".00"
|
|
50
|
+
placeholder="Enter amount"
|
|
51
|
+
onChange={handleChange}
|
|
52
|
+
bind:value={inputValue}
|
|
53
|
+
/>
|
|
54
|
+
|
|
55
|
+
<!-- Compact input with clear button -->
|
|
56
|
+
<TextEditor
|
|
57
|
+
compact={true}
|
|
58
|
+
removable={true}
|
|
59
|
+
placeholder="Search..."
|
|
60
|
+
bind:value={inputValue}
|
|
61
|
+
/>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Best Practices
|
|
65
|
+
|
|
66
|
+
### Form Validation
|
|
67
|
+
```svelte
|
|
68
|
+
<script lang="ts">
|
|
69
|
+
let value = '';
|
|
70
|
+
let error = '';
|
|
71
|
+
|
|
72
|
+
const validate = (inputValue: string) => {
|
|
73
|
+
if (!inputValue || inputValue.trim().length === 0) {
|
|
74
|
+
error = 'This field cannot be empty';
|
|
75
|
+
} else if (inputValue.length < 3) {
|
|
76
|
+
error = 'At least 3 characters required';
|
|
77
|
+
} else {
|
|
78
|
+
error = '';
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const handleChange = (newValue: string) => {
|
|
83
|
+
value = newValue;
|
|
84
|
+
validate(newValue);
|
|
85
|
+
};
|
|
86
|
+
</script>
|
|
87
|
+
|
|
88
|
+
<TextEditor
|
|
89
|
+
placeholder="Enter content"
|
|
90
|
+
bind:value={value}
|
|
91
|
+
onChange={handleChange}
|
|
92
|
+
/>
|
|
93
|
+
{#if error}
|
|
94
|
+
<div class="error-message">{error}</div>
|
|
95
|
+
{/if}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Text Input with Styling
|
|
99
|
+
```svelte
|
|
100
|
+
<script lang="ts">
|
|
101
|
+
let description = '';
|
|
102
|
+
</script>
|
|
103
|
+
|
|
104
|
+
<TextEditor
|
|
105
|
+
variant="outlined"
|
|
106
|
+
placeholder="Enter description..."
|
|
107
|
+
bind:value={description}
|
|
108
|
+
style="min-width: 300px;"
|
|
109
|
+
/>
|
|
110
|
+
<div class="char-count">{description.length} characters</div>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Style Customization
|
|
114
|
+
|
|
115
|
+
```css
|
|
116
|
+
/* Custom styles */
|
|
117
|
+
.custom-text-editor {
|
|
118
|
+
border-radius: 8px;
|
|
119
|
+
border: 2px solid #e1e5e9;
|
|
120
|
+
font-family: 'Inter', sans-serif;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.custom-text-editor:focus {
|
|
124
|
+
border-color: #007bff;
|
|
125
|
+
box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Accessibility
|
|
130
|
+
|
|
131
|
+
```svelte
|
|
132
|
+
<label for="user-name">User Name:</label>
|
|
133
|
+
<TextEditor
|
|
134
|
+
id="user-name"
|
|
135
|
+
placeholder="Enter user name"
|
|
136
|
+
aria-describedby="name-help"
|
|
137
|
+
bind:value={userName}
|
|
138
|
+
/>
|
|
139
|
+
<div id="name-help" class="form-help">
|
|
140
|
+
User name will be displayed in the system, real name recommended
|
|
141
|
+
</div>
|
|
142
|
+
```
|