@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,466 @@
|
|
|
1
|
+
# TextEditor
|
|
2
|
+
|
|
3
|
+
A versatile text input component that provides comprehensive input handling, event forwarding, and display modes. Built on top of the CommonEditor base component with advanced features like prefix/suffix support, clear functionality, and flexible styling.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @ticatec/uniface-element
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Import
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import TextEditor from "@ticatec/uniface-element/TextEditor";
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Basic Usage
|
|
18
|
+
|
|
19
|
+
```svelte
|
|
20
|
+
<script>
|
|
21
|
+
import TextEditor from "@ticatec/uniface-element/TextEditor";
|
|
22
|
+
|
|
23
|
+
let inputValue = '';
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<TextEditor
|
|
27
|
+
bind:value={inputValue}
|
|
28
|
+
placeholder="Enter text..."
|
|
29
|
+
/>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Props
|
|
33
|
+
|
|
34
|
+
| Prop | Type | Default | Description |
|
|
35
|
+
|------|------|---------|-------------|
|
|
36
|
+
| `value` | `string` | `""` | Current input value |
|
|
37
|
+
| `disabled` | `boolean` | `false` | Whether the input is disabled |
|
|
38
|
+
| `readonly` | `boolean` | `false` | Whether the input is read-only |
|
|
39
|
+
| `variant` | `"" \| "plain" \| "outlined" \| "filled"` | `""` | Input visual variant |
|
|
40
|
+
| `compact` | `boolean` | `false` | Whether to use compact spacing |
|
|
41
|
+
| `style` | `string` | `""` | Additional CSS styles |
|
|
42
|
+
| `prefix` | `string` | `""` | Text prefix to display |
|
|
43
|
+
| `suffix` | `string` | `""` | Text suffix to display |
|
|
44
|
+
| `removable` | `boolean` | `true` | Whether to show clear button |
|
|
45
|
+
| `displayMode` | `DisplayMode` | `DisplayMode.Edit` | Display mode (Edit/View) |
|
|
46
|
+
| `class` | `string` | `""` | CSS class name |
|
|
47
|
+
|
|
48
|
+
## Events
|
|
49
|
+
|
|
50
|
+
The TextEditor component forwards all native input events:
|
|
51
|
+
|
|
52
|
+
| Event | Description |
|
|
53
|
+
|-------|-------------|
|
|
54
|
+
| `input` | Fired on every input change |
|
|
55
|
+
| `change` | Fired when input loses focus or Enter is pressed |
|
|
56
|
+
| `focus` | Fired when input gains focus |
|
|
57
|
+
| `blur` | Fired when input loses focus |
|
|
58
|
+
| `keydown` | Fired when a key is pressed down |
|
|
59
|
+
| `keyup` | Fired when a key is released |
|
|
60
|
+
| `keypress` | Fired when a key is pressed |
|
|
61
|
+
| `compositionstart` | Fired when IME composition starts |
|
|
62
|
+
| `compositionend` | Fired when IME composition ends |
|
|
63
|
+
| `compositionupdate` | Fired during IME composition |
|
|
64
|
+
|
|
65
|
+
## Methods
|
|
66
|
+
|
|
67
|
+
| Method | Description |
|
|
68
|
+
|--------|-------------|
|
|
69
|
+
| `setFocus()` | Programmatically focus the input |
|
|
70
|
+
|
|
71
|
+
## Examples
|
|
72
|
+
|
|
73
|
+
### Basic Text Input
|
|
74
|
+
|
|
75
|
+
```svelte
|
|
76
|
+
<script>
|
|
77
|
+
import TextEditor from "@ticatec/uniface-element/TextEditor";
|
|
78
|
+
|
|
79
|
+
let userName = '';
|
|
80
|
+
let email = '';
|
|
81
|
+
</script>
|
|
82
|
+
|
|
83
|
+
<div class="form-group">
|
|
84
|
+
<label>Username:</label>
|
|
85
|
+
<TextEditor bind:value={userName} placeholder="Enter username" />
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
<div class="form-group">
|
|
89
|
+
<label>Email:</label>
|
|
90
|
+
<TextEditor bind:value={email} placeholder="Enter email address" />
|
|
91
|
+
</div>
|
|
92
|
+
|
|
93
|
+
<style>
|
|
94
|
+
.form-group {
|
|
95
|
+
margin-bottom: 16px;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
label {
|
|
99
|
+
display: block;
|
|
100
|
+
margin-bottom: 4px;
|
|
101
|
+
font-weight: 500;
|
|
102
|
+
}
|
|
103
|
+
</style>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### With Event Handlers
|
|
107
|
+
|
|
108
|
+
```svelte
|
|
109
|
+
<script>
|
|
110
|
+
import TextEditor from "@ticatec/uniface-element/TextEditor";
|
|
111
|
+
|
|
112
|
+
let inputValue = '';
|
|
113
|
+
let isFocused = false;
|
|
114
|
+
|
|
115
|
+
function handleInput(event) {
|
|
116
|
+
console.log('Input changed:', event.target.value);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function handleChange(event) {
|
|
120
|
+
console.log('Change committed:', event.target.value);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function handleFocus(event) {
|
|
124
|
+
console.log('Input focused');
|
|
125
|
+
isFocused = true;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function handleBlur(event) {
|
|
129
|
+
console.log('Input blurred');
|
|
130
|
+
isFocused = false;
|
|
131
|
+
}
|
|
132
|
+
</script>
|
|
133
|
+
|
|
134
|
+
<TextEditor
|
|
135
|
+
bind:value={inputValue}
|
|
136
|
+
placeholder="Type something..."
|
|
137
|
+
on:input={handleInput}
|
|
138
|
+
on:change={handleChange}
|
|
139
|
+
on:focus={handleFocus}
|
|
140
|
+
on:blur={handleBlur}
|
|
141
|
+
/>
|
|
142
|
+
|
|
143
|
+
{#if isFocused}
|
|
144
|
+
<p>Input is currently focused</p>
|
|
145
|
+
{/if}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Different Variants
|
|
149
|
+
|
|
150
|
+
```svelte
|
|
151
|
+
<script>
|
|
152
|
+
import TextEditor from "@ticatec/uniface-element/TextEditor";
|
|
153
|
+
|
|
154
|
+
let value1 = '', value2 = '', value3 = '', value4 = '';
|
|
155
|
+
</script>
|
|
156
|
+
|
|
157
|
+
<!-- Default variant -->
|
|
158
|
+
<TextEditor bind:value={value1} placeholder="Default" />
|
|
159
|
+
|
|
160
|
+
<!-- Plain variant -->
|
|
161
|
+
<TextEditor bind:value={value2} variant="plain" placeholder="Plain" />
|
|
162
|
+
|
|
163
|
+
<!-- Outlined variant -->
|
|
164
|
+
<TextEditor bind:value={value3} variant="outlined" placeholder="Outlined" />
|
|
165
|
+
|
|
166
|
+
<!-- Filled variant -->
|
|
167
|
+
<TextEditor bind:value={value4} variant="filled" placeholder="Filled" />
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### With Prefix and Suffix
|
|
171
|
+
|
|
172
|
+
```svelte
|
|
173
|
+
<script>
|
|
174
|
+
import TextEditor from "@ticatec/uniface-element/TextEditor";
|
|
175
|
+
|
|
176
|
+
let amount = '';
|
|
177
|
+
let website = '';
|
|
178
|
+
let username = '';
|
|
179
|
+
</script>
|
|
180
|
+
|
|
181
|
+
<!-- Currency input with prefix -->
|
|
182
|
+
<TextEditor
|
|
183
|
+
bind:value={amount}
|
|
184
|
+
prefix="$"
|
|
185
|
+
placeholder="0.00"
|
|
186
|
+
/>
|
|
187
|
+
|
|
188
|
+
<!-- Website URL with prefix -->
|
|
189
|
+
<TextEditor
|
|
190
|
+
bind:value={website}
|
|
191
|
+
prefix="https://"
|
|
192
|
+
placeholder="example.com"
|
|
193
|
+
/>
|
|
194
|
+
|
|
195
|
+
<!-- Username with suffix -->
|
|
196
|
+
<TextEditor
|
|
197
|
+
bind:value={username}
|
|
198
|
+
suffix="@company.com"
|
|
199
|
+
placeholder="username"
|
|
200
|
+
/>
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### With Icons
|
|
204
|
+
|
|
205
|
+
```svelte
|
|
206
|
+
<script>
|
|
207
|
+
import TextEditor from "@ticatec/uniface-element/TextEditor";
|
|
208
|
+
import Icon from "@ticatec/uniface-element/Icon";
|
|
209
|
+
|
|
210
|
+
let searchTerm = '';
|
|
211
|
+
let email = '';
|
|
212
|
+
</script>
|
|
213
|
+
|
|
214
|
+
<!-- Search input with leading icon -->
|
|
215
|
+
<TextEditor bind:value={searchTerm} placeholder="Search...">
|
|
216
|
+
<svelte:fragment slot="leading-icon">
|
|
217
|
+
<Icon name="search" />
|
|
218
|
+
</svelte:fragment>
|
|
219
|
+
</TextEditor>
|
|
220
|
+
|
|
221
|
+
<!-- Email input with trailing icon -->
|
|
222
|
+
<TextEditor bind:value={email} placeholder="Enter email">
|
|
223
|
+
<svelte:fragment slot="trailing-icon">
|
|
224
|
+
<Icon name="email" />
|
|
225
|
+
</svelte:fragment>
|
|
226
|
+
</TextEditor>
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Disabled and Readonly States
|
|
230
|
+
|
|
231
|
+
```svelte
|
|
232
|
+
<script>
|
|
233
|
+
import TextEditor from "@ticatec/uniface-element/TextEditor";
|
|
234
|
+
|
|
235
|
+
let normalValue = '';
|
|
236
|
+
let readonlyValue = 'This is readonly';
|
|
237
|
+
let disabledValue = '';
|
|
238
|
+
</script>
|
|
239
|
+
|
|
240
|
+
<!-- Normal input -->
|
|
241
|
+
<TextEditor bind:value={normalValue} placeholder="Normal input" />
|
|
242
|
+
|
|
243
|
+
<!-- Readonly input -->
|
|
244
|
+
<TextEditor bind:value={readonlyValue} readonly />
|
|
245
|
+
|
|
246
|
+
<!-- Disabled input -->
|
|
247
|
+
<TextEditor bind:value={disabledValue} disabled placeholder="Disabled input" />
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Compact Mode
|
|
251
|
+
|
|
252
|
+
```svelte
|
|
253
|
+
<script>
|
|
254
|
+
import TextEditor from "@ticatec/uniface-element/TextEditor";
|
|
255
|
+
|
|
256
|
+
let compactValue = '';
|
|
257
|
+
</script>
|
|
258
|
+
|
|
259
|
+
<div class="toolbar">
|
|
260
|
+
<TextEditor
|
|
261
|
+
bind:value={compactValue}
|
|
262
|
+
compact
|
|
263
|
+
placeholder="Compact input"
|
|
264
|
+
/>
|
|
265
|
+
</div>
|
|
266
|
+
|
|
267
|
+
<style>
|
|
268
|
+
.toolbar {
|
|
269
|
+
display: flex;
|
|
270
|
+
align-items: center;
|
|
271
|
+
padding: 8px;
|
|
272
|
+
background: #f8f9fa;
|
|
273
|
+
}
|
|
274
|
+
</style>
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### Without Clear Button
|
|
278
|
+
|
|
279
|
+
```svelte
|
|
280
|
+
<script>
|
|
281
|
+
import TextEditor from "@ticatec/uniface-element/TextEditor";
|
|
282
|
+
|
|
283
|
+
let value = '';
|
|
284
|
+
</script>
|
|
285
|
+
|
|
286
|
+
<TextEditor
|
|
287
|
+
bind:value
|
|
288
|
+
removable={false}
|
|
289
|
+
placeholder="No clear button"
|
|
290
|
+
/>
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### Form Integration
|
|
294
|
+
|
|
295
|
+
```svelte
|
|
296
|
+
<script>
|
|
297
|
+
import TextEditor from "@ticatec/uniface-element/TextEditor";
|
|
298
|
+
import Button from "@ticatec/uniface-element/Button";
|
|
299
|
+
|
|
300
|
+
let formData = {
|
|
301
|
+
firstName: '',
|
|
302
|
+
lastName: '',
|
|
303
|
+
company: '',
|
|
304
|
+
title: ''
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
function handleSubmit() {
|
|
308
|
+
console.log('Form submitted:', formData);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function resetForm() {
|
|
312
|
+
formData = {
|
|
313
|
+
firstName: '',
|
|
314
|
+
lastName: '',
|
|
315
|
+
company: '',
|
|
316
|
+
title: ''
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
</script>
|
|
320
|
+
|
|
321
|
+
<form on:submit|preventDefault={handleSubmit}>
|
|
322
|
+
<div class="form-row">
|
|
323
|
+
<div class="form-field">
|
|
324
|
+
<label>First Name</label>
|
|
325
|
+
<TextEditor bind:value={formData.firstName} placeholder="John" />
|
|
326
|
+
</div>
|
|
327
|
+
<div class="form-field">
|
|
328
|
+
<label>Last Name</label>
|
|
329
|
+
<TextEditor bind:value={formData.lastName} placeholder="Doe" />
|
|
330
|
+
</div>
|
|
331
|
+
</div>
|
|
332
|
+
|
|
333
|
+
<div class="form-field">
|
|
334
|
+
<label>Company</label>
|
|
335
|
+
<TextEditor bind:value={formData.company} placeholder="Acme Corp" />
|
|
336
|
+
</div>
|
|
337
|
+
|
|
338
|
+
<div class="form-field">
|
|
339
|
+
<label>Job Title</label>
|
|
340
|
+
<TextEditor bind:value={formData.title} placeholder="Software Engineer" />
|
|
341
|
+
</div>
|
|
342
|
+
|
|
343
|
+
<div class="form-actions">
|
|
344
|
+
<Button type="secondary" label="Reset" onClick={resetForm} />
|
|
345
|
+
<Button type="primary" label="Submit" onClick={handleSubmit} />
|
|
346
|
+
</div>
|
|
347
|
+
</form>
|
|
348
|
+
|
|
349
|
+
<style>
|
|
350
|
+
.form-row {
|
|
351
|
+
display: grid;
|
|
352
|
+
grid-template-columns: 1fr 1fr;
|
|
353
|
+
gap: 16px;
|
|
354
|
+
margin-bottom: 16px;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
.form-field {
|
|
358
|
+
margin-bottom: 16px;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
label {
|
|
362
|
+
display: block;
|
|
363
|
+
margin-bottom: 4px;
|
|
364
|
+
font-weight: 500;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
.form-actions {
|
|
368
|
+
display: flex;
|
|
369
|
+
gap: 12px;
|
|
370
|
+
justify-content: flex-end;
|
|
371
|
+
}
|
|
372
|
+
</style>
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
### Programmatic Focus
|
|
376
|
+
|
|
377
|
+
```svelte
|
|
378
|
+
<script>
|
|
379
|
+
import TextEditor from "@ticatec/uniface-element/TextEditor";
|
|
380
|
+
import Button from "@ticatec/uniface-element/Button";
|
|
381
|
+
|
|
382
|
+
let textEditor;
|
|
383
|
+
let inputValue = '';
|
|
384
|
+
|
|
385
|
+
function focusInput() {
|
|
386
|
+
textEditor.setFocus();
|
|
387
|
+
}
|
|
388
|
+
</script>
|
|
389
|
+
|
|
390
|
+
<Button label="Focus Input" onClick={focusInput} />
|
|
391
|
+
|
|
392
|
+
<TextEditor
|
|
393
|
+
bind:this={textEditor}
|
|
394
|
+
bind:value={inputValue}
|
|
395
|
+
placeholder="Click button to focus me"
|
|
396
|
+
/>
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
### Display Modes
|
|
400
|
+
|
|
401
|
+
```svelte
|
|
402
|
+
<script>
|
|
403
|
+
import TextEditor from "@ticatec/uniface-element/TextEditor";
|
|
404
|
+
import { DisplayMode } from "@ticatec/uniface-element/common/DisplayMode";
|
|
405
|
+
|
|
406
|
+
let value = 'Sample text';
|
|
407
|
+
let isEditing = false;
|
|
408
|
+
</script>
|
|
409
|
+
|
|
410
|
+
<button on:click={() => isEditing = !isEditing}>
|
|
411
|
+
{isEditing ? 'Switch to View' : 'Switch to Edit'}
|
|
412
|
+
</button>
|
|
413
|
+
|
|
414
|
+
<TextEditor
|
|
415
|
+
bind:value
|
|
416
|
+
displayMode={isEditing ? DisplayMode.Edit : DisplayMode.View}
|
|
417
|
+
placeholder="Enter text..."
|
|
418
|
+
/>
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
## Features
|
|
422
|
+
|
|
423
|
+
- **Comprehensive Event Handling**: Forwards all native input events automatically
|
|
424
|
+
- **Advanced Input Support**: Handles composition events for international text input
|
|
425
|
+
- **Flexible Display**: Supports both edit and view modes
|
|
426
|
+
- **Clear Functionality**: Optional clear button with customizable behavior
|
|
427
|
+
- **Icon Support**: Leading and trailing icon slots
|
|
428
|
+
- **Prefix/Suffix**: Text prefix and suffix support
|
|
429
|
+
- **Focus Management**: Programmatic focus control
|
|
430
|
+
- **Flexible Styling**: Multiple visual variants and custom styling
|
|
431
|
+
|
|
432
|
+
## Event Forwarding
|
|
433
|
+
|
|
434
|
+
The TextEditor component uses an advanced event forwarding system that automatically forwards all native input events while allowing for custom handling of specific events like `input` and `change`.
|
|
435
|
+
|
|
436
|
+
## Accessibility
|
|
437
|
+
|
|
438
|
+
- Proper semantic HTML structure
|
|
439
|
+
- Keyboard navigation support
|
|
440
|
+
- Screen reader compatible
|
|
441
|
+
- Focus indicators and management
|
|
442
|
+
- ARIA attributes where appropriate
|
|
443
|
+
|
|
444
|
+
## Best Practices
|
|
445
|
+
|
|
446
|
+
1. **Event Handling**: Use `on:input` for real-time feedback and `on:change` for committed changes
|
|
447
|
+
2. **Validation**: Implement validation logic in event handlers
|
|
448
|
+
3. **Placeholder Text**: Provide helpful placeholder text for better UX
|
|
449
|
+
4. **Labels**: Always associate inputs with proper labels
|
|
450
|
+
5. **Error States**: Handle and display validation errors appropriately
|
|
451
|
+
6. **Focus Management**: Use programmatic focus for better accessibility
|
|
452
|
+
|
|
453
|
+
## Browser Support
|
|
454
|
+
|
|
455
|
+
- Modern browsers with full input event support
|
|
456
|
+
- Compatible with Svelte 5+
|
|
457
|
+
- IME (Input Method Editor) support for international input
|
|
458
|
+
- Touch-friendly interface
|
|
459
|
+
|
|
460
|
+
## Related Components
|
|
461
|
+
|
|
462
|
+
- `PasswordEditor` - Specialized password input with visibility toggle
|
|
463
|
+
- `SearchBox` - Search-specific input with built-in search icon
|
|
464
|
+
- `NumberEditor` - Numeric input with validation
|
|
465
|
+
- `MemoEditor` - Multi-line text input (textarea)
|
|
466
|
+
- `PromptsTextEditor` - Text input with auto-suggestions
|