@ticatec/uniface-element 0.2.4 → 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 (176) 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/README.md +596 -0
  70. package/dist/dialog/README_CN.md +596 -0
  71. package/dist/drawer/README.md +679 -1
  72. package/dist/drawer/README_CN.md +679 -0
  73. package/dist/group-box/group-check-box/GroupCheckBox.svelte +62 -5
  74. package/dist/group-box/group-check-box/GroupCheckBox.svelte.d.ts +7 -2
  75. package/dist/group-box/group-check-box/README.md +749 -0
  76. package/dist/group-box/group-check-box/README_CN.md +750 -0
  77. package/dist/group-box/group-radio-box/GroupRadioBox.svelte +69 -4
  78. package/dist/group-box/group-radio-box/GroupRadioBox.svelte.d.ts +8 -2
  79. package/dist/group-box/group-radio-box/README.md +920 -0
  80. package/dist/group-box/group-radio-box/README_CN.md +920 -0
  81. package/dist/image-files/README.md +1346 -0
  82. package/dist/image-files/README_CN.md +1346 -0
  83. package/dist/input-options-select/InputOptionsSelect.svelte +161 -65
  84. package/dist/input-options-select/InputOptionsSelect.svelte.d.ts +4 -1
  85. package/dist/lib/forwardAllEvents.d.ts +3 -0
  86. package/dist/lib/forwardAllEvents.js +24 -0
  87. package/dist/list-box/README.md +579 -0
  88. package/dist/list-box/README_CN.md +682 -0
  89. package/dist/lookup-editor/LookupEditor.svelte +15 -3
  90. package/dist/lookup-editor/LookupEditor.svelte.d.ts +3 -4
  91. package/dist/lookup-editor/README.md +684 -0
  92. package/dist/lookup-editor/README_CN.md +684 -0
  93. package/dist/memo-editor/MemoEditor.svelte +77 -27
  94. package/dist/memo-editor/MemoEditor.svelte.d.ts +6 -3
  95. package/dist/memo-editor/README.md +819 -0
  96. package/dist/memo-editor/README_CN.md +819 -0
  97. package/dist/message-box/README.md +398 -0
  98. package/dist/message-box/README_CN.md +398 -0
  99. package/dist/number-editor/NumberEditor.svelte +2 -2
  100. package/dist/number-editor/NumberEditor.svelte.d.ts +1 -1
  101. package/dist/number-editor/README.md +353 -22
  102. package/dist/number-editor/README_CN.md +357 -0
  103. package/dist/number-range/README.md +443 -0
  104. package/dist/number-range/README_CN.md +443 -0
  105. package/dist/options-multi-select/OptionsMultiSelect.svelte +87 -12
  106. package/dist/options-multi-select/OptionsMultiSelect.svelte.d.ts +3 -1
  107. package/dist/options-multi-select/README.md +480 -0
  108. package/dist/options-multi-select/README_CN.md +480 -0
  109. package/dist/options-select/OptionsSelect.svelte +36 -5
  110. package/dist/options-select/OptionsSelect.svelte.d.ts +3 -4
  111. package/dist/options-select/README.md +632 -0
  112. package/dist/options-select/README_CN.md +632 -0
  113. package/dist/page/README.md +605 -0
  114. package/dist/page/README_CN.md +605 -0
  115. package/dist/pagination/README.md +946 -0
  116. package/dist/pagination/README_CN.md +946 -0
  117. package/dist/pagination-panel/README.md +1075 -0
  118. package/dist/pagination-panel/README_CN.md +1075 -0
  119. package/dist/popup-hint/README.md +841 -0
  120. package/dist/popup-hint/README_CN.md +840 -0
  121. package/dist/progress-bar/README.md +242 -0
  122. package/dist/progress-bar/README_CN.md +242 -0
  123. package/dist/progress-step-bar/README.md +316 -0
  124. package/dist/progress-step-bar/README_CN.md +316 -0
  125. package/dist/prompts-text-editor/PromptsTextEditor.svelte +6 -3
  126. package/dist/prompts-text-editor/PromptsTextEditor.svelte.d.ts +3 -1
  127. package/dist/prompts-text-editor/README.md +329 -0
  128. package/dist/prompts-text-editor/README_CN.md +329 -0
  129. package/dist/property-editor/README.md +969 -0
  130. package/dist/property-editor/README_CN.md +969 -0
  131. package/dist/radio-button/README.md +372 -0
  132. package/dist/radio-button/README_CN.md +372 -0
  133. package/dist/radio-button/RadioButton.svelte +32 -3
  134. package/dist/radio-button/RadioButton.svelte.d.ts +12 -1
  135. package/dist/search-box/README.md +425 -0
  136. package/dist/search-box/README_CN.md +424 -0
  137. package/dist/search-box/SearchBox.svelte +22 -6
  138. package/dist/search-box/SearchBox.svelte.d.ts +4 -1
  139. package/dist/tabs/README.md +919 -0
  140. package/dist/tabs/README_CN.md +920 -0
  141. package/dist/tag/README.md +922 -0
  142. package/dist/tag/README_CN.md +922 -0
  143. package/dist/text-editor/PasswordEditor.svelte +17 -2
  144. package/dist/text-editor/PasswordEditor.svelte.d.ts +3 -3
  145. package/dist/text-editor/PasswordEditor_README.md +551 -0
  146. package/dist/text-editor/PasswordEditor_README_CN.md +551 -0
  147. package/dist/text-editor/README.md +466 -0
  148. package/dist/text-editor/README_CN.md +466 -0
  149. package/dist/text-editor/TextEditor.svelte +51 -19
  150. package/dist/text-editor/TextEditor.svelte.d.ts +0 -1
  151. package/dist/time-editor/README.md +498 -24
  152. package/dist/time-editor/README_CN.md +498 -0
  153. package/dist/time-editor/TimeEditor.svelte +7 -3
  154. package/dist/time-editor/TimeEditor.svelte.d.ts +3 -1
  155. package/dist/toast/README.md +667 -0
  156. package/dist/toast/README_CN.md +667 -0
  157. package/dist/transfer/README.md +795 -0
  158. package/dist/transfer/Transfer.svelte +6 -4
  159. package/dist/transfer/Transfer.svelte.d.ts +3 -1
  160. package/dist/tree-view/README.md +761 -0
  161. package/dist/tree-view/README_CN.md +761 -0
  162. package/dist/tree-view/TreeView.svelte +5 -3
  163. package/dist/tree-view/TreeView.svelte.d.ts +3 -1
  164. package/dist/unit-number-editor/README.md +546 -20
  165. package/dist/unit-number-editor/README_CN.md +525 -0
  166. package/dist/unit-number-editor/UnitNumberEditor.svelte +62 -8
  167. package/dist/unit-number-editor/UnitNumberEditor.svelte.d.ts +5 -1
  168. package/docs/form-field/cn/README_CN.md +364 -0
  169. package/docs/form-field/en/README.md +364 -0
  170. package/docs/form-panel/flex-form/cn/README_CN.md +586 -0
  171. package/docs/form-panel/flex-form/en/README.md +586 -0
  172. package/docs/form-panel/flex-row-form/cn/README_CN.md +787 -0
  173. package/docs/form-panel/flex-row-form/en/README.md +787 -0
  174. package/docs/form-panel/grid-form/en/README.md +744 -0
  175. package/package.json +1 -1
  176. package/dist/drawer/README-CN.md +0 -1
