@juspay/svelte-ui-components 2.2.4 → 2.8.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.
@@ -31,8 +31,7 @@
31
31
  <div class="button-progress-bar"></div>
32
32
  {/if}
33
33
  <button
34
- style:--opacity={enable ? 1 : 0.4}
35
- style:--cursor={enable ? 'pointer' : 'not-allowed'}
34
+ class:disabled={!enable}
36
35
  onclick={handleButtonClick}
37
36
  {onkeyup}
38
37
  disabled={!(enable && !showLoader)}
@@ -46,7 +45,7 @@
46
45
  <div class="button-icon">{@render icon()}</div>
47
46
  {/if}
48
47
  {#if text}
49
- <div class="button-text">{text}</div>
48
+ <div class="button-text">{@html text}</div>
50
49
  {/if}
51
50
  </button>
52
51
  </div>
@@ -81,6 +80,11 @@
81
80
  box-shadow: var(--button-box-shadow, none);
82
81
  }
83
82
 
83
+ .disabled {
84
+ cursor: var(--disabled-cursor, not-allowed);
85
+ opacity: var(--disabled-opacity, 0.4);
86
+ }
87
+
84
88
  .button-loader {
85
89
  order: var(--button-loader-order, 1);
86
90
  }
@@ -23,6 +23,8 @@
23
23
  name = '',
24
24
  testId = '',
25
25
  textTransformers = [],
26
+ textViewPresentation = [],
27
+ onFocus = () => {},
26
28
  onFocusout = () => {},
27
29
  onInput = () => {},
28
30
  onPaste = () => {},
@@ -60,7 +62,7 @@
60
62
  return valueValidation;
61
63
  });
62
64
 
63
- let showErrorMessage = $derived(validationState === 'Invalid');
65
+ const showErrorMessage = $derived(validationState === 'Invalid');
64
66
 
65
67
  function handleOnInput(event: Event) {
66
68
  if (inputElement === null) {
@@ -81,12 +83,16 @@
81
83
  }
82
84
  if (numberLength > maxLength) {
83
85
  const existingInput = value;
84
- if (existingInput.length == maxLength) {
85
- inputElement.value = value;
86
+ if (existingInput.length === maxLength) {
87
+ inputElement.value = applyTextPresentation(value);
86
88
  return;
87
89
  }
90
+ /**
91
+ * choose last max length number of digits if length is bigger than max length passed in props
92
+ */
88
93
  currentValue = currentValue.substring(numberLength - maxLength);
89
94
  }
95
+ currentValue = applyTextPresentation(currentValue);
90
96
  inputElement.value = currentValue;
91
97
  }
92
98
  value = inputElement.value;
@@ -128,7 +134,9 @@
128
134
  /**
129
135
  * choose last max length number of digits if length is bigger than max length passed in props
130
136
  */
131
- const finalValue = filteredNumber.substring(filteredNumberLength - maxLength);
137
+ const finalValue = applyTextPresentation(
138
+ filteredNumber.substring(filteredNumberLength - maxLength)
139
+ );
132
140
  // Adding reactivity
133
141
  value = finalValue;
134
142
  onPaste(event);
@@ -141,6 +149,13 @@
141
149
  }
142
150
  }
143
151
 
