@juspay/svelte-ui-components 1.0.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.
- package/README.md +115 -0
- package/dist/Accordion/Accordion.svelte +35 -0
- package/dist/Accordion/Accordion.svelte.d.ts +18 -0
- package/dist/Animations/ModalAnimation.svelte +28 -0
- package/dist/Animations/ModalAnimation.svelte.d.ts +20 -0
- package/dist/Animations/OverlayAnimation.svelte +7 -0
- package/dist/Animations/OverlayAnimation.svelte.d.ts +27 -0
- package/dist/Badge/Badge.svelte +45 -0
- package/dist/Badge/Badge.svelte.d.ts +17 -0
- package/dist/Badge/properties.d.ts +4 -0
- package/dist/Badge/properties.js +1 -0
- package/dist/Banner/Banner.svelte +61 -0
- package/dist/Banner/Banner.svelte.d.ts +20 -0
- package/dist/Banner/properties.d.ts +5 -0
- package/dist/Banner/properties.js +1 -0
- package/dist/BrandLoader/BrandLoader.svelte +125 -0
- package/dist/BrandLoader/BrandLoader.svelte.d.ts +18 -0
- package/dist/BrandLoader/properties.d.ts +8 -0
- package/dist/BrandLoader/properties.js +7 -0
- package/dist/Button/Button.svelte +87 -0
- package/dist/Button/Button.svelte.d.ts +21 -0
- package/dist/Button/properties.d.ts +9 -0
- package/dist/Button/properties.js +7 -0
- package/dist/Carousel/Carousel.svelte +219 -0
- package/dist/Carousel/Carousel.svelte.d.ts +19 -0
- package/dist/Carousel/properties.d.ts +18 -0
- package/dist/Carousel/properties.js +7 -0
- package/dist/CheckListItem/CheckListItem.svelte +40 -0
- package/dist/CheckListItem/CheckListItem.svelte.d.ts +19 -0
- package/dist/Icon/Icon.svelte +32 -0
- package/dist/Icon/Icon.svelte.d.ts +20 -0
- package/dist/Icon/properties.d.ts +5 -0
- package/dist/Icon/properties.js +4 -0
- package/dist/Input/Input.svelte +218 -0
- package/dist/Input/Input.svelte.d.ts +26 -0
- package/dist/Input/properties.d.ts +25 -0
- package/dist/Input/properties.js +23 -0
- package/dist/InputButton/InputButton.svelte +157 -0
- package/dist/InputButton/InputButton.svelte.d.ts +27 -0
- package/dist/InputButton/properties.d.ts +8 -0
- package/dist/InputButton/properties.js +17 -0
- package/dist/ListItem/ListItem.svelte +196 -0
- package/dist/ListItem/ListItem.svelte.d.ts +32 -0
- package/dist/ListItem/properties.d.ts +8 -0
- package/dist/ListItem/properties.js +7 -0
- package/dist/Loader/Loader.svelte +89 -0
- package/dist/Loader/Loader.svelte.d.ts +15 -0
- package/dist/Modal/Modal.svelte +200 -0
- package/dist/Modal/Modal.svelte.d.ts +25 -0
- package/dist/Modal/properties.d.ts +15 -0
- package/dist/Modal/properties.js +12 -0
- package/dist/Select/Select.svelte +271 -0
- package/dist/Select/Select.svelte.d.ts +21 -0
- package/dist/Select/properties.d.ts +9 -0
- package/dist/Select/properties.js +1 -0
- package/dist/Status/Status.svelte +64 -0
- package/dist/Status/Status.svelte.d.ts +20 -0
- package/dist/Status/properties.d.ts +8 -0
- package/dist/Status/properties.js +6 -0
- package/dist/Table/Table.svelte +147 -0
- package/dist/Table/Table.svelte.d.ts +19 -0
- package/dist/Table/properties.d.ts +8 -0
- package/dist/Table/properties.js +1 -0
- package/dist/Toggle/Toggle.svelte +86 -0
- package/dist/Toggle/Toggle.svelte.d.ts +17 -0
- package/dist/Toolbar/Toolbar.svelte +95 -0
- package/dist/Toolbar/Toolbar.svelte.d.ts +25 -0
- package/dist/Toolbar/properties.d.ts +6 -0
- package/dist/Toolbar/properties.js +5 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +30 -0
- package/dist/types.d.ts +19 -0
- package/dist/types.js +1 -0
- package/dist/utils.d.ts +11 -0
- package/dist/utils.js +147 -0
- package/package.json +162 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
<script>import { onMount } from "svelte";
|
|
2
|
+
export let properties = {
|
|
3
|
+
tableTitle: "",
|
|
4
|
+
tableHeaders: [],
|
|
5
|
+
tableData: [],
|
|
6
|
+
isTableScrollable: false,
|
|
7
|
+
isContentScrollable: false
|
|
8
|
+
};
|
|
9
|
+
let sortOrders = {};
|
|
10
|
+
let sortedTableData = [...properties.tableData];
|
|
11
|
+
function sortTableData(column) {
|
|
12
|
+
if (!sortOrders[column]) {
|
|
13
|
+
sortOrders[column] = "asc";
|
|
14
|
+
} else {
|
|
15
|
+
sortOrders[column] = sortOrders[column] === "asc" ? "desc" : "asc";
|
|
16
|
+
}
|
|
17
|
+
sortedTableData = [...properties.tableData].sort((a, b) => {
|
|
18
|
+
const colIndex = properties.tableHeaders.indexOf(column);
|
|
19
|
+
const valueA = a[colIndex];
|
|
20
|
+
const valueB = b[colIndex];
|
|
21
|
+
if (typeof valueA === "number" && typeof valueB === "number") {
|
|
22
|
+
return sortOrders[column] === "asc" ? valueA - valueB : valueB - valueA;
|
|
23
|
+
} else if (typeof valueA === "string" && typeof valueB === "string") {
|
|
24
|
+
return sortOrders[column] === "asc" ? valueA.localeCompare(valueB) : valueB.localeCompare(valueA);
|
|
25
|
+
} else if (typeof valueA === "boolean" && typeof valueB === "boolean") {
|
|
26
|
+
return sortOrders[column] === "asc" ? valueA === valueB ? 0 : valueA ? -1 : 1 : valueA === valueB ? 0 : valueA ? 1 : -1;
|
|
27
|
+
} else {
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
|
33
|
+
onMount(() => {
|
|
34
|
+
sortedTableData = [...properties.tableData];
|
|
35
|
+
});
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
{#if properties && properties.tableTitle}
|
|
39
|
+
<div class="table-title">
|
|
40
|
+
{properties.tableTitle}
|
|
41
|
+
</div>
|
|
42
|
+
{/if}
|
|
43
|
+
{#if properties.tableHeaders.length !== 0 || properties.tableData.length !== 0}
|
|
44
|
+
<div
|
|
45
|
+
class="table-container {properties.isTableScrollable ? 'scrollable-table' : ' '}"
|
|
46
|
+
role="grid"
|
|
47
|
+
>
|
|
48
|
+
<table>
|
|
49
|
+
<thead>
|
|
50
|
+
<tr>
|
|
51
|
+
{#each properties.tableHeaders as header}
|
|
52
|
+
<th class="table-header {properties.isTableScrollable ? 'table-header-sticky' : ' '}">
|
|
53
|
+
{header}
|
|
54
|
+
{#if sortOrders[header] === 'asc'}
|
|
55
|
+
<span
|
|
56
|
+
class="sort-arrow"
|
|
57
|
+
on:click={() => sortTableData(header)}
|
|
58
|
+
on:keydown
|
|
59
|
+
role="button"
|
|
60
|
+
tabindex="0">▼</span
|
|
61
|
+
>
|
|
62
|
+
{:else}
|
|
63
|
+
<span
|
|
64
|
+
class="sort-arrow"
|
|
65
|
+
on:click={() => sortTableData(header)}
|
|
66
|
+
on:keydown
|
|
67
|
+
role="button"
|
|
68
|
+
tabindex="0">▲</span
|
|
69
|
+
>
|
|
70
|
+
{/if}
|
|
71
|
+
</th>
|
|
72
|
+
{/each}
|
|
73
|
+
</tr>
|
|
74
|
+
</thead>
|
|
75
|
+
<tbody>
|
|
76
|
+
{#each sortedTableData as row}
|
|
77
|
+
<tr>
|
|
78
|
+
{#each row as cell}
|
|
79
|
+
<td class="table-content">
|
|
80
|
+
<div class={properties.isContentScrollable ? 'scrollable-content' : ' '}>
|
|
81
|
+
{cell}
|
|
82
|
+
</div>
|
|
83
|
+
</td>
|
|
84
|
+
{/each}
|
|
85
|
+
</tr>
|
|
86
|
+
{/each}
|
|
87
|
+
</tbody>
|
|
88
|
+
</table>
|
|
89
|
+
</div>
|
|
90
|
+
{/if}
|
|
91
|
+
|
|
92
|
+
<style>
|
|
93
|
+
.table-title {
|
|
94
|
+
margin: var(--table-title-margin, 0px 0px 10px 0px);
|
|
95
|
+
font-size: var(--table-tile-font-size, 25px);
|
|
96
|
+
font-family: var(--table-title-font-family);
|
|
97
|
+
padding: var(--table-title-padding);
|
|
98
|
+
}
|
|
99
|
+
.table-container {
|
|
100
|
+
border-top: var(--table-border, 0.5px solid #ccc);
|
|
101
|
+
width: var(--table-container-width, 400px);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.scrollable-table {
|
|
105
|
+
height: var(--table-container-height, 143px);
|
|
106
|
+
overflow-y: auto;
|
|
107
|
+
}
|
|
108
|
+
table {
|
|
109
|
+
width: var(--table-width, 400px);
|
|
110
|
+
border-collapse: var(--table-border-collapse, collapse);
|
|
111
|
+
}
|
|
112
|
+
.table-header,
|
|
113
|
+
.table-content {
|
|
114
|
+
border: var(--table-inner-border, 1px solid #ccc);
|
|
115
|
+
padding: var(--table-padding, 8px);
|
|
116
|
+
text-align: var(--table-text-align, left);
|
|
117
|
+
width: var(--table-column-width, 100px);
|
|
118
|
+
word-break: break-all;
|
|
119
|
+
}
|
|
120
|
+
.scrollable-content {
|
|
121
|
+
overflow-y: auto;
|
|
122
|
+
height: var(--scrollable-column-height, 20px);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.table-header {
|
|
126
|
+
background-color: var(--table-header-border-bgcolor, beige);
|
|
127
|
+
font-size: var(--table-header-font-size);
|
|
128
|
+
font-family: var(--table-header-font-family);
|
|
129
|
+
color: var(--table-header-font-color);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.table-header-sticky {
|
|
133
|
+
position: sticky;
|
|
134
|
+
top: -1px;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.table-content {
|
|
138
|
+
background-color: var(--table-content-border-bgcolor);
|
|
139
|
+
font-size: var(--table-content-font-size);
|
|
140
|
+
font-family: var(--table-content-font-family);
|
|
141
|
+
color: var(--table-content-font-color);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.sort-arrow {
|
|
145
|
+
font-size: 10px;
|
|
146
|
+
}
|
|
147
|
+
</style>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { TableProperties } from './properties';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
properties?: TableProperties | undefined;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
keydown: KeyboardEvent;
|
|
9
|
+
} & {
|
|
10
|
+
[evt: string]: CustomEvent<any>;
|
|
11
|
+
};
|
|
12
|
+
slots: {};
|
|
13
|
+
};
|
|
14
|
+
export type TableProps = typeof __propDef.props;
|
|
15
|
+
export type TableEvents = typeof __propDef.events;
|
|
16
|
+
export type TableSlots = typeof __propDef.slots;
|
|
17
|
+
export default class Table extends SvelteComponent<TableProps, TableEvents, TableSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<script>export let toggleValue = false;
|
|
2
|
+
export let toggleText = "";
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<div class="toggle-container">
|
|
6
|
+
<div class="toggle-text">{toggleText}</div>
|
|
7
|
+
<label class="switch">
|
|
8
|
+
<input class="input-checkbox" type="checkbox" bind:checked={toggleValue} />
|
|
9
|
+
<span class="slider round" />
|
|
10
|
+
</label>
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
<style>
|
|
14
|
+
.toggle-container {
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
gap: 8px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.toggle-text {
|
|
21
|
+
font-size: 14px;
|
|
22
|
+
font-weight: 500;
|
|
23
|
+
color: #4a4a4a;
|
|
24
|
+
margin-right: 8px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.switch {
|
|
28
|
+
position: relative;
|
|
29
|
+
display: inline-block;
|
|
30
|
+
width: 46px;
|
|
31
|
+
height: 25px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.switch .input-checkbox {
|
|
35
|
+
opacity: 0;
|
|
36
|
+
width: 0;
|
|
37
|
+
height: 0;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.slider {
|
|
41
|
+
position: absolute;
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
top: 0;
|
|
44
|
+
left: 0;
|
|
45
|
+
right: 0;
|
|
46
|
+
bottom: 0;
|
|
47
|
+
background-color: var(--slider-unchecked-color, #ccc);
|
|
48
|
+
-webkit-transition: 0.4s;
|
|
49
|
+
transition: 0.4s;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.slider:before {
|
|
53
|
+
position: absolute;
|
|
54
|
+
content: '';
|
|
55
|
+
height: 23px;
|
|
56
|
+
width: 23px;
|
|
57
|
+
left: 2px;
|
|
58
|
+
bottom: 1px;
|
|
59
|
+
top: 1px;
|
|
60
|
+
background-color: white;
|
|
61
|
+
-webkit-transition: 0.4s;
|
|
62
|
+
transition: 0.4s;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.input-checkbox:checked + .slider {
|
|
66
|
+
background-color: var(--slider-checked-color, #2196f3);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.input-checkbox:focus + .slider {
|
|
70
|
+
box-shadow: 0 0 1px #171717;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.input-checkbox:checked + .slider:before {
|
|
74
|
+
-webkit-transform: translateX(19px);
|
|
75
|
+
-ms-transform: translateX(19px);
|
|
76
|
+
transform: translateX(19px);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.slider.round {
|
|
80
|
+
border-radius: 23px;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.slider.round:before {
|
|
84
|
+
border-radius: 50%;
|
|
85
|
+
}
|
|
86
|
+
</style>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
toggleValue?: boolean | undefined;
|
|
5
|
+
toggleText?: string | undefined;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {};
|
|
11
|
+
};
|
|
12
|
+
export type ToggleProps = typeof __propDef.props;
|
|
13
|
+
export type ToggleEvents = typeof __propDef.events;
|
|
14
|
+
export type ToggleSlots = typeof __propDef.slots;
|
|
15
|
+
export default class Toggle extends SvelteComponent<ToggleProps, ToggleEvents, ToggleSlots> {
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<script>import { createEventDispatcher } from "svelte";
|
|
2
|
+
import { defaultToolbarProperties } from "./properties";
|
|
3
|
+
export let properties = defaultToolbarProperties;
|
|
4
|
+
const dispatch = createEventDispatcher();
|
|
5
|
+
function handleBackClick() {
|
|
6
|
+
dispatch("backClick");
|
|
7
|
+
}
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<div class="toolbar">
|
|
11
|
+
<div class="content">
|
|
12
|
+
{#if $$slots.leftContent}
|
|
13
|
+
<slot name="leftContent" />
|
|
14
|
+
{:else if properties.showBackButton && properties.backIcon !== null}
|
|
15
|
+
<div class="back" on:click={handleBackClick} on:keydown role="button" tabindex="0">
|
|
16
|
+
<img src={properties.backIcon} alt="Back" />
|
|
17
|
+
</div>
|
|
18
|
+
{/if}
|
|
19
|
+
{#if $$slots.centerContent}
|
|
20
|
+
<div class="center-content">
|
|
21
|
+
<slot name="centerContent" />
|
|
22
|
+
</div>
|
|
23
|
+
{:else if properties.text !== null}
|
|
24
|
+
<div class="text">
|
|
25
|
+
{properties.text}
|
|
26
|
+
</div>
|
|
27
|
+
{/if}
|
|
28
|
+
{#if $$slots.rightContent}
|
|
29
|
+
<div class="right-content">
|
|
30
|
+
<slot name="rightContent" />
|
|
31
|
+
</div>
|
|
32
|
+
{/if}
|
|
33
|
+
</div>
|
|
34
|
+
<div class="additional-content">
|
|
35
|
+
{#if $$slots.additionalContent}
|
|
36
|
+
<slot name="additionalContent" />
|
|
37
|
+
{/if}
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<style>
|
|
42
|
+
.toolbar {
|
|
43
|
+
display: flex;
|
|
44
|
+
flex-direction: column;
|
|
45
|
+
padding: var(--toolbar-padding, 0px);
|
|
46
|
+
height: fit-content;
|
|
47
|
+
width: 100vw;
|
|
48
|
+
position: fixed;
|
|
49
|
+
top: 0;
|
|
50
|
+
left: 0;
|
|
51
|
+
right: 0;
|
|
52
|
+
background: var(--toolbar-background, #ffffff);
|
|
53
|
+
box-shadow: var(--toolbar-box-shadow, 0px 2px 12px #55687c1a);
|
|
54
|
+
z-index: var(--toolbar-z-index, 10);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.content {
|
|
58
|
+
display: flex;
|
|
59
|
+
flex-direction: row;
|
|
60
|
+
padding: var(--toolbar-content-padding, 0px);
|
|
61
|
+
align-items: center;
|
|
62
|
+
justify-content: var(--toolbar-justify-content, normal);
|
|
63
|
+
visibility: var(--toolbar-content-visibility, visible);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.additional-content {
|
|
67
|
+
display: flex;
|
|
68
|
+
flex-direction: row;
|
|
69
|
+
padding: var(--toolbar-additional-content-padding, 0px);
|
|
70
|
+
align-items: center;
|
|
71
|
+
height: var(--toolbar-additional-content-height, fit-content);
|
|
72
|
+
justify-content: var(--toolbar-justify-additional-content, normal);
|
|
73
|
+
visibility: var(--toolbar-additional-content-visibility, visible);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.back {
|
|
77
|
+
height: 20px;
|
|
78
|
+
width: 20px;
|
|
79
|
+
padding: 20px 14px;
|
|
80
|
+
cursor: pointer;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.center-content {
|
|
84
|
+
display: flex;
|
|
85
|
+
flex: 1;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.text {
|
|
89
|
+
font-size: 18px;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.right-content {
|
|
93
|
+
margin-left: auto;
|
|
94
|
+
}
|
|
95
|
+
</style>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { ToolbarProperties } from './properties';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
properties?: ToolbarProperties | undefined;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
keydown: KeyboardEvent;
|
|
9
|
+
backClick: CustomEvent<any>;
|
|
10
|
+
} & {
|
|
11
|
+
[evt: string]: CustomEvent<any>;
|
|
12
|
+
};
|
|
13
|
+
slots: {
|
|
14
|
+
leftContent: {};
|
|
15
|
+
centerContent: {};
|
|
16
|
+
rightContent: {};
|
|
17
|
+
additionalContent: {};
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export type ToolbarProps = typeof __propDef.props;
|
|
21
|
+
export type ToolbarEvents = typeof __propDef.events;
|
|
22
|
+
export type ToolbarSlots = typeof __propDef.slots;
|
|
23
|
+
export default class Toolbar extends SvelteComponent<ToolbarProps, ToolbarEvents, ToolbarSlots> {
|
|
24
|
+
}
|
|
25
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export { default as Modal } from './Modal/Modal.svelte';
|
|
2
|
+
export { default as BrandLoader } from './BrandLoader/BrandLoader.svelte';
|
|
3
|
+
export { default as Button } from './Button/Button.svelte';
|
|
4
|
+
export { default as Input } from './Input/Input.svelte';
|
|
5
|
+
export { default as InputButton } from './InputButton/InputButton.svelte';
|
|
6
|
+
export { default as ListItem } from './ListItem/ListItem.svelte';
|
|
7
|
+
export { default as Loader } from './Loader/Loader.svelte';
|
|
8
|
+
export { default as Toolbar } from './Toolbar/Toolbar.svelte';
|
|
9
|
+
export { default as Icon } from './Icon/Icon.svelte';
|
|
10
|
+
export { default as Select } from './Select/Select.svelte';
|
|
11
|
+
export { default as ModalAnimation } from './Animations/ModalAnimation.svelte';
|
|
12
|
+
export { default as OverlayAnimation } from './Animations/OverlayAnimation.svelte';
|
|
13
|
+
export { default as Status } from './Status/Status.svelte';
|
|
14
|
+
export { default as Carousel } from './Carousel/Carousel.svelte';
|
|
15
|
+
export { default as Badge } from './Badge/Badge.svelte';
|
|
16
|
+
export { default as Banner } from './Banner/Banner.svelte';
|
|
17
|
+
export { default as Toggle } from './Toggle/Toggle.svelte';
|
|
18
|
+
export { default as Accordion } from './Accordion/Accordion.svelte';
|
|
19
|
+
export { default as CheckListItem } from './CheckListItem/CheckListItem.svelte';
|
|
20
|
+
export type { ButtonProperties } from './Button/properties';
|
|
21
|
+
export type { ModalProperties, ModalAlign, ModalSize } from './Modal/properties';
|
|
22
|
+
export type { InputProperties } from './Input/properties';
|
|
23
|
+
export type { InputButtonProperties } from './InputButton/properties';
|
|
24
|
+
export type { ListItemProperties } from './ListItem/properties';
|
|
25
|
+
export type { InputDataType } from './types';
|
|
26
|
+
export type { AutoCompleteType } from './types';
|
|
27
|
+
export type { CustomValidator } from './types';
|
|
28
|
+
export type { ValidationState } from './types';
|
|
29
|
+
export type { IconProperties } from './Icon/properties';
|
|
30
|
+
export type { BrandLoaderProperties } from './BrandLoader/properties';
|
|
31
|
+
export type { StatusProperties } from './Status/properties';
|
|
32
|
+
export type { SelectProperties } from './Select/properties';
|
|
33
|
+
export type { ToolbarProperties } from './Toolbar/properties';
|
|
34
|
+
export type { CarouselProperties } from './Carousel/properties';
|
|
35
|
+
export type { BadgeProperties } from './Badge/properties';
|
|
36
|
+
export type { BannerProperties } from './Banner/properties';
|
|
37
|
+
export { defaultIconProperties } from './Icon/properties';
|
|
38
|
+
export { defaultButtonProperties } from './Button/properties';
|
|
39
|
+
export { defaultModalProperties } from './Modal/properties';
|
|
40
|
+
export { defaultInputProperties } from './Input/properties';
|
|
41
|
+
export { defaultInputButtonProperties } from './InputButton/properties';
|
|
42
|
+
export { defaultBrandLoaderProperties } from './BrandLoader/properties';
|
|
43
|
+
export { defaultStatusProperties } from './Status/properties';
|
|
44
|
+
export { defaultListItemProperties } from './ListItem/properties';
|
|
45
|
+
export { defaultToolbarProperties } from './Toolbar/properties';
|
|
46
|
+
export { defaultCarouselProperties } from './Carousel/properties';
|
|
47
|
+
export { validateInput } from './utils';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export { default as Modal } from './Modal/Modal.svelte';
|
|
2
|
+
export { default as BrandLoader } from './BrandLoader/BrandLoader.svelte';
|
|
3
|
+
export { default as Button } from './Button/Button.svelte';
|
|
4
|
+
export { default as Input } from './Input/Input.svelte';
|
|
5
|
+
export { default as InputButton } from './InputButton/InputButton.svelte';
|
|
6
|
+
export { default as ListItem } from './ListItem/ListItem.svelte';
|
|
7
|
+
export { default as Loader } from './Loader/Loader.svelte';
|
|
8
|
+
export { default as Toolbar } from './Toolbar/Toolbar.svelte';
|
|
9
|
+
export { default as Icon } from './Icon/Icon.svelte';
|
|
10
|
+
export { default as Select } from './Select/Select.svelte';
|
|
11
|
+
export { default as ModalAnimation } from './Animations/ModalAnimation.svelte';
|
|
12
|
+
export { default as OverlayAnimation } from './Animations/OverlayAnimation.svelte';
|
|
13
|
+
export { default as Status } from './Status/Status.svelte';
|
|
14
|
+
export { default as Carousel } from './Carousel/Carousel.svelte';
|
|
15
|
+
export { default as Badge } from './Badge/Badge.svelte';
|
|
16
|
+
export { default as Banner } from './Banner/Banner.svelte';
|
|
17
|
+
export { default as Toggle } from './Toggle/Toggle.svelte';
|
|
18
|
+
export { default as Accordion } from './Accordion/Accordion.svelte';
|
|
19
|
+
export { default as CheckListItem } from './CheckListItem/CheckListItem.svelte';
|
|
20
|
+
export { defaultIconProperties } from './Icon/properties';
|
|
21
|
+
export { defaultButtonProperties } from './Button/properties';
|
|
22
|
+
export { defaultModalProperties } from './Modal/properties';
|
|
23
|
+
export { defaultInputProperties } from './Input/properties';
|
|
24
|
+
export { defaultInputButtonProperties } from './InputButton/properties';
|
|
25
|
+
export { defaultBrandLoaderProperties } from './BrandLoader/properties';
|
|
26
|
+
export { defaultStatusProperties } from './Status/properties';
|
|
27
|
+
export { defaultListItemProperties } from './ListItem/properties';
|
|
28
|
+
export { defaultToolbarProperties } from './Toolbar/properties';
|
|
29
|
+
export { defaultCarouselProperties } from './Carousel/properties';
|
|
30
|
+
export { validateInput } from './utils';
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @name InputDataType
|
|
3
|
+
* @description Different types of input data which can be passed to the Input Component
|
|
4
|
+
*/
|
|
5
|
+
export type InputDataType = 'text' | 'tel' | 'password' | 'email';
|
|
6
|
+
export type AutoCompleteType = 'tel' | 'name' | 'email' | 'one-time-code' | 'postal-code' | 'street-address' | 'on' | 'address-level1';
|
|
7
|
+
/**
|
|
8
|
+
* @name CustomValidator
|
|
9
|
+
* @description Function type for taking input parameter and returning a boolean denoting if the value is valid or not
|
|
10
|
+
*/
|
|
11
|
+
export type CustomValidator = (inputValue: string, currentValidationState: ValidationState) => ValidationState;
|
|
12
|
+
export type TextTransformer = (text: string) => string;
|
|
13
|
+
/**
|
|
14
|
+
* @description Type Map for Possible length values that can be passed to components
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* @description Type Map for All possible output of an Input Filed Validation
|
|
18
|
+
*/
|
|
19
|
+
export type ValidationState = 'Valid' | 'InProgress' | 'Invalid';
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CustomValidator, InputDataType, ValidationState } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* @description A common function to validate value provided inside the input component
|
|
4
|
+
* @param inputValue String value coming from input field
|
|
5
|
+
* @param dataType Datatype of the value being entered in the input component
|
|
6
|
+
* @param validPattern Regular expression which is supposed to be applied on the input string
|
|
7
|
+
* @param inProgressPattern Regular expression which is supposed to be applied on the input string while input is in progress
|
|
8
|
+
* @param customValidators Array of customer validator functions
|
|
9
|
+
* @returns ValidationState : InProgress | Valid | Invalid
|
|
10
|
+
*/
|
|
11
|
+
export declare function validateInput(inputValue: string, dataType: InputDataType, validPattern: RegExp | null, inProgressPattern: RegExp | null, customValidators: CustomValidator[]): ValidationState;
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description A common function to validate value provided inside the input component
|
|
3
|
+
* @param inputValue String value coming from input field
|
|
4
|
+
* @param dataType Datatype of the value being entered in the input component
|
|
5
|
+
* @param validPattern Regular expression which is supposed to be applied on the input string
|
|
6
|
+
* @param inProgressPattern Regular expression which is supposed to be applied on the input string while input is in progress
|
|
7
|
+
* @param customValidators Array of customer validator functions
|
|
8
|
+
* @returns ValidationState : InProgress | Valid | Invalid
|
|
9
|
+
*/
|
|
10
|
+
export function validateInput(inputValue, dataType, validPattern, inProgressPattern, customValidators) {
|
|
11
|
+
let validationResult = 'Valid';
|
|
12
|
+
switch (dataType) {
|
|
13
|
+
case 'email':
|
|
14
|
+
validationResult = validateEmailInput(inputValue);
|
|
15
|
+
break;
|
|
16
|
+
case 'tel':
|
|
17
|
+
validationResult =
|
|
18
|
+
validPattern === null
|
|
19
|
+
? validatePhoneNumber(inputValue)
|
|
20
|
+
: validateTextWithPattern(inputValue, validPattern, inProgressPattern);
|
|
21
|
+
break;
|
|
22
|
+
case 'password':
|
|
23
|
+
validationResult = validatePassword(inputValue, validPattern, inProgressPattern);
|
|
24
|
+
break;
|
|
25
|
+
case 'text':
|
|
26
|
+
validationResult = validateTextWithPattern(inputValue, validPattern, inProgressPattern);
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
customValidators.forEach((validator) => {
|
|
30
|
+
const currentResult = validator(inputValue, validationResult);
|
|
31
|
+
if (currentResult === 'Invalid') {
|
|
32
|
+
validationResult = 'Invalid';
|
|
33
|
+
}
|
|
34
|
+
else if (currentResult === 'InProgress') {
|
|
35
|
+
validationResult = 'InProgress';
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
validationResult =
|
|
39
|
+
validationResult === 'Valid' && currentResult === 'Valid' ? 'Valid' : validationResult;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return validationResult;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* @description Validates input string against passed RegExp
|
|
46
|
+
* @param inputValue string
|
|
47
|
+
* @param validationPattern RegExp for valid input
|
|
48
|
+
* @param inProgressPattern RegExp for inprogress input
|
|
49
|
+
* @returns ValidationState
|
|
50
|
+
*/
|
|
51
|
+
function validateTextWithPattern(inputValue, validationPattern, inProgressPattern) {
|
|
52
|
+
if (validationPattern !== null) {
|
|
53
|
+
if (validationPattern.test(inputValue)) {
|
|
54
|
+
return 'Valid';
|
|
55
|
+
}
|
|
56
|
+
else if ((inProgressPattern !== null && inProgressPattern.test(inputValue)) ||
|
|
57
|
+
inputValue.length === 0) {
|
|
58
|
+
return 'InProgress';
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
return 'Invalid';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return 'Valid';
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* @description Validates password string against passed RegExp
|
|
68
|
+
* @param password string
|
|
69
|
+
* @param validationPattern RegExp for valid input
|
|
70
|
+
* @param inProgressPattern RegExp for inprogress input
|
|
71
|
+
* @returns ValidationState
|
|
72
|
+
*/
|
|
73
|
+
function validatePassword(password, validationPattern, inProgressPattern) {
|
|
74
|
+
if (validationPattern !== null) {
|
|
75
|
+
if (validationPattern.test(password)) {
|
|
76
|
+
return 'Valid';
|
|
77
|
+
}
|
|
78
|
+
else if (inProgressPattern !== null &&
|
|
79
|
+
inProgressPattern.test(password) &&
|
|
80
|
+
password.length === 0) {
|
|
81
|
+
return 'InProgress';
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
return 'Invalid';
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return 'Valid';
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* @description Validates an email input based upon RF 5322 Email format
|
|
91
|
+
* @param emailId String
|
|
92
|
+
* @returns ValidationState
|
|
93
|
+
*/
|
|
94
|
+
function validateEmailInput(emailId) {
|
|
95
|
+
try {
|
|
96
|
+
/**
|
|
97
|
+
* @description Using RFC 5322 Format for validation
|
|
98
|
+
* @tutorial https://www.regextester.com/115911
|
|
99
|
+
* @tutorial https://emailregex.com/
|
|
100
|
+
* @tutorial https://stackoverflow.com/questions/42982005/email-address-regular-expression-rfc-5322-passed-in-to-match-does-not-work
|
|
101
|
+
* @tutorial https://www.regular-expressions.info/email.html
|
|
102
|
+
*/
|
|
103
|
+
const validPattern = new RegExp(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/);
|
|
104
|
+
const inProgressPattern = new RegExp(/[^ ]{1,}[\w0-9.,_,@]{0,}/);
|
|
105
|
+
if (validPattern.test(emailId)) {
|
|
106
|
+
return 'Valid';
|
|
107
|
+
}
|
|
108
|
+
else if (inProgressPattern.test(emailId) || emailId.length === 0) {
|
|
109
|
+
return 'InProgress';
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
return 'Invalid';
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
catch (e) {
|
|
116
|
+
console.error('Email Regex creation failed: ', e);
|
|
117
|
+
}
|
|
118
|
+
return 'Valid';
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* @description Validates Indian phone numbers
|
|
122
|
+
* @todo Update Regex to take different variations of input in next update
|
|
123
|
+
* @link https://stackoverflow.com/questions/18351553/regular-expression-validation-for-indian-phone-number-and-mobile-number
|
|
124
|
+
* @param phoneNumber
|
|
125
|
+
* @returns ValidationState
|
|
126
|
+
*/
|
|
127
|
+
function validatePhoneNumber(phoneNumber) {
|
|
128
|
+
let validationPattern = null;
|
|
129
|
+
let inProgressPattern = null;
|
|
130
|
+
try {
|
|
131
|
+
validationPattern = new RegExp('^[6-9]{1}[0-9]{9}$');
|
|
132
|
+
inProgressPattern = new RegExp('^[6-9]{1}[0-9]{0,9}$');
|
|
133
|
+
if (validationPattern.test(phoneNumber)) {
|
|
134
|
+
return 'Valid';
|
|
135
|
+
}
|
|
136
|
+
else if (inProgressPattern.test(phoneNumber) || phoneNumber.length === 0) {
|
|
137
|
+
return 'InProgress';
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
return 'Invalid';
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
catch (e) {
|
|
144
|
+
console.error('Phone Regex creation failed', e);
|
|
145
|
+
}
|
|
146
|
+
return phoneNumber.length === 10 ? 'Valid' : phoneNumber.length > 10 ? 'InProgress' : 'Invalid';
|
|
147
|
+
}
|