@juspay/svelte-ui-components 1.3.0 → 1.5.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 CHANGED
@@ -41,11 +41,11 @@ All of the components can be easily imported from the 'svelte-ui-components' pac
41
41
  #### Example: Importing component from the package
42
42
 
43
43
  ```svelte
44
- <script>
45
- import { Button } from '@juspay/svelte-ui-components';
44
+ <script lang="ts">
45
+ import { Button, defaultButtonProperties } from '@juspay/svelte-ui-components';
46
46
  </script>
47
47
 
48
- <Button>Click me</Button>
48
+ <Button properties={{ ...defaultButtonProperties, text: 'Click' }} />
49
49
  ```
50
50
 
51
51
  ### Customizing the components
@@ -65,7 +65,7 @@ There are two ways to customize the component.
65
65
 
66
66
  #### Example: Customizing the component
67
67
 
68
- ````svelte
68
+ ```svelte
69
69
  <script lang="ts">
70
70
  import {
71
71
  Button,
@@ -83,7 +83,6 @@ There are two ways to customize the component.
83
83
  }
84
84
  </script>
85
85
 
86
- ```svelte
87
86
  <div class="form">
88
87
  <Button properties={buttonProperties} on:click={handleSubmitClick} />
89
88
  </div>
@@ -92,10 +91,10 @@ There are two ways to customize the component.
92
91
  .form {
93
92
  --button-color: black;
94
93
  --button-text-color: white;
95
- // and many more
94
+ /* Other styling values */
96
95
  }
97
96
  </style>