@@ -0,0 +1,551 @@
1
+ # 密码编辑器组件
2
+
3
+ 一个专为密码输入设计的组件,带有可见性切换功能。允许用户显示/隐藏密码文本以提升可用性,同时保持安全性。基于 `CommonEditor` 基础组件构建。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm install @ticatec/uniface-element
9
+ ```
10
+
11
+ ## 导入
12
+
13
+ ```typescript
14
+ import { PasswordEditor } from "@ticatec/uniface-element/TextEditor";
15
+ ```
16
+
17
+ ## 基本用法
18
+
19
+ ```svelte
20
+ <script>
21
+ import { PasswordEditor } from "@ticatec/uniface-element/TextEditor";
22
+
23
+ let password = '';
24
+ </script>
25
+
26
+ <PasswordEditor
27
+ bind:value={password}
28
+ placeholder="输入密码..."
29
+ />
30
+ ```
31
+
32
+ ## 属性
33
+
34
+ | 属性 | 类型 | 默认值 | 描述 |
35
+ |------|------|---------|-------------|
36
+ | `value` | `string` | `""` | 当前密码值 |
37
+ | `disabled` | `boolean` | `false` | 输入框是否禁用 |
38
+ | `readonly` | `boolean` | `false` | 输入框是否只读 |
39
+ | `variant` | `"" \| "plain" \| "outlined" \| "filled"` | `""` | 输入框的视觉变体 |
40
+ | `compact` | `boolean` | `false` | 是否使用紧凑间距 |
41
+ | `style` | `string` | `""` | 附加 CSS 样式 |
42
+ | `class` | `string` | `""` | CSS 类名 |
43
+ | `onfocus` | `((event: FocusEvent) => void) \| null` | `null` | 输入框获得焦点时的回调函数 |
44
+ | `onblur` | `((event: FocusEvent) => void) \| null` | `null` | 输入框失去焦点时的回调函数 |
45
+ | `onchange` | `((event: Event) => void) \| null` | `null` | 值更改时的回调函数 |
46
+
47
+ ## 事件
48
+
49
+ | 事件 | 描述 |
50
+ |-------|-------------|
51
+ | `focus` | 输入框获得焦点时触发 |
52
+ | `blur` | 输入框失去焦点时触发 |
53
+
54
+ ## 示例
55
+
56
+ ### 基本密码输入
57
+
58
+ ```svelte
59
+ <script>
60
+ import { PasswordEditor } from "@ticatec/uniface-element/TextEditor";
61
+
62
+ let password = '';
63
+ let confirmPassword = '';
64
+ </script>
65
+
66
+ <div class="form-group">
67
+ <label>密码:</label>
68
+ <PasswordEditor bind:value={password} placeholder="输入密码" />
69
+ </div>
70
+
71
+ <div class="form-group">
72
+ <label>确认密码:</label>
73
+ <PasswordEditor bind:value={confirmPassword} placeholder="确认密码" />
74
+ </div>
75
+
76
+ <style>
77
+ .form-group {
78
+ margin-bottom: 16px;
79
+ }
80
+
81
+ label {
82
+ display: block;
83
+ margin-bottom: 4px;
84
+ font-weight: 500;
85
+ }
86
+ </style>
87
+ ```
88
+
89
+ ### 带事件处理程序
90
+
91
+ ```svelte
92
+ <script>
93
+ import { PasswordEditor } from "@ticatec/uniface-element/TextEditor";
94
+
95
+ let password = '';
96
+ let isFocused = false;
97
+
98
+ function handleChange(event) {
99
+ console.log('密码已更改');
100
+ }
101
+
102
+ function handleFocus(event) {
103
+ console.log('密码输入框已聚焦');
104
+ isFocused = true;
105
+ }
106
+
107
+ function handleBlur(event) {
108
+ console.log('密码输入框已失焦');
109
+ isFocused = false;
110
+ }
111
+ </script>
112
+
113
+ <PasswordEditor
114
+ bind:value={password}
115
+ placeholder="输入安全密码..."
116
+ onchange={handleChange}
117
+ onfocus={handleFocus}
118
+ onblur={handleBlur}
119
+ />
120
+
121
+ {#if isFocused}
122
+ <p>密码字段处于活动状态</p>
123
+ {/if}
124
+ ```
125
+
126
+ ### 不同变体
127
+
128
+ ```svelte
129
+ <script>
130
+ import { PasswordEditor } from "@ticatec/uniface-element/TextEditor";
131
+
132
+ let pass1 = '', pass2 = '', pass3 = '';
133
+ </script>
134
+
135
+ <!-- 默认变体 -->
136
+ <PasswordEditor bind:value={pass1} placeholder="默认密码" />
137
+
138
+ <!-- 轮廓变体 -->
139
+ <PasswordEditor bind:value={pass2} variant="outlined" placeholder="轮廓密码" />
140
+
141
+ <!-- 填充变体 -->
142
+ <PasswordEditor bind:value={pass3} variant="filled" placeholder="填充密码" />
143
+ ```
144
+
145
+ ### 禁用和只读状态
146
+
147
+ ```svelte
148
+ <script>
149
+ import { PasswordEditor } from "@ticatec/uniface-element/TextEditor";
150
+
151
+ let normalPassword = '';
152
+ let readonlyPassword = '只读密码';
153
+ let disabledPassword = '';
154
+ </script>
155
+
156
+ <!-- 正常密码输入 -->
157
+ <PasswordEditor bind:value={normalPassword} placeholder="正常密码" />
158
+
159
+ <!-- 只读密码输入 -->
160
+ <PasswordEditor bind:value={readonlyPassword} readonly />
161
+
162
+ <!-- 禁用密码输入 -->
163
+ <PasswordEditor bind:value={disabledPassword} disabled placeholder="禁用密码" />
164
+ ```
165
+
166
+ ### 紧凑模式
167
+
168
+ ```svelte
169
+ <script>
170
+ import { PasswordEditor } from "@ticatec/uniface-element/TextEditor";
171
+
172
+ let compactPassword = '';
173
+ </script>
174
+
175
+ <div class="login-form">
176
+ <PasswordEditor
177
+ bind:value={compactPassword}
178
+ compact
179
+ placeholder="密码"
180
+ />
181
+ </div>
182
+
183
+ <style>
184
+ .login-form {
185
+ max-width: 300px;
186
+ padding: 16px;
187
+ background: #f8f9fa;
188
+ border-radius: 8px;
189
+ }
190
+ </style>
191
+ ```
192
+
193
+ ### 登录表单示例
194
+
195
+ ```svelte
196
+ <script>
197
+ import { PasswordEditor } from "@ticatec/uniface-element/TextEditor";
198
+ import TextEditor from "@ticatec/uniface-element/TextEditor";
199
+ import Button from "@ticatec/uniface-element/Button";
200
+
201
+ let credentials = {
202
+ username: '',
203
+ password: ''
204
+ };
205
+
206
+ function handleLogin() {
207
+ if (credentials.username && credentials.password) {
208
+ console.log('正在登录...', credentials.username);
209
+ // 执行登录逻辑
210
+ }
211
+ }
212
+
213
+ function handleKeydown(event) {
214
+ if (event.key === 'Enter') {
215
+ handleLogin();
216
+ }
217
+ }
218
+ </script>
219
+
220
+ <div class="login-container">
221
+ <h2>登录</h2>
222
+
223
+ <div class="form-field">
224
+ <label>用户名</label>
225
+ <TextEditor
226
+ bind:value={credentials.username}
227
+ placeholder="输入用户名"
228
+ on:keydown={handleKeydown}
229
+ />
230
+ </div>
231
+
232
+ <div class="form-field">
233
+ <label>密码</label>
234
+ <PasswordEditor
235
+ bind:value={credentials.password}
236
+ placeholder="输入密码"
237
+ on:keydown={handleKeydown}
238
+ />
239
+ </div>
240
+
241
+ <Button
242
+ type="primary"
243
+ label="登录"
244
+ onClick={handleLogin}
245
+ disabled={!credentials.username || !credentials.password}
246
+ />
247
+ </div>
248
+
249
+ <style>
250
+ .login-container {
251
+ max-width: 400px;
252
+ margin: 0 auto;
253
+ padding: 24px;
254
+ border: 1px solid #ddd;
255
+ border-radius: 8px;
256
+ }
257
+
258
+ h2 {
259
+ text-align: center;
260
+ margin-bottom: 24px;
261
+ }
262
+
263
+ .form-field {
264
+ margin-bottom: 16px;
265
+ }
266
+
267
+ label {
268
+ display: block;
269
+ margin-bottom: 4px;
270
+ font-weight: 500;
271
+ }
272
+ </style>
273
+ ```
274
+
275
+ ### 密码强度指示器
276
+
277
+ ```svelte
278
+ <script>
279
+ import { PasswordEditor } from "@ticatec/uniface-element/TextEditor";
280
+
281
+ let password = '';
282
+
283
+ $: passwordStrength = calculateStrength(password);
284
+
285
+ function calculateStrength(pass) {
286
+ if (!pass) return { score: 0, label: '', color: '' };
287
+
288
+ let score = 0;
289
+ if (pass.length >= 8) score++;
290
+ if (/[a-z]/.test(pass)) score++;
291
+ if (/[A-Z]/.test(pass)) score++;
292
+ if (/[0-9]/.test(pass)) score++;
293
+ if (/[^A-Za-z0-9]/.test(pass)) score++;
294
+
295
+ const labels = ['', '弱', '一般', '良好', '强', '非常强'];
296
+ const colors = ['', '#ff4444', '#ff8800', '#ffaa00', '#88cc00', '#44cc00'];
297
+
298
+ return {
299
+ score,
300
+ label: labels[score],
301
+ color: colors[score]
302
+ };
303
+ }
304
+ </script>
305
+
306
+ <div class="password-container">
307
+ <label>创建密码</label>
308
+ <PasswordEditor bind:value={password} placeholder="输入一个强密码" />
309
+
310
+ {#if password}
311
+ <div class="strength-indicator">
312
+ <div class="strength-bar">
313
+ <div
314
+ class="strength-fill"
315
+ style="width: {passwordStrength.score * 20}%; background-color: {passwordStrength.color}"
316
+ ></div>
317
+ </div>
318
+ <span class="strength-label" style="color: {passwordStrength.color}">
319
+ {passwordStrength.label}
320
+ </span>
321
+ </div>
322
+ {/if}
323
+
324
+ <div class="password-requirements">
325
+ <p>密码应包含:</p>
326
+ <ul>
327
+ <li class:met={password.length >= 8}>至少 8 个字符</li>
328
+ <li class:met={/[a-z]/.test(password)}>小写字母</li>
329
+ <li class:met={/[A-Z]/.test(password)}>大写字母</li>
330
+ <li class:met={/[0-9]/.test(password)}>数字</li>
331
+ <li class:met={/[^A-Za-z0-9]/.test(password)}>特殊字符</li>
332
+ </ul>
333
+ </div>
334
+ </div>
335
+
336
+ <style>
337
+ .password-container {
338
+ max-width: 400px;
339
+ }
340
+
341
+ label {
342
+ display: block;
343
+ margin-bottom: 4px;
344
+ font-weight: 500;
345
+ }
346
+
347
+ .strength-indicator {
348
+ margin-top: 8px;
349
+ display: flex;
350
+ align-items: center;
351
+ gap: 12px;
352
+ }
353
+
354
+ .strength-bar {
355
+ flex: 1;
356
+ height: 4px;
357
+ background: #e0e0e0;
358
+ border-radius: 2px;
359
+ overflow: hidden;
360
+ }
361
+
362
+ .strength-fill {
363
+ height: 100%;
364
+ transition: width 0.3s ease, background-color 0.3s ease;
365
+ }
366
+
367
+ .strength-label {
368
+ font-size: 12px;
369
+ font-weight: 500;
370
+ }
371
+
372
+ .password-requirements {
373
+ margin-top: 12px;
374
+ font-size: 14px;
375
+ }
376
+
377
+ .password-requirements p {
378
+ margin: 0 0 8px 0;
379
+ font-weight: 500;
380
+ }
381
+
382
+ .password-requirements ul {
383
+ margin: 0;
384
+ padding-left: 20px;
385
+ }
386
+
387
+ .password-requirements li {
388
+ color: #666;
389
+ transition: color 0.3s ease;
390
+ }
391
+
392
+ .password-requirements li.met {
393
+ color: #44cc00;
394
+ }
395
+ </style>
396
+ ```
397
+
398
+ ### 注册表单
399
+
400
+ ```svelte
401
+ <script>
402
+ import { PasswordEditor } from "@ticatec/uniface-element/TextEditor";
403
+ import TextEditor from "@ticatec/uniface-element/TextEditor";
404
+ import Button from "@ticatec/uniface-element/Button";
405
+
406
+ let formData = {
407
+ email: '',
408
+ password: '',
409
+ confirmPassword: ''
410
+ };
411
+
412
+ $: passwordsMatch = formData.password &&
413
+ formData.confirmPassword &&
414
+ formData.password === formData.confirmPassword;
415
+
416
+ $: isValid = formData.email &&
417
+ formData.password &&
418
+ passwordsMatch;
419
+
420
+ function handleRegister() {
421
+ if (isValid) {
422
+ console.log('正在注册用户...', formData.email);
423
+ // 执行注册逻辑
424
+ }
425
+ }
426
+ </script>
427
+
428
+ <div class="register-container">
429
+ <h2>创建账户</h2>
430
+
431
+ <div class="form-field">
432
+ <label>邮箱</label>
433
+ <TextEditor
434
+ bind:value={formData.email}
435
+ placeholder="输入邮箱地址"
436
+ />
437
+ </div>
438
+
439
+ <div class="form-field">
440
+ <label>密码</label>
441
+ <PasswordEditor
442
+ bind:value={formData.password}
443
+ placeholder="创建密码"
444
+ />
445
+ </div>
446
+
447
+ <div class="form-field">
448
+ <label>确认密码</label>
449
+ <PasswordEditor
450
+ bind:value={formData.confirmPassword}
451
+ placeholder="确认密码"
452
+ />
453
+ {#if formData.confirmPassword && !passwordsMatch}
454
+ <div class="error-message">密码不匹配</div>
455
+ {/if}
456
+ </div>
457
+
458
+ <Button
459
+ type="primary"
460
+ label="创建账户"
461
+ onClick={handleRegister}
462
+ disabled={!isValid}
463
+ />
464
+ </div>
465
+
466
+ <style>
467
+ .register-container {
468
+ max-width: 400px;
469
+ margin: 0 auto;
470
+ padding: 24px;
471
+ border: 1px solid #ddd;
472
+ border-radius: 8px;
473
+ }
474
+
475
+ h2 {
476
+ text-align: center;
477
+ margin-bottom: 24px;
478
+ }
479
+
480
+ .form-field {
481
+ margin-bottom: 16px;
482
+ }
483
+
484
+ label {
485
+ display: block;
486
+ margin-bottom: 4px;
487
+ font-weight: 500;
488
+ }
489
+
490
+ .error-message {
491
+ margin-top: 4px;
492
+ color: #ff4444;
493
+ font-size: 12px;
494
+ }
495
+ </style>
496
+ ```
497
+
498
+ ## 功能
499
+
500
+ - **可见性切换**:内置眼睛图标,用于显示/隐藏密码文本
501
+ - **安全性**:默认保持密码掩码
502
+ - **事件处理**:自定义焦点、失焦和更改事件回调
503
+ - **灵活样式**:支持多种视觉变体和自定义样式
504
+ - **状态管理**:支持禁用和只读状态
505
+ - **响应式**:适配所有设备尺寸
506
+
507
+ ## 行为
508
+
509
+ 1. **默认状态**:密码文本默认隐藏(掩码)
510
+ 2. **切换可见性**:点击眼睛图标显示/隐藏密码
511
+ 3. **禁用/只读**:禁用或只读时隐藏眼睛图标
512
+ 4. **焦点管理**:为可访问性提供适当的焦点处理
513
+ 5. **输入类型切换**:在 `password` 和 `text` 输入类型之间动态切换
514
+
515
+ ## 安全注意事项
516
+
517
+ - 默认掩码密码文本以确保安全
518
+ - 可见性切换有助于提高密码输入准确性
519
+ - 组件不记录或暴露密码内容
520
+ - 遵循标准密码输入安全实践
521
+
522
+ ## 可访问性
523
+
524
+ - 适当的语义化 HTML 结构
525
+ - 支持键盘导航
526
+ - 屏幕阅读器兼容
527
+ - 焦点指示器和管理
528
+ - 交互状态的清晰视觉反馈
529
+
530
+ ## 最佳实践
531
+
532
+ 1. **密码要求**:始终提供明确的密码要求
533
+ 2. **确认字段**:为新密码创建使用确认字段
534
+ 3. **强度指示器**:考虑添加密码强度反馈
535
+ 4. **错误处理**:提供清晰的验证消息
536
+ 5. **安全性**:切勿以明文存储或记录密码值
537
+ 6. **可访问性**:确保适当的标签和键盘导航
538
+
539
+ ## 浏览器支持
540
+
541
+ - 支持完整输入事件的现代浏览器
542
+ - 兼容 Svelte 5+
543
+ - 触控友好界面
544
+ - 响应式设计原则
545
+
546
+ ## 相关组件
547
+
548
+ - `TextEditor` - 基本文本输入组件
549
+ - `SearchBox` - 专用搜索输入
550
+ - `NumberEditor` - 数字输入验证
551
+ - `Button` - 用于表单提交和操作