@sveltia/ui 0.33.1 → 0.34.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/components/text-field/search-bar.svelte +3 -5
- package/dist/components/text-field/search-bar.svelte.d.ts +8 -0
- package/dist/components/text-field/secret-input.svelte +142 -0
- package/dist/components/text-field/secret-input.svelte.d.ts +34 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/locales/en.d.ts +4 -0
- package/dist/locales/en.js +4 -0
- package/dist/locales/ja.d.ts +4 -0
- package/dist/locales/ja.js +4 -0
- package/package.json +1 -1
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
* @property {string} [value] Input value.
|
|
23
23
|
* @property {Snippet} [searchIcon] Search icon slot content.
|
|
24
24
|
* @property {Snippet} [closeIcon] Close icon slot content.
|
|
25
|
+
* @property {() => void} [onClear] Callback invoked when the clear button is clicked.
|
|
25
26
|
*/
|
|
26
27
|
|
|
27
28
|
/**
|
|
@@ -40,6 +41,7 @@
|
|
|
40
41
|
children,
|
|
41
42
|
searchIcon,
|
|
42
43
|
closeIcon,
|
|
44
|
+
onClear,
|
|
43
45
|
...restProps
|
|
44
46
|
/* eslint-enable prefer-const */
|
|
45
47
|
} = $props();
|
|
@@ -98,11 +100,7 @@
|
|
|
98
100
|
onclick={() => {
|
|
99
101
|
value = '';
|
|
100
102
|
inputElement?.focus();
|
|
101
|
-
|
|
102
|
-
inputElement?.dispatchEvent(new KeyboardEvent('input'));
|
|
103
|
-
inputElement?.dispatchEvent(new KeyboardEvent('keypress'));
|
|
104
|
-
inputElement?.dispatchEvent(new KeyboardEvent('change'));
|
|
105
|
-
});
|
|
103
|
+
onClear?.();
|
|
106
104
|
}}
|
|
107
105
|
>
|
|
108
106
|
{#snippet startIcon()}
|
|
@@ -24,6 +24,10 @@ declare const SearchBar: import("svelte").Component<TextInputProps & import("../
|
|
|
24
24
|
* Close icon slot content.
|
|
25
25
|
*/
|
|
26
26
|
closeIcon?: Snippet<[]> | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Callback invoked when the clear button is clicked.
|
|
29
|
+
*/
|
|
30
|
+
onClear?: (() => void) | undefined;
|
|
27
31
|
} & Record<string, any>, {
|
|
28
32
|
focus: () => void;
|
|
29
33
|
}, "value">;
|
|
@@ -40,6 +44,10 @@ type Props = {
|
|
|
40
44
|
* Close icon slot content.
|
|
41
45
|
*/
|
|
42
46
|
closeIcon?: Snippet<[]> | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Callback invoked when the clear button is clicked.
|
|
49
|
+
*/
|
|
50
|
+
onClear?: (() => void) | undefined;
|
|
43
51
|
};
|
|
44
52
|
import type { TextInputProps } from '../../typedefs';
|
|
45
53
|
import type { InputEventHandlers } from '../../typedefs';
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
Similar to `PasswordInput`, but it doesn’t use `type="password"` to hide the input value. Instead,
|
|
4
|
+
it relies on CSS to visually conceal the input to prevent password managers from prompting to save
|
|
5
|
+
the password.
|
|
6
|
+
@see https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/-webkit-text-security
|
|
7
|
+
-->
|
|
8
|
+
<script>
|
|
9
|
+
import { _ } from 'svelte-i18n';
|
|
10
|
+
import Button from '../button/button.svelte';
|
|
11
|
+
import Icon from '../icon/icon.svelte';
|
|
12
|
+
import TextInput from './text-input.svelte';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @import { Snippet } from 'svelte';
|
|
16
|
+
* @import { CommonEventHandlers, InputEventHandlers, TextInputProps } from '../../typedefs';
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {object} Props
|
|
21
|
+
* @property {string} [value] Input value.
|
|
22
|
+
* @property {Snippet} [visibilityIcon] Visibility icon slot content.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @type {TextInputProps & CommonEventHandlers & InputEventHandlers & Props & Record<string, any>}
|
|
27
|
+
*/
|
|
28
|
+
let {
|
|
29
|
+
/* eslint-disable prefer-const */
|
|
30
|
+
value = $bindable(),
|
|
31
|
+
flex = false,
|
|
32
|
+
monospace = true,
|
|
33
|
+
class: className,
|
|
34
|
+
hidden = false,
|
|
35
|
+
disabled = false,
|
|
36
|
+
readonly = false,
|
|
37
|
+
required = false,
|
|
38
|
+
invalid = false,
|
|
39
|
+
children,
|
|
40
|
+
visibilityIcon,
|
|
41
|
+
...restProps
|
|
42
|
+
/* eslint-enable prefer-const */
|
|
43
|
+
} = $props();
|
|
44
|
+
|
|
45
|
+
const id = $props.id();
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Reference to the `<input>` element.
|
|
49
|
+
* @type {HTMLInputElement | undefined}
|
|
50
|
+
*/
|
|
51
|
+
let inputElement = $state();
|
|
52
|
+
let show = $state(false);
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<div
|
|
56
|
+
role="none"
|
|
57
|
+
class="sui secret-input {className}"
|
|
58
|
+
class:flex
|
|
59
|
+
class:disabled
|
|
60
|
+
class:readonly
|
|
61
|
+
class:show
|
|
62
|
+
{hidden}
|
|
63
|
+
>
|
|
64
|
+
<TextInput
|
|
65
|
+
bind:element={inputElement}
|
|
66
|
+
{...restProps}
|
|
67
|
+
{id}
|
|
68
|
+
bind:value
|
|
69
|
+
spellcheck="false"
|
|
70
|
+
{flex}
|
|
71
|
+
{monospace}
|
|
72
|
+
{hidden}
|
|
73
|
+
{disabled}
|
|
74
|
+
{readonly}
|
|
75
|
+
{required}
|
|
76
|
+
{invalid}
|
|
77
|
+
/>
|
|
78
|
+
<Button
|
|
79
|
+
iconic
|
|
80
|
+
disabled={disabled || readonly}
|
|
81
|
+
pressed={show}
|
|
82
|
+
aria-label={$_(show ? '_sui.secret_input.hide_secret' : '_sui.secret_input.show_secret')}
|
|
83
|
+
aria-controls={id}
|
|
84
|
+
onclick={() => {
|
|
85
|
+
show = !show;
|
|
86
|
+
}}
|
|
87
|
+
>
|
|
88
|
+
{#snippet startIcon()}
|
|
89
|
+
{#if visibilityIcon}
|
|
90
|
+
{@render visibilityIcon()}
|
|
91
|
+
{:else}
|
|
92
|
+
<Icon name={show ? 'visibility_off' : 'visibility'} />
|
|
93
|
+
{/if}
|
|
94
|
+
{/snippet}
|
|
95
|
+
</Button>
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
<style>.secret-input {
|
|
99
|
+
display: inline-flex;
|
|
100
|
+
align-items: center;
|
|
101
|
+
margin: var(--sui-focus-ring-width);
|
|
102
|
+
min-width: var(--sui-textbox-singleline-min-width);
|
|
103
|
+
}
|
|
104
|
+
.secret-input.flex {
|
|
105
|
+
width: -moz-available;
|
|
106
|
+
width: -webkit-fill-available;
|
|
107
|
+
width: stretch;
|
|
108
|
+
min-width: 0;
|
|
109
|
+
}
|
|
110
|
+
.secret-input.show :global(input) {
|
|
111
|
+
-webkit-text-security: none;
|
|
112
|
+
}
|
|
113
|
+
.secret-input :global(.text-input) {
|
|
114
|
+
flex: auto;
|
|
115
|
+
margin: 0 !important;
|
|
116
|
+
width: 0;
|
|
117
|
+
min-width: 0 !important;
|
|
118
|
+
}
|
|
119
|
+
.secret-input :global(input) {
|
|
120
|
+
border-start-end-radius: 0;
|
|
121
|
+
border-end-end-radius: 0;
|
|
122
|
+
-webkit-text-security: disc;
|
|
123
|
+
}
|
|
124
|
+
.secret-input :global(button) {
|
|
125
|
+
flex: none;
|
|
126
|
+
margin-block: 0;
|
|
127
|
+
margin-inline-start: -1px;
|
|
128
|
+
margin-inline-end: 0;
|
|
129
|
+
border-width: 1px;
|
|
130
|
+
border-color: var(--sui-textbox-border-color);
|
|
131
|
+
width: var(--sui-textbox-height);
|
|
132
|
+
aspect-ratio: 1/1;
|
|
133
|
+
}
|
|
134
|
+
.secret-input :global(button:last-child) {
|
|
135
|
+
border-start-start-radius: 0;
|
|
136
|
+
border-start-end-radius: 4px;
|
|
137
|
+
border-end-end-radius: 4px;
|
|
138
|
+
border-end-start-radius: 0;
|
|
139
|
+
}
|
|
140
|
+
.secret-input :global(button) :global(.icon) {
|
|
141
|
+
font-size: var(--sui-font-size-xx-large);
|
|
142
|
+
}</style>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export default SecretInput;
|
|
2
|
+
type SecretInput = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<TextInputProps & KeyboardEventHandlers & MouseEventHandlers & FocusEventHandlers & DragEventHandlers & InputEventHandlers & Props & Record<string, any>>): void;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Similar to `PasswordInput`, but it doesn’t use `type="password"` to hide the input value. Instead,
|
|
8
|
+
* it relies on CSS to visually conceal the input to prevent password managers from prompting to save
|
|
9
|
+
* the password.
|
|
10
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/-webkit-text-security
|
|
11
|
+
*/
|
|
12
|
+
declare const SecretInput: import("svelte").Component<TextInputProps & import("../../typedefs").KeyboardEventHandlers & import("../../typedefs").MouseEventHandlers & import("../../typedefs").FocusEventHandlers & import("../../typedefs").DragEventHandlers & InputEventHandlers & {
|
|
13
|
+
/**
|
|
14
|
+
* Input value.
|
|
15
|
+
*/
|
|
16
|
+
value?: string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Visibility icon slot content.
|
|
19
|
+
*/
|
|
20
|
+
visibilityIcon?: Snippet<[]> | undefined;
|
|
21
|
+
} & Record<string, any>, {}, "value">;
|
|
22
|
+
type Props = {
|
|
23
|
+
/**
|
|
24
|
+
* Input value.
|
|
25
|
+
*/
|
|
26
|
+
value?: string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Visibility icon slot content.
|
|
29
|
+
*/
|
|
30
|
+
visibilityIcon?: Snippet<[]> | undefined;
|
|
31
|
+
};
|
|
32
|
+
import type { TextInputProps } from '../../typedefs';
|
|
33
|
+
import type { InputEventHandlers } from '../../typedefs';
|
|
34
|
+
import type { Snippet } from 'svelte';
|
package/dist/index.d.ts
CHANGED
|
@@ -67,6 +67,7 @@ export { default as TextEditor } from "./components/text-editor/text-editor.svel
|
|
|
67
67
|
export { default as NumberInput } from "./components/text-field/number-input.svelte";
|
|
68
68
|
export { default as PasswordInput } from "./components/text-field/password-input.svelte";
|
|
69
69
|
export { default as SearchBar } from "./components/text-field/search-bar.svelte";
|
|
70
|
+
export { default as SecretInput } from "./components/text-field/secret-input.svelte";
|
|
70
71
|
export { default as TextArea } from "./components/text-field/text-area.svelte";
|
|
71
72
|
export { default as TextInput } from "./components/text-field/text-input.svelte";
|
|
72
73
|
export { default as Toast } from "./components/toast/toast.svelte";
|
package/dist/index.js
CHANGED
|
@@ -71,6 +71,7 @@ export { default as TextEditor } from './components/text-editor/text-editor.svel
|
|
|
71
71
|
export { default as NumberInput } from './components/text-field/number-input.svelte';
|
|
72
72
|
export { default as PasswordInput } from './components/text-field/password-input.svelte';
|
|
73
73
|
export { default as SearchBar } from './components/text-field/search-bar.svelte';
|
|
74
|
+
export { default as SecretInput } from './components/text-field/secret-input.svelte';
|
|
74
75
|
export { default as TextArea } from './components/text-field/text-area.svelte';
|
|
75
76
|
export { default as TextInput } from './components/text-field/text-input.svelte';
|
|
76
77
|
export { default as Toast } from './components/toast/toast.svelte';
|
package/dist/locales/en.d.ts
CHANGED
|
@@ -35,6 +35,10 @@ export namespace strings {
|
|
|
35
35
|
let show_password: string;
|
|
36
36
|
let hide_password: string;
|
|
37
37
|
}
|
|
38
|
+
namespace secret_input {
|
|
39
|
+
let show_secret: string;
|
|
40
|
+
let hide_secret: string;
|
|
41
|
+
}
|
|
38
42
|
namespace select_tags {
|
|
39
43
|
let selected_options: string;
|
|
40
44
|
let remove_x: string;
|
package/dist/locales/en.js
CHANGED
|
@@ -35,6 +35,10 @@ export const strings = {
|
|
|
35
35
|
show_password: 'Show Password',
|
|
36
36
|
hide_password: 'Hide Password',
|
|
37
37
|
},
|
|
38
|
+
secret_input: {
|
|
39
|
+
show_secret: 'Show Secret',
|
|
40
|
+
hide_secret: 'Hide Secret',
|
|
41
|
+
},
|
|
38
42
|
select_tags: {
|
|
39
43
|
selected_options: 'Selected options',
|
|
40
44
|
remove_x: 'Remove {name}',
|
package/dist/locales/ja.d.ts
CHANGED
|
@@ -35,6 +35,10 @@ export namespace strings {
|
|
|
35
35
|
let show_password: string;
|
|
36
36
|
let hide_password: string;
|
|
37
37
|
}
|
|
38
|
+
namespace secret_input {
|
|
39
|
+
let show_secret: string;
|
|
40
|
+
let hide_secret: string;
|
|
41
|
+
}
|
|
38
42
|
namespace select_tags {
|
|
39
43
|
let selected_options: string;
|
|
40
44
|
let remove_x: string;
|
package/dist/locales/ja.js
CHANGED