@juspay/svelte-ui-components 2.9.0 → 2.11.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 +337 -77
- package/dist/Accordion/Accordion.svelte +4 -2
- package/dist/Accordion/Accordion.svelte.d.ts +2 -4
- package/dist/Accordion/properties.d.ts +6 -0
- package/dist/Accordion/properties.js +1 -0
- package/dist/Animations/ModalAnimation.svelte +11 -9
- package/dist/Avatar/Avatar.svelte +122 -0
- package/dist/Avatar/Avatar.svelte.d.ts +4 -0
- package/dist/Avatar/properties.d.ts +15 -0
- package/dist/Avatar/properties.js +1 -0
- package/dist/Badge/Badge.svelte +2 -2
- package/dist/Badge/properties.d.ts +1 -0
- package/dist/Banner/Banner.svelte +132 -48
- package/dist/Banner/Banner.svelte.d.ts +1 -1
- package/dist/Banner/properties.d.ts +8 -3
- package/dist/Book/Book.svelte +281 -0
- package/dist/Book/Book.svelte.d.ts +4 -0
- package/dist/Book/properties.d.ts +24 -0
- package/dist/Book/properties.js +1 -0
- package/dist/BrandLoader/BrandLoader.svelte +3 -3
- package/dist/BrandLoader/properties.d.ts +1 -0
- package/dist/Browser/Browser.svelte +193 -0
- package/dist/Browser/Browser.svelte.d.ts +3 -0
- package/dist/Browser/properties.d.ts +16 -0
- package/dist/Browser/properties.js +1 -0
- package/dist/Button/Button.svelte +20 -7
- package/dist/Button/properties.d.ts +7 -4
- package/dist/Calendar/Calendar.svelte +476 -0
- package/dist/Calendar/Calendar.svelte.d.ts +4 -0
- package/dist/Calendar/properties.d.ts +30 -0
- package/dist/Calendar/properties.js +1 -0
- package/dist/Carousel/Carousel.svelte +19 -16
- package/dist/Carousel/properties.d.ts +1 -0
- package/dist/CheckListItem/CheckListItem.svelte +31 -26
- package/dist/CheckListItem/properties.d.ts +4 -1
- package/dist/Checkbox/Checkbox.svelte +157 -0
- package/dist/Checkbox/Checkbox.svelte.d.ts +4 -0
- package/dist/Checkbox/properties.d.ts +17 -0
- package/dist/Checkbox/properties.js +1 -0
- package/dist/Choicebox/Choicebox.svelte +85 -0
- package/dist/Choicebox/Choicebox.svelte.d.ts +4 -0
- package/dist/Choicebox/properties.d.ts +14 -0
- package/dist/Choicebox/properties.js +1 -0
- package/dist/CommandMenu/CommandMenu.svelte +452 -0
- package/dist/CommandMenu/CommandMenu.svelte.d.ts +4 -0
- package/dist/CommandMenu/properties.d.ts +26 -0
- package/dist/CommandMenu/properties.js +1 -0
- package/dist/ContextMenu/ContextMenu.svelte +308 -0
- package/dist/ContextMenu/ContextMenu.svelte.d.ts +4 -0
- package/dist/ContextMenu/properties.d.ts +26 -0
- package/dist/ContextMenu/properties.js +1 -0
- package/dist/Gauge/Gauge.svelte +70 -0
- package/dist/Gauge/Gauge.svelte.d.ts +4 -0
- package/dist/Gauge/properties.d.ts +9 -0
- package/dist/Gauge/properties.js +1 -0
- package/dist/GridItem/GridItem.svelte +5 -4
- package/dist/GridItem/properties.d.ts +1 -0
- package/dist/Icon/Icon.svelte +3 -3
- package/dist/Icon/properties.d.ts +1 -0
- package/dist/IconStack/IconStack.svelte +3 -3
- package/dist/IconStack/properties.d.ts +1 -0
- package/dist/Img/Img.svelte +5 -3
- package/dist/Img/properties.d.ts +5 -1
- package/dist/Input/Input.svelte +12 -6
- package/dist/Input/properties.d.ts +1 -0
- package/dist/InputButton/InputButton.svelte +4 -3
- package/dist/InputButton/properties.d.ts +5 -6
- package/dist/KeyboardInput/KeyboardInput.svelte +93 -0
- package/dist/KeyboardInput/KeyboardInput.svelte.d.ts +4 -0
- package/dist/KeyboardInput/properties.d.ts +12 -0
- package/dist/KeyboardInput/properties.js +1 -0
- package/dist/ListItem/ListItem.svelte +31 -28
- package/dist/ListItem/properties.d.ts +1 -0
- package/dist/Loader/Loader.svelte +10 -6
- package/dist/Loader/Loader.svelte.d.ts +3 -25
- package/dist/Loader/properties.d.ts +3 -0
- package/dist/Loader/properties.js +1 -0
- package/dist/LoadingDots/LoadingDots.svelte +64 -0
- package/dist/LoadingDots/LoadingDots.svelte.d.ts +3 -0
- package/dist/LoadingDots/properties.d.ts +8 -0
- package/dist/LoadingDots/properties.js +1 -0
- package/dist/Menu/Menu.svelte +349 -0
- package/dist/Menu/Menu.svelte.d.ts +4 -0
- package/dist/Menu/properties.d.ts +24 -0
- package/dist/Menu/properties.js +1 -0
- package/dist/Modal/Modal.svelte +10 -9
- package/dist/Modal/properties.d.ts +1 -0
- package/dist/Pagination/Pagination.svelte +152 -0
- package/dist/Pagination/Pagination.svelte.d.ts +4 -0
- package/dist/Pagination/properties.d.ts +14 -0
- package/dist/Pagination/properties.js +1 -0
- package/dist/Phone/Phone.svelte +234 -0
- package/dist/Phone/Phone.svelte.d.ts +3 -0
- package/dist/Phone/properties.d.ts +11 -0
- package/dist/Phone/properties.js +1 -0
- package/dist/Pill/Pill.svelte +130 -0
- package/dist/Pill/Pill.svelte.d.ts +4 -0
- package/dist/Pill/properties.d.ts +16 -0
- package/dist/Pill/properties.js +1 -0
- package/dist/Progress/Progress.svelte +68 -0
- package/dist/Progress/Progress.svelte.d.ts +4 -0
- package/dist/Progress/properties.d.ts +10 -0
- package/dist/Progress/properties.js +1 -0
- package/dist/Radio/Radio.svelte +128 -0
- package/dist/Radio/Radio.svelte.d.ts +4 -0
- package/dist/Radio/properties.d.ts +15 -0
- package/dist/Radio/properties.js +1 -0
- package/dist/RelativeTime/RelativeTime.svelte +117 -0
- package/dist/RelativeTime/RelativeTime.svelte.d.ts +4 -0
- package/dist/RelativeTime/properties.d.ts +13 -0
- package/dist/RelativeTime/properties.js +1 -0
- package/dist/Scroller/Scroller.svelte +389 -0
- package/dist/Scroller/Scroller.svelte.d.ts +4 -0
- package/dist/Scroller/properties.d.ts +30 -0
- package/dist/Scroller/properties.js +1 -0
- package/dist/Select/Select.svelte +382 -344
- package/dist/Select/Select.svelte.d.ts +1 -1
- package/dist/Select/properties.d.ts +16 -26
- package/dist/Sheet/Sheet.svelte +264 -0
- package/dist/Sheet/Sheet.svelte.d.ts +4 -0
- package/dist/Sheet/properties.d.ts +19 -0
- package/dist/Sheet/properties.js +1 -0
- package/dist/Shimmer/Shimmer.svelte +44 -0
- package/dist/Shimmer/Shimmer.svelte.d.ts +4 -0
- package/dist/Shimmer/properties.d.ts +4 -0
- package/dist/Shimmer/properties.js +1 -0
- package/dist/Slider/Slider.svelte +144 -0
- package/dist/Slider/Slider.svelte.d.ts +4 -0
- package/dist/Slider/properties.d.ts +17 -0
- package/dist/Slider/properties.js +1 -0
- package/dist/Snippet/Snippet.svelte +123 -0
- package/dist/Snippet/Snippet.svelte.d.ts +4 -0
- package/dist/Snippet/properties.d.ts +15 -0
- package/dist/Snippet/properties.js +1 -0
- package/dist/SplitButton/SplitButton.svelte +135 -0
- package/dist/SplitButton/SplitButton.svelte.d.ts +4 -0
- package/dist/SplitButton/properties.d.ts +17 -0
- package/dist/SplitButton/properties.js +1 -0
- package/dist/Status/Status.svelte +5 -3
- package/dist/Status/properties.d.ts +1 -0
- package/dist/Stepper/Step.svelte +3 -3
- package/dist/Stepper/Stepper.svelte +3 -3
- package/dist/Stepper/properties.d.ts +2 -0
- package/dist/Table/Table.svelte +15 -8
- package/dist/Table/properties.d.ts +1 -0
- package/dist/Tabs/Tabs.svelte +240 -0
- package/dist/Tabs/Tabs.svelte.d.ts +4 -0
- package/dist/Tabs/properties.d.ts +16 -0
- package/dist/Tabs/properties.js +1 -0
- package/dist/ThemeSwitcher/ThemeSwitcher.svelte +249 -0
- package/dist/ThemeSwitcher/ThemeSwitcher.svelte.d.ts +4 -0
- package/dist/ThemeSwitcher/properties.d.ts +19 -0
- package/dist/ThemeSwitcher/properties.js +1 -0
- package/dist/Toast/Toast.svelte +25 -30
- package/dist/Toast/properties.d.ts +1 -0
- package/dist/Toggle/Toggle.svelte +2 -2
- package/dist/Toggle/properties.d.ts +1 -0
- package/dist/Toolbar/Toolbar.svelte +8 -7
- package/dist/Toolbar/properties.d.ts +1 -0
- package/dist/Tooltip/Tooltip.svelte +153 -0
- package/dist/Tooltip/Tooltip.svelte.d.ts +4 -0
- package/dist/Tooltip/properties.d.ts +13 -0
- package/dist/Tooltip/properties.js +1 -0
- package/dist/assets/battery.svg +5 -0
- package/dist/assets/checkmark.svg +3 -0
- package/dist/assets/chevron-down-sm.svg +3 -0
- package/dist/assets/chevron-down.svg +3 -0
- package/dist/assets/chevron-left-lg.svg +3 -0
- package/dist/assets/chevron-left.svg +3 -0
- package/dist/assets/chevron-right-lg.svg +3 -0
- package/dist/assets/chevron-right.svg +3 -0
- package/dist/assets/chevron-up.svg +3 -0
- package/dist/assets/close.svg +4 -0
- package/dist/assets/copy.svg +4 -0
- package/dist/assets/error-circle.svg +5 -0
- package/dist/assets/lock.svg +3 -0
- package/dist/assets/minus.svg +3 -0
- package/dist/assets/monitor.svg +5 -0
- package/dist/assets/moon.svg +3 -0
- package/dist/assets/palette.svg +7 -0
- package/dist/assets/search.svg +4 -0
- package/dist/assets/signal.svg +6 -0
- package/dist/assets/sun.svg +11 -0
- package/dist/assets/wifi.svg +3 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.js +27 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +18 -4
- package/package.json +26 -1
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { PhoneProperties } from './properties';
|
|
3
|
+
import signalSvg from '../assets/signal.svg?raw';
|
|
4
|
+
import wifiSvg from '../assets/wifi.svg?raw';
|
|
5
|
+
import batterySvg from '../assets/battery.svg?raw';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
children,
|
|
9
|
+
variant = 'modern',
|
|
10
|
+
showStatusBar = true,
|
|
11
|
+
showHomeBar = true,
|
|
12
|
+
testId,
|
|
13
|
+
classes
|
|
14
|
+
}: PhoneProperties = $props();
|
|
15
|
+
|
|
16
|
+
let isModern = $derived(variant === 'modern');
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<div class="phone-wrapper {classes ?? ''}" data-pw={typeof testId === 'string' ? testId : null}>
|
|
20
|
+
<div class="side-buttons-left">
|
|
21
|
+
<div class="side-button volume-up"></div>
|
|
22
|
+
<div class="side-button volume-down"></div>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<div class="side-buttons-right">
|
|
26
|
+
<div class="side-button power"></div>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<div class="phone-frame">
|
|
30
|
+
<div class="phone-screen" class:modern={isModern} class:classic={!isModern}>
|
|
31
|
+
{#if showStatusBar}
|
|
32
|
+
<div class="status-bar">
|
|
33
|
+
<div class="status-bar-left">
|
|
34
|
+
<span class="status-time">9:41</span>
|
|
35
|
+
</div>
|
|
36
|
+
<!-- eslint-disable svelte/no-at-html-tags -->
|
|
37
|
+
<div class="status-bar-right">
|
|
38
|
+
<span class="status-icon">{@html signalSvg}</span>
|
|
39
|
+
<span class="status-icon">{@html wifiSvg}</span>
|
|
40
|
+
<span class="status-icon battery-icon">{@html batterySvg}</span>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
{/if}
|
|
44
|
+
|
|
45
|
+
{#if isModern}
|
|
46
|
+
<div class="notch"></div>
|
|
47
|
+
{/if}
|
|
48
|
+
|
|
49
|
+
<div class="screen-content">
|
|
50
|
+
{#if typeof children === 'function'}
|
|
51
|
+
{@render children()}
|
|
52
|
+
{/if}
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
{#if isModern && showHomeBar}
|
|
56
|
+
<div class="home-bar-container">
|
|
57
|
+
<div class="home-bar"></div>
|
|
58
|
+
</div>
|
|
59
|
+
{/if}
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
{#if !isModern}
|
|
63
|
+
<div class="home-button-container">
|
|
64
|
+
<div class="home-button"></div>
|
|
65
|
+
</div>
|
|
66
|
+
{/if}
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
<style>
|
|
71
|
+
.phone-wrapper {
|
|
72
|
+
display: inline-block;
|
|
73
|
+
position: relative;
|
|
74
|
+
transform-origin: top left;
|
|
75
|
+
transform: scale(var(--phone-scale, 1));
|
|
76
|
+
rotate: var(--phone-rotation, 0deg);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.phone-frame {
|
|
80
|
+
position: relative;
|
|
81
|
+
width: var(--phone-frame-width, 375px);
|
|
82
|
+
border-radius: var(--phone-frame-border-radius, 50px);
|
|
83
|
+
padding: var(--phone-frame-padding, 12px);
|
|
84
|
+
box-sizing: border-box;
|
|
85
|
+
background: var(--phone-frame-color, black);
|
|
86
|
+
box-shadow: var(
|
|
87
|
+
--phone-frame-shadow,
|
|
88
|
+
0 20px 60px rgba(0, 0, 0, 0.3),
|
|
89
|
+
0 0 0 1px rgba(0, 0, 0, 0.1)
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.phone-screen {
|
|
94
|
+
position: relative;
|
|
95
|
+
border-radius: var(--phone-screen-border-radius, 38px);
|
|
96
|
+
background: var(--phone-screen-background, #000);
|
|
97
|
+
overflow: hidden;
|
|
98
|
+
display: flex;
|
|
99
|
+
flex-direction: column;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.phone-screen.modern {
|
|
103
|
+
aspect-ratio: var(--phone-screen-aspect-ratio, 9 / 19.5);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.phone-screen.classic {
|
|
107
|
+
aspect-ratio: var(--phone-screen-aspect-ratio, 9 / 16);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.status-bar {
|
|
111
|
+
display: flex;
|
|
112
|
+
justify-content: space-between;
|
|
113
|
+
align-items: center;
|
|
114
|
+
height: var(--phone-status-bar-height, 44px);
|
|
115
|
+
padding: 0 24px;
|
|
116
|
+
color: var(--phone-status-bar-color, #fff);
|
|
117
|
+
font-size: var(--phone-status-bar-font-size, 14px);
|
|
118
|
+
background: var(--phone-status-bar-background, transparent);
|
|
119
|
+
flex-shrink: 0;
|
|
120
|
+
z-index: 2;
|
|
121
|
+
position: relative;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.status-bar-left {
|
|
125
|
+
display: flex;
|
|
126
|
+
align-items: center;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.status-time {
|
|
130
|
+
font-weight: 600;
|
|
131
|
+
letter-spacing: 0.5px;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.status-bar-right {
|
|
135
|
+
display: flex;
|
|
136
|
+
align-items: center;
|
|
137
|
+
gap: 6px;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.status-icon {
|
|
141
|
+
display: inline-flex;
|
|
142
|
+
width: 16px;
|
|
143
|
+
height: 12px;
|
|
144
|
+
color: inherit;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.status-icon :global(svg) {
|
|
148
|
+
width: 100%;
|
|
149
|
+
height: 100%;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.battery-icon {
|
|
153
|
+
width: 24px;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.notch {
|
|
157
|
+
width: var(--phone-notch-width, 120px);
|
|
158
|
+
height: var(--phone-notch-height, 32px);
|
|
159
|
+
background: var(--phone-notch-background, var(--phone-frame-color, black));
|
|
160
|
+
border-radius: var(--phone-notch-border-radius, 20px);
|
|
161
|
+
position: absolute;
|
|
162
|
+
top: 10px;
|
|
163
|
+
left: 50%;
|
|
164
|
+
transform: translateX(-50%);
|
|
165
|
+
z-index: 3;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.screen-content {
|
|
169
|
+
flex: 1;
|
|
170
|
+
overflow: var(--phone-content-overflow, hidden);
|
|
171
|
+
position: relative;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.home-bar-container {
|
|
175
|
+
display: flex;
|
|
176
|
+
justify-content: center;
|
|
177
|
+
padding: 8px 0;
|
|
178
|
+
flex-shrink: 0;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.home-bar {
|
|
182
|
+
width: var(--phone-home-bar-width, 134px);
|
|
183
|
+
height: var(--phone-home-bar-height, 5px);
|
|
184
|
+
background: var(--phone-home-bar-color, #fff);
|
|
185
|
+
border-radius: var(--phone-home-bar-radius, 3px);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.home-button-container {
|
|
189
|
+
display: flex;
|
|
190
|
+
justify-content: center;
|
|
191
|
+
padding: 10px 0;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.home-button {
|
|
195
|
+
width: var(--phone-home-button-size, 50px);
|
|
196
|
+
height: var(--phone-home-button-size, 50px);
|
|
197
|
+
border-radius: 50%;
|
|
198
|
+
border: 2px solid var(--phone-home-button-border-color, #555);
|
|
199
|
+
background: transparent;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.side-buttons-left {
|
|
203
|
+
position: absolute;
|
|
204
|
+
top: 120px;
|
|
205
|
+
left: -3px;
|
|
206
|
+
display: flex;
|
|
207
|
+
flex-direction: column;
|
|
208
|
+
gap: 12px;
|
|
209
|
+
z-index: 1;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.side-buttons-right {
|
|
213
|
+
position: absolute;
|
|
214
|
+
top: 140px;
|
|
215
|
+
right: -3px;
|
|
216
|
+
z-index: 1;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.side-button {
|
|
220
|
+
background: var(--phone-side-button-color, var(--phone-frame-color, black));
|
|
221
|
+
border-radius: 2px;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.side-button.volume-up,
|
|
225
|
+
.side-button.volume-down {
|
|
226
|
+
width: 3px;
|
|
227
|
+
height: 30px;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.side-button.power {
|
|
231
|
+
width: 3px;
|
|
232
|
+
height: 40px;
|
|
233
|
+
}
|
|
234
|
+
</style>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export type PhoneVariant = 'modern' | 'classic';
|
|
3
|
+
export type PhoneProperties = OptionalPhoneProperties;
|
|
4
|
+
export type OptionalPhoneProperties = {
|
|
5
|
+
children?: Snippet;
|
|
6
|
+
variant?: PhoneVariant;
|
|
7
|
+
showStatusBar?: boolean;
|
|
8
|
+
showHomeBar?: boolean;
|
|
9
|
+
testId?: string;
|
|
10
|
+
classes?: string;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { PillProperties } from './properties';
|
|
3
|
+
import Button from '../Button/Button.svelte';
|
|
4
|
+
import closeSvg from '../assets/close.svg?raw';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
text,
|
|
8
|
+
dismissible = false,
|
|
9
|
+
disabled = false,
|
|
10
|
+
testId,
|
|
11
|
+
dismissIcon,
|
|
12
|
+
onclick,
|
|
13
|
+
ondismiss,
|
|
14
|
+
classes
|
|
15
|
+
}: PillProperties = $props();
|
|
16
|
+
|
|
17
|
+
let interactive = $derived(typeof onclick === 'function');
|
|
18
|
+
|
|
19
|
+
function handleClick(event: MouseEvent): void {
|
|
20
|
+
if (disabled) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
onclick?.(event);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function handleKeydown(event: KeyboardEvent): void {
|
|
27
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
28
|
+
event.preventDefault();
|
|
29
|
+
if (event.currentTarget instanceof HTMLElement) {
|
|
30
|
+
event.currentTarget.click();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function handleDismiss(event: MouseEvent): void {
|
|
36
|
+
event.stopPropagation();
|
|
37
|
+
if (disabled) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
ondismiss?.();
|
|
41
|
+
}
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
|
45
|
+
<div
|
|
46
|
+
class="pill {classes ?? ''}"
|
|
47
|
+
class:disabled
|
|
48
|
+
onclick={interactive ? handleClick : null}
|
|
49
|
+
onkeydown={interactive ? handleKeydown : null}
|
|
50
|
+
role={interactive ? 'button' : null}
|
|
51
|
+
tabindex={interactive ? 0 : null}
|
|
52
|
+
aria-disabled={interactive && disabled ? true : null}
|
|
53
|
+
data-pw={typeof testId === 'string' ? testId : null}
|
|
54
|
+
>
|
|
55
|
+
<span class="pill-text">{text}</span>
|
|
56
|
+
{#if dismissible}
|
|
57
|
+
<div class="pill-dismiss">
|
|
58
|
+
<Button
|
|
59
|
+
{disabled}
|
|
60
|
+
onclick={handleDismiss}
|
|
61
|
+
ariaLabel="Dismiss"
|
|
62
|
+
{...typeof testId === 'string' ? { testId: `${testId}-dismiss` } : {}}
|
|
63
|
+
>
|
|
64
|
+
{#if typeof dismissIcon === 'function'}
|
|
65
|
+
{@render dismissIcon()}
|
|
66
|
+
{:else}
|
|
67
|
+
<!-- eslint-disable svelte/no-at-html-tags -->
|
|
68
|
+
{@html closeSvg}
|
|
69
|
+
{/if}
|
|
70
|
+
</Button>
|
|
71
|
+
</div>
|
|
72
|
+
{/if}
|
|
73
|
+
</div>
|
|
74
|
+
|
|
75
|
+
<style>
|
|
76
|
+
.pill {
|
|
77
|
+
display: inline-flex;
|
|
78
|
+
align-items: center;
|
|
79
|
+
gap: var(--pill-gap, 4px);
|
|
80
|
+
background-color: var(--pill-background, #e0e0e0);
|
|
81
|
+
color: var(--pill-color, #333333);
|
|
82
|
+
font-size: var(--pill-font-size, 13px);
|
|
83
|
+
font-weight: var(--pill-font-weight, 500);
|
|
84
|
+
font-family: var(--pill-font-family);
|
|
85
|
+
padding: var(--pill-padding, 6px 10px);
|
|
86
|
+
border-radius: var(--pill-border-radius, 999px);
|
|
87
|
+
border: var(--pill-border, none);
|
|
88
|
+
cursor: var(--pill-cursor, pointer);
|
|
89
|
+
max-width: var(--pill-max-width);
|
|
90
|
+
line-height: 1;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.pill:hover:not(.disabled) {
|
|
94
|
+
background-color: var(--pill-hover-background, var(--pill-background, #d0d0d0));
|
|
95
|
+
color: var(--pill-hover-color, var(--pill-color, #333333));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.pill.disabled {
|
|
99
|
+
opacity: var(--pill-disabled-opacity, 0.4);
|
|
100
|
+
cursor: var(--pill-disabled-cursor, not-allowed);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.pill-text {
|
|
104
|
+
overflow: hidden;
|
|
105
|
+
text-overflow: var(--pill-text-overflow, ellipsis);
|
|
106
|
+
white-space: nowrap;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.pill-dismiss {
|
|
110
|
+
--button-color: transparent;
|
|
111
|
+
--button-border: none;
|
|
112
|
+
--button-padding: 0;
|
|
113
|
+
--button-text-color: var(--pill-dismiss-color, currentColor);
|
|
114
|
+
--button-hover-color: transparent;
|
|
115
|
+
--button-hover-text-color: var(
|
|
116
|
+
--pill-dismiss-hover-color,
|
|
117
|
+
var(--pill-dismiss-color, currentColor)
|
|
118
|
+
);
|
|
119
|
+
--cursor: inherit;
|
|
120
|
+
display: inline-flex;
|
|
121
|
+
align-items: center;
|
|
122
|
+
justify-content: center;
|
|
123
|
+
flex-shrink: 0;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.pill-dismiss :global(svg) {
|
|
127
|
+
width: var(--pill-dismiss-size, 14px);
|
|
128
|
+
height: var(--pill-dismiss-size, 14px);
|
|
129
|
+
}
|
|
130
|
+
</style>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export type PillProperties = MandatoryPillProperties & OptionalPillProperties & PillEventProperties;
|
|
3
|
+
export type MandatoryPillProperties = {
|
|
4
|
+
text: string;
|
|
5
|
+
};
|
|
6
|
+
export type OptionalPillProperties = {
|
|
7
|
+
dismissible?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
testId?: string;
|
|
10
|
+
dismissIcon?: Snippet;
|
|
11
|
+
classes?: string;
|
|
12
|
+
};
|
|
13
|
+
export type PillEventProperties = {
|
|
14
|
+
onclick?: (event: MouseEvent) => void;
|
|
15
|
+
ondismiss?: () => void;
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ProgressProperties } from './properties';
|
|
3
|
+
|
|
4
|
+
let { value, max = 100, showLabel = false, testId, classes }: ProgressProperties = $props();
|
|
5
|
+
|
|
6
|
+
let percentage = $derived(Math.min(100, Math.max(0, (value / max) * 100)));
|
|
7
|
+
let isIndeterminate = $derived(value < 0);
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<div class="container {classes ?? ''}" data-pw={typeof testId === 'string' ? testId : null}>
|
|
11
|
+
<div class="track">
|
|
12
|
+
<div
|
|
13
|
+
class="bar"
|
|
14
|
+
class:indeterminate={isIndeterminate}
|
|
15
|
+
style:width={isIndeterminate ? null : `${percentage}%`}
|
|
16
|
+
></div>
|
|
17
|
+
</div>
|
|
18
|
+
{#if showLabel && !isIndeterminate}
|
|
19
|
+
<div class="label">{Math.round(percentage)}%</div>
|
|
20
|
+
{/if}
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
<style>
|
|
24
|
+
.container {
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
width: var(--progress-container-width, 100%);
|
|
28
|
+
padding: var(--progress-container-padding, 0);
|
|
29
|
+
gap: var(--progress-container-gap, 8px);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.track {
|
|
33
|
+
flex: 1;
|
|
34
|
+
height: var(--progress-track-height, 8px);
|
|
35
|
+
background: var(--progress-track-background, #e0e0e0);
|
|
36
|
+
border-radius: var(--progress-track-border-radius, 4px);
|
|
37
|
+
overflow: hidden;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.bar {
|
|
41
|
+
height: 100%;
|
|
42
|
+
background: var(--progress-bar-background, #2196f3);
|
|
43
|
+
border-radius: var(--progress-bar-border-radius, 4px);
|
|
44
|
+
transition: var(--progress-bar-transition, width 0.3s ease);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.bar.indeterminate {
|
|
48
|
+
width: 30%;
|
|
49
|
+
animation: indeterminate var(--progress-indeterminate-duration, 1.5s) ease-in-out infinite;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.label {
|
|
53
|
+
font-size: var(--progress-label-font-size, 14px);
|
|
54
|
+
font-weight: var(--progress-label-font-weight, 500);
|
|
55
|
+
color: var(--progress-label-color, #333);
|
|
56
|
+
font-family: var(--progress-label-font-family, inherit);
|
|
57
|
+
margin: var(--progress-label-margin, 0);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@keyframes indeterminate {
|
|
61
|
+
0% {
|
|
62
|
+
transform: translateX(-100%);
|
|
63
|
+
}
|
|
64
|
+
100% {
|
|
65
|
+
transform: translateX(400%);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
</style>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type ProgressProperties = MandatoryProgressProperties & OptionalProgressProperties;
|
|
2
|
+
export type MandatoryProgressProperties = {
|
|
3
|
+
value: number;
|
|
4
|
+
};
|
|
5
|
+
export type OptionalProgressProperties = {
|
|
6
|
+
max?: number;
|
|
7
|
+
showLabel?: boolean;
|
|
8
|
+
testId?: string;
|
|
9
|
+
classes?: string;
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { RadioProperties } from './properties';
|
|
3
|
+
|
|
4
|
+
let {
|
|
5
|
+
name,
|
|
6
|
+
value,
|
|
7
|
+
selectedValue = $bindable(''),
|
|
8
|
+
text = '',
|
|
9
|
+
disabled = false,
|
|
10
|
+
testId,
|
|
11
|
+
onchange,
|
|
12
|
+
classes
|
|
13
|
+
}: RadioProperties = $props();
|
|
14
|
+
|
|
15
|
+
let checked = $derived(selectedValue === value);
|
|
16
|
+
|
|
17
|
+
function handleChange(): void {
|
|
18
|
+
if (disabled) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
selectedValue = value;
|
|
22
|
+
onchange?.(value);
|
|
23
|
+
}
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<label
|
|
27
|
+
class="radio-container {classes ?? ''}"
|
|
28
|
+
class:disabled
|
|
29
|
+
data-pw={typeof testId === 'string' ? testId : null}
|
|
30
|
+
>
|
|
31
|
+
<input
|
|
32
|
+
type="radio"
|
|
33
|
+
class="radio-input"
|
|
34
|
+
{name}
|
|
35
|
+
{value}
|
|
36
|
+
{checked}
|
|
37
|
+
{disabled}
|
|
38
|
+
onchange={handleChange}
|
|
39
|
+
/>
|
|
40
|
+
<span class="radio-indicator" class:checked class:disabled>
|
|
41
|
+
<span class="radio-dot" class:checked class:disabled></span>
|
|
42
|
+
</span>
|
|
43
|
+
{#if text.length > 0}
|
|
44
|
+
<span class="radio-text" class:disabled>{text}</span>
|
|
45
|
+
{/if}
|
|
46
|
+
</label>
|
|
47
|
+
|
|
48
|
+
<style>
|
|
49
|
+
.radio-container {
|
|
50
|
+
display: var(--radio-container-display, inline-flex);
|
|
51
|
+
align-items: var(--radio-container-align-items, center);
|
|
52
|
+
gap: var(--radio-container-gap, 8px);
|
|
53
|
+
cursor: var(--radio-container-cursor, pointer);
|
|
54
|
+
opacity: var(--radio-container-opacity, 1);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.radio-container.disabled {
|
|
58
|
+
cursor: not-allowed;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.radio-input {
|
|
62
|
+
position: absolute;
|
|
63
|
+
opacity: 0;
|
|
64
|
+
width: 0;
|
|
65
|
+
height: 0;
|
|
66
|
+
margin: 0;
|
|
67
|
+
pointer-events: none;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.radio-indicator {
|
|
71
|
+
display: inline-flex;
|
|
72
|
+
align-items: center;
|
|
73
|
+
justify-content: center;
|
|
74
|
+
width: var(--radio-size, 20px);
|
|
75
|
+
height: var(--radio-size, 20px);
|
|
76
|
+
border: var(--radio-border, 2px solid #9e9e9e);
|
|
77
|
+
border-radius: var(--radio-border-radius, 50%);
|
|
78
|
+
background-color: var(--radio-background, #ffffff);
|
|
79
|
+
transition: var(--radio-transition, 0.2s);
|
|
80
|
+
box-sizing: border-box;
|
|
81
|
+
flex-shrink: 0;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.radio-indicator.checked {
|
|
85
|
+
border: var(--radio-selected-border, 2px solid #2196f3);
|
|
86
|
+
background-color: var(--radio-selected-background, #ffffff);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.radio-indicator.disabled {
|
|
90
|
+
border: var(--radio-disabled-border, 2px solid #cccccc);
|
|
91
|
+
background-color: var(--radio-disabled-background, #f5f5f5);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.radio-container:not(.disabled):hover .radio-indicator:not(.checked) {
|
|
95
|
+
border: var(--radio-hover-border, 2px solid #2196f3);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.radio-input:focus-visible + .radio-indicator {
|
|
99
|
+
box-shadow: var(--radio-focus-shadow, 0 0 0 3px rgba(33, 150, 243, 0.3));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.radio-dot {
|
|
103
|
+
width: 0;
|
|
104
|
+
height: 0;
|
|
105
|
+
border-radius: var(--radio-dot-border-radius, 50%);
|
|
106
|
+
background-color: var(--radio-dot-color, #2196f3);
|
|
107
|
+
transition: var(--radio-transition, 0.2s);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.radio-dot.checked {
|
|
111
|
+
width: var(--radio-dot-size, 10px);
|
|
112
|
+
height: var(--radio-dot-size, 10px);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.radio-dot.checked.disabled {
|
|
116
|
+
background-color: var(--radio-disabled-dot-color, #cccccc);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.radio-text {
|
|
120
|
+
font-size: var(--radio-text-font-size, 14px);
|
|
121
|
+
font-weight: var(--radio-text-font-weight, 400);
|
|
122
|
+
color: var(--radio-text-color, #333333);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.radio-text.disabled {
|
|
126
|
+
color: var(--radio-disabled-text-color, #999999);
|
|
127
|
+
}
|
|
128
|
+
</style>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type RadioProperties = MandatoryRadioProperties & OptionalRadioProperties & RadioEventProperties;
|
|
2
|
+
export type MandatoryRadioProperties = {
|
|
3
|
+
name: string;
|
|
4
|
+
value: string;
|
|
5
|
+
};
|
|
6
|
+
export type OptionalRadioProperties = {
|
|
7
|
+
selectedValue?: string;
|
|
8
|
+
text?: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
testId?: string;
|
|
11
|
+
classes?: string;
|
|
12
|
+
};
|
|
13
|
+
export type RadioEventProperties = {
|
|
14
|
+
onchange?: (value: string) => void;
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|