@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.
Files changed (76) hide show
  1. package/README.md +115 -0
  2. package/dist/Accordion/Accordion.svelte +35 -0
  3. package/dist/Accordion/Accordion.svelte.d.ts +18 -0
  4. package/dist/Animations/ModalAnimation.svelte +28 -0
  5. package/dist/Animations/ModalAnimation.svelte.d.ts +20 -0
  6. package/dist/Animations/OverlayAnimation.svelte +7 -0
  7. package/dist/Animations/OverlayAnimation.svelte.d.ts +27 -0
  8. package/dist/Badge/Badge.svelte +45 -0
  9. package/dist/Badge/Badge.svelte.d.ts +17 -0
  10. package/dist/Badge/properties.d.ts +4 -0
  11. package/dist/Badge/properties.js +1 -0
  12. package/dist/Banner/Banner.svelte +61 -0
  13. package/dist/Banner/Banner.svelte.d.ts +20 -0
  14. package/dist/Banner/properties.d.ts +5 -0
  15. package/dist/Banner/properties.js +1 -0
  16. package/dist/BrandLoader/BrandLoader.svelte +125 -0
  17. package/dist/BrandLoader/BrandLoader.svelte.d.ts +18 -0
  18. package/dist/BrandLoader/properties.d.ts +8 -0
  19. package/dist/BrandLoader/properties.js +7 -0
  20. package/dist/Button/Button.svelte +87 -0
  21. package/dist/Button/Button.svelte.d.ts +21 -0
  22. package/dist/Button/properties.d.ts +9 -0
  23. package/dist/Button/properties.js +7 -0
  24. package/dist/Carousel/Carousel.svelte +219 -0
  25. package/dist/Carousel/Carousel.svelte.d.ts +19 -0
  26. package/dist/Carousel/properties.d.ts +18 -0
  27. package/dist/Carousel/properties.js +7 -0
  28. package/dist/CheckListItem/CheckListItem.svelte +40 -0
  29. package/dist/CheckListItem/CheckListItem.svelte.d.ts +19 -0
  30. package/dist/Icon/Icon.svelte +32 -0
  31. package/dist/Icon/Icon.svelte.d.ts +20 -0
  32. package/dist/Icon/properties.d.ts +5 -0
  33. package/dist/Icon/properties.js +4 -0
  34. package/dist/Input/Input.svelte +218 -0
  35. package/dist/Input/Input.svelte.d.ts +26 -0
  36. package/dist/Input/properties.d.ts +25 -0
  37. package/dist/Input/properties.js +23 -0
  38. package/dist/InputButton/InputButton.svelte +157 -0
  39. package/dist/InputButton/InputButton.svelte.d.ts +27 -0
  40. package/dist/InputButton/properties.d.ts +8 -0
  41. package/dist/InputButton/properties.js +17 -0
  42. package/dist/ListItem/ListItem.svelte +196 -0
  43. package/dist/ListItem/ListItem.svelte.d.ts +32 -0
  44. package/dist/ListItem/properties.d.ts +8 -0
  45. package/dist/ListItem/properties.js +7 -0
  46. package/dist/Loader/Loader.svelte +89 -0
  47. package/dist/Loader/Loader.svelte.d.ts +15 -0
  48. package/dist/Modal/Modal.svelte +200 -0
  49. package/dist/Modal/Modal.svelte.d.ts +25 -0
  50. package/dist/Modal/properties.d.ts +15 -0
  51. package/dist/Modal/properties.js +12 -0
  52. package/dist/Select/Select.svelte +271 -0
  53. package/dist/Select/Select.svelte.d.ts +21 -0
  54. package/dist/Select/properties.d.ts +9 -0
  55. package/dist/Select/properties.js +1 -0
  56. package/dist/Status/Status.svelte +64 -0
  57. package/dist/Status/Status.svelte.d.ts +20 -0
  58. package/dist/Status/properties.d.ts +8 -0
  59. package/dist/Status/properties.js +6 -0
  60. package/dist/Table/Table.svelte +147 -0
  61. package/dist/Table/Table.svelte.d.ts +19 -0
  62. package/dist/Table/properties.d.ts +8 -0
  63. package/dist/Table/properties.js +1 -0
  64. package/dist/Toggle/Toggle.svelte +86 -0
  65. package/dist/Toggle/Toggle.svelte.d.ts +17 -0
  66. package/dist/Toolbar/Toolbar.svelte +95 -0
  67. package/dist/Toolbar/Toolbar.svelte.d.ts +25 -0
  68. package/dist/Toolbar/properties.d.ts +6 -0
  69. package/dist/Toolbar/properties.js +5 -0
  70. package/dist/index.d.ts +47 -0
  71. package/dist/index.js +30 -0
  72. package/dist/types.d.ts +19 -0
  73. package/dist/types.js +1 -0
  74. package/dist/utils.d.ts +11 -0
  75. package/dist/utils.js +147 -0
  76. package/package.json +162 -0
