@juspay/svelte-ui-components 1.34.1 → 1.34.2

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.
Files changed (89) hide show
  1. package/dist/Accordion/Accordion.svelte +17 -30
  2. package/dist/Accordion/Accordion.svelte.d.ts +6 -20
  3. package/dist/Animations/ModalAnimation.svelte +44 -30
  4. package/dist/Animations/ModalAnimation.svelte.d.ts +9 -21
  5. package/dist/Animations/OverlayAnimation.svelte +9 -2
  6. package/dist/Animations/OverlayAnimation.svelte.d.ts +6 -28
  7. package/dist/Badge/Badge.svelte +9 -8
  8. package/dist/Badge/Badge.svelte.d.ts +3 -18
  9. package/dist/Banner/Banner.svelte +20 -19
  10. package/dist/Banner/Banner.svelte.d.ts +3 -23
  11. package/dist/Banner/properties.d.ts +6 -2
  12. package/dist/BrandLoader/BrandLoader.svelte +11 -12
  13. package/dist/BrandLoader/BrandLoader.svelte.d.ts +3 -19
  14. package/dist/BrandLoader/properties.d.ts +1 -4
  15. package/dist/BrandLoader/properties.js +1 -7
  16. package/dist/Button/Button.svelte +38 -27
  17. package/dist/Button/Button.svelte.d.ts +4 -23
  18. package/dist/Button/properties.d.ts +9 -5
  19. package/dist/Button/properties.js +1 -7
  20. package/dist/Carousel/Carousel.svelte +132 -108
  21. package/dist/Carousel/Carousel.svelte.d.ts +3 -20
  22. package/dist/Carousel/properties.d.ts +6 -12
  23. package/dist/Carousel/properties.js +1 -7
  24. package/dist/CheckListItem/CheckListItem.svelte +18 -12
  25. package/dist/CheckListItem/CheckListItem.svelte.d.ts +4 -23
  26. package/dist/CheckListItem/properties.d.ts +7 -0
  27. package/dist/CheckListItem/properties.js +1 -0
  28. package/dist/GridItem/GridItem.svelte +17 -11
  29. package/dist/GridItem/GridItem.svelte.d.ts +4 -24
  30. package/dist/GridItem/properties.d.ts +8 -0
  31. package/dist/GridItem/properties.js +1 -0
  32. package/dist/Icon/Icon.svelte +8 -6
  33. package/dist/Icon/Icon.svelte.d.ts +3 -21
  34. package/dist/Icon/properties.d.ts +3 -2
  35. package/dist/Icon/properties.js +1 -4
  36. package/dist/IconStack/IconStack.svelte +5 -3
  37. package/dist/IconStack/IconStack.svelte.d.ts +4 -19
  38. package/dist/IconStack/properties.d.ts +4 -1
  39. package/dist/Img/Img.svelte +13 -9
  40. package/dist/Img/Img.svelte.d.ts +4 -20
  41. package/dist/Img/properties.d.ts +2 -2
  42. package/dist/Input/Input.svelte +172 -139
  43. package/dist/Input/Input.svelte.d.ts +6 -32
  44. package/dist/Input/properties.d.ts +23 -22
  45. package/dist/Input/properties.js +1 -23
  46. package/dist/InputButton/InputButton.svelte +76 -78
  47. package/dist/InputButton/InputButton.svelte.d.ts +6 -35
  48. package/dist/InputButton/properties.d.ts +6 -4
  49. package/dist/InputButton/properties.js +1 -18
  50. package/dist/ListItem/ListItem.svelte +87 -64
  51. package/dist/ListItem/ListItem.svelte.d.ts +4 -35
  52. package/dist/ListItem/properties.d.ts +21 -7
  53. package/dist/ListItem/properties.js +1 -8
  54. package/dist/Loader/Loader.svelte +1 -4
  55. package/dist/Loader/Loader.svelte.d.ts +24 -15
  56. package/dist/Modal/Modal.svelte +117 -95
  57. package/dist/Modal/Modal.svelte.d.ts +3 -29
  58. package/dist/Modal/properties.d.ts +21 -13
  59. package/dist/Modal/properties.js +1 -14
  60. package/dist/Select/Select.svelte +170 -142
  61. package/dist/Select/Select.svelte.d.ts +3 -26
  62. package/dist/Select/properties.d.ts +19 -10
  63. package/dist/Status/Status.svelte +15 -15
  64. package/dist/Status/Status.svelte.d.ts +3 -21
  65. package/dist/Status/properties.d.ts +2 -2
  66. package/dist/Status/properties.js +1 -6
  67. package/dist/Stepper/Step.svelte +13 -13
  68. package/dist/Stepper/Step.svelte.d.ts +4 -23
  69. package/dist/Stepper/Stepper.svelte +10 -7
  70. package/dist/Stepper/Stepper.svelte.d.ts +3 -20
  71. package/dist/Stepper/properties.d.ts +12 -0
  72. package/dist/Table/Table.svelte +73 -47
  73. package/dist/Table/Table.svelte.d.ts +3 -20
  74. package/dist/Table/properties.d.ts +5 -5
  75. package/dist/Toast/Toast.svelte +144 -76
  76. package/dist/Toast/Toast.svelte.d.ts +24 -23
  77. package/dist/Toast/properties.d.ts +10 -11
  78. package/dist/Toast/properties.js +1 -4
  79. package/dist/Toggle/Toggle.svelte +12 -11
  80. package/dist/Toggle/Toggle.svelte.d.ts +4 -21
  81. package/dist/Toggle/properties.d.ts +5 -0
  82. package/dist/Toggle/properties.js +1 -0
  83. package/dist/Toolbar/Toolbar.svelte +27 -20
  84. package/dist/Toolbar/Toolbar.svelte.d.ts +3 -26
  85. package/dist/Toolbar/properties.d.ts +10 -4
  86. package/dist/Toolbar/properties.js +1 -5
  87. package/dist/index.d.ts +0 -11
  88. package/dist/index.js +0 -11
  89. package/package.json +29 -29
