@juspay/svelte-ui-components 1.20.0 → 1.22.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.
@@ -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' : ''}
@@ -194,25 +207,31 @@ $: {
194
207
  display: flex;
195
208
  flex-direction: column;
196
209
  margin: var(--input-container-margin);
210
+ padding: var(--input-container-padding);
197
211
  }
198
212
 
199
213
  .label {
200
214
  font-weight: var(--input-label-msg-text-weight, 400);
201
215
  font-size: var(--input-label-msg-text-size, 12px);
202
216
  color: var(--input-label-msg-text-color, #637c95);
203
- margin-bottom: 6px;
217
+ margin: var(--input-label-msg-margin, 0px 0px 6px 0px);
218
+ padding: var(--input-label-msg-padding);
204
219
  }
205
220
 
206
221
  .error-message {
207
222
  font-weight: var(--input-error-msg-text-weight, 400);
208
223
  font-size: var(--input-error-msg-text-size, 12px);
209
224
  color: var(--input-error-msg-text-color, #fa1405);
225
+ margin: var(--input-error-msg-margin);
226
+ padding: var(--input-error-msg-padding);
210
227
  }
211
228
 
212
229
  .info-message {
213
230
  font-weight: var(--input-info-msg-text-weight, 400);
214
231
  font-size: var(--input-info-msg-text-size, 12px);
215
232
  color: var(--input-info-msg-text-color, #fa1405);
233
+ margin: var(--input-info-msg-margin);
234
+ padding: var(--input-info-msg-padding);
216
235
  }
217
236
 
218
237
  ::placeholder {
@@ -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,8 @@ 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);
115
+ padding: var(--input-button-container-padding);
105
116
  }
106
117
 
107
118
  .input-button {
@@ -110,6 +121,7 @@ function onFocusOut(event) {
110
121
  border-radius: var(--input-button-radius, 4px);
111
122
  border: var(--input-button-border);
112
123
  box-shadow: var(--input-button-box-shadow, 0px 1px 8px #2f537733);
124
+ background: var(--input-button-background);
113
125
  }
114
126
  .input-button-container:focus-within {
115
127
  border: var(--input-button-focus-border);
@@ -146,16 +158,16 @@ function onFocusOut(event) {
146
158
 
147
159
  .error-message {
148
160
  font-weight: var(--input-error-msg-text-weight, 400);
149
- font-size: var(--input-error-msg-text-size, 14px);
161
+ font-size: var(--input-error-msg-text-size, 12px);
150
162
  color: var(--input-error-msg-text-color, #fa1405);
151
- margin-top: 12px;
163
+ margin: var(--input-btn-error-msg-margin, 12px 0px 0px 0px);
152
164
  }
153
165
 
154
166
  .info-message {
155
167
  font-weight: var(--input-info-msg-text-weight, 400);
156
168
  font-size: var(--input-info-msg-text-size, 12px);
157
169
  color: var(--input-info-msg-text-color, #fa1405);
158
- margin-top: 12px;
170
+ margin: var(--input-btn-info-msg-margin, 12px 0px 0px 0px);
159
171
  }
160
172
 
161
173
  .left-button {
@@ -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 {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/svelte-ui-components",
3
- "version": "1.20.0",
3
+ "version": "1.22.0",
4
4
  "scripts": {
5
5
  "dev": "vite dev --host",
6
6
  "build": "vite build && npm run package",