package/README.md ADDED
@@ -0,0 +1,115 @@
1
+ # Svelte UI Components
2
+
3
+ This library provides a collection of reusable UI components built with [Svelte](https://svelte.dev/).
4
+
5
+ ## Installation
6
+
7
+ This library is publish on npm & can be installed via any npm client.
8
+ Use the following command to install the library.
9
+
10
+ ```bash
11
+ npm install @juspay/svelte-ui-components
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ The library contains a collection of components that can be imported & used in your svelte project.
17
+
18
+ ### Available components
19
+
20
+ - Accordion
21
+ - Badge
22
+ - Banner
23
+ - Brand Loader (aka Splash Screen )
24
+ - Button
25
+ - Carousel
26
+ - Checkbox / Checklist Item
27
+ - Icon
28
+ - Input
29
+ - Input with attached Button
30
+ - List Item
31
+ - Loader
32
+ - Modal
33
+ - Select
34
+ - Status Screen
35
+ - Table
36
+ - Toggle
37
+ - Toolbar
38
+
39
+ All of the components can be easily imported from the 'svelte-ui-components' package.
40
+
41
+ #### Example: Importing component from the package
42
+
43
+ ```svelte
44
+ <script>
45
+ import { Button } from '@juspay/svelte-ui-components';
46
+ </script>
47
+
48
+ <Button>Click me</Button>
49
+ ```
50
+
51
+ ### Customizing the components
52
+
53
+ Each component comes with a set of configuration options that can be used to customize the component.
54
+ There are two ways to customize the component.
55
+
56
+ 1. Using css variables:
57
+
58
+ - All the components have exposed css variables for all the properties available.
59
+ - The css variables can be used to customize the component.
60
+
61
+ 2. Using props:
62
+
63
+ - All the components have exposed props for dynamic values/variables.
64
+ - The props can be used to customize the component.
65
+
66
+ #### Example: Customizing the component
67
+
68
+ ````svelte
69
+ <script lang="ts">
70
+ import {
71
+ Button,
72
+ type ButtonProperties,
73
+ defaultButtonProperties
74
+ } from '@juspay/svelte-ui-components';
75
+
76
+ const buttonProperties: ButtonProperties = {
77
+ ...defaultButtonProperties,
78
+ text: 'Submit'
79
+ };
80
+
81
+ function handleSubmitClick() {
82
+ // handle click
83
+ }
84
+ </script>
85
+
86
+ ```svelte
87
+ <div class="form">
88
+ <Button properties={buttonProperties} on:click={handleSubmitClick} />
89
+ </div>
90
+
91
+ <style>
92
+ .form {
93
+ --button-color: black;
94
+ --button-text-color: white;
95
+ // and many more
96
+ }
97
+ </style>
98
+ ````
99
+
100
+ ### Contributing
101
+
102
+ - Clone the repository
103
+ - Install dependencies using `pnpm install`
104
+ - Make changes to the components
105
+ - Run tests using `pnpm run test`
106
+ - Commit the changes
107
+ - Push the changes
108
+ - Create a pull request
109
+
110
+ ### Todo Items
111
+
112
+ - [ ] Add demo support
113
+ - [ ] Add documentation for all components
114
+ - [ ] Add more components
115
+ - [ ] Add tests
@@ -0,0 +1,35 @@
1
+ <script>import { afterUpdate, onMount } from "svelte";
2
+ export let expand = false;
3
+ let maxHeight = 0;
4
+ let accordionRef;
5
+ function updateMaxHeight() {
6
+ if (expand) {
7
+ accordionRef.style.maxHeight = `${maxHeight}px`;
8
+ } else {
9
+ accordionRef.style.maxHeight = "0";
10
+ }
11
+ }
12
+ afterUpdate(updateMaxHeight);
13
+ onMount(() => {
14
+ accordionRef.style.transition = "max-height 0.2s ease-out";
15
+ updateMaxHeight();
16
+ });
17
+ $: {
18
+ if (accordionRef) {
19
+ maxHeight = accordionRef.scrollHeight;
20
+ updateMaxHeight();
21
+ }
22
+ }
23
+ </script>
24
+
25
+ <div class="accordion" bind:this={accordionRef}>
26
+ <slot />
27
+ </div>
28
+
29
+ <style>
30
+ .accordion {
31
+ max-height: 0;
32
+ overflow: hidden;
33
+ transition: max-height 0s ease-in;
34
+ }
35
+ </style>
@@ -0,0 +1,18 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ expand?: boolean | undefined;
5
+ };
6
+ events: {
7
+ [evt: string]: CustomEvent<any>;
8
+ };
9
+ slots: {
10
+ default: {};
11
+ };
12
+ };
13
+ export type AccordionProps = typeof __propDef.props;
14
+ export type AccordionEvents = typeof __propDef.events;
15
+ export type AccordionSlots = typeof __propDef.slots;
16
+ export default class Accordion extends SvelteComponent<AccordionProps, AccordionEvents, AccordionSlots> {
17
+ }
18
+ export {};
@@ -0,0 +1,28 @@
1
+ <script>import { fly, fade } from "svelte/transition";
2
+ export let enable = true;
3
+ export let align = "bottom";
4
+ let flyAnimationProperties = { x: 0, y: 0, duration: 380 };
5
+ let fadeAnimationProperties = { duration: 300 };
6
+ switch (align) {
7
+ case "top":
8
+ flyAnimationProperties = { ...flyAnimationProperties, y: -30 };
9
+ break;
10
+ case "bottom":
11
+ flyAnimationProperties = { ...flyAnimationProperties, y: 300 };
12
+ break;
13
+ }
14
+ </script>
15
+
16
+ {#if enable}
17
+ {#if align === 'top' || align === 'bottom'}
18
+ <div transition:fly={flyAnimationProperties}>
19
+ <slot />
20
+ </div>
21
+ {:else}
22
+ <div in:fade={fadeAnimationProperties} out:fade={fadeAnimationProperties}>
23
+ <slot />
24
+ </div>
25
+ {/if}
26
+ {:else}
27
+ <slot />
28
+ {/if}
@@ -0,0 +1,20 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { ModalAlign } from '../Modal/properties';
3
+ declare const __propDef: {
4
+ props: {
5
+ enable?: boolean | undefined;
6
+ align?: ModalAlign | undefined;
7
+ };
8
+ events: {
9
+ [evt: string]: CustomEvent<any>;
10
+ };
11
+ slots: {
12
+ default: {};
13
+ };
14
+ };
15
+ export type ModalAnimationProps = typeof __propDef.props;
16
+ export type ModalAnimationEvents = typeof __propDef.events;
17
+ export type ModalAnimationSlots = typeof __propDef.slots;
18
+ export default class ModalAnimation extends SvelteComponent<ModalAnimationProps, ModalAnimationEvents, ModalAnimationSlots> {
19
+ }
20
+ export {};
@@ -0,0 +1,7 @@
1
+ <script>
2
+ import { fade } from 'svelte/transition';
3
+ </script>
4
+
5
+ <div out:fade={{ duration: 350 }}>
6
+ <slot />
7
+ </div>
@@ -0,0 +1,27 @@
1
+ /** @typedef {typeof __propDef.props} OverlayAnimationProps */
2
+ /** @typedef {typeof __propDef.events} OverlayAnimationEvents */
3
+ /** @typedef {typeof __propDef.slots} OverlayAnimationSlots */
4
+ export default class OverlayAnimation extends SvelteComponent<{
5
+ [x: string]: never;
6
+ }, {
7
+ [evt: string]: CustomEvent<any>;
8
+ }, {
9
+ default: {};
10
+ }> {
11
+ }
12
+ export type OverlayAnimationProps = typeof __propDef.props;
13
+ export type OverlayAnimationEvents = typeof __propDef.events;
14
+ export type OverlayAnimationSlots = typeof __propDef.slots;
15
+ import { SvelteComponent } from "svelte";
16
+ declare const __propDef: {
17
+ props: {
18
+ [x: string]: never;
19
+ };
20
+ events: {
21
+ [evt: string]: CustomEvent<any>;
22
+ };
23
+ slots: {
24
+ default: {};
25
+ };
26
+ };
27
+ export {};
@@ -0,0 +1,45 @@
1
+ <script>export let properties = null;
2
+ </script>
3
+
4
+ {#if properties !== null}
5
+ <div class="badge-icon">
6
+ <div class="badge-wrap">
7
+ <img class="icon-img" src={properties.image} alt="" />
8
+ <div class="badge">{properties.value}</div>
9
+ </div>
10
+ </div>
11
+ {/if}
12
+
13
+ <style>
14
+ .badge-wrap {
15
+ position: relative;
16
+ display: inline-block;
17
+ margin: var(--badge-wrap-margin, 0px 12px 10px 0px);
18
+ padding: var(--badge-wrap-padding, 8px 8px 8px 8px);
19
+ }
20
+
21
+ .badge {
22
+ position: absolute;
23
+ color: var(--badge-color, #fff);
24
+ background-color: var(--badge-background, #727272);
25
+ font-size: var(--badge-font-size, 12px);
26
+ font-family: var(--badge-font-family, Euclid Circular A);
27
+ padding: var(--badge-padding, 2px 7.5px);
28
+ border-radius: var(--badge-border-radius, 100px);
29
+ min-width: var(--badge-min-width, 7px);
30
+ min-height: var(--badge-min-height, 7px);
31
+ border: var(--badge-border, 0.6px solid #fff);
32
+ top: var(--badge-top, 0);
33
+ right: var(--badge-right, 0);
34
+ bottom: var(--badge-bottom);
35
+ left: var(--badge-left);
36
+ }
37
+
38
+ .icon-img {
39
+ border-radius: var(--badge-img-border-radius, 6px);
40
+ width: var(--badge-img-width, 64px);
41
+ height: var(--badge-img-height, 64px);
42
+ object-fit: contain;
43
+ box-shadow: var(--badge-img-icon-shadow, 0 0 0 0.5px #798fa54d);
44
+ }
45
+ </style>
@@ -0,0 +1,17 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { BadgeProperties } from './properties';
3
+ declare const __propDef: {
4
+ props: {
5
+ properties?: BadgeProperties | null | undefined;
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {};
11
+ };
12
+ export type BadgeProps = typeof __propDef.props;
13
+ export type BadgeEvents = typeof __propDef.events;
14
+ export type BadgeSlots = typeof __propDef.slots;
15
+ export default class Badge extends SvelteComponent<BadgeProps, BadgeEvents, BadgeSlots> {
16
+ }
17
+ export {};
@@ -0,0 +1,4 @@
1
+ export type BadgeProperties = {
2
+ image: string;
3
+ value: string;
4
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,61 @@
1
+ <script>export let properties = null;
2
+ </script>
3
+
4
+ {#if properties !== null}
5
+ <div class="banner" on:click on:keydown role="button" tabindex="0">
6
+ {#if properties.icon !== null}
7
+ <div class="banner-image">
8
+ <img src={properties.icon} alt="" />
9
+ </div>
10
+ {/if}
11
+ <div class="banner-text">
12
+ {#if properties.linkText !== null}
13
+ <div>{properties.text}<span class="link-text">{properties.linkText}</span></div>
14
+ {:else}
15
+ <div>{properties.text}</div>
16
+ {/if}
17
+ </div>
18
+ </div>
19
+ {/if}
20
+
21
+ <style>
22
+ .banner {
23
+ position: var(--banner-position, sticky);
24
+ top: var(--banner-top, 0px);
25
+ display: var(--banner-display, flex);
26
+ align-items: center;
27
+ background-color: var(--banner-bg-color, #637c9529);
28
+ width: var(--banner-width, 100%);
29
+ height: var(--banner-height, 37px);
30
+ padding: var(--banner-padding, 10px 12px, 10px, 12px);
31
+ gap: var(--banner-gap, 8px);
32
+ justify-content: center;
33
+ cursor: pointer;
34
+ }
35
+
36
+ .banner-image {
37
+ color: var(--banner-img-color, #637c95);
38
+ width: var(--banner-img-width, 18px);
39
+ height: var(--banner-img-height, 11.69px);
40
+ margin-bottom: var(--banner-img-margin-bottom, 6px);
41
+ align-items: center;
42
+ }
43
+
44
+ .banner-text {
45
+ size: var(--banner-text-size, 14px);
46
+ font-family: var(--banner-font-family, Euclid Circular A);
47
+ font-style: var(--banner-font-style, normal);
48
+ color: var(--banner-text-color, #637c95);
49
+ font-size: var(--banner-font-size, 14px);
50
+ line-height: var(--banner-line-height, 17.75px);
51
+ font-weight: var(--banner-font-weight, 500);
52
+ overflow: hidden;
53
+ text-overflow: ellipsis;
54
+ white-space: nowrap;
55
+ align-items: center;
56
+ }
57
+
58
+ .link-text {
59
+ color: var(--banner-linktext-color, #0099ff);
60
+ }
61
+ </style>
@@ -0,0 +1,20 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { BannerProperties } from './properties';
3
+ declare const __propDef: {
4
+ props: {
5
+ properties?: BannerProperties | null | undefined;
6
+ };
7
+ events: {
8
+ click: MouseEvent;
9
+ keydown: KeyboardEvent;
10
+ } & {
11
+ [evt: string]: CustomEvent<any>;
12
+ };
13
+ slots: {};
14
+ };
15
+ export type BannerProps = typeof __propDef.props;
16
+ export type BannerEvents = typeof __propDef.events;
17
+ export type BannerSlots = typeof __propDef.slots;
18
+ export default class Banner extends SvelteComponent<BannerProps, BannerEvents, BannerSlots> {
19
+ }
20
+ export {};
@@ -0,0 +1,5 @@
1
+ export type BannerProperties = {
2
+ icon: string | null;
3
+ text: string;
4
+ linkText: string | null;
5
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,125 @@
1
+ <script context="module">export const prerender = true;
2
+ </script>
3
+
4
+ <script>import { defaultBrandLoaderProperties } from "./properties";
5
+ export let properties = defaultBrandLoaderProperties;
6
+ </script>
7
+
8
+ <div class="background">
9
+ <div class="loader">
10
+ <img src={properties.brandLogoURL} alt="" />
11
+ <div class="text">{properties.brandText}</div>
12
+ {#if properties.subText}
13
+ <div class="sub-text">{properties.subText}</div>
14
+ {/if}
15
+ <div class="lds-ellipsis">
16
+ <div />
17
+ <div />
18
+ <div />
19
+ <div />
20
+ </div>
21
+ </div>
22
+ </div>
23
+
24
+ <style>
25
+ .background {
26
+ height: var(--loader-background-height);
27
+ width: var(--loader-background-width);
28
+ }
29
+
30
+ .loader {
31
+ height: var(--loader-height, 100vh);
32
+ width: var(--loader-width, 100vw);
33
+ display: flex;
34
+ justify-content: center;
35
+ align-items: center;
36
+ flex-direction: column;
37
+ }
38
+
39
+ .loader img {
40
+ height: 40px;
41
+ width: 71px;
42
+ }
43
+
44
+ .text {
45
+ font-size: 22px;
46
+ padding: 16px 0px;
47
+ color: var(--loader-text-color, white);
48
+ font-family: var(--loader-text-font, Euclid Circular A);
49
+ }
50
+
51
+ .sub-text {
52
+ font-size: 12px;
53
+ margin-bottom: 16px;
54
+ }
55
+
56
+ @supports ((-webkit-backdrop-filter: none) or (backdrop-filter: none)) {
57
+ .background {
58
+ animation: animateBackground 5s ease-in-out infinite normal;
59
+ -webkit-animation: animateBackground 5s ease-in-out infinite normal;
60
+ }
61
+
62
+ .loader {
63
+ background-color: var(--loader-background-color, #ffffff33);
64
+ -webkit-backdrop-filter: blur(50px);
65
+ backdrop-filter: blur(50px);
66
+ }
67
+ }
68
+
69
+ .lds-ellipsis {
70
+ display: inline-block;
71
+ position: relative;
72
+ width: 80px;
73
+ height: 80px;
74
+ }
75
+ .lds-ellipsis div {
76
+ display: inherit;
77
+ position: absolute;
78
+ top: 5px;
79
+ width: 13px;
80
+ height: 13px;
81
+ border-radius: 50%;
82
+ background: var(--loader-dot-color, #3a4550);
83
+ animation-timing-function: cubic-bezier(0, 1, 1, 0);
84
+ }
85
+ .lds-ellipsis div:nth-child(1) {
86
+ left: 8px;
87
+ animation: lds-ellipsis1 0.6s infinite;
88
+ }
89
+ .lds-ellipsis div:nth-child(2) {
90
+ left: 8px;
91
+ animation: lds-ellipsis2 0.6s infinite;
92
+ }
93
+ .lds-ellipsis div:nth-child(3) {
94
+ left: 32px;
95
+ animation: lds-ellipsis2 0.6s infinite;
96
+ }
97
+ .lds-ellipsis div:nth-child(4) {
98
+ left: 56px;
99
+ animation: lds-ellipsis3 0.6s infinite;
100
+ }
101
+ @keyframes lds-ellipsis1 {
102
+ 0% {
103
+ transform: scale(0);
104
+ }
105
+ 100% {
106
+ transform: scale(1);
107
+ }
108
+ }
109
+ @keyframes lds-ellipsis3 {
110
+ 0% {
111
+ transform: scale(1);
112
+ }
113
+ 100% {
114
+ transform: scale(0);
115
+ }
116
+ }
117
+ @keyframes lds-ellipsis2 {
118
+ 0% {
119
+ transform: translate(0, 0);
120
+ }
121
+ 100% {
122
+ transform: translate(24px, 0);
123
+ }
124
+ }
125
+ </style>
@@ -0,0 +1,18 @@
1
+ import { SvelteComponent } from "svelte";
2
+ export declare const prerender = true;
3
+ import type { BrandLoaderProperties } from './properties';
4
+ declare const __propDef: {
5
+ props: {
6
+ properties?: BrandLoaderProperties | undefined;
7
+ };
8
+ events: {
9
+ [evt: string]: CustomEvent<any>;
10
+ };
11
+ slots: {};
12
+ };
13
+ export type BrandLoaderProps = typeof __propDef.props;
14
+ export type BrandLoaderEvents = typeof __propDef.events;
15
+ export type BrandLoaderSlots = typeof __propDef.slots;
16
+ export default class BrandLoader extends SvelteComponent<BrandLoaderProps, BrandLoaderEvents, BrandLoaderSlots> {
17
+ }
18
+ export {};
@@ -0,0 +1,8 @@
1
+ export type BrandLoaderProperties = {
2
+ fullScreen: boolean;
3
+ subText: string | null;
4
+ brandLogoURL: string;
5
+ brandText: string;
6
+ loaderBackgroundImage: string;
7
+ };
8
+ export declare const defaultBrandLoaderProperties: BrandLoaderProperties;
@@ -0,0 +1,7 @@
1
+ export const defaultBrandLoaderProperties = {
2
+ fullScreen: true,
3
+ subText: null,
4
+ brandLogoURL: 'https://sdk.breeze.in/gallery/icons/logo.svg',
5
+ brandText: 'breeze',
6
+ loaderBackgroundImage: '/images/loader-background.svg'
7
+ };
@@ -0,0 +1,87 @@
1
+ <script>import { createEventDispatcher } from "svelte";
2
+ import Loader from "../Loader/Loader.svelte";
3
+ import { defaultButtonProperties } from "./properties";
4
+ export let properties = defaultButtonProperties;
5
+ export let showProgressBar = false;
6
+ const dispatch = createEventDispatcher();
7
+ function handleButtonClick() {
8
+ if (showProgressBar) {
9
+ return;
10
+ }
11
+ dispatch("click");
12
+ if (properties.showLoader && properties.loaderType === "ProgressBar") {
13
+ showProgressBar = true;
14
+ }
15
+ }
16
+ </script>
17
+
18
+ <div class="button-container">
19
+ {#if showProgressBar}
20
+ <div class="button-progress-bar" />
21
+ {/if}
22
+ <button
23
+ style="
24
+ --opacity: {properties.enable ? 1 : 0.4};
25
+ --cursor: {properties.enable ? 'pointer' : 'not-allowed'};"
26
+ on:click={handleButtonClick}
27
+ disabled={!(properties.enable && !properties.showLoader)}
28
+ type={properties.type}
29
+ >
30
+ {#if properties.showLoader && properties.loaderType === 'Circular'}
31
+ <Loader />
32
+ {/if}
33
+ {#if $$slots.icon}
34
+ <slot name="icon" />
35
+ {/if}
36
+ {properties.text}
37
+ </button>
38
+ </div>
39
+
40
+ <style>
41
+ .button-container {
42
+ position: relative;
43
+ width: var(--button-width, fit-content);
44
+ }
45
+ button {
46
+ max-height: var(--button-max-height);
47
+ max-width: var(--button-max-width);
48
+ font-family: var(--button-font-family);
49
+ font-weight: var(--button-font-weight, 500);
50
+ font-size: var(--button-font-size, 14px);
51
+ background-color: var(--button-color, var(--primary-button-color, #3a4550));
52
+ color: var(--button-text-color, var(--primary-text-color, white));
53
+ height: var(--button-height, fit-content);
54
+ padding: var(--button-padding, 16px);
55
+ margin: var(--button-margin);
56
+ border-radius: var(--button-border-radius, 0px);
57
+ width: var(--button-width, fit-content);
58
+ cursor: var(--cursor, pointer);
59
+ opacity: var(--opacity, 1);
60
+ border: var(--button-border, none);
61
+ display: flex;
62
+ justify-content: var(--button-justify-content, center);
63
+ align-items: center;
64
+ flex-direction: row;
65
+ gap: var(--button-content-gap, 16px);
66
+ visibility: var(--button-visibility, visible);
67
+ }
68
+
69
+ .button-progress-bar {
70
+ position: absolute;
71
+ height: 100%;
72
+ width: 100%;
73
+ background: var(--button-progress-loader-background-color, #00000030);
74
+ animation: fill-loader var(--button-progress-loader-duration, 8s) forwards;
75
+ z-index: 2;
76
+ }
77
+
78
+ @keyframes fill-loader {
79
+ 0% {
80
+ width: 0;
81
+ }
82
+
83
+ 100% {
84
+ width: 100%;
85
+ }
86
+ }
87
+ </style>
@@ -0,0 +1,21 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ properties?: import("./properties").ButtonProperties | undefined;
5
+ showProgressBar?: boolean | undefined;
6
+ };
7
+ events: {
8
+ click: CustomEvent<any>;
9
+ } & {
10
+ [evt: string]: CustomEvent<any>;
11
+ };
12
+ slots: {
13
+ icon: {};
14
+ };
15
+ };
16
+ export type ButtonProps = typeof __propDef.props;
17
+ export type ButtonEvents = typeof __propDef.events;
18
+ export type ButtonSlots = typeof __propDef.slots;
19
+ export default class Button extends SvelteComponent<ButtonProps, ButtonEvents, ButtonSlots> {
20
+ }
21
+ export {};