@juspay/svelte-ui-components 1.10.0 → 1.12.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.
@@ -27,13 +27,15 @@ function handleButtonClick() {
27
27
  disabled={!(properties.enable && !properties.showLoader)}
28
28
  type={properties.type}
29
29
  >
30
- {#if properties.showLoader && properties.loaderType === 'Circular'}
31
- <div class="button-loader"><Loader /></div>
32
- {/if}
33
- {#if $$slots.icon}
30
+ {#if properties.showLoader && properties.loaderType === 'Circular'}
31
+ <div class="button-loader"><Loader /></div>
32
+ {/if}
33
+ {#if $$slots.icon}
34
34
  <div class="button-icon"><slot name="icon" /></div>
35
35
  {/if}
36
- <div class="button-text">{properties.text}</div>
36
+ {#if properties.text !== null && properties.text.length > 0}
37
+ <div class="button-text">{properties.text}</div>
38
+ {/if}
37
39
  </button>
38
40
  </div>
39
41
 
@@ -61,7 +63,7 @@ function handleButtonClick() {
61
63
  display: flex;
62
64
  justify-content: var(--button-justify-content, center);
63
65
  align-items: center;
64
- flex-direction: var(--button-content-flex-direction, row);;
66
+ flex-direction: var(--button-content-flex-direction, row);
65
67
  gap: var(--button-content-gap, 16px);
66
68
  visibility: var(--button-visibility, visible);
67
69
  }
@@ -6,7 +6,7 @@ function handleCheckboxClick(e) {
6
6
  if (e.target instanceof HTMLInputElement && typeof e.target.checked === "boolean") {
7
7
  checked = e.target.checked;
8
8
  }
9
- dispatch("click");
9
+ dispatch("click", checked);
10
10
  }
11
11
  </script>
12
12
 
@@ -15,7 +15,7 @@ function handleCheckboxClick(e) {
15
15
  {#if $$slots.checkboxLabel}
16
16
  <slot name="checkboxLabel" />
17
17
  {:else}
18
- <span class="text">
18
+ <span class="text" class:checked={checked}>
19
19
  <!-- eslint-disable-next-line -->
20
20
  {@html text}
21
21
  </span>
@@ -35,6 +35,11 @@ function handleCheckboxClick(e) {
35
35
  color: var(--check-list-item-text-color);
36
36
  }
37
37
 
38
+ .text.checked {
39
+ color: var(--check-list-item-checked-text-color);
40
+ font-weight: var(--check-list-item-checked-font-weight);
41
+ }
42
+
38
43
  input.checkbox {
39
44
  accent-color: var(--checkbox-accent-color, #000);
40
45
  border: 5px solid red;
@@ -133,6 +133,7 @@ $: {
133
133
  on:focusout={onFocusOut}
134
134
  on:input={onInput}
135
135
  on:paste={onPaste}
136
+ data-pw={properties.dataPw}
136
137
  class="
137
138
  {properties.actionInput ? 'action-input' : ''}
138
139
  "
@@ -21,5 +21,6 @@ export type InputProperties = {
21
21
  autoComplete: AutoCompleteType;
22
22
  name: string;
23
23
  textTransformers: TextTransformer[];
24
+ dataPw?: string;
24
25
  };
25
26
  export declare const defaultInputProperties: InputProperties;
@@ -178,7 +178,7 @@ function onFocusOut(event) {
178
178
  --button-content-gap: var(--left-button-content-gap);
179
179
  --button-content-flex-direction: var(--left-button-content-flex-direction, row);
180
180
  }
181
-
181
+
182
182
  .right-button {
183
183
  flex: var(--right-button-flex, 1);
184
184
  display: flex;
@@ -101,7 +101,9 @@ function handleTopSectionClick() {
101
101
  </div>
102
102
  {/if}
103
103
  {#if showRightContentLoader}
104
- <Loader />
104
+ <div class="right-content-loader">
105
+ <Loader />
106
+ </div>
105
107
  {/if}
106
108
  {#if properties.rightContentText && properties.rightContentText !== ''}
107
109
  <span class="right-content-text">{properties.rightContentText}</span>
@@ -221,6 +223,10 @@ function handleTopSectionClick() {
221
223
  display: var(--list-item-right-content-display, flex);
222
224
  }
223
225
 
226
+ .right-content-loader {
227
+ margin: var(--list-item-right-content-loader-margin);
228
+ }
229
+
224
230
  .bottom-section {
225
231
  flex-direction: row;
226
232
  margin-top: 0;
@@ -2,10 +2,12 @@
2
2
  import ModalAnimation from "../Animations/ModalAnimation.svelte";
3
3
  import OverlayAnimation from "../Animations/OverlayAnimation.svelte";
4
4
  import { defaultModalProperties } from "./properties";
5
+ import { createDebouncer } from "../utils";
5
6
  const dispatch = createEventDispatcher();
6
7
  let overlayDiv;
7
8
  let backPressed = false;
8
9
  export let properties = defaultModalProperties;
10
+ const debounce = createDebouncer(properties.debounceTime);
9
11
  function handlePopstate() {
10
12
  backPressed = true;
11
13
  dispatch("close");
@@ -18,7 +20,9 @@ function handleLeftImageClick() {
18
20
  }
19
21
  function handleOverlayClick(event) {
20
22
  if (event.target && event.target === overlayDiv) {
21
- dispatch("overlayClick");
23
+ debounce(() => {
24
+ dispatch("overlayClick");
25
+ });
22
26
  }
23
27
  }
24
28
  function handleKeyDown(event) {
@@ -130,9 +134,9 @@ onDestroy(() => {
130
134
  }
131
135
 
132
136
  .slot-content {
133
- display: flex;
134
- overflow-y: scroll;
135
- scrollbar-width: none;
137
+ display: var(--modal-display, flex);
138
+ overflow-y: var(--modal-overflow-y, scroll);
139
+ scrollbar-width: var(--modal-scrollbar-width, none);
136
140
  }
137
141
 
138
142
  .slot-content::-webkit-scrollbar {
@@ -13,5 +13,6 @@ export type ModalProperties = {
13
13
  rightImage: string | null;
14
14
  text: string | null;
15
15
  };
16
+ debounceTime: number;
16
17
  };
17
18
  export declare const defaultModalProperties: ModalProperties;
@@ -9,5 +9,6 @@ export const defaultModalProperties = {
9
9
  text: null
10
10
  },
11
11
  enableTransition: true,
12
- transitionType: 'ALL'
12
+ transitionType: 'ALL',
13
+ debounceTime: 700,
13
14
  };
@@ -111,7 +111,7 @@ onDestroy(() => {
111
111
  });
112
112
  </script>
113
113
 
114
- {#if properties.label !== null}
114
+ {#if properties.label !== null && properties.label !== ''}
115
115
  <label class="label-container" for={properties.label}>
116
116
  {properties.label}
117
117
  </label>
@@ -136,7 +136,7 @@ onDestroy(() => {
136
136
  {#if properties.selectMultipleItems && Array.isArray(properties.selectedItemLabel) && Array.isArray(properties.selectedItem)}
137
137
  {#if properties.selectedItem.length === 0}
138
138
  {properties.placeholder}
139
- {:else if properties.selectedItemLabel?.length === 0 || properties.showSelectedItemInDropdown && properties.showSelectedItem !== false}
139
+ {:else if properties.selectedItemLabel?.length === 0 || (properties.showSelectedItemInDropdown && properties.showSelectedItem !== false)}
140
140
  {properties.selectedItem.join(', ')}
141
141
  {:else if properties.showSelectedItem !== false}
142
142
  {properties.selectedItemLabel.join(', ')}
@@ -145,7 +145,7 @@ onDestroy(() => {
145
145
  {/if}
146
146
  {:else if properties.selectedItem === ''}
147
147
  {properties.placeholder}
148
- {:else if properties.selectedItemLabel === null || properties.selectedItemLabel === '' && properties.showSelectedItem !== false}
148
+ {:else if properties.selectedItemLabel === null || (properties.selectedItemLabel === '' && properties.showSelectedItem !== false)}
149
149
  {properties.selectedItem}
150
150
  {:else if properties.showSelectedItem !== false}
151
151
  {properties.selectedItemLabel}
@@ -231,8 +231,6 @@ onDestroy(() => {
231
231
  height: var(--dropdown-arrow-icon-height, 16px);
232
232
  width: var(--dropdown-arrow-icon-width, 16px);
233
233
  transition: transform 0.1s;
234
- position: absolute;
235
- right: 10px;
236
234
  }
237
235
 
238
236
  .active {
@@ -265,7 +263,8 @@ onDestroy(() => {
265
263
  white-space: var(--selected-item-white-space, nowrap);
266
264
  overflow: var(--selected-item-overflow, hidden);
267
265
  text-overflow: var(--selected-item-text-overflow, ellipsis);
268
- max-width: var(--selected-item-max-widhh, 100%);
266
+ max-width: var(--selected-item-max-width, 100%);
267
+ padding: var(--selected-item-padding, var(--item-padding, 8px 16px));
269
268
  }
270
269
 
271
270
  .selected-content {
@@ -334,21 +333,6 @@ onDestroy(() => {
334
333
  --button-width: var(--multipleSelect-btn-width, 100%);
335
334
  }
336
335
 
337
- .icon-container {
338
- width: var(--select-icon-container-width, fit-content);
339
- height: var(--select-icon-container-height, fit-content);
340
- border-radius: var(--select-icon-container-border-radius);
341
- opacity: var(--select-icon-container-opacity);
342
- background: var(--select-icon-container-background);
343
- display: flex;
344
- align-items: center;
345
- justify-content: center;
346
- margin: var(--select-icon-container-margin, 0px 8px 0px 0px);
347
- padding: var(--select-icon-container-padding);
348
- --image-height: var(--select-icon-height);
349
- --image-width: var(--select-icon-height);
350
- }
351
-
352
336
  .apply-btn-container {
353
337
  padding: var(--apply-btn-container-padding, 5px);
354
338
  border-top: var(--apply-btn-container-border-top, 1px solid #ddd);
@@ -79,6 +79,13 @@ onDestroy(() => {
79
79
 
80
80
  <div class="toast-message">
81
81
  {properties.message}
82
+ {#if properties.subtext}
83
+ <div class="toast-subtext">{properties.subtext}</div>
84
+ {/if}
85
+
86
+ {#if $$slots.bottomContent}
87
+ <slot name="bottomContent" />
88
+ {/if}
82
89
  </div>
83
90
 
84
91
  {#if properties.rightIcon}
@@ -93,14 +100,18 @@ onDestroy(() => {
93
100
  .toast {
94
101
  padding: var(--toast-padding, 10px);
95
102
  font-size: var(--toast-font-size, 14px);
103
+ font-family: var(--toast-font-family);
104
+ font-weight: var(--toast-font-weight);
96
105
  height: var(--toast-height, auto);
97
106
  border-radius: var(--toast-border-radius, 0px);
107
+ border: var(--toast-border, none);
108
+ border-style: var(--toast-border-style);
98
109
  width: var(--toast-width, auto);
99
110
  align-items: var(--toast-align-items, center);
100
111
  margin: var(--toast-margin, 0px 10px 10px 10px);
101
112
  justify-content: var(--toast-justify-content, space-between);
102
113
  z-index: var(--toast-z-index, 1000);
103
- display: var(--taost-dispay, flex);
114
+ display: var(--toast-display, flex);
104
115
  position: var(--toast-position, absolute);
105
116
  top: var(--toast-top, 10px);
106
117
  left: var(--toast-left, 0);
@@ -115,7 +126,7 @@ onDestroy(() => {
115
126
  .toast-icon-wrapper {
116
127
  width: var(--toast-icon-wrapper-width, 20px);
117
128
  height: var(--toast-icon-wrapper-height, 20px);
118
- margin: var(--toast-icon-margin, 0 6px 0 0);
129
+ margin: var(--toast-icon-margin, 0px 6px 0px 0px);
119
130
  padding: var(--toast-icon-wrapper-padding, 1px);
120
131
  }
121
132
 
@@ -126,8 +137,16 @@ onDestroy(() => {
126
137
 
127
138
  .toast-message {
128
139
  display: var(--toast-message-display, flex);
129
- flex: var(--taost-message-flex, 1);
140
+ flex: var(--toast-message-flex, 1);
130
141
  padding: var(--toast-message-padding, 1px);
142
+ flex-direction: column;
143
+ }
144
+
145
+ .toast-subtext {
146
+ color: var(--toast-subtext-color, #c7c7c7);
147
+ font-size: var(--toast-subtext-font-size, 10px);
148
+ font-weight: var(--toast-subtext-font-weight, 400);
149
+ margin: var(--toast-subtext-margin, 10px 0px 0px 0px);
131
150
  }
132
151
 
133
152
  .close-button {
@@ -135,7 +154,7 @@ onDestroy(() => {
135
154
  height: var(--toast-close-button-height, 20px);
136
155
  cursor: var(--toast-close-button-cursor, pointer);
137
156
  gap: var(--toast-close-button-gap, 6px);
138
- margin: var(--toast-close-button-margin, 0 0 0 10px);
157
+ margin: var(--toast-close-button-margin, 0px 0px 0px 10px);
139
158
  display: var(--toast-close-button-display, flex);
140
159
  align-items: var(--toast-close-button-align-items, center);
141
160
  justify-content: var(--toast-close-button-justify-content, center);
@@ -145,20 +164,24 @@ onDestroy(() => {
145
164
  .success {
146
165
  color: var(--toast-success-text, #fff);
147
166
  background-color: var(--toast-background-color, #24aa5a);
167
+ --toast-border: var(--toast-success-border);
148
168
  }
149
169
 
150
170
  .info {
151
171
  color: var(--toast-info-text, #fff);
152
172
  background-color: var(--toast-background-color, #87ceeb);
173
+ --toast-border: var(--toast-info-border);
153
174
  }
154
175
 
155
176
  .warn {
156
177
  color: var(--toast-warn-text, #fff);
157
178
  background-color: var(--toast-background-color, #f3a42d);
179
+ --toast-border: var(--toast-warn-border);
158
180
  }
159
181
 
160
182
  .error {
161
183
  color: var(--toast-error-text, #fff);
162
184
  background-color: var(--toast-background-color, #f04438);
185
+ --toast-border: var(--toast-error-border);
163
186
  }
164
187
  </style>
@@ -10,7 +10,9 @@ declare const __propDef: {
10
10
  } & {
11
11
  [evt: string]: CustomEvent<any>;
12
12
  };
13
- slots: {};
13
+ slots: {
14
+ bottomContent: {};
15
+ };
14
16
  };
15
17
  export type ToastProps = typeof __propDef.props;
16
18
  export type ToastEvents = typeof __propDef.events;
@@ -4,6 +4,7 @@ export type ToastProperties = {
4
4
  duration: number;
5
5
  leftIcon?: string;
6
6
  message: string;
7
+ subtext?: string;
7
8
  rightIcon?: string;
8
9
  type?: ToastType;
9
10
  direction?: ToastDirection;
package/dist/utils.d.ts CHANGED
@@ -9,3 +9,9 @@ import type { CustomValidator, InputDataType, ValidationState } from './types';
9
9
  * @returns ValidationState : InProgress | Valid | Invalid
10
10
  */
11
11
  export declare function validateInput(inputValue: string, dataType: InputDataType, validPattern: RegExp | null, inProgressPattern: RegExp | null, customValidators: CustomValidator[]): ValidationState;
12
+ /**
13
+ * @description Creates a debouncer function that delays invoking the provided callback until a specified delay period has elapsed since the last invocation.
14
+ * @param delay The delay period in milliseconds before invoking the callback.
15
+ * @returns A debouncer function that accepts a callback and delays its invocation based on the specified delay.
16
+ */
17
+ export declare function createDebouncer(delay: number): (callback: Function, ...args: any[]) => void;
package/dist/utils.js CHANGED
@@ -145,3 +145,18 @@ function validatePhoneNumber(phoneNumber) {
145
145
  }
146
146
  return phoneNumber.length === 10 ? 'Valid' : phoneNumber.length > 10 ? 'InProgress' : 'Invalid';
147
147
  }
148
+ /**
149
+ * @description Creates a debouncer function that delays invoking the provided callback until a specified delay period has elapsed since the last invocation.
150
+ * @param delay The delay period in milliseconds before invoking the callback.
151
+ * @returns A debouncer function that accepts a callback and delays its invocation based on the specified delay.
152
+ */
153
+ export function createDebouncer(delay) {
154
+ let lastCallTime = 0;
155
+ return function (callback, ...args) {
156
+ const now = Date.now();
157
+ if (now - lastCallTime > delay) {
158
+ lastCallTime = now;
159
+ callback(...args);
160
+ }
161
+ };
162
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/svelte-ui-components",
3
- "version": "1.10.0",
3
+ "version": "1.12.0",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run package",