@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.
Files changed (178) hide show
  1. package/dist/accordion/README.md +169 -0
  2. package/dist/accordion/README_CN.md +176 -0
  3. package/dist/action-bar/README.md +275 -0
  4. package/dist/action-bar/README_CN.md +285 -0
  5. package/dist/app-layout/README.md +374 -0
  6. package/dist/app-layout/README_CN.md +381 -0
  7. package/dist/app-top-bar/README.md +357 -0
  8. package/dist/app-top-bar/README_CN.md +365 -0
  9. package/dist/attachment-files/AttachmentFilesField.svelte +67 -1
  10. package/dist/attachment-files/AttachmentFilesField.svelte.d.ts +8 -1
  11. package/dist/base-calendar/CalendarBase.svelte +0 -3
  12. package/dist/box/README.md +385 -0
  13. package/dist/box/README_CN.md +393 -0
  14. package/dist/breadcrumbs/README.md +442 -0
  15. package/dist/breadcrumbs/README_CN.md +442 -0
  16. package/dist/button/Button.svelte +27 -7
  17. package/dist/button/Button.svelte.d.ts +3 -1
  18. package/dist/button/IconButton.svelte +26 -6
  19. package/dist/button/IconButton.svelte.d.ts +3 -1
  20. package/dist/button/IconButton_README.md +513 -0
  21. package/dist/button/IconButton_README_CN.md +513 -0
  22. package/dist/button/README.md +428 -0
  23. package/dist/button/README_CN.md +428 -0
  24. package/dist/button/TextButton.svelte +26 -6
  25. package/dist/button/TextButton.svelte.d.ts +3 -1
  26. package/dist/button/TextButton_README.md +571 -0
  27. package/dist/button/TextButton_README_CN.md +571 -0
  28. package/dist/card/README.md +666 -0
  29. package/dist/card/README_CN.md +666 -0
  30. package/dist/cascade-options-select/CascadeOptionSelect.svelte +43 -7
  31. package/dist/cascade-options-select/CascadeOptionSelect.svelte.d.ts +3 -4
  32. package/dist/cascade-options-select/README.md +663 -2
  33. package/dist/cascade-options-select/README_CN.md +664 -0
  34. package/dist/checkbox/CheckBox.svelte +20 -6
  35. package/dist/checkbox/CheckBox.svelte.d.ts +4 -2
  36. package/dist/checkbox/README.md +562 -0
  37. package/dist/checkbox/README_CN.md +727 -0
  38. package/dist/common-editor/NumberInput.svelte +39 -26
  39. package/dist/common-editor/NumberInput.svelte.d.ts +5 -1
  40. package/dist/concise-data-table/ConciseListTable.svelte +133 -36
  41. package/dist/concise-data-table/ConciseListTable.svelte.d.ts +8 -1
  42. package/dist/concise-data-table/DataCell.svelte +5 -6
  43. package/dist/concise-data-table/DataRow.svelte +22 -2
  44. package/dist/concise-data-table/DataRow.svelte.d.ts +1 -0
  45. package/dist/concise-data-table/README.md +606 -0
  46. package/dist/concise-data-table/README_CN.md +611 -0
  47. package/dist/context-menu/ContextMenu.svelte +138 -21
  48. package/dist/context-menu/ContextMenu.svelte.d.ts +5 -0
  49. package/dist/context-menu/ContextMenuItem.d.ts +20 -4
  50. package/dist/context-menu/README.md +551 -0
  51. package/dist/context-menu/README_CN.md +551 -0
  52. package/dist/criteria-field/CriteriaField.svelte +3 -5
  53. package/dist/criteria-field/README.md +532 -0
  54. package/dist/criteria-field/README_CN.md +532 -0
  55. package/dist/data-table/README.md +712 -0
  56. package/dist/data-table/README_CN.md +712 -0
  57. package/dist/date-picker/DatePicker.svelte +44 -7
  58. package/dist/date-picker/DatePicker.svelte.d.ts +3 -4
  59. package/dist/date-picker/DateTimePicker.svelte +32 -8
  60. package/dist/date-picker/DateTimePicker.svelte.d.ts +3 -4
  61. package/dist/date-picker/README.md +326 -0
  62. package/dist/date-picker/README_CN.md +316 -0
  63. package/dist/date-picker/ScrollBar.svelte +18 -8
  64. package/dist/date-picker/ScrollBar.svelte.d.ts +1 -1
  65. package/dist/date-picker/TimePanel.svelte +5 -5
  66. package/dist/date-picker/TimePanel.svelte.d.ts +1 -1
  67. package/dist/date-range/README.md +374 -0
  68. package/dist/date-range/README_CN.md +374 -0
  69. package/dist/dialog/DialogBoard.svelte +1 -1
  70. package/dist/dialog/README.md +596 -0
  71. package/dist/dialog/README_CN.md +596 -0
  72. package/dist/drawer/README.md +679 -1
  73. package/dist/drawer/README_CN.md +679 -0
  74. package/dist/group-box/group-check-box/GroupCheckBox.svelte +62 -5
  75. package/dist/group-box/group-check-box/GroupCheckBox.svelte.d.ts +7 -2
  76. package/dist/group-box/group-check-box/README.md +749 -0
  77. package/dist/group-box/group-check-box/README_CN.md +750 -0
  78. package/dist/group-box/group-radio-box/GroupRadioBox.svelte +69 -4
  79. package/dist/group-box/group-radio-box/GroupRadioBox.svelte.d.ts +8 -2
  80. package/dist/group-box/group-radio-box/README.md +920 -0
  81. package/dist/group-box/group-radio-box/README_CN.md +920 -0
  82. package/dist/image-files/README.md +1346 -0
  83. package/dist/image-files/README_CN.md +1346 -0
  84. package/dist/input-options-select/InputOptionsSelect.svelte +161 -65
  85. package/dist/input-options-select/InputOptionsSelect.svelte.d.ts +4 -1
  86. package/dist/lib/forwardAllEvents.d.ts +3 -0
  87. package/dist/lib/forwardAllEvents.js +24 -0
  88. package/dist/list-box/README.md +579 -0
  89. package/dist/list-box/README_CN.md +682 -0
  90. package/dist/lookup-editor/LookupEditor.svelte +15 -3
  91. package/dist/lookup-editor/LookupEditor.svelte.d.ts +3 -4
  92. package/dist/lookup-editor/README.md +684 -0
  93. package/dist/lookup-editor/README_CN.md +684 -0
  94. package/dist/memo-editor/MemoEditor.svelte +77 -27
  95. package/dist/memo-editor/MemoEditor.svelte.d.ts +6 -3
  96. package/dist/memo-editor/README.md +819 -0
  97. package/dist/memo-editor/README_CN.md +819 -0
  98. package/dist/message-box/README.md +398 -0
  99. package/dist/message-box/README_CN.md +398 -0
  100. package/dist/number-editor/NumberEditor.svelte +2 -2
  101. package/dist/number-editor/NumberEditor.svelte.d.ts +1 -1
  102. package/dist/number-editor/README.md +353 -22
  103. package/dist/number-editor/README_CN.md +357 -0
  104. package/dist/number-range/README.md +443 -0
  105. package/dist/number-range/README_CN.md +443 -0
  106. package/dist/options-multi-select/OptionsMultiSelect.svelte +87 -12
  107. package/dist/options-multi-select/OptionsMultiSelect.svelte.d.ts +3 -1
  108. package/dist/options-multi-select/README.md +480 -0
  109. package/dist/options-multi-select/README_CN.md +480 -0
  110. package/dist/options-select/OptionsSelect.svelte +36 -5
  111. package/dist/options-select/OptionsSelect.svelte.d.ts +3 -4
  112. package/dist/options-select/README.md +632 -0
  113. package/dist/options-select/README_CN.md +632 -0
  114. package/dist/page/README.md +605 -0
  115. package/dist/page/README_CN.md +605 -0
  116. package/dist/pagination/README.md +946 -0
  117. package/dist/pagination/README_CN.md +946 -0
  118. package/dist/pagination-panel/README.md +1075 -0
  119. package/dist/pagination-panel/README_CN.md +1075 -0
  120. package/dist/popup-hint/README.md +841 -0
  121. package/dist/popup-hint/README_CN.md +840 -0
  122. package/dist/progress-bar/README.md +242 -0
  123. package/dist/progress-bar/README_CN.md +242 -0
  124. package/dist/progress-step-bar/README.md +316 -0
  125. package/dist/progress-step-bar/README_CN.md +316 -0
  126. package/dist/prompts-text-editor/PromptsTextEditor.svelte +6 -3
  127. package/dist/prompts-text-editor/PromptsTextEditor.svelte.d.ts +3 -1
  128. package/dist/prompts-text-editor/README.md +329 -0
  129. package/dist/prompts-text-editor/README_CN.md +329 -0
  130. package/dist/property-editor/README.md +969 -0
  131. package/dist/property-editor/README_CN.md +969 -0
  132. package/dist/radio-button/README.md +372 -0
  133. package/dist/radio-button/README_CN.md +372 -0
  134. package/dist/radio-button/RadioButton.svelte +32 -3
  135. package/dist/radio-button/RadioButton.svelte.d.ts +12 -1
  136. package/dist/search-box/README.md +425 -0
  137. package/dist/search-box/README_CN.md +424 -0
  138. package/dist/search-box/SearchBox.svelte +22 -6
  139. package/dist/search-box/SearchBox.svelte.d.ts +4 -1
  140. package/dist/tabs/README.md +919 -0
  141. package/dist/tabs/README_CN.md +920 -0
  142. package/dist/tag/README.md +922 -0
  143. package/dist/tag/README_CN.md +922 -0
  144. package/dist/text-editor/PasswordEditor.svelte +17 -2
  145. package/dist/text-editor/PasswordEditor.svelte.d.ts +3 -3
  146. package/dist/text-editor/PasswordEditor_README.md +551 -0
  147. package/dist/text-editor/PasswordEditor_README_CN.md +551 -0
  148. package/dist/text-editor/README.md +466 -0
  149. package/dist/text-editor/README_CN.md +466 -0
  150. package/dist/text-editor/TextEditor.svelte +51 -19
  151. package/dist/text-editor/TextEditor.svelte.d.ts +0 -1
  152. package/dist/ticatec-uniface-web.css +1 -0
  153. package/dist/time-editor/README.md +498 -24
  154. package/dist/time-editor/README_CN.md +498 -0
  155. package/dist/time-editor/TimeEditor.svelte +7 -3
  156. package/dist/time-editor/TimeEditor.svelte.d.ts +3 -1
  157. package/dist/toast/README.md +667 -0
  158. package/dist/toast/README_CN.md +667 -0
  159. package/dist/transfer/README.md +795 -0
  160. package/dist/transfer/Transfer.svelte +6 -4
  161. package/dist/transfer/Transfer.svelte.d.ts +3 -1
  162. package/dist/tree-view/README.md +761 -0
  163. package/dist/tree-view/README_CN.md +761 -0
  164. package/dist/tree-view/TreeView.svelte +5 -3
  165. package/dist/tree-view/TreeView.svelte.d.ts +3 -1
  166. package/dist/unit-number-editor/README.md +546 -20
  167. package/dist/unit-number-editor/README_CN.md +525 -0
  168. package/dist/unit-number-editor/UnitNumberEditor.svelte +62 -8
  169. package/dist/unit-number-editor/UnitNumberEditor.svelte.d.ts +5 -1
  170. package/docs/form-field/cn/README_CN.md +364 -0
  171. package/docs/form-field/en/README.md +364 -0
  172. package/docs/form-panel/flex-form/cn/README_CN.md +586 -0
  173. package/docs/form-panel/flex-form/en/README.md +586 -0
  174. package/docs/form-panel/flex-row-form/cn/README_CN.md +787 -0
  175. package/docs/form-panel/flex-row-form/en/README.md +787 -0
  176. package/docs/form-panel/grid-form/en/README.md +744 -0
  177. package/package.json +1 -1
  178. package/dist/drawer/README-CN.md +0 -1
