@juspay/svelte-ui-components 1.17.0 → 1.18.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.
@@ -66,6 +66,7 @@ function handleButtonClick() {
66
66
  flex-direction: var(--button-content-flex-direction, row);
67
67
  gap: var(--button-content-gap, 16px);
68
68
  visibility: var(--button-visibility, visible);
69
+ box-shadow: var(--button-box-shadow, none);
69
70
  }
70
71
 
71
72
  .button-loader {
@@ -3,6 +3,7 @@ import ModalAnimation from "../Animations/ModalAnimation.svelte";
3
3
  import OverlayAnimation from "../Animations/OverlayAnimation.svelte";
4
4
  import { defaultModalProperties } from "./properties";
5
5
  import { createDebouncer } from "../utils";
6
+ import Button from "../Button/Button.svelte";
6
7
  const dispatch = createEventDispatcher();
7
8
  let overlayDiv;
8
9
  let backPressed = false;
@@ -18,6 +19,12 @@ function handleRightImageClick() {
18
19
  function handleLeftImageClick() {
19
20
  dispatch("headerLeftImageClick");
20
21
  }
22
+ function handlePrimaryButtonClick() {
23
+ dispatch("primaryButtonClick");
24
+ }
25
+ function handleSecondaryButtonClick() {
26
+ dispatch("secondaryButtonClick");
27
+ }
21
28
  function handleOverlayClick(event) {
22
29
  if (event.target && event.target === overlayDiv) {
23
30
  debounce(() => {
@@ -93,6 +100,32 @@ onDestroy(() => {
93
100
  <div class="slot-content">
94
101
  <slot name="content" />
95
102
  </div>
103
+ {#if $$slots.footer}
104
+ <div class="footer-content">
105
+ <slot name="footer" />
106
+ </div>
107
+ {:else if properties.footer?.primaryButton || properties.footer?.secondaryButton}
108
+ <div class="footer-content">
109
+ <div class="footer-action-buttons">
110
+ {#if properties.footer.secondaryButton}
111
+ <div class="footer-secondary-button">
112
+ <Button
113
+ properties={properties.footer.secondaryButton}
114
+ on:click={handleSecondaryButtonClick}
115
+ />
116
+ </div>
117
+ {/if}
118
+ {#if properties.footer.primaryButton}
119
+ <div class="footer-primary-button">
120
+ <Button
121
+ properties={properties.footer.primaryButton}
122
+ on:click={handlePrimaryButtonClick}
123
+ />
124
+ </div>
125
+ {/if}
126
+ </div>
127
+ </div>
128
+ {/if}
96
129
  </div>
97
130
  </ModalAnimation>
98
131
  </div>
@@ -131,6 +164,7 @@ onDestroy(() => {
131
164
  display: flex;
132
165
  flex-direction: column;
133
166
  border-radius: var(--modal-border-radius, 0px);
167
+ overflow: var(--modal-content-overflow, auto);
134
168
  }
135
169
 
136
170
  .slot-content {
@@ -181,6 +215,75 @@ onDestroy(() => {
181
215
  background-color: var(--modal-header-background-color, #f6f7f9);
182
216
  padding: var(--modal-header-padding, 18px 20px);
183
217
  border-radius: var(--modal-header-border-radius, 0px);
218
+ border-bottom: var(--modal-header-border-bottom, none);
219
+ }
220
+
221
+ .footer-content {
222
+ display: flex;
223
+ background-color: var(--modal-footer-background-color, #f6f7f9);
224
+ padding: var(--modal-footer-padding, 18px 20px);
225
+ border-radius: var(--modal-footer-border-radius, 0px);
226
+ border-top: var(--modal-footer-border-top, none);
227
+ justify-content: var(--modal-footer-justify-content, none);
228
+ }
229
+
230
+ .footer-action-buttons {
231
+ display: flex;
232
+ gap: var(--modal-footer-gap, 0px);
233
+ width: var(--modal-footer-action-buttons-width, auto);
234
+ }
235
+
236
+ .footer-secondary-button {
237
+ --button-max-height: var(--modal-footer-secondary-button-max-height);
238
+ --button-max-width: var(--modal-footer-secondary-button-max-width);
239
+ --button-font-family: var(--modal-footer-secondary-button-font-family);
240
+ --button-font-weight: var(--modal-footer-secondary-button-font-weight, 500);
241
+ --button-font-size: var(--modal-footer-secondary-button-font-size, 14px);
242
+ --button-color: var(--modal-footer-secondary-button-color, #3a4550);
243
+ --button-text-color: var(--modal-footer-secondary-button-text-color, white);
244
+ --button-height: var(--modal-footer-secondary-button-height, fit-content);
245
+ --button-padding: var(--modal-footer-secondary-button-padding, 16px);
246
+ --button-margin: var(--modal-footer-secondary-button-margin);
247
+ --button-border-radius: var(--modal-footer-secondary-button-border-radius, 0px);
248
+ --button-width: var(--modal-footer-secondary-button-width, fit-content);
249
+ --cursor: var(--modal-footer-secondary-button-cursor, pointer);
250
+ --opacity: var(--modal-footer-secondary-button-opacity, 1);
251
+ --button-border: var(--modal-footer-secondary-button-border, none);
252
+ --button-justify-content: var(--modal-footer-secondary-button-justify-content, center);
253
+ --button-content-flex-direction: var(
254
+ --modal-footer-secondary-button-content-flex-direction,
255
+ row
256
+ );
257
+ --button-content-gap: var(--modal-footer-secondary-button-content-gap, 16px);
258
+ --button-visibility: var(--modal-footer-secondary-button-visibility, visible);
259
+ --button-box-shadow: var(--modal-footer-secondary-button-box-shadow, none);
260
+ order: var(--modal-secondary-button-order, none);
261
+ flex: var(--modal-footer-secondary-button-flex-value, none);
262
+ }
263
+
264
+ .footer-primary-button {
265
+ --button-max-height: var(--modal-footer-primary-button-max-height);
266
+ --button-max-width: var(--modal-footer-primary-button-max-width);
267
+ --button-font-family: var(--modal-footer-primary-button-font-family);
268
+ --button-font-weight: var(--modal-footer-primary-button-font-weight, 500);
269
+ --button-font-size: var(--modal-footer-primary-button-font-size, 14px);
270
+ --button-color: var(--modal-footer-primary-button-color, #3a4550);
271
+ --button-text-color: var(--modal-footer-primary-button-text-color, white);
272
+ --button-height: var(--modal-footer-primary-button-height, fit-content);
273
+ --button-padding: var(--modal-footer-primary-button-padding, 16px);
274
+ --button-margin: var(--modal-footer-primary-button-margin);
275
+ --button-border-radius: var(--modal-footer-primary-button-border-radius, 0px);
276
+ --button-width: var(--modal-footer-primary-button-width, fit-content);
277
+ --cursor: var(--modal-footer-primary-button-cursor, pointer);
278
+ --opacity: var(--modal-footer-primary-button-opacity, 1);
279
+ --button-border: var(--modal-footer-primary-button-border, none);
280
+ --button-justify-content: var(--modal-footer-primary-button-justify-content, center);
281
+ --button-content-flex-direction: var(--modal-footer-primary-button-content-flex-direction, row);
282
+ --button-content-gap: var(--modal-footer-primary-button-content-gap, 16px);
283
+ --button-visibility: var(--modal-footer-primary-button-visibility, visible);
284
+ --button-box-shadow: var(--modal-footer-primary-button-box-shadow, none);
285
+ order: var(--modal-primary-button-order, none);
286
+ flex: var(--modal-footer-primary-button-flex-value, none);
184
287
  }
185
288
 
186
289
  .header-text {
@@ -9,12 +9,15 @@ declare const __propDef: {
9
9
  close: CustomEvent<any>;
10
10
  headerRightImageClick: CustomEvent<any>;
11
11
  headerLeftImageClick: CustomEvent<any>;
12
+ primaryButtonClick: CustomEvent<any>;
13
+ secondaryButtonClick: CustomEvent<any>;
12
14
  overlayClick: CustomEvent<any>;
13
15
  } & {
14
16
  [evt: string]: CustomEvent<any>;
15
17
  };
16
18
  slots: {
17
19
  content: {};
20
+ footer: {};
18
21
  };
19
22
  };
20
23
  export type ModalProps = typeof __propDef.props;
@@ -1,3 +1,4 @@
1
+ import type { ButtonProperties } from '../Button/properties';
1
2
  import type { ModalTransition } from '../types';
2
3
  export type ModalSize = 'large' | 'medium' | 'small' | 'fit-content';
3
4
  export type ModalAlign = 'top' | 'center' | 'bottom';
@@ -13,6 +14,10 @@ export type ModalProperties = {
13
14
  rightImage: string | null;
14
15
  text: string | null;
15
16
  };
17
+ footer?: {
18
+ primaryButton?: ButtonProperties;
19
+ secondaryButton?: ButtonProperties;
20
+ };
16
21
  debounceTime: number;
17
22
  };
18
23
  export declare const defaultModalProperties: ModalProperties;
@@ -10,5 +10,5 @@ export const defaultModalProperties = {
10
10
  },
11
11
  enableTransition: true,
12
12
  transitionType: 'ALL',
13
- debounceTime: 700,
13
+ debounceTime: 700
14
14
  };
@@ -1,6 +1,7 @@
1
1
  <script>import { createEventDispatcher, onDestroy, onMount } from "svelte";
2
2
  import Img from "../Img/Img.svelte";
3
3
  import Button from "../Button/Button.svelte";
4
+ import CheckListItem from "../CheckListItem/CheckListItem.svelte";
4
5
  let selectedElementDiv = null;
5
6
  export let dropDownIconAlt = "";
6
7
  export let properties = {
@@ -12,7 +13,8 @@ export let properties = {
12
13
  showSelectedItemInDropdown: false,
13
14
  selectMultipleItems: false,
14
15
  leftIcon: null,
15
- showSelectedItem: true
16
+ showSelectedItem: true,
17
+ showSelectedItemCount: false
16
18
  };
17
19
  const dropDownIcon = properties.dropDownIcon ?? "https://sdk.breeze.in/gallery/icons/down-arrow.svg";
18
20
  let applyButtonProps;
@@ -31,13 +33,6 @@ const selectAllButtonProps = {
31
33
  loaderType: null,
32
34
  type: "submit"
33
35
  };
34
- const clearAllButtonProps = {
35
- text: "Clear All",
36
- enable: true,
37
- showLoader: false,
38
- loaderType: null,
39
- type: "submit"
40
- };
41
36
  let isSelectOpen = false;
42
37
  const dispatch = createEventDispatcher();
43
38
  $:
@@ -81,13 +76,14 @@ function toggleSelect() {
81
76
  isSelectOpen = !isSelectOpen;
82
77
  dispatch("dropdownClick");
83
78
  }
84
- function clearAllItems() {
85
- properties.selectedItem = [];
86
- properties.selectedItemLabel = [];
87
- }
88
79
  function selectAllItems() {
89
- properties.selectedItem = [...properties.allItems];
90
- properties.selectedItemLabel = [...properties.allItems];
80
+ if (properties.selectedItem.length === properties.allItems.length) {
81
+ properties.selectedItem = [];
82
+ properties.selectedItemLabel = [];
83
+ } else {
84
+ properties.selectedItem = [...properties.allItems];
85
+ properties.selectedItemLabel = [...properties.allItems];
86
+ }
91
87
  }
92
88
  function closeSelect(event) {
93
89
  const clickedElement = event.target;
@@ -96,7 +92,8 @@ function closeSelect(event) {
96
92
  const isApplyButtonClicked = clickedElement.classList.contains("apply-btn");
97
93
  const isClearAllButtonClicked = clickedElement.innerText === "Clear All";
98
94
  const isSelectAllButtonClicked = clickedElement.innerText === "Select All";
99
- if (!isItemClicked && !isApplyButtonClicked && !isClearAllButtonClicked && !isSelectAllButtonClicked) {
95
+ const isCheckListClicked = clickedElement.classList.contains("checkbox");
96
+ if (!isItemClicked && !isApplyButtonClicked && !isClearAllButtonClicked && !isSelectAllButtonClicked && !isCheckListClicked) {
100
97
  isSelectOpen = false;
101
98
  }
102
99
  }
@@ -154,6 +151,11 @@ onDestroy(() => {
154
151
  {/if}
155
152
  </div>
156
153
  <div class="filler" />
154
+ {#if properties.showSelectedItemCount && properties.selectMultipleItems && Array.isArray(properties.selectedItem)}
155
+ <div class="selected-item-count">
156
+ {properties.selectedItem.length}
157
+ </div>
158
+ {/if}
157
159
  {#if !properties.hideDropDownIcon}
158
160
  <img
159
161
  src={dropDownIcon}
@@ -167,9 +169,14 @@ onDestroy(() => {
167
169
  style="--non-selected-display:{isSelectOpen ? 'inline-block' : 'none'};"
168
170
  >
169
171
  {#if properties.selectMultipleItems && !properties.showSingleSelectButton}
170
- <div class="multipleSelect-btn">
172
+ <div class="select-all-btn">
173
+ <CheckListItem
174
+ checked={Array.isArray(properties.selectedItem) &&
175
+ properties.selectedItem.length === properties.allItems.length}
176
+ text=""
177
+ on:click={selectAllItems}
178
+ />
171
179
  <Button properties={selectAllButtonProps} on:click={selectAllItems} />
172
- <Button properties={clearAllButtonProps} on:click={clearAllItems} />
173
180
  </div>
174
181
  {/if}
175
182
  <div class="item-list">
@@ -183,6 +190,9 @@ onDestroy(() => {
183
190
  role="button"
184
191
  tabindex="0"
185
192
  >
193
+ {#if properties.selectMultipleItems}
194
+ <CheckListItem checked={isSelected(properties.selectedItem, item)} text="" />
195
+ {/if}
186
196
  {item}
187
197
  </div>
188
198
  {/each}
@@ -221,6 +231,13 @@ onDestroy(() => {
221
231
  --button-margin: var(--select-btn-margin, 1px);
222
232
  --button-border-radius: var(--select-btn-border-radius, 2px);
223
233
  --input-button-margin: var(--select-input-button-margin, 10px);
234
+ --check-list-item-margin: var(--select-check-list-item-margin, 0px);
235
+ --checkbox-margin: var(--select-checkbox-margin, 2px 8px 0px 0px);
236
+ --checkbox-height: var(--select-checkbox-height, 14px);
237
+ --checkbox-width: var(--select-checkbox-width, 14px);
238
+ --checkbox-accent-color: var(--select-checkbox-accent-color, #3a4550);
239
+ --check-list-item-checked-font-weight: var(--select-check-list-item-checked-font-weight, bold);
240
+ --check-list-item-width: var(--select-check-list-item-width, fit-content);
224
241
  }
225
242
 
226
243
  .select:hover {
@@ -243,6 +260,7 @@ onDestroy(() => {
243
260
  border-radius: var(--item-border-radius);
244
261
  cursor: pointer;
245
262
  position: relative;
263
+ display: flex;
246
264
  }
247
265
 
248
266
  .filler {
@@ -323,14 +341,17 @@ onDestroy(() => {
323
341
  display: var(--label-container-display, inline-block);
324
342
  }
325
343
 
326
- .multipleSelect-btn {
344
+ .select-all-btn {
327
345
  display: flex;
328
- width: var(--multipleSelect-btn-width, 99%);
329
- white-space: var(--multipleSelect-btn-white-space, nowrap);
330
- padding: var(--multipleSelect-btn-padding, 1px);
331
- --button-border: var(--multipleSelect-btn-border, 1px solid white);
332
- --button-font-size: var(--multipleSelect-btn-font-size, 12px);
333
- --button-width: var(--multipleSelect-btn-width, 100%);
346
+ width: var(--select-all-btn-width, 99%);
347
+ white-space: var(--select-all-btn-white-space, nowrap);
348
+ padding: var(--select-all-btn-padding, 10px 16px);
349
+ --button-font-size: var(--select-all-btn-font-size, 14px);
350
+ --button-width: var(--select-all-btn-width, 100%);
351
+ --button-color: var(--select-all-btn-color, #ffffff);
352
+ --button-text-color: var(--select-all-btn-text-color, #333);
353
+ --button-padding: var(--select-all-btn-inner-padding, 0px);
354
+ --button-justify-content: var(--select-all-btn-justify-content, flex-start);
334
355
  }
335
356
 
336
357
  .apply-btn-container {
@@ -360,4 +381,18 @@ onDestroy(() => {
360
381
  --image-height: var(--select-icon-height);
361
382
  --image-width: var(--select-icon-height);
362
383
  }
384
+
385
+ .selected-item-count {
386
+ margin: var(--selected-item-count-margin, 0px 6px);
387
+ height: var(--selected-item-count-height, 18px);
388
+ width: var(--selected-item-count-width, 18px);
389
+ min-width: var(--selected-item-count-min-width, 18px);
390
+ padding: var(--selected-item-count-padding, 4px);
391
+ display: var(--selected-item-count-display, flex);
392
+ justify-content: var(--selected-item-count-justify-content, center);
393
+ align-items: var(--selected-item-count-align-item, center);
394
+ background-color: var(--selected-item-count-bg-color, #3a4550);
395
+ color: var(--selected-item-count-text-color, #ffffff);
396
+ border-radius: var(--selected-item-count-border-radius, 4px);
397
+ }
363
398
  </style>
@@ -12,4 +12,5 @@ export type SelectProperties = {
12
12
  leftIcon: ImgProps | null;
13
13
  showSingleSelectButton?: boolean | null;
14
14
  showSelectedItem?: boolean;
15
+ showSelectedItemCount?: boolean;
15
16
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/svelte-ui-components",
3
- "version": "1.17.0",
3
+ "version": "1.18.0",
4
4
  "scripts": {
5
5
  "dev": "vite dev --host",
6
6
  "build": "vite build && npm run package",