@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
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
export let style: string = '';
|
|
14
14
|
export let value: string = '';
|
|
15
15
|
export {className as class};
|
|
16
|
+
export let onfocus: ((event: FocusEvent) => void) | null = null;
|
|
17
|
+
export let onblur: ((event: FocusEvent) => void) | null = null;
|
|
18
|
+
export let onchange: ((event: Event) => void) | null = null;
|
|
16
19
|
|
|
17
20
|
let className: string = '';
|
|
18
21
|
let input$:any;
|
|
@@ -26,15 +29,27 @@
|
|
|
26
29
|
|
|
27
30
|
$: input$ = prefixFilter($$props, "input$", excludeAttrs);
|
|
28
31
|
|
|
32
|
+
const handleFocus = (event: FocusEvent) => {
|
|
33
|
+
onfocus?.(event);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const handleBlur = (event: FocusEvent) => {
|
|
37
|
+
onblur?.(event);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const handleChange = (event: Event) => {
|
|
41
|
+
onchange?.(event);
|
|
42
|
+
};
|
|
43
|
+
|
|
29
44
|
|
|
30
45
|
</script>
|
|
31
46
|
<CommonEditor {style} {value} {readonly} {variant} {compact} class={className}>
|
|
32
47
|
{#if type=="password"}
|
|
33
48
|
<input type="password" style="flex: 1 1 auto" bind:value={value} {disabled} {...input$}
|
|
34
|
-
on:blur on:focus />
|
|
49
|
+
on:blur={handleBlur} on:focus={handleFocus} on:change={handleChange} />
|
|
35
50
|
{:else}
|
|
36
51
|
<input type="text" style="flex: 1 1 auto" bind:value={value} {disabled} {...input$}
|
|
37
|
-
on:blur on:focus />
|
|
52
|
+
on:blur={handleBlur} on:focus={handleFocus} on:change={handleChange} />
|
|
38
53
|
{/if}
|
|
39
54
|
<div slot="trailing-icon" class="editor-embed-icon">
|
|
40
55
|
{#if (!readonly && !disabled)}
|
|
@@ -20,10 +20,10 @@ declare const PasswordEditor: $$__sveltets_2_IsomorphicComponent<{
|
|
|
20
20
|
style?: string | undefined;
|
|
21
21
|
value?: string | undefined;
|
|
22
22
|
class?: string | undefined;
|
|
23
|
+
onfocus?: ((event: FocusEvent) => void) | null | undefined;
|
|
24
|
+
onblur?: ((event: FocusEvent) => void) | null | undefined;
|
|
25
|
+
onchange?: ((event: Event) => void) | null | undefined;
|
|
23
26
|
}, {
|
|
24
|
-
blur: FocusEvent;
|
|
25
|
-
focus: FocusEvent;
|
|
26
|
-
} & {
|
|
27
27
|
[evt: string]: CustomEvent<any>;
|
|
28
28
|
}, {}, {
|
|
29
29
|
class: string;
|
|
@@ -0,0 +1,551 @@
|
|
|
1
|
+
# PasswordEditor
|
|
2
|
+
|
|
3
|
+
A specialized password input component with visibility toggle functionality. Allows users to show/hide password text for better usability while maintaining security. Built on top of the CommonEditor base component.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @ticatec/uniface-element
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Import
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { PasswordEditor } from "@ticatec/uniface-element/TextEditor";
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Basic Usage
|
|
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="Enter password..."
|
|
29
|
+
/>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Props
|
|
33
|
+
|
|
34
|
+
| Prop | Type | Default | Description |
|
|
35
|
+
|------|------|---------|-------------|
|
|
36
|
+
| `value` | `string` | `""` | Current password 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
|
+
| `class` | `string` | `""` | CSS class name |
|
|
43
|
+
| `onfocus` | `((event: FocusEvent) => void) \| null` | `null` | Callback when input gains focus |
|
|
44
|
+
| `onblur` | `((event: FocusEvent) => void) \| null` | `null` | Callback when input loses focus |
|
|
45
|
+
| `onchange` | `((event: Event) => void) \| null` | `null` | Callback when value changes |
|
|
46
|
+
|
|
47
|
+
## Events
|
|
48
|
+
|
|
49
|
+
| Event | Description |
|
|
50
|
+
|-------|-------------|
|
|
51
|
+
| `focus` | Fired when input gains focus |
|
|
52
|
+
| `blur` | Fired when input loses focus |
|
|
53
|
+
|
|
54
|
+
## Examples
|
|
55
|
+
|
|
56
|
+
### Basic Password Input
|
|
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>Password:</label>
|
|
68
|
+
<PasswordEditor bind:value={password} placeholder="Enter password" />
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
<div class="form-group">
|
|
72
|
+
<label>Confirm Password:</label>
|
|
73
|
+
<PasswordEditor bind:value={confirmPassword} placeholder="Confirm password" />
|
|
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
|
+
### With Event Handlers
|
|
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('Password changed');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function handleFocus(event) {
|
|
103
|
+
console.log('Password input focused');
|
|
104
|
+
isFocused = true;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function handleBlur(event) {
|
|
108
|
+
console.log('Password input blurred');
|
|
109
|
+
isFocused = false;
|
|
110
|
+
}
|
|
111
|
+
</script>
|
|
112
|
+
|
|
113
|
+
<PasswordEditor
|
|
114
|
+
bind:value={password}
|
|
115
|
+
placeholder="Enter secure password..."
|
|
116
|
+
onchange={handleChange}
|
|
117
|
+
onfocus={handleFocus}
|
|
118
|
+
onblur={handleBlur}
|
|
119
|
+
/>
|
|
120
|
+
|
|
121
|
+
{#if isFocused}
|
|
122
|
+
<p>Password field is active</p>
|
|
123
|
+
{/if}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Different Variants
|
|
127
|
+
|
|
128
|
+
```svelte
|
|
129
|
+
<script>
|
|
130
|
+
import { PasswordEditor } from "@ticatec/uniface-element/TextEditor";
|
|
131
|
+
|
|
132
|
+
let pass1 = '', pass2 = '', pass3 = '';
|
|
133
|
+
</script>
|
|
134
|
+
|
|
135
|
+
<!-- Default variant -->
|
|
136
|
+
<PasswordEditor bind:value={pass1} placeholder="Default password" />
|
|
137
|
+
|
|
138
|
+
<!-- Outlined variant -->
|
|
139
|
+
<PasswordEditor bind:value={pass2} variant="outlined" placeholder="Outlined password" />
|
|
140
|
+
|
|
141
|
+
<!-- Filled variant -->
|
|
142
|
+
<PasswordEditor bind:value={pass3} variant="filled" placeholder="Filled password" />
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Disabled and Readonly States
|
|
146
|
+
|
|
147
|
+
```svelte
|
|
148
|
+
<script>
|
|
149
|
+
import { PasswordEditor } from "@ticatec/uniface-element/TextEditor";
|
|
150
|
+
|
|
151
|
+
let normalPassword = '';
|
|
152
|
+
let readonlyPassword = 'readonly-pass';
|
|
153
|
+
let disabledPassword = '';
|
|
154
|
+
</script>
|
|
155
|
+
|
|
156
|
+
<!-- Normal password input -->
|
|
157
|
+
<PasswordEditor bind:value={normalPassword} placeholder="Normal password" />
|
|
158
|
+
|
|
159
|
+
<!-- Readonly password input -->
|
|
160
|
+
<PasswordEditor bind:value={readonlyPassword} readonly />
|
|
161
|
+
|
|
162
|
+
<!-- Disabled password input -->
|
|
163
|
+
<PasswordEditor bind:value={disabledPassword} disabled placeholder="Disabled password" />
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Compact Mode
|
|
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="Password"
|
|
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
|
+
### Login Form Example
|
|
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('Logging in...', credentials.username);
|
|
209
|
+
// Perform login logic
|
|
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>Login</h2>
|
|
222
|
+
|
|
223
|
+
<div class="form-field">
|
|
224
|
+
<label>Username</label>
|
|
225
|
+
<TextEditor
|
|
226
|
+
bind:value={credentials.username}
|
|
227
|
+
placeholder="Enter username"
|
|
228
|
+
on:keydown={handleKeydown}
|
|
229
|
+
/>
|
|
230
|
+
</div>
|
|
231
|
+
|
|
232
|
+
<div class="form-field">
|
|
233
|
+
<label>Password</label>
|
|
234
|
+
<PasswordEditor
|
|
235
|
+
bind:value={credentials.password}
|
|
236
|
+
placeholder="Enter password"
|
|
237
|
+
on:keydown={handleKeydown}
|
|
238
|
+
/>
|
|
239
|
+
</div>
|
|
240
|
+
|
|
241
|
+
<Button
|
|
242
|
+
type="primary"
|
|
243
|
+
label="Login"
|
|
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
|
+
### Password Strength Indicator
|
|
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 = ['', 'Weak', 'Fair', 'Good', 'Strong', 'Very Strong'];
|
|
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>Create Password</label>
|
|
308
|
+
<PasswordEditor bind:value={password} placeholder="Enter a strong password" />
|
|
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>Password should contain:</p>
|
|
326
|
+
<ul>
|
|
327
|
+
<li class:met={password.length >= 8}>At least 8 characters</li>
|
|
328
|
+
<li class:met={/[a-z]/.test(password)}>Lowercase letter</li>
|
|
329
|
+
<li class:met={/[A-Z]/.test(password)}>Uppercase letter</li>
|
|
330
|
+
<li class:met={/[0-9]/.test(password)}>Number</li>
|
|
331
|
+
<li class:met={/[^A-Za-z0-9]/.test(password)}>Special character</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
|
+
### Registration Form
|
|
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('Registering user...', formData.email);
|
|
423
|
+
// Perform registration logic
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
</script>
|
|
427
|
+
|
|
428
|
+
<div class="register-container">
|
|
429
|
+
<h2>Create Account</h2>
|
|
430
|
+
|
|
431
|
+
<div class="form-field">
|
|
432
|
+
<label>Email</label>
|
|
433
|
+
<TextEditor
|
|
434
|
+
bind:value={formData.email}
|
|
435
|
+
placeholder="Enter email address"
|
|
436
|
+
/>
|
|
437
|
+
</div>
|
|
438
|
+
|
|
439
|
+
<div class="form-field">
|
|
440
|
+
<label>Password</label>
|
|
441
|
+
<PasswordEditor
|
|
442
|
+
bind:value={formData.password}
|
|
443
|
+
placeholder="Create password"
|
|
444
|
+
/>
|
|
445
|
+
</div>
|
|
446
|
+
|
|
447
|
+
<div class="form-field">
|
|
448
|
+
<label>Confirm Password</label>
|
|
449
|
+
<PasswordEditor
|
|
450
|
+
bind:value={formData.confirmPassword}
|
|
451
|
+
placeholder="Confirm password"
|
|
452
|
+
/>
|
|
453
|
+
{#if formData.confirmPassword && !passwordsMatch}
|
|
454
|
+
<div class="error-message">Passwords do not match</div>
|
|
455
|
+
{/if}
|
|
456
|
+
</div>
|
|
457
|
+
|
|
458
|
+
<Button
|
|
459
|
+
type="primary"
|
|
460
|
+
label="Create Account"
|
|
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
|
+
## Features
|
|
499
|
+
|
|
500
|
+
- **Visibility Toggle**: Built-in eye icon to show/hide password text
|
|
501
|
+
- **Security**: Maintains password masking by default
|
|
502
|
+
- **Event Handling**: Custom focus, blur, and change event callbacks
|
|
503
|
+
- **Flexible Styling**: Multiple visual variants and custom styling
|
|
504
|
+
- **State Management**: Disabled and readonly states
|
|
505
|
+
- **Responsive**: Works well on all device sizes
|
|
506
|
+
|
|
507
|
+
## Behavior
|
|
508
|
+
|
|
509
|
+
1. **Default State**: Password text is hidden (masked)
|
|
510
|
+
2. **Toggle Visibility**: Click the eye icon to show/hide password
|
|
511
|
+
3. **Disabled/Readonly**: Eye icon is hidden when input is disabled or readonly
|
|
512
|
+
4. **Focus Management**: Proper focus handling for accessibility
|
|
513
|
+
5. **Input Type Switching**: Dynamically switches between `password` and `text` input types
|
|
514
|
+
|
|
515
|
+
## Security Considerations
|
|
516
|
+
|
|
517
|
+
- Password text is masked by default for security
|
|
518
|
+
- Visibility toggle helps with password entry accuracy
|
|
519
|
+
- No password content is logged or exposed in the component
|
|
520
|
+
- Follows standard password input security practices
|
|
521
|
+
|
|
522
|
+
## Accessibility
|
|
523
|
+
|
|
524
|
+
- Proper semantic HTML structure
|
|
525
|
+
- Keyboard navigation support
|
|
526
|
+
- Screen reader compatible
|
|
527
|
+
- Focus indicators and management
|
|
528
|
+
- Clear visual feedback for interaction states
|
|
529
|
+
|
|
530
|
+
## Best Practices
|
|
531
|
+
|
|
532
|
+
1. **Password Requirements**: Always provide clear password requirements
|
|
533
|
+
2. **Confirmation**: Use confirmation fields for new password creation
|
|
534
|
+
3. **Strength Indicators**: Consider adding password strength feedback
|
|
535
|
+
4. **Error Handling**: Provide clear validation messages
|
|
536
|
+
5. **Security**: Never store or log password values in plain text
|
|
537
|
+
6. **Accessibility**: Ensure proper labeling and keyboard navigation
|
|
538
|
+
|
|
539
|
+
## Browser Support
|
|
540
|
+
|
|
541
|
+
- Modern browsers with full input event support
|
|
542
|
+
- Compatible with Svelte 5+
|
|
543
|
+
- Touch-friendly interface
|
|
544
|
+
- Responsive design principles
|
|
545
|
+
|
|
546
|
+
## Related Components
|
|
547
|
+
|
|
548
|
+
- `TextEditor` - Basic text input component
|
|
549
|
+
- `SearchBox` - Search-specific input
|
|
550
|
+
- `NumberEditor` - Numeric input validation
|
|
551
|
+
- `Button` - For form submission and actions
|