@@ -0,0 +1,329 @@
1
+ # PromptsTextEditor
2
+
3
+ A text input component with auto-suggestion functionality that displays a dropdown menu of predefined words/prompts when clicked. Perfect for scenarios where users need to input from a set of known options with the ability to type custom values.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @ticatec/uniface-element
9
+ ```
10
+
11
+ ## Import
12
+
13
+ ```typescript
14
+ import PromptsTextEditor from "@ticatec/uniface-element/PromptsTextEditor";
15
+ ```
16
+
17
+ ## Basic Usage
18
+
19
+ ```svelte
20
+ <script>
21
+ import PromptsTextEditor from "@ticatec/uniface-element/PromptsTextEditor";
22
+
23
+ let value = '';
24
+ let suggestions = ['Apple', 'Banana', 'Cherry', 'Date', 'Elderberry'];
25
+
26
+ function handleChange(newValue) {
27
+ console.log('Value changed:', newValue);
28
+ }
29
+ </script>
30
+
31
+ <PromptsTextEditor
32
+ bind:value
33
+ words={suggestions}
34
+ onchange={handleChange}
35
+ placeholder="Type or select a fruit..."
36
+ />
37
+ ```
38
+
39
+ ## Props
40
+
41
+ | Prop | Type | Default | Description |
42
+ |------|------|---------|-------------|
43
+ | `value` | `string \| null` | Required | Current input value |
44
+ | `words` | `Array<string>` | Required | Array of suggestion words to display |
45
+ | `onchange` | `OnChangeHandler<string \| null>` | `null` | Callback when value changes |
46
+ | `onfocus` | `((event: FocusEvent) => void) \| null` | `null` | Callback when input gains focus |
47
+ | `onblur` | `((event: FocusEvent) => void) \| null` | `null` | Callback when input loses focus |
48
+ | `disabled` | `boolean` | `false` | Whether the input is disabled |
49
+ | `readonly` | `boolean` | `false` | Whether the input is read-only |
50
+ | `placeholder` | `string` | `""` | Placeholder text |
51
+ | `variant` | `"" \| "plain" \| "outlined" \| "filled"` | `""` | Input visual variant |
52
+ | `compact` | `boolean` | `false` | Whether to use compact spacing |
53
+ | `prefix` | `string` | `""` | Text prefix to display |
54
+ | `suffix` | `string` | `""` | Text suffix to display |
55
+ | `displayMode` | `DisplayMode` | `DisplayMode.Edit` | Display mode (Edit/View) |
56
+ | `removable` | `boolean` | `true` | Whether to show clear button |
57
+ | `menu$height` | `number` | `0` | Fixed height for dropdown menu |
58
+ | `style` | `string` | `""` | Additional CSS styles |
59
+ | `class` | `string` | `""` | CSS class name |
60
+
61
+ ## Examples
62
+
63
+ ### Basic Text Prompts
64
+
65
+ ```svelte
66
+ <script>
67
+ import PromptsTextEditor from "@ticatec/uniface-element/PromptsTextEditor";
68
+
69
+ let selectedTag = '';
70
+ let availableTags = [
71
+ 'JavaScript', 'TypeScript', 'Svelte', 'React', 'Vue',
72
+ 'Python', 'Java', 'C++', 'Go', 'Rust'
73
+ ];
74
+ </script>
75
+
76
+ <PromptsTextEditor
77
+ bind:value={selectedTag}
78
+ words={availableTags}
79
+ placeholder="Select or type a programming language..."
80
+ />
81
+ ```
82
+
83
+ ### With Event Handlers
84
+
85
+ ```svelte
86
+ <script>
87
+ import PromptsTextEditor from "@ticatec/uniface-element/PromptsTextEditor";
88
+
89
+ let currentValue = '';
90
+ let commands = [
91
+ 'git add .', 'git commit -m', 'git push origin',
92
+ 'npm install', 'npm run build', 'npm test'
93
+ ];
94
+
95
+ function handleValueChange(newValue) {
96
+ console.log('Command changed:', newValue);
97
+ }
98
+
99
+ function handleFocus(event) {
100
+ console.log('Input focused');
101
+ }
102
+
103
+ function handleBlur(event) {
104
+ console.log('Input blurred');
105
+ }
106
+ </script>
107
+
108
+ <PromptsTextEditor
109
+ bind:value={currentValue}
110
+ words={commands}
111
+ onchange={handleValueChange}
112
+ onfocus={handleFocus}
113
+ onblur={handleBlur}
114
+ placeholder="Type or select a command..."
115
+ />
116
+ ```
117
+
118
+ ### Different Variants
119
+
120
+ ```svelte
121
+ <script>
122
+ import PromptsTextEditor from "@ticatec/uniface-element/PromptsTextEditor";
123
+
124
+ let value1 = '', value2 = '', value3 = '';
125
+ let options = ['Option 1', 'Option 2', 'Option 3'];
126
+ </script>
127
+
128
+ <!-- Default variant -->
129
+ <PromptsTextEditor bind:value={value1} words={options} placeholder="Default" />
130
+
131
+ <!-- Outlined variant -->
132
+ <PromptsTextEditor bind:value={value2} words={options} variant="outlined" placeholder="Outlined" />
133
+
134
+ <!-- Filled variant -->
135
+ <PromptsTextEditor bind:value={value3} words={options} variant="filled" placeholder="Filled" />
136
+ ```
137
+
138
+ ### With Icons
139
+
140
+ ```svelte
141
+ <script>
142
+ import PromptsTextEditor from "@ticatec/uniface-element/PromptsTextEditor";
143
+ import Icon from "@ticatec/uniface-element/Icon";
144
+
145
+ let searchQuery = '';
146
+ let recentSearches = [
147
+ 'JavaScript tutorials', 'Svelte components', 'TypeScript types',
148
+ 'CSS animations', 'HTML semantics'
149
+ ];
150
+ </script>
151
+
152
+ <PromptsTextEditor
153
+ bind:value={searchQuery}
154
+ words={recentSearches}
155
+ placeholder="Search...">
156
+ <svelte:fragment slot="leading-icon">
157
+ <Icon name="search" />
158
+ </svelte:fragment>
159
+ </PromptsTextEditor>
160
+ ```
161
+
162
+ ### Custom Menu Height
163
+
164
+ ```svelte
165
+ <script>
166
+ import PromptsTextEditor from "@ticatec/uniface-element/PromptsTextEditor";
167
+
168
+ let selectedItem = '';
169
+ let longList = Array.from({length: 50}, (_, i) => `Item ${i + 1}`);
170
+ </script>
171
+
172
+ <PromptsTextEditor
173
+ bind:value={selectedItem}
174
+ words={longList}
175
+ menu$height={200}
176
+ placeholder="Select from many options..."
177
+ />
178
+ ```
179
+
180
+ ### Form Integration
181
+
182
+ ```svelte
183
+ <script>
184
+ import PromptsTextEditor from "@ticatec/uniface-element/PromptsTextEditor";
185
+ import Button from "@ticatec/uniface-element/Button";
186
+
187
+ let formData = {
188
+ category: '',
189
+ priority: '',
190
+ status: ''
191
+ };
192
+
193
+ const categories = ['Bug', 'Feature', 'Enhancement', 'Documentation'];
194
+ const priorities = ['Low', 'Medium', 'High', 'Critical'];
195
+ const statuses = ['Open', 'In Progress', 'Review', 'Closed'];
196
+
197
+ function handleSubmit() {
198
+ console.log('Form submitted:', formData);
199
+ }
200
+ </script>
201
+
202
+ <form on:submit|preventDefault={handleSubmit}>
203
+ <div class="form-field">
204
+ <label>Category</label>
205
+ <PromptsTextEditor
206
+ bind:value={formData.category}
207
+ words={categories}
208
+ placeholder="Select category..."
209
+ />
210
+ </div>
211
+
212
+ <div class="form-field">
213
+ <label>Priority</label>
214
+ <PromptsTextEditor
215
+ bind:value={formData.priority}
216
+ words={priorities}
217
+ placeholder="Select priority..."
218
+ />
219
+ </div>
220
+
221
+ <div class="form-field">
222
+ <label>Status</label>
223
+ <PromptsTextEditor
224
+ bind:value={formData.status}
225
+ words={statuses}
226
+ placeholder="Select status..."
227
+ />
228
+ </div>
229
+
230
+ <Button type="primary" label="Submit" onClick={handleSubmit} />
231
+ </form>
232
+
233
+ <style>
234
+ .form-field {
235
+ margin-bottom: 16px;
236
+ }
237
+
238
+ label {
239
+ display: block;
240
+ margin-bottom: 4px;
241
+ font-weight: 500;
242
+ }
243
+ </style>
244
+ ```
245
+
246
+ ### Disabled and Readonly States
247
+
248
+ ```svelte
249
+ <script>
250
+ import PromptsTextEditor from "@ticatec/uniface-element/PromptsTextEditor";
251
+
252
+ let value1 = 'Readonly value';
253
+ let value2 = '';
254
+ let options = ['Option A', 'Option B', 'Option C'];
255
+ </script>
256
+
257
+ <!-- Readonly -->
258
+ <PromptsTextEditor
259
+ bind:value={value1}
260
+ words={options}
261
+ readonly
262
+ placeholder="This is readonly"
263
+ />
264
+
265
+ <!-- Disabled -->
266
+ <PromptsTextEditor
267
+ bind:value={value2}
268
+ words={options}
269
+ disabled
270
+ placeholder="This is disabled"
271
+ />
272
+ ```
273
+
274
+ ## Features
275
+
276
+ - **Auto-suggestion**: Dropdown list of predefined words/prompts
277
+ - **Free text input**: Users can type custom values not in the suggestion list
278
+ - **Clear functionality**: Optional clear button when `removable` is true
279
+ - **Focus management**: Automatic focus handling and events
280
+ - **Keyboard navigation**: Navigate suggestions with keyboard
281
+ - **Flexible styling**: Multiple visual variants and custom styling
282
+ - **Icon support**: Leading icon slot for additional context
283
+
284
+ ## Behavior
285
+
286
+ 1. **Dropdown Trigger**: Click the dropdown arrow to show all available options
287
+ 2. **Selection**: Click any option to select it and close the dropdown
288
+ 3. **Free Input**: Type any text, even if not in the suggestions list
289
+ 4. **Clear Action**: Click the clear button (when enabled) to empty the input
290
+ 5. **Click Outside**: Dropdown closes when clicking outside the component
291
+
292
+ ## Styling
293
+
294
+ The component inherits styling from the base `CommonEditor` and can be customized using:
295
+
296
+ - CSS custom properties (defined in the theme)
297
+ - The `style` prop for inline styles
298
+ - The `class` prop for custom CSS classes
299
+ - The `variant` prop for predefined visual styles
300
+
301
+ ## Accessibility
302
+
303
+ - Proper keyboard navigation support
304
+ - Screen reader compatible
305
+ - Focus management and indicators
306
+ - Semantic HTML structure
307
+ - ARIA attributes for dropdown interaction
308
+
309
+ ## Best Practices
310
+
311
+ 1. **Suggestion Quality**: Provide relevant, useful suggestions that match user expectations
312
+ 2. **List Length**: Keep suggestion lists manageable (under 20 items for optimal UX)
313
+ 3. **Custom Height**: Use `menu$height` for long lists to prevent UI overflow
314
+ 4. **Clear Labels**: Provide descriptive placeholders and labels
315
+ 5. **Event Handling**: Use `onchange`, `onfocus`, and `onblur` for proper form integration
316
+ 6. **State Management**: Bind to reactive variables for proper state updates
317
+
318
+ ## Browser Support
319
+
320
+ - Modern browsers with ES6+ support
321
+ - Compatible with Svelte 5+
322
+ - Responsive design principles
323
+
324
+ ## Related Components
325
+
326
+ - `TextEditor` - Simple text input without suggestions
327
+ - `OptionsSelect` - Dropdown selection from predefined options
328
+ - `OptionsMultiSelect` - Multiple selection dropdown
329
+ - `LookupEditor` - Advanced lookup with search capabilities
@@ -0,0 +1,329 @@
1
+ # 提示文本编辑器组件
2
+
3
+ 一个带自动建议功能的文本输入组件,点击时显示预定义单词/提示的下拉菜单。适用于用户需要从一组已知选项中输入并支持自定义输入的场景。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm install @ticatec/uniface-element
9
+ ```
10
+
11
+ ## 导入
12
+
13
+ ```typescript
14
+ import PromptsTextEditor from "@ticatec/uniface-element/PromptsTextEditor";
15
+ ```
16
+
17
+ ## 基本用法
18
+
19
+ ```svelte
20
+ <script>
21
+ import PromptsTextEditor from "@ticatec/uniface-element/PromptsTextEditor";
22
+
23
+ let value = '';
24
+ let suggestions = ['苹果', '香蕉', '樱桃', '枣', '接骨木'];
25
+
26
+ function handleChange(newValue) {
27
+ console.log('值已更改:', newValue);
28
+ }
29
+ </script>
30
+
31
+ <PromptsTextEditor
32
+ bind:value
33
+ words={suggestions}
34
+ onchange={handleChange}
35
+ placeholder="输入或选择一种水果..."
36
+ />
37
+ ```
38
+
39
+ ## 属性
40
+
41
+ | 属性 | 类型 | 默认值 | 描述 |
42
+ |------|------|---------|-------------|
43
+ | `value` | `string \| null` | 必需 | 当前输入值 |
44
+ | `words` | `Array<string>` | 必需 | 显示的建议单词数组 |
45
+ | `onchange` | `OnChangeHandler<string \| null>` | `null` | 值更改时的回调函数 |
46
+ | `onfocus` | `((event: FocusEvent) => void) \| null` | `null` | 输入框获得焦点时的回调函数 |
47
+ | `onblur` | `((event: FocusEvent) => void) \| null` | `null` | 输入框失去焦点时的回调函数 |
48
+ | `disabled` | `boolean` | `false` | 输入框是否禁用 |
49
+ | `readonly` | `boolean` | `false` | 输入框是否只读 |
50
+ | `placeholder` | `string` | `""` | 占位符文本 |
51
+ | `variant` | `"" \| "plain" \| "outlined" \| "filled"` | `""` | 输入框的视觉变体 |
52
+ | `compact` | `boolean` | `false` | 是否使用紧凑间距 |
53
+ | `prefix` | `string` | `""` | 显示的文本前缀 |
54
+ | `suffix` | `string` | `""` | 显示的文本后缀 |
55
+ | `displayMode` | `DisplayMode` | `DisplayMode.Edit` | 显示模式(编辑/查看) |
56
+ | `removable` | `boolean` | `true` | 是否显示清除按钮 |
57
+ | `menu$height` | `number` | `0` | 下拉菜单的固定高度 |
58
+ | `style` | `string` | `""` | 附加 CSS 样式 |
59
+ | `class` | `string` | `""` | CSS 类名 |
60
+
61
+ ## 示例
62
+
63
+ ### 基本文本提示
64
+
65
+ ```svelte
66
+ <script>
67
+ import PromptsTextEditor from "@ticatec/uniface-element/PromptsTextEditor";
68
+
69
+ let selectedTag = '';
70
+ let availableTags = [
71
+ 'JavaScript', 'TypeScript', 'Svelte', 'React', 'Vue',
72
+ 'Python', 'Java', 'C++', 'Go', 'Rust'
73
+ ];
74
+ </script>
75
+
76
+ <PromptsTextEditor
77
+ bind:value={selectedTag}
78
+ words={availableTags}
79
+ placeholder="选择或输入一种编程语言..."
80
+ />
81
+ ```
82
+
83
+ ### 带事件处理程序
84
+
85
+ ```svelte
86
+ <script>
87
+ import PromptsTextEditor from "@ticatec/uniface-element/PromptsTextEditor";
88
+
89
+ let currentValue = '';
90
+ let commands = [
91
+ 'git add .', 'git commit -m', 'git push origin',
92
+ 'npm install', 'npm run build', 'npm test'
93
+ ];
94
+
95
+ function handleValueChange(newValue) {
96
+ console.log('命令已更改:', newValue);
97
+ }
98
+
99
+ function handleFocus(event) {
100
+ console.log('输入框已聚焦');
101
+ }
102
+
103
+ function handleBlur(event) {
104
+ console.log('输入框已失焦');
105
+ }
106
+ </script>
107
+
108
+ <PromptsTextEditor
109
+ bind:value={currentValue}
110
+ words={commands}
111
+ onchange={handleValueChange}
112
+ onfocus={handleFocus}
113
+ onblur={handleBlur}
114
+ placeholder="输入或选择一个命令..."
115
+ />
116
+ ```
117
+
118
+ ### 不同变体
119
+
120
+ ```svelte
121
+ <script>
122
+ import PromptsTextEditor from "@ticatec/uniface-element/PromptsTextEditor";
123
+
124
+ let value1 = '', value2 = '', value3 = '';
125
+ let options = ['选项 1', '选项 2', '选项 3'];
126
+ </script>
127
+
128
+ <!-- 默认变体 -->
129
+ <PromptsTextEditor bind:value={value1} words={options} placeholder="默认" />
130
+
131
+ <!-- 轮廓变体 -->
132
+ <PromptsTextEditor bind:value={value2} words={options} variant="outlined" placeholder="轮廓" />
133
+
134
+ <!-- 填充变体 -->
135
+ <PromptsTextEditor bind:value={value3} words={options} variant="filled" placeholder="填充" />
136
+ ```
137
+
138
+ ### 带图标
139
+
140
+ ```svelte
141
+ <script>
142
+ import PromptsTextEditor from "@ticatec/uniface-element/PromptsTextEditor";
143
+ import Icon from "@ticatec/uniface-element/Icon";
144
+
145
+ let searchQuery = '';
146
+ let recentSearches = [
147
+ 'JavaScript 教程', 'Svelte 组件', 'TypeScript 类型',
148
+ 'CSS 动画', 'HTML 语义'
149
+ ];
150
+ </script>
151
+
152
+ <PromptsTextEditor
153
+ bind:value={searchQuery}
154
+ words={recentSearches}
155
+ placeholder="搜索...">
156
+ <svelte:fragment slot="leading-icon">
157
+ <Icon name="search" />
158
+ </svelte:fragment>
159
+ </PromptsTextEditor>
160
+ ```
161
+
162
+ ### 自定义菜单高度
163
+
164
+ ```svelte
165
+ <script>
166
+ import PromptsTextEditor from "@ticatec/uniface-element/PromptsTextEditor";
167
+
168
+ let selectedItem = '';
169
+ let longList = Array.from({length: 50}, (_, i) => `项目 ${i + 1}`);
170
+ </script>
171
+
172
+ <PromptsTextEditor
173
+ bind:value={selectedItem}
174
+ words={longList}
175
+ menu$height={200}
176
+ placeholder="从多个选项中选择..."
177
+ />
178
+ ```
179
+
180
+ ### 表单集成
181
+
182
+ ```svelte
183
+ <script>
184
+ import PromptsTextEditor from "@ticatec/uniface-element/PromptsTextEditor";
185
+ import Button from "@ticatec/uniface-element/Button";
186
+
187
+ let formData = {
188
+ category: '',
189
+ priority: '',
190
+ status: ''
191
+ };
192
+
193
+ const categories = ['错误', '功能', '增强', '文档'];
194
+ const priorities = ['低', '中', '高', '紧急'];
195
+ const statuses = ['开放', '进行中', '审核', '关闭'];
196
+
197
+ function handleSubmit() {
198
+ console.log('表单提交:', formData);
199
+ }
200
+ </script>
201
+
202
+ <form on:submit|preventDefault={handleSubmit}>
203
+ <div class="form-field">
204
+ <label>类别</label>
205
+ <PromptsTextEditor
206
+ bind:value={formData.category}
207
+ words={categories}
208
+ placeholder="选择类别..."
209
+ />
210
+ </div>
211
+
212
+ <div class="form-field">
213
+ <label>优先级</label>
214
+ <PromptsTextEditor
215
+ bind:value={formData.priority}
216
+ words={priorities}
217
+ placeholder="选择优先级..."
218
+ />
219
+ </div>
220
+
221
+ <div class="form-field">
222
+ <label>状态</label>
223
+ <PromptsTextEditor
224
+ bind:value={formData.status}
225
+ words={statuses}
226
+ placeholder="选择状态..."
227
+ />
228
+ </div>
229
+
230
+ <Button type="primary" label="提交" onClick={handleSubmit} />
231
+ </form>
232
+
233
+ <style>
234
+ .form-field {
235
+ margin-bottom: 16px;
236
+ }
237
+
238
+ label {
239
+ display: block;
240
+ margin-bottom: 4px;
241
+ font-weight: 500;
242
+ }
243
+ </style>
244
+ ```
245
+
246
+ ### 禁用和只读状态
247
+
248
+ ```svelte
249
+ <script>
250
+ import PromptsTextEditor from "@ticatec/uniface-element/PromptsTextEditor";
251
+
252
+ let value1 = '只读值';
253
+ let value2 = '';
254
+ let options = ['选项 A', '选项 B', '选项 C'];
255
+ </script>
256
+
257
+ <!-- 只读 -->
258
+ <PromptsTextEditor
259
+ bind:value={value1}
260
+ words={options}
261
+ readonly
262
+ placeholder="这是只读的"
263
+ />
264
+
265
+ <!-- 禁用 -->
266
+ <PromptsTextEditor
267
+ bind:value={value2}
268
+ words={options}
269
+ disabled
270
+ placeholder="这是禁用的"
271
+ />
272
+ ```
273
+
274
+ ## 功能
275
+
276
+ - **自动建议**:显示预定义单词/提示的下拉列表
277
+ - **自由文本输入**:用户可以输入不在建议列表中的自定义值
278
+ - **清除功能**:当 `removable` 为 true 时显示可选的清除按钮
279
+ - **焦点管理**:自动处理焦点及相关事件
280
+ - **键盘导航**:支持通过键盘导航建议选项
281
+ - **灵活样式**:支持多种视觉变体和自定义样式
282
+ - **图标支持**:支持前导图标插槽以提供额外上下文
283
+
284
+ ## 行为
285
+
286
+ 1. **下拉触发**:点击下拉箭头显示所有可用选项
287
+ 2. **选择**:点击任意选项进行选择并关闭下拉菜单
288
+ 3. **自由输入**:输入任意文本,即使不在建议列表中
289
+ 4. **清除操作**:点击清除按钮(启用时)清空输入框
290
+ 5. **点击外部**:点击组件外部时关闭下拉菜单
291
+
292
+ ## 样式
293
+
294
+ 组件继承自基础 `CommonEditor` 的样式,并可通过以下方式自定义:
295
+
296
+ - CSS 自定义属性(在主题中定义)
297
+ - `style` 属性用于内联样式
298
+ - `class` 属性用于自定义 CSS 类
299
+ - `variant` 属性用于预定义视觉样式
300
+
301
+ ## 可访问性
302
+
303
+ - 全面支持键盘导航
304
+ - 屏幕阅读器兼容
305
+ - 焦点管理和指示器
306
+ - 语义化 HTML 结构
307
+ - 下拉交互的 ARIA 属性
308
+
309
+ ## 最佳实践
310
+
311
+ 1. **建议质量**:提供符合用户预期的相关且有用的建议
312
+ 2. **列表长度**:保持建议列表长度适中(少于 20 项以获得最佳用户体验)
313
+ 3. **自定义高度**:对长列表使用 `menu$height` 以防止 UI 溢出
314
+ 4. **清晰标签**:提供描述性的占位符和标签
315
+ 5. **事件处理**:使用 `onchange`、`onfocus` 和 `onblur` 进行适当的表单集成
316
+ 6. **状态管理**:绑定到响应式变量以确保状态正确更新
317
+
318
+ ## 浏览器支持
319
+
320
+ - 支持 ES6+ 的现代浏览器
321
+ - 兼容 Svelte 5+
322
+ - 响应式设计原则
323
+
324
+ ## 相关组件
325
+
326
+ - `TextEditor` - 不带建议的简单文本输入
327
+ - `OptionsSelect` - 从预定义选项中进行下拉选择
328
+ - `OptionsMultiSelect` - 多选下拉菜单
329
+ - `LookupEditor` - 具有搜索功能的高级查找组件