98
- ````
97
+ ```
99
98
 
100
99
  ### Contributing
101
100
 
@@ -39,7 +39,8 @@
39
39
  border-radius: var(--badge-img-border-radius, 6px);
40
40
  width: var(--badge-img-width, 64px);
41
41
  height: var(--badge-img-height, 64px);
42
- object-fit: contain;
42
+ object-fit: var(--badge-object-fit, contain);
43
43
  box-shadow: var(--badge-img-icon-shadow, 0 0 0 0.5px #798fa54d);
44
+ background-color: var(--badge-img-background-color);
44
45
  }
45
46
  </style>
@@ -12,10 +12,14 @@ function handleCheckboxClick(e) {
12
12
 
13
13
  <div class="container">
14
14
  <input type="checkbox" class="checkbox" bind:checked on:click={handleCheckboxClick} />
15
- <span class="text">
16
- <!-- eslint-disable-next-line -->
17
- {@html text}
18
- </span>
15
+ {#if $$slots.checkboxLabel}
16
+ <slot name="checkboxLabel" />
17
+ {:else}
18
+ <span class="text">
19
+ <!-- eslint-disable-next-line -->
20
+ {@html text}
21
+ </span>
22
+ {/if}
19
23
  </div>
20
24
 
21
25
  <style>
@@ -36,5 +40,9 @@ function handleCheckboxClick(e) {
36
40
  border: 5px solid red;
37
41
  height: var(--checkbox-height, 24px);
38
42
  width: var(--checkbox-width, 24px);
43
+ margin: var(--checkbox-margin);
44
+ padding: var(--checkbox-padding);
45
+ border-radius: var(--checkbox-border-radius);
46
+ visibility: var(--checkbox-visibility);
39
47
  }
40
48
  </style>
@@ -9,7 +9,9 @@ declare const __propDef: {
9
9
  } & {
10
10
  [evt: string]: CustomEvent<any>;
11
11
  };
12
- slots: {};
12
+ slots: {
13
+ checkboxLabel: {};
14
+ };
13
15
  };
14
16
  export type CheckListItemProps = typeof __propDef.props;
15
17
  export type CheckListItemEvents = typeof __propDef.events;
@@ -102,16 +102,13 @@ onDestroy(() => {
102
102
  bottom: 0;
103
103
  left: 0;
104
104
  right: 0;
105
- width: 100vw;
106
- height: 100vh;
105
+ width: var(--modal-width, 100vw);
106
+ height: var(--modal-height, 100vh);
107
107
  display: flex;
108
108
  flex-direction: column;
109
109
  z-index: var(--modal-z-index, 15);
110
110
  -webkit-tap-highlight-color: transparent;
111
- margin-top: var(--margin-top, 0px);
112
- margin-bottom: var(--margin-bottom, 0px);
113
- margin-left: var(--margin-left, 0px);
114
- margin-right: var(--margin-right, 0px);
111
+ margin: var(--modal-margin);
115
112
  }
116
113
 
117
114
  .overlay-active {
@@ -125,7 +122,7 @@ onDestroy(() => {
125
122
 
126
123
  .modal-content {
127
124
  pointer-events: auto;
128
- background-color: var(--content-background-color, #ffffff);
125
+ background-color: var(--modal-content-background-color, #ffffff);
129
126
  cursor: auto;
130
127
  display: flex;
131
128
  flex-direction: column;
@@ -0,0 +1,73 @@
1
+ <script>import { createEventDispatcher } from "svelte";
2
+ export let stepIndex;
3
+ export let label;
4
+ export let icon;
5
+ const dispatch = createEventDispatcher();
6
+ function handleStepClick() {
7
+ dispatch("handleStepClick", { selectedIndex: stepIndex });
8
+ }
9
+ </script>
10
+
11
+ <div class="step" on:click={handleStepClick} role="button" tabindex="0" on:keydown>
12
+ {#if icon !== null}
13
+ <div class="step-icon-container">
14
+ <img class="step-icon" src={icon} alt="" />
15
+ </div>
16
+ {:else}
17
+ <div class="step-index-container">
18
+ <div class={'step-index-text'}>
19
+ {stepIndex}
20
+ </div>
21
+ </div>
22
+ {/if}
23
+ <div class={'step-text'}>
24
+ {label}
25
+ </div>
26
+ <div class={'separator'} />
27
+ </div>
28
+
29
+ <style>
30
+ .step {
31
+ display: flex;
32
+ flex-direction: var(--step-flex-direction, row);
33
+ align-items: center;
34
+ }
35
+
36
+ .step-index-container {
37
+ display: flex;
38
+ justify-content: center;
39
+ align-items: center;
40
+ height: var(--step-index-container-height, 30px);
41
+ width: var(--step-index-container-width, 30px);
42
+ border-radius: var(--step-index-container-radius, 50%);
43
+ background-color: var(--step-index-container-background-color, #798fa5cc);
44
+ }
45
+
46
+ .separator {
47
+ display: var(--separator-display, block);
48
+ height: var(--separator-height, 1px);
49
+ width: var(--separator-width, 50px);
50
+ margin: var(--separator-margin, 0px 12px 0px 12px);
51
+ background-image: var(
52
+ --separator-background-image,
53
+ repeating-linear-gradient(
54
+ to right,
55
+ var(--separator-background-image-color, #798fa5cc),
56
+ var(--separator-background-image-color, #798fa5cc) 6px,
57
+ transparent 6px,
58
+ transparent 10px
59
+ )
60
+ );
61
+ }
62
+
63
+ .step-text {
64
+ margin: var(--step-text-margin, 0px 0px 0px 12px);
65
+ font-size: var(--step-text-font-size, 12px);
66
+ color: var(--step-text-color, #798fa5cc);
67
+ }
68
+
69
+ .step-index-text {
70
+ font-size: var(--step-index-font-size, 14px);
71
+ color: var(--step-index-color, white);
72
+ }
73
+ </style>
@@ -0,0 +1,21 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ stepIndex: number;
5
+ label: string;
6
+ icon: string | null;
7
+ };
8
+ events: {
9
+ keydown: KeyboardEvent;
10
+ handleStepClick: CustomEvent<any>;
11
+ } & {
12
+ [evt: string]: CustomEvent<any>;
13
+ };
14
+ slots: {};
15
+ };
16
+ export type StepProps = typeof __propDef.props;
17
+ export type StepEvents = typeof __propDef.events;
18
+ export type StepSlots = typeof __propDef.slots;
19
+ export default class Step extends SvelteComponent<StepProps, StepEvents, StepSlots> {
20
+ }
21
+ export {};
@@ -0,0 +1,55 @@
1
+ <script>import Step from "./Step.svelte";
2
+ export let properties;
3
+ </script>
4
+
5
+ <div class="container">
6
+ {#each properties.steps as currentStep, stepIndex}
7
+ <div
8
+ class:active-step={properties.currentStepIndex === stepIndex}
9
+ class:completed-step={properties.currentStepIndex > stepIndex}
10
+ class="step-container"
11
+ >
12
+ <Step
13
+ on:handleStepClick
14
+ label={currentStep.label}
15
+ icon={currentStep.icon ?? null}
16
+ stepIndex={stepIndex + 1}
17
+ />
18
+ </div>
19
+ {/each}
20
+ </div>
21
+
22
+ <style>
23
+ .container {
24
+ display: flex;
25
+ flex-direction: var(--container-flex-direction, row);
26
+ align-items: center;
27
+ }
28
+
29
+ .step-container:last-child {
30
+ --separator-display: none;
31
+ }
32
+
33
+ .step-container {
34
+ display: flex;
35
+ align-items: center;
36
+ }
37
+
38
+ .active-step {
39
+ --step-text-color: var(--step-text-active-color, #2f3841);
40
+ --separator-background-image-color: var(--separator-background-image-active-color, #2f3841);
41
+ --step-index-container-background-color: var(
42
+ --step-index-container-active-background-color,
43
+ #2f3841
44
+ );
45
+ }
46
+
47
+ .completed-step {
48
+ --step-text-color: var(--step-text-completed-color, #24aa5a);
49
+ --separator-background-image-color: var(--separator-background-image-completed-color, #24aa5a);
50
+ --step-index-container-background-color: var(
51
+ --step-index-container-completed-background-color,
52
+ #24aa5a
53
+ );
54
+ }
55
+ </style>
@@ -0,0 +1,19 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { StepperProperties } from './properties';
3
+ declare const __propDef: {
4
+ props: {
5
+ properties: StepperProperties;
6
+ };
7
+ events: {
8
+ handleStepClick: CustomEvent<any>;
9
+ } & {
10
+ [evt: string]: CustomEvent<any>;
11
+ };
12
+ slots: {};
13
+ };
14
+ export type StepperProps = typeof __propDef.props;
15
+ export type StepperEvents = typeof __propDef.events;
16
+ export type StepperSlots = typeof __propDef.slots;
17
+ export default class Stepper extends SvelteComponent<StepperProps, StepperEvents, StepperSlots> {
18
+ }
19
+ export {};
@@ -0,0 +1,8 @@
1
+ export type StepperProperties = {
2
+ steps: Array<Step>;
3
+ currentStepIndex: number;
4
+ };
5
+ export type Step = {
6
+ label: string;
7
+ icon?: string;
8
+ };
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.d.ts CHANGED
@@ -18,6 +18,8 @@ export { default as Toggle } from './Toggle/Toggle.svelte';
18
18
  export { default as Accordion } from './Accordion/Accordion.svelte';
19
19
  export { default as CheckListItem } from './CheckListItem/CheckListItem.svelte';
20
20
  export { default as Table } from './Table/Table.svelte';
21
+ export { default as Stepper } from './Stepper/Stepper.svelte';
22
+ export { default as Step } from './Stepper/Step.svelte';
21
23
  export type { ButtonProperties } from './Button/properties';
22
24
  export type { ModalProperties, ModalAlign, ModalSize } from './Modal/properties';
23
25
  export type { InputProperties } from './Input/properties';
@@ -36,6 +38,7 @@ export type { CarouselProperties } from './Carousel/properties';
36
38
  export type { BadgeProperties } from './Badge/properties';
37
39
  export type { BannerProperties } from './Banner/properties';
38
40
  export type { TableProperties } from './Table/properties';
41
+ export type { StepperProperties } from './Stepper/properties';
39
42
  export { defaultIconProperties } from './Icon/properties';
40
43
  export { defaultButtonProperties } from './Button/properties';
41
44
  export { defaultModalProperties } from './Modal/properties';
package/dist/index.js CHANGED
@@ -18,6 +18,8 @@ export { default as Toggle } from './Toggle/Toggle.svelte';
18
18
  export { default as Accordion } from './Accordion/Accordion.svelte';
19
19
  export { default as CheckListItem } from './CheckListItem/CheckListItem.svelte';
20
20
  export { default as Table } from './Table/Table.svelte';
21
+ export { default as Stepper } from './Stepper/Stepper.svelte';
22
+ export { default as Step } from './Stepper/Step.svelte';
21
23
  export { defaultIconProperties } from './Icon/properties';
22
24
  export { defaultButtonProperties } from './Button/properties';
23
25
  export { defaultModalProperties } from './Modal/properties';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/svelte-ui-components",
3
- "version": "1.3.0",
3
+ "version": "1.5.0",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run package",
@@ -54,7 +54,7 @@
54
54
  "svelte-check": "^3.6.0",
55
55
  "tslib": "^2.6.2",
56
56
  "typescript": "^5.2.2",
57
- "vite": "^4.5.0",
57
+ "vite": "^4.5.2",
58
58
  "vitest": "^0.34.6",
59
59
  "type-decoder": "^1.2.0"
60
60
  },