@juspay/svelte-ui-components 1.11.0 → 1.13.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.
@@ -33,7 +33,9 @@ function handleButtonClick() {
33
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
 
@@ -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;
@@ -0,0 +1,113 @@
1
+ <script>import { createEventDispatcher } from "svelte";
2
+ export let icon = "";
3
+ export let text = "";
4
+ export let headerIcon = "";
5
+ export let showLoader = false;
6
+ const dispatch = createEventDispatcher();
7
+ function onClick() {
8
+ showLoader = !showLoader;
9
+ dispatch("onClick");
10
+ }
11
+ </script>
12
+
13
+ <div class="container" on:click={onClick} on:keydown role="button" tabindex="0">
14
+ <div class="grid-header">
15
+ <img src={headerIcon} alt="" class="grid-item-header-icon" />
16
+ </div>
17
+ <div class:grid-body-loader={showLoader}>
18
+ <div class="grid-item-body">
19
+ <img src={icon} alt="" class="grid-item-icon" />
20
+ </div>
21
+ </div>
22
+ <div class="grid-item-footer">{text}</div>
23
+ </div>
24
+
25
+ <style>
26
+ .container {
27
+ box-sizing: border-box;
28
+ height: var(--grid-item-height, fit-content);
29
+ width: var(--grid-item-width, fit-content);
30
+ display: flex;
31
+ flex-direction: column;
32
+ justify-content: center;
33
+ align-items: center;
34
+ position: relative;
35
+ cursor: pointer;
36
+ /** Remove button tap effect */
37
+ -webkit-tap-highlight-color: transparent;
38
+ }
39
+
40
+ .grid-header {
41
+ display: flex;
42
+ width: var(--grid-header-width, 100%);
43
+ justify-content: var(--grid-header-justify-content, end);
44
+ position: var(--grid-header-position, absolute);
45
+ top: var(--grid-header-top, 5px);
46
+ z-index: var(--grid-header-z-index, 100);
47
+ }
48
+
49
+ .grid-item-header-icon {
50
+ height: var(--grid-item-header-icon-height, 16px);
51
+ width: var(--grid-item-header-icon-width, auto);
52
+ object-fit: var(--grid-item-header-icon-object-fit, contain);
53
+ z-index: var(--grid-item-header-icon-z-index, 2);
54
+ }
55
+
56
+ .grid-item-body {
57
+ height: var(--grid-item-height, 64px);
58
+ width: var(--grid-item-width, 64px);
59
+ background-color: var(--grid-item-background-color, #faf9f9);
60
+ border: var(--grid-item-border, 1px solid #eaeaea);
61
+ border-radius: var(--grid-item-border-radius, 4px);
62
+ margin: var(--grid-item-margin, 8px 0 0 0);
63
+ display: flex;
64
+ justify-content: center;
65
+ align-items: center;
66
+ }
67
+
68
+ .grid-item-icon {
69
+ height: var(--grid-item-icon-height, 32px);
70
+ width: var(--grid-item-icon-width, auto);
71
+ object-fit: var(--grid-item-icon-object-fit, contain);
72
+ z-index: var(--grid-item-icon-z-index, 100);
73
+ }
74
+
75
+ .grid-item-footer {
76
+ margin: var(--grid-item-footer-margin, 8px 0 0 0);
77
+ font-size: var(--grid-item-font-size, 14px);
78
+ color: var(--grid-item-color, #333);
79
+ }
80
+
81
+ .grid-body-loader {
82
+ position: relative;
83
+ }
84
+
85
+ .grid-body-loader::before {
86
+ content: '';
87
+ box-sizing: border-box;
88
+ position: absolute;
89
+ inset: 0px;
90
+ margin: var(--grid-item-margin, 8px 0 0 0);
91
+ border-radius: var(--grid-item-border-radius, 4px);
92
+ border: var(--animation-version, 32px solid #cbcccf66);
93
+ animation: clipperAnimation var(--loader-animation-duration) infinite linear;
94
+ }
95
+
96
+ @keyframes clipperAnimation {
97
+ 0% {
98
+ clip-path: polygon(50% 50%, 0 0, 0 0, 0 0, 0 0, 0 0);
99
+ }
100
+ 25% {
101
+ clip-path: polygon(50% 50%, 0 0, 100% 0, 100% 0, 100% 0, 100% 0);
102
+ }
103
+ 50% {
104
+ clip-path: polygon(50% 50%, 0 0, 100% 0, 100% 100%, 100% 100%, 100% 100%);
105
+ }
106
+ 75% {
107
+ clip-path: polygon(50% 50%, 0 0, 100% 0, 100% 100%, 0 100%, 0 100%);
108
+ }
109
+ 100% {
110
+ clip-path: polygon(50% 50%, 0 0, 100% 0, 100% 100%, 0 100%, 0 0);
111
+ }
112
+ }
113
+ </style>
@@ -0,0 +1,22 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ icon?: string | undefined;
5
+ text?: string | undefined;
6
+ headerIcon?: string | undefined;
7
+ showLoader?: boolean | undefined;
8
+ };
9
+ events: {
10
+ keydown: KeyboardEvent;
11
+ onClick: CustomEvent<any>;
12
+ } & {
13
+ [evt: string]: CustomEvent<any>;
14
+ };
15
+ slots: {};
16
+ };
17
+ export type GridItemProps = typeof __propDef.props;
18
+ export type GridItemEvents = typeof __propDef.events;
19
+ export type GridItemSlots = typeof __propDef.slots;
20
+ export default class GridItem extends SvelteComponent<GridItemProps, GridItemEvents, GridItemSlots> {
21
+ }
22
+ export {};
@@ -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
  };
@@ -333,7 +333,6 @@ onDestroy(() => {
333
333
  --button-width: var(--multipleSelect-btn-width, 100%);
334
334
  }
335
335
 
336
-
337
336
  .apply-btn-container {
338
337
  padding: var(--apply-btn-container-padding, 5px);
339
338
  border-top: var(--apply-btn-container-border-top, 1px solid #ddd);
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,8 +1,8 @@
1
1
  {
2
2
  "name": "@juspay/svelte-ui-components",
3
- "version": "1.11.0",
3
+ "version": "1.13.0",
4
4
  "scripts": {
5
- "dev": "vite dev",
5
+ "dev": "vite dev --host",
6
6
  "build": "vite build && npm run package",
7
7
  "preview": "vite preview",
8
8
  "package": "svelte-kit sync && svelte-package && publint",