@@ -1,20 +1,4 @@
1
- import { SvelteComponent } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- src: string;
5
- alt: string;
6
- fallback?: string | null;
7
- };
8
- events: {
9
- [evt: string]: CustomEvent<any>;
10
- };
11
- slots: {};
12
- exports?: {} | undefined;
13
- bindings?: string | undefined;
14
- };
15
- export type ImgProps = typeof __propDef.props;
16
- export type ImgEvents = typeof __propDef.events;
17
- export type ImgSlots = typeof __propDef.slots;
18
- export default class Img extends SvelteComponent<ImgProps, ImgEvents, ImgSlots> {
19
- }
20
- export {};
1
+ import type { ImgProperties } from './properties';
2
+ declare const Img: import("svelte").Component<ImgProperties, {}, "">;
3
+ type Img = ReturnType<typeof Img>;
4
+ export default Img;
@@ -1,5 +1,5 @@
1
- export type ImgProps = {
1
+ export type ImgProperties = {
2
2
  src: string;
3
3
  alt: string;
4
- fallback: string | null;
4
+ fallback?: string | null;
5
5
  };
@@ -1,171 +1,203 @@
1
- <script>import { validateInput } from "../utils";
2
- import { createEventDispatcher, onMount } from "svelte";
3
- import { defaultInputProperties } from "./properties";
4
- const dispatch = createEventDispatcher();
5
- export let properties = defaultInputProperties;
6
- let inputElement;
7
- $:
8
- state = getValidationState(properties);
9
- function getValidationState(prop) {
10
- const valueValidation = validateInput(
11
- prop.value,
12
- prop.dataType,
13
- prop.validationPattern,
14
- prop.inProgressPattern,
15
- prop.validators
16
- );
17
- if (valueValidation === "InProgress" && prop.value.length > 0 && inputElement && inputElement !== document.activeElement) {
18
- return "Invalid";
19
- } else {
20
- return valueValidation;
21
- }
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);
1
+ <script lang="ts">
2
+ import { validateInput } from '../utils';
3
+ import type { InputProperties } from './properties';
4
+ import type { ValidationState } from '../types';
5
+
6
+ let {
7
+ value = $bindable(''),
8
+ placeholder = '',
9
+ dataType = 'text',
10
+ label = '',
11
+ onErrorMessage = '',
12
+ infoMessage = '',
13
+ validators = [],
14
+ disable = false,
15
+ validationPattern = null,
16
+ inProgressPattern = null,
17
+ addFocusColor = false,
18
+ maxLength = 1000,
19
+ minLength = 0,
20
+ actionInput = false,
21
+ useTextArea = false,
22
+ autoComplete = 'on',
23
+ name = '',
24
+ testId = '',
25
+ textTransformers = [],
26
+ onFocusout = () => {},
27
+ onInput = () => {},
28
+ onPaste = () => {},
29
+ onStateChange = () => {},
30
+ onClick = () => {}
31
+ }: InputProperties = $props();
32
+
33
+ export function focus() {
34
+ try {
35
+ inputElement?.focus();
36
+ inputElement?.scrollIntoView({ behavior: 'smooth', block: 'center' });
37
+ } catch (error) {
38
+ console.error('Error focusing or scrolling inputElement:', error);
39
+ }
29
40
  }
30
- }
31
- $:
32
- showErrorMessage = state === "Invalid";
33
- function onInput(event) {
34
- let currentValue = inputElement.value;
35
- if (properties.dataType === "tel" && currentValue.length > 0) {
36
- currentValue = properties.textTransformers.reduce((prevValue, currIndexFunction) => {
37
- let newValue = currIndexFunction(prevValue);
38
- return newValue;
39
- }, currentValue);
40
- currentValue = currentValue.replace(/\D+|\D/gm, "");
41
- const numberLength = currentValue.length;
42
- if (numberLength === 0) {
43
- inputElement.value = properties.value;
44
- return;
41
+
42
+ let inputElement: HTMLInputElement | HTMLTextAreaElement | null = $state(null);
43
+
44
+ let validationState = $derived.by(() => {
45
+ const valueValidation: ValidationState = validateInput(
46
+ value,
47
+ dataType,
48
+ validationPattern,
49
+ inProgressPattern,
50
+ validators
51
+ );
52
+ if (
53
+ valueValidation === 'InProgress' &&
54
+ value.length > 0 &&
55
+ inputElement &&
56
+ inputElement !== document.activeElement
57
+ ) {
58
+ return 'Invalid';
45
59
  }
46
- if (numberLength > properties.maxLength) {
47
- const existingInput = properties.value;
48
- if (existingInput.length == properties.maxLength) {
49
- inputElement.value = properties.value;
50
- return;
51
- }
52
- currentValue = currentValue.substring(numberLength - properties.maxLength);
60
+ return valueValidation;
61
+ });
62
+
63
+ let showErrorMessage = $derived(validationState === 'Invalid');
64
+
65
+ function handleOnInput(event: Event) {
66
+ if (inputElement === null) {
67
+ return;
53
68
  }
54
- inputElement.value = currentValue;
55
- }
56
- properties.value = currentValue;
57
- properties = properties;
58
- dispatch("valueChange", { value: currentValue });
59
- dispatch("input", event);
60
- }
61
- function onPaste(event) {
62
- if (event.clipboardData) {
63
- if (properties.dataType === "tel") {
64
- let unfilteredNumber = event.clipboardData.getData("text");
65
- unfilteredNumber = properties.textTransformers.reduce((prevValue, currIndexFunction) => {
69
+
70
+ let currentValue = inputElement.value;
71
+ if (dataType === 'tel' && currentValue.length > 0) {
72
+ currentValue = textTransformers.reduce((prevValue, currIndexFunction) => {
66
73
  let newValue = currIndexFunction(prevValue);
67
74
  return newValue;
68
- }, unfilteredNumber);
69
- const filteredNumber = unfilteredNumber.replace(/\D+|\D/gm, "");
70
- const filteredNumberLength = filteredNumber.length;
71
- if (filteredNumber.length === 0) {
72
- properties = properties;
73
- event.preventDefault();
75
+ }, currentValue);
76
+ currentValue = currentValue.replace(/\D+|\D/gm, '');
77
+ const numberLength = currentValue.length;
78
+ if (numberLength === 0) {
79
+ inputElement.value = value;
80
+ return;
74
81
  }
75
- if (filteredNumber.length > properties.maxLength) {
76
- const finalValue = filteredNumber.substring(filteredNumberLength - properties.maxLength);
77
- properties.value = finalValue;
78
- properties = properties;
79
- dispatch("paste", event);
80
- event.preventDefault();
82
+ if (numberLength > maxLength) {
83
+ const existingInput = value;
84
+ if (existingInput.length == maxLength) {
85
+ inputElement.value = value;
86
+ return;
87
+ }
88
+ currentValue = currentValue.substring(numberLength - maxLength);
81
89
  }
90
+ inputElement.value = currentValue;
82
91
  }
92
+ value = inputElement.value;
93
+ onInput(inputElement.value, event);
83
94
  }
84
- }
85
- function onFocusOut(event) {
86
- if (state === "InProgress" && properties.value.length > 0) {
87
- state = "Invalid";
88
- }
89
- dispatch("focusout", event);
90
- }
91
- function onClick(event) {
92
- dispatch("click", event);
93
- }
94
- onMount(() => {
95
- if (properties.focus) {
96
- inputElement.focus();
95
+
96
+ /**
97
+ *
98
+ * @param event
99
+ * ENABLED ONLY FOR 'dataType = tel'
100
+ */
101
+ function handleOnPaste(event: ClipboardEvent) {
102
+ if (inputElement === null) {
103
+ return;
104
+ }
105
+
106
+ if (event.clipboardData) {
107
+ if (dataType === 'tel') {
108
+ let unfilteredNumber = event.clipboardData.getData('text');
109
+ unfilteredNumber = textTransformers.reduce((prevValue, currIndexFunction) => {
110
+ let newValue = currIndexFunction(prevValue);
111
+ return newValue;
112
+ }, unfilteredNumber);
113
+ /**
114
+ * removes everything except numbers
115
+ */
116
+ const filteredNumber = unfilteredNumber.replace(/\D+|\D/gm, '');
117
+ const filteredNumberLength = filteredNumber.length;
118
+ /**
119
+ * pasted text is non numeric
120
+ */
121
+ if (filteredNumber.length === 0) {
122
+ event.preventDefault();
123
+ }
124
+ /**
125
+ * user pasted 10+ digit number , overrides all cases
126
+ */
127
+ if (filteredNumber.length > maxLength) {
128
+ /**
129
+ * choose last max length number of digits if length is bigger than max length passed in props
130
+ */
131
+ const finalValue = filteredNumber.substring(filteredNumberLength - maxLength);
132
+ // Adding reactivity
133
+ value = finalValue;
134
+ onPaste(event);
135
+ event.preventDefault(); // prevent bubble and let finalValue be entered
136
+ }
137
+ /**
138
+ * if numeric pasted text has length less than max length, bubble to onInput.
139
+ */
140
+ }
141
+ }
97
142
  }
98
- dispatch("stateChange", { state });
99
- });
100
- $: {
101
- dispatch("stateChange", { state });
102
- }
143
+
144
+ $effect(() => {
145
+ onStateChange(validationState);
146
+ });
103
147
  </script>
104
148
 
105
149
  <div class="input-container">
106
- {#if properties.label && properties.label !== '' && !properties.actionInput}
107
- <label class="label" for={properties.name}>
108
- {properties.label}
150
+ {#if typeof label === 'string' && label !== '' && !actionInput}
151
+ <label class="label" for={name}>
152
+ {label}
109
153
  </label>
110
154
  {/if}
111
155
 
112
- {#if properties.useTextArea}
156
+ {#if useTextArea}
157
+ <!-- svelte-ignore element_invalid_self_closing_tag -->
113
158
  <textarea
114
- value={properties.value}
115
- placeholder={properties.placeholder}
116
- autocomplete={properties.autoComplete}
117
- name={properties.name}
118
- on:keydown
119
- on:keyup
120
- on:keypress
121
- on:focus
122
- on:focusout={onFocusOut}
123
- on:input={onInput}
124
- on:paste={onPaste}
125
- on:click={onClick}
126
- class="
127
- {properties.actionInput ? 'action-input' : ''}
128
- "
129
- style="--focus-border: {properties.addFocusColor ? 1 : 0}px;"
130
- disabled={properties.disable}
159
+ {value}
160
+ {placeholder}
161
+ autocomplete={autoComplete}
162
+ {name}
163
+ onfocusout={onFocusout}
164
+ oninput={handleOnInput}
165
+ onpaste={handleOnPaste}
166
+ onclick={onClick}
167
+ class:action-input={actionInput}
168
+ style="--focus-border: {addFocusColor ? 1 : 0}px;"
169
+ disabled={disable}
131
170
  bind:this={inputElement}
132
- maxlength={properties.dataType === 'tel' ? undefined : properties.maxLength}
133
- minlength={properties.minLength}
171
+ maxlength={dataType === 'tel' ? undefined : maxLength}
172
+ minlength={minLength}
134
173
  />
135
174
  {:else}
136
175
  <input
137
- type={properties.dataType}
138
- value={properties.value}
139
- placeholder={properties.placeholder}
140
- autocomplete={properties.autoComplete}
141
- name={properties.name}
142
- on:keydown
143
- on:keyup
144
- on:keypress
145
- on:focus
146
- on:focusout={onFocusOut}
147
- on:input={onInput}
148
- on:paste={onPaste}
149
- on:click={onClick}
150
- data-pw={properties.testId}
151
- class="
152
- {properties.actionInput ? 'action-input' : ''}
153
- "
154
- disabled={properties.disable}
176
+ type={dataType}
177
+ {value}
178
+ {placeholder}
179
+ autocomplete={autoComplete}
180
+ {name}
181
+ onfocusout={onFocusout}
182
+ oninput={handleOnInput}
183
+ onpaste={onPaste}
184
+ data-pw={testId}
185
+ class:action-input={actionInput}
186
+ disabled={disable}
155
187
  bind:this={inputElement}
156
- maxlength={properties.dataType === 'tel' ? undefined : properties.maxLength}
157
- minlength={properties.minLength}
188
+ maxlength={dataType === 'tel' ? undefined : maxLength}
189
+ minlength={minLength}
158
190
  />
159
191
  {/if}
160
192
 
161
- {#if properties.message.onError !== '' && showErrorMessage && !properties.actionInput}
193
+ {#if onErrorMessage !== '' && showErrorMessage && !actionInput}
162
194
  <div class="error-message">
163
- {properties.message.onError}
195
+ {onErrorMessage}
164
196
  </div>
165
197
  {/if}
166
- {#if properties.message.info !== '' && !properties.actionInput}
198
+ {#if infoMessage !== '' && !actionInput}
167
199
  <div class="info-message">
168
- {properties.message.info}
200
+ {infoMessage}
169
201
  </div>
170
202
  {/if}
171
203
  </div>
@@ -184,6 +216,7 @@ $: {
184
216
  font-weight: var(--input-font-weight, 500);
185
217
  width: var(--input-width, fit-content);
186
218
  margin: var(--input-margin, 0px 0px 12px 0px);
219
+ appearance: none !important;
187
220
  -webkit-appearance: none !important; /* For Safari MWeb */
188
221
  box-shadow: var(--input-box-shadow, 0px 1px 8px #2f537733);
189
222
  border: var(--input-border, none);
@@ -1,32 +1,6 @@
1
- import { SvelteComponent } from "svelte";
2
- import { type InputProperties } from './properties';
3
- declare const __propDef: {
4
- props: {
5
- properties?: InputProperties;
6
- focus?: () => void;
7
- };
8
- events: {
9
- keydown: KeyboardEvent;
10
- keyup: KeyboardEvent;
11
- keypress: KeyboardEvent;
12
- focus: FocusEvent;
13
- valueChange: CustomEvent<any>;
14
- input: CustomEvent<any>;
15
- paste: CustomEvent<any>;
16
- focusout: CustomEvent<any>;
17
- click: CustomEvent<any>;
18
- stateChange: CustomEvent<any>;
19
- } & {
20
- [evt: string]: CustomEvent<any>;
21
- };
22
- slots: {};
23
- exports?: {} | undefined;
24
- bindings?: string | undefined;
25
- };
26
- export type InputProps = typeof __propDef.props;
27
- export type InputEvents = typeof __propDef.events;
28
- export type InputSlots = typeof __propDef.slots;
29
- export default class Input extends SvelteComponent<InputProps, InputEvents, InputSlots> {
30
- get focus(): () => void;
31
- }
32
- export {};
1
+ import type { InputProperties } from './properties';
2
+ declare const Input: import("svelte").Component<InputProperties, {
3
+ focus: () => void;
4
+ }, "value">;
5
+ type Input = ReturnType<typeof Input>;
6
+ export default Input;
@@ -1,26 +1,27 @@
1
- import type { AutoCompleteType, CustomValidator, InputDataType, TextTransformer } from '../types';
1
+ import type { AutoCompleteType, CustomValidator, InputDataType, TextTransformer, ValidationState } from '../types';
2
2
  export type InputProperties = {
3
3
  value: string;
4
- placeholder: string;
5
- dataType: InputDataType;
6
- label: string | null;
7
- message: {
8
- onError: string;
9
- info: string;
10
- };
11
- validators: CustomValidator[];
12
- focus: boolean;
13
- disable: boolean;
14
- validationPattern: RegExp | null;
15
- inProgressPattern: RegExp | null;
16
- addFocusColor: boolean;
17
- maxLength: number;
18
- minLength: number;
19
- actionInput: boolean;
20
- useTextArea: boolean;
21
- autoComplete: AutoCompleteType;
22
- name: string;
23
- textTransformers: TextTransformer[];
4
+ placeholder?: string | null;
5
+ dataType?: InputDataType;
6
+ label?: string | null;
7
+ onErrorMessage?: string | null;
8
+ infoMessage?: string | null;
9
+ validators?: CustomValidator[];
10
+ disable?: boolean;
11
+ validationPattern?: RegExp | null;
12
+ inProgressPattern?: RegExp | null;
13
+ addFocusColor?: boolean;
14
+ maxLength?: number;
15
+ minLength?: number;
16
+ actionInput?: boolean;
17
+ useTextArea?: boolean;
18
+ autoComplete?: AutoCompleteType;
19
+ name?: string;
20
+ textTransformers?: TextTransformer[];
24
21
  testId?: string;
22
+ onInput?: (value: string, event: Event) => void;
23
+ onFocusout?: (event: FocusEvent) => void;
24
+ onPaste?: (event: ClipboardEvent) => void;
25
+ onClick?: (event: MouseEvent) => void;
26
+ onStateChange?: (state: ValidationState) => void;
25
27
  };
26
- export declare const defaultInputProperties: InputProperties;
@@ -1,23 +1 @@
1
- export const defaultInputProperties = {
2
- value: '',
3
- placeholder: '',
4
- dataType: 'text',
5
- label: '',
6
- message: {
7
- onError: 'error',
8
- info: ''
9
- },
10
- validators: [],
11
- focus: true,
12
- disable: false,
13
- validationPattern: null,
14
- inProgressPattern: null,
15
- addFocusColor: false,
16
- maxLength: 1000,
17
- minLength: 0,
18
- actionInput: false,
19
- useTextArea: false,
20
- autoComplete: 'on',
21
- name: '',
22
- textTransformers: []
23
- };
1
+ export {};