152
+ function applyTextPresentation(currentValue: string): string {
153
+ return textViewPresentation.reduce((prevValue, currIndexFunction) => {
154
+ let newValue = currIndexFunction(prevValue);
155
+ return newValue;
156
+ }, currentValue);
157
+ }
158
+
144
159
  function _onFocusOut(event: FocusEvent) {
145
160
  if (validationState === 'InProgress' && value.length > 0) {
146
161
  validationState = 'Invalid';
@@ -167,6 +182,7 @@
167
182
  {placeholder}
168
183
  autocomplete={autoComplete}
169
184
  {name}
185
+ onfocus={onFocus}
170
186
  onfocusout={_onFocusOut}
171
187
  oninput={handleOnInput}
172
188
  onpaste={handleOnPaste}
@@ -185,9 +201,11 @@
185
201
  {placeholder}
186
202
  autocomplete={autoComplete}
187
203
  {name}
204
+ onfocus={onFocus}
188
205
  onfocusout={_onFocusOut}
189
206
  oninput={handleOnInput}
190
- onpaste={onPaste}
207
+ onpaste={handleOnPaste}
208
+ onclick={onClick}
191
209
  data-pw={testId}
192
210
  class:action-input={actionInput}
193
211
  disabled={disable}
@@ -251,7 +269,7 @@
251
269
 
252
270
  .action-input {
253
271
  border-radius: var(--input-radius, 4px 0px 0px 4px);
254
- box-shadow: 0px 0px 0px #ffffff;
272
+ box-shadow: var(--input-box-shadow, 0px 0px 0px #ffffff);
255
273
  margin-bottom: 0;
256
274
  }
257
275
 
@@ -21,10 +21,12 @@ export type OptionalInputProperties = {
21
21
  autoComplete?: AutoCompleteType;
22
22
  name?: string;
23
23
  textTransformers?: TextTransformer[];
24
+ textViewPresentation?: TextTransformer[];
24
25
  testId?: string;
25
26
  };
26
27
  export type InputEventProperties = {
27
28
  onInput?: (value: string, event: Event) => void;
29
+ onFocus?: (event: FocusEvent) => void;
28
30
  onFocusout?: (event: FocusEvent) => void;
29
31
  onPaste?: (event: ClipboardEvent) => void;
30
32
  onClick?: (event: MouseEvent) => void;
@@ -15,7 +15,8 @@
15
15
  rightButtonEventProperties,
16
16
  leftButtonEventProperties,
17
17
  bottomButtonEventProperties,
18
- leftIcon
18
+ leftIcon,
19
+ rightIcon
19
20
  }: InputButtonProperties = $props();
20
21
 
21
22
  let validationState = $state<ValidationState>('InProgress');
@@ -23,7 +24,7 @@
23
24
  let inputRef: SvelteComponent | null = $state(null);
24
25
 
25
26
  // Derive enable state for right button
26
- let isRightButtonEnabled = $derived(validationState === 'Valid');
27
+ const isRightButtonEnabled = $derived(validationState === 'Valid');
27
28
 
28
29
  function rightButtonClick(event: MouseEvent): void {
29
30
  if (validationState === 'Valid') {
@@ -71,6 +72,7 @@
71
72
  <div class="input" onkeyup={triggerRightClickIfValid}>
72
73
  <Input
73
74
  {...inputProperties}
75
+ {...inputEventProperties}
74
76
  bind:value
75
77
  bind:this={inputRef}
76
78
  onStateChange={handleStateChange}
@@ -83,6 +85,7 @@
83
85
  {...rightButtonProperties}
84
86
  enable={isRightButtonEnabled}
85
87
  onclick={rightButtonClick}
88
+ icon={rightIcon}
86
89
  />
87
90
  </div>
88
91
  {/if}
@@ -163,7 +166,7 @@
163
166
  font-size: var(--input-label-msg-text-size, 12px);
164
167
  color: var(--input-label-msg-text-color, #637c95);
165
168
  line-height: var(--input-label-msg-text-line-height);
166
- margin-bottom: 6px;
169
+ margin: var(--input-label-msg-text-margin, 0px 0px 6px 0px);
167
170
  }
168
171
 
169
172
  .invalid {
@@ -203,6 +206,11 @@
203
206
  flex-direction: row;
204
207
  --button-content-gap: var(--left-button-content-gap);
205
208
  --button-content-flex-direction: var(--left-button-content-flex-direction, row);
209
+ --button-icon-order: var(--left-button-icon-order);
210
+ --button-icon-display: var(--left-button-icon-display);
211
+ --button-text-order: var(--left-button-text-order);
212
+ --disabled-cursor: var(--left-button-disabled-cursor);
213
+ --disabled-opacity: var(--left-button-disabled-opacity);
206
214
  }
207
215
 
208
216
  .right-button {
@@ -227,5 +235,10 @@
227
235
  --button-content-gap: var(--right-button-content-gap);
228
236
  --button-visibility: var(--right-button-visibility, visible);
229
237
  --button-content-flex-direction: var(--right-button-content-flex-direction, row);
238
+ --button-icon-order: var(--right-button-icon-order);
239
+ --button-icon-display: var(--right-button-icon-display);
240
+ --button-text-order: var(--right-button-text-order);
241
+ --disabled-cursor: var(--right-button-disabled-cursor);
242
+ --disabled-opacity: var(--right-button-disabled-opacity);
230
243
  }
231
244
  </style>
@@ -11,6 +11,7 @@ export type OptionalInputButtonProperties = {
11
11
  leftButtonProperties?: _ButtonProperties | null;
12
12
  bottomButtonProperties?: _ButtonProperties | null;
13
13
  leftIcon?: Snippet;
14
+ rightIcon?: Snippet;
14
15
  };
15
16
  export type InputButtonEventProperties = {
16
17
  inputEventProperties?: InputEventProperties;
@@ -172,7 +172,9 @@
172
172
  top: var(--toast-top, 10px);
173
173
  left: var(--toast-left, 0);
174
174
  right: var(--toast-right, 0);
175
- background-color: var(--default-background-color, #87ceeb);
175
+ background-color: var(--toast-background-color, #87ceeb);
176
+ opacity: var(--toast-opacity, 1);
177
+ box-sizing: var(--toast-box-sizing);
176
178
  }
177
179
 
178
180
  .no-page-overlap {
@@ -180,14 +182,17 @@
180
182
  }
181
183
 
182
184
  .toast-icon-wrapper {
185
+ display: flex;
183
186
  width: var(--toast-icon-wrapper-width, 20px);
184
187
  height: var(--toast-icon-wrapper-height, 20px);
185
188
  margin: var(--toast-icon-margin, 0px 6px 0px 0px);
186
189
  padding: var(--toast-icon-wrapper-padding, 1px);
190
+ align-items: center;
187
191
  }
188
192
 
189
193
  .toast-icon {
190
194
  height: var(--toast-icon-height, 100%);
195
+ filter: var(--toast-icon-filter);
191
196
  border-radius: var(--toast-icon-border-radius, 50%);
192
197
  }
193
198
 
@@ -219,25 +224,25 @@
219
224
 
220
225
  .success {
221
226
  color: var(--toast-success-text, #fff);
222
- background-color: var(--toast-background-color, #24aa5a);
227
+ background-color: var(--toast-success-background-color, var(--toast-background-color, #24aa5a));
223
228
  --toast-border: var(--toast-success-border);
224
229
  }
225
230
 
226
231
  .info {
227
232
  color: var(--toast-info-text, #fff);
228
- background-color: var(--toast-background-color, #87ceeb);
233
+ background-color: var(--toast-info-background-color, var(--toast-background-color, #87ceeb));
229
234
  --toast-border: var(--toast-info-border);
230
235
  }
231
236
 
232
237
  .warn {
233
238
  color: var(--toast-warn-text, #fff);
234
- background-color: var(--toast-background-color, #f3a42d);
239
+ background-color: var(--toast-warn-background-color, var(--toast-background-color, #f3a42d));
235
240
  --toast-border: var(--toast-warn-border);
236
241
  }
237
242
 
238
243
  .error {
239
244
  color: var(--toast-error-text, #fff);
240
- background-color: var(--toast-background-color, #f04438);
245
+ background-color: var(--toast-error-background-color, var(--toast-background-color, #f04438));
241
246
  --toast-border: var(--toast-error-border);
242
247
  }
243
248
  </style>
package/dist/index.d.ts CHANGED
@@ -23,6 +23,7 @@ export { default as Step } from './Stepper/Step.svelte';
23
23
  export { default as Toast } from './Toast/Toast.svelte';
24
24
  export { default as GridItem } from './GridItem/GridItem.svelte';
25
25
  export { default as IconStack } from './IconStack/IconStack.svelte';
26
+ export { default as Img } from './Img/Img.svelte';
26
27
  export type * from './Button/properties';
27
28
  export type * from './Modal/properties';
28
29
  export type * from './Input/properties';
@@ -41,4 +42,5 @@ export type * from './Table/properties';
41
42
  export type * from './Stepper/properties';
42
43
  export type * from './Toast/properties';
43
44
  export type * from './IconStack/properties';
45
+ export type * from './Img/properties';
44
46
  export { validateInput } from './utils';
package/dist/index.js CHANGED
@@ -23,4 +23,5 @@ export { default as Step } from './Stepper/Step.svelte';
23
23
  export { default as Toast } from './Toast/Toast.svelte';
24
24
  export { default as GridItem } from './GridItem/GridItem.svelte';
25
25
  export { default as IconStack } from './IconStack/IconStack.svelte';
26
+ export { default as Img } from './Img/Img.svelte';
26
27
  export { validateInput } from './utils';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/svelte-ui-components",
3
- "version": "2.2.4",
3
+ "version": "2.8.0",
4
4
  "scripts": {
5
5
  "dev": "vite dev --host",
6
6
  "build": "vite build && npm run package",