@juspay/svelte-ui-components 1.20.0 → 1.21.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/Input/Input.svelte
CHANGED
|
@@ -20,6 +20,14 @@ function getValidationState(prop) {
|
|
|
20
20
|
return valueValidation;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
+
export function focus() {
|
|
24
|
+
try {
|
|
25
|
+
inputElement?.focus();
|
|
26
|
+
inputElement?.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.error("Error focusing or scrolling inputElement:", error);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
23
31
|
$:
|
|
24
32
|
showErrorMessage = state === "Invalid";
|
|
25
33
|
function onInput(event) {
|
|
@@ -79,6 +87,9 @@ function onFocusOut(event) {
|
|
|
79
87
|
}
|
|
80
88
|
dispatch("focusout", event);
|
|
81
89
|
}
|
|
90
|
+
function onClick(event) {
|
|
91
|
+
dispatch("click", event);
|
|
92
|
+
}
|
|
82
93
|
onMount(() => {
|
|
83
94
|
if (properties.focus) {
|
|
84
95
|
inputElement.focus();
|
|
@@ -110,6 +121,7 @@ $: {
|
|
|
110
121
|
on:focusout={onFocusOut}
|
|
111
122
|
on:input={onInput}
|
|
112
123
|
on:paste={onPaste}
|
|
124
|
+
on:click={onClick}
|
|
113
125
|
class="
|
|
114
126
|
{properties.actionInput ? 'action-input' : ''}
|
|
115
127
|
"
|
|
@@ -133,6 +145,7 @@ $: {
|
|
|
133
145
|
on:focusout={onFocusOut}
|
|
134
146
|
on:input={onInput}
|
|
135
147
|
on:paste={onPaste}
|
|
148
|
+
on:click={onClick}
|
|
136
149
|
data-pw={properties.dataPw}
|
|
137
150
|
class="
|
|
138
151
|
{properties.actionInput ? 'action-input' : ''}
|
|
@@ -3,6 +3,7 @@ import { type InputProperties } from './properties';
|
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
properties?: InputProperties | undefined;
|
|
6
|
+
focus?: (() => void) | undefined;
|
|
6
7
|
};
|
|
7
8
|
events: {
|
|
8
9
|
keydown: KeyboardEvent;
|
|
@@ -12,6 +13,7 @@ declare const __propDef: {
|
|
|
12
13
|
input: CustomEvent<any>;
|
|
13
14
|
paste: CustomEvent<any>;
|
|
14
15
|
focusout: CustomEvent<any>;
|
|
16
|
+
click: CustomEvent<any>;
|
|
15
17
|
stateChange: CustomEvent<any>;
|
|
16
18
|
} & {
|
|
17
19
|
[evt: string]: CustomEvent<any>;
|
|
@@ -22,5 +24,6 @@ export type InputProps = typeof __propDef.props;
|
|
|
22
24
|
export type InputEvents = typeof __propDef.events;
|
|
23
25
|
export type InputSlots = typeof __propDef.slots;
|
|
24
26
|
export default class Input extends SvelteComponent<InputProps, InputEvents, InputSlots> {
|
|
27
|
+
get focus(): () => void;
|
|
25
28
|
}
|
|
26
29
|
export {};
|
|
@@ -4,6 +4,7 @@ import { createEventDispatcher } from "svelte";
|
|
|
4
4
|
import { defaultInputButtonProperties } from "./properties";
|
|
5
5
|
const dispatch = createEventDispatcher();
|
|
6
6
|
export let properties = defaultInputButtonProperties;
|
|
7
|
+
let inputRef;
|
|
7
8
|
$:
|
|
8
9
|
state = "InProgress";
|
|
9
10
|
$: {
|
|
@@ -40,6 +41,12 @@ function handleState(event) {
|
|
|
40
41
|
function onFocusOut(event) {
|
|
41
42
|
dispatch("focusout", event);
|
|
42
43
|
}
|
|
44
|
+
function onInputClick(event) {
|
|
45
|
+
dispatch("inputClick", event);
|
|
46
|
+
}
|
|
47
|
+
export function focus() {
|
|
48
|
+
inputRef?.focus();
|
|
49
|
+
}
|
|
43
50
|
</script>
|
|
44
51
|
|
|
45
52
|
{#if properties.inputProperties.label && properties.inputProperties.label !== ''}
|
|
@@ -65,7 +72,9 @@ function onFocusOut(event) {
|
|
|
65
72
|
on:input={(event) => dispatch('input', event)}
|
|
66
73
|
on:focusout={onFocusOut}
|
|
67
74
|
on:focus
|
|
75
|
+
on:click={onInputClick}
|
|
68
76
|
--input-width="auto"
|
|
77
|
+
bind:this={inputRef}
|
|
69
78
|
/>
|
|
70
79
|
</div>
|
|
71
80
|
{#if properties.rightButtonProperties != null}
|
|
@@ -102,6 +111,7 @@ function onFocusOut(event) {
|
|
|
102
111
|
--input-border: none;
|
|
103
112
|
--input-focus-border: none;
|
|
104
113
|
border: var(--input-button-container-border);
|
|
114
|
+
background: var(--input-button-container-background);
|
|
105
115
|
}
|
|
106
116
|
|
|
107
117
|
.input-button {
|
|
@@ -110,6 +120,7 @@ function onFocusOut(event) {
|
|
|
110
120
|
border-radius: var(--input-button-radius, 4px);
|
|
111
121
|
border: var(--input-button-border);
|
|
112
122
|
box-shadow: var(--input-button-box-shadow, 0px 1px 8px #2f537733);
|
|
123
|
+
background: var(--input-button-background);
|
|
113
124
|
}
|
|
114
125
|
.input-button-container:focus-within {
|
|
115
126
|
border: var(--input-button-focus-border);
|
|
@@ -3,6 +3,7 @@ import { type InputButtonProperties } from './properties';
|
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
properties?: InputButtonProperties | undefined;
|
|
6
|
+
focus?: (() => void) | undefined;
|
|
6
7
|
};
|
|
7
8
|
events: {
|
|
8
9
|
focus: FocusEvent;
|
|
@@ -12,6 +13,7 @@ declare const __propDef: {
|
|
|
12
13
|
bottomButtonClick: CustomEvent<any>;
|
|
13
14
|
stateChange: CustomEvent<any>;
|
|
14
15
|
focusout: CustomEvent<any>;
|
|
16
|
+
inputClick: CustomEvent<any>;
|
|
15
17
|
} & {
|
|
16
18
|
[evt: string]: CustomEvent<any>;
|
|
17
19
|
};
|
|
@@ -25,5 +27,6 @@ export type InputButtonProps = typeof __propDef.props;
|
|
|
25
27
|
export type InputButtonEvents = typeof __propDef.events;
|
|
26
28
|
export type InputButtonSlots = typeof __propDef.slots;
|
|
27
29
|
export default class InputButton extends SvelteComponent<InputButtonProps, InputButtonEvents, InputButtonSlots> {
|
|
30
|
+
get focus(): () => void;
|
|
28
31
|
}
|
|
29
32
|
export {};
|