polymorph-ui-components 0.1.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 +354 -0
- package/dist/Accordion/Accordion.svelte +28 -0
- package/dist/Accordion/Accordion.svelte.d.ts +4 -0
- package/dist/Accordion/properties.d.ts +7 -0
- package/dist/Accordion/properties.js +1 -0
- package/dist/Animations/ModalAnimation.svelte +55 -0
- package/dist/Animations/ModalAnimation.svelte.d.ts +12 -0
- package/dist/Animations/OverlayAnimation.svelte +14 -0
- package/dist/Animations/OverlayAnimation.svelte.d.ts +7 -0
- 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 +53 -0
- package/dist/Badge/Badge.svelte.d.ts +4 -0
- package/dist/Badge/properties.d.ts +6 -0
- package/dist/Badge/properties.js +1 -0
- package/dist/Banner/Banner.svelte +158 -0
- package/dist/Banner/Banner.svelte.d.ts +4 -0
- package/dist/Banner/properties.d.ts +19 -0
- package/dist/Banner/properties.js +1 -0
- 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/Browser/Browser.svelte +176 -0
- package/dist/Browser/Browser.svelte.d.ts +3 -0
- package/dist/Browser/properties.d.ts +14 -0
- package/dist/Browser/properties.js +1 -0
- package/dist/Button/Button.svelte +153 -0
- package/dist/Button/Button.svelte.d.ts +4 -0
- package/dist/Button/properties.d.ts +24 -0
- package/dist/Button/properties.js +1 -0
- package/dist/Calendar/Calendar.svelte +477 -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 +258 -0
- package/dist/Carousel/Carousel.svelte.d.ts +4 -0
- package/dist/Carousel/properties.d.ts +20 -0
- package/dist/Carousel/properties.js +1 -0
- package/dist/CheckListItem/CheckListItem.svelte +65 -0
- package/dist/CheckListItem/CheckListItem.svelte.d.ts +4 -0
- package/dist/CheckListItem/properties.d.ts +15 -0
- package/dist/CheckListItem/properties.js +1 -0
- 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/ColorPicker/ColorPicker.svelte +583 -0
- package/dist/ColorPicker/ColorPicker.svelte.d.ts +4 -0
- package/dist/ColorPicker/properties.d.ts +15 -0
- package/dist/ColorPicker/properties.js +1 -0
- package/dist/Combobox/Combobox.svelte +432 -0
- package/dist/Combobox/Combobox.svelte.d.ts +6 -0
- package/dist/Combobox/properties.d.ts +42 -0
- package/dist/Combobox/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 +145 -0
- package/dist/GridItem/GridItem.svelte.d.ts +4 -0
- package/dist/GridItem/properties.d.ts +15 -0
- package/dist/GridItem/properties.js +1 -0
- package/dist/Icon/Icon.svelte +61 -0
- package/dist/Icon/Icon.svelte.d.ts +4 -0
- package/dist/Icon/properties.d.ts +12 -0
- package/dist/Icon/properties.js +1 -0
- package/dist/IconStack/IconStack.svelte +55 -0
- package/dist/IconStack/IconStack.svelte.d.ts +4 -0
- package/dist/IconStack/properties.d.ts +9 -0
- package/dist/IconStack/properties.js +1 -0
- package/dist/Img/Img.svelte +37 -0
- package/dist/Img/Img.svelte.d.ts +4 -0
- package/dist/Img/properties.d.ts +13 -0
- package/dist/Img/properties.js +1 -0
- package/dist/Input/Input.svelte +349 -0
- package/dist/Input/Input.svelte.d.ts +8 -0
- package/dist/Input/properties.d.ts +45 -0
- package/dist/Input/properties.js +1 -0
- package/dist/InputButton/InputButton.svelte +252 -0
- package/dist/InputButton/InputButton.svelte.d.ts +7 -0
- package/dist/InputButton/properties.d.ts +22 -0
- package/dist/InputButton/properties.js +1 -0
- 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 +309 -0
- package/dist/ListItem/ListItem.svelte.d.ts +4 -0
- package/dist/ListItem/properties.d.ts +34 -0
- package/dist/ListItem/properties.js +1 -0
- package/dist/Loader/Loader.svelte +90 -0
- package/dist/Loader/Loader.svelte.d.ts +4 -0
- package/dist/Loader/properties.d.ts +4 -0
- package/dist/Loader/properties.js +1 -0
- package/dist/LoadingDots/LoadingDots.svelte +59 -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 +356 -0
- package/dist/Menu/Menu.svelte.d.ts +4 -0
- package/dist/Menu/properties.d.ts +28 -0
- package/dist/Menu/properties.js +1 -0
- package/dist/Modal/Modal.svelte +357 -0
- package/dist/Modal/Modal.svelte.d.ts +4 -0
- package/dist/Modal/properties.d.ts +39 -0
- package/dist/Modal/properties.js +1 -0
- package/dist/Pagination/Pagination.svelte +148 -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 +124 -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 +109 -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 +390 -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 +472 -0
- package/dist/Select/Select.svelte.d.ts +4 -0
- package/dist/Select/properties.d.ts +20 -0
- package/dist/Select/properties.js +1 -0
- 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 +147 -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 +145 -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/SplitInput/SplitInput.svelte +225 -0
- package/dist/SplitInput/SplitInput.svelte.d.ts +7 -0
- package/dist/SplitInput/properties.d.ts +20 -0
- package/dist/SplitInput/properties.js +1 -0
- package/dist/Stepper/Step.svelte +88 -0
- package/dist/Stepper/Step.svelte.d.ts +4 -0
- package/dist/Stepper/Stepper.svelte +64 -0
- package/dist/Stepper/Stepper.svelte.d.ts +4 -0
- package/dist/Stepper/properties.d.ts +27 -0
- package/dist/Stepper/properties.js +1 -0
- package/dist/Table/Table.svelte +357 -0
- package/dist/Table/Table.svelte.d.ts +4 -0
- package/dist/Table/properties.d.ts +26 -0
- package/dist/Table/properties.js +1 -0
- package/dist/Tabs/Tabs.svelte +303 -0
- package/dist/Tabs/Tabs.svelte.d.ts +4 -0
- package/dist/Tabs/properties.d.ts +30 -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 +220 -0
- package/dist/Toast/Toast.svelte.d.ts +4 -0
- package/dist/Toast/properties.d.ts +24 -0
- package/dist/Toast/properties.js +1 -0
- package/dist/Toggle/Toggle.svelte +99 -0
- package/dist/Toggle/Toggle.svelte.d.ts +4 -0
- package/dist/Toggle/properties.d.ts +9 -0
- package/dist/Toggle/properties.js +1 -0
- package/dist/Toolbar/Toolbar.svelte +142 -0
- package/dist/Toolbar/Toolbar.svelte.d.ts +4 -0
- package/dist/Toolbar/properties.d.ts +16 -0
- package/dist/Toolbar/properties.js +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/back.svg +3 -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/sort-default.svg +4 -0
- package/dist/assets/sun.svg +11 -0
- package/dist/assets/swap-vertical.svg +6 -0
- package/dist/assets/wifi.svg +3 -0
- package/dist/index.d.ts +103 -0
- package/dist/index.js +55 -0
- package/dist/types.d.ts +42 -0
- package/dist/types.js +1 -0
- package/dist/utils.d.ts +28 -0
- package/dist/utils.js +294 -0
- package/package.json +91 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount, onDestroy } from 'svelte';
|
|
3
|
+
import type { CarouselProperties } from './properties';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
views,
|
|
7
|
+
autoplay = false,
|
|
8
|
+
autoplayInterval = 1000,
|
|
9
|
+
showDots = false,
|
|
10
|
+
isScrollableLast = false,
|
|
11
|
+
testId,
|
|
12
|
+
onkeydown,
|
|
13
|
+
classes
|
|
14
|
+
}: CarouselProperties = $props();
|
|
15
|
+
|
|
16
|
+
let slidesDiv: HTMLDivElement | null = $state(null);
|
|
17
|
+
let intervalId: number;
|
|
18
|
+
let endTouch: number;
|
|
19
|
+
let startTouch: number;
|
|
20
|
+
let startMouse: number;
|
|
21
|
+
let endMouse: number;
|
|
22
|
+
let carouselWidth: string;
|
|
23
|
+
let carouselDiv: HTMLDivElement | null = $state(null);
|
|
24
|
+
let activeSlideIndex = $state(0);
|
|
25
|
+
let widthUnits: string;
|
|
26
|
+
|
|
27
|
+
function handleDotKeydown(event: KeyboardEvent, index: number) {
|
|
28
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
29
|
+
event.preventDefault();
|
|
30
|
+
moveSlideToIndex(index);
|
|
31
|
+
}
|
|
32
|
+
onkeydown?.(event);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function nextSlide() {
|
|
36
|
+
if (activeSlideIndex != views.length - 1 || isScrollableLast) {
|
|
37
|
+
activeSlideIndex++;
|
|
38
|
+
changeCurrentSlide();
|
|
39
|
+
if (autoplay) {
|
|
40
|
+
resetInterval();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function previousSlide() {
|
|
46
|
+
if (activeSlideIndex != 0 || isScrollableLast) {
|
|
47
|
+
activeSlideIndex--;
|
|
48
|
+
changeCurrentSlide();
|
|
49
|
+
if (autoplay) {
|
|
50
|
+
resetInterval();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function changeCurrentSlide() {
|
|
56
|
+
if (activeSlideIndex > views.length - 1) {
|
|
57
|
+
activeSlideIndex = 0;
|
|
58
|
+
} else if (activeSlideIndex < 0) {
|
|
59
|
+
activeSlideIndex = views.length - 1;
|
|
60
|
+
}
|
|
61
|
+
if (slidesDiv) {
|
|
62
|
+
slidesDiv.style.transform = `translateX(${
|
|
63
|
+
-activeSlideIndex * parseInt(carouselWidth)
|
|
64
|
+
}${widthUnits})`;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function moveSlideToIndex(index: number) {
|
|
69
|
+
activeSlideIndex = index;
|
|
70
|
+
changeCurrentSlide();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function resetInterval() {
|
|
74
|
+
clearInterval(intervalId);
|
|
75
|
+
intervalId = window.setInterval(nextSlide, autoplayInterval);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function handleTouchStart(event: TouchEvent) {
|
|
79
|
+
if (event.touches.length > 0) {
|
|
80
|
+
const touch = event.touches.item(0);
|
|
81
|
+
if (touch !== null) {
|
|
82
|
+
startTouch = touch.clientX;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function handleTouchEnd(event: TouchEvent) {
|
|
88
|
+
if (event.changedTouches.length > 0) {
|
|
89
|
+
const changedTouch = event.changedTouches.item(0);
|
|
90
|
+
if (changedTouch !== null) {
|
|
91
|
+
endTouch = changedTouch.clientX;
|
|
92
|
+
if (startTouch - endTouch > 20) {
|
|
93
|
+
nextSlide();
|
|
94
|
+
} else {
|
|
95
|
+
if (endTouch - startTouch > 20) {
|
|
96
|
+
previousSlide();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function handleMouseDown(event: MouseEvent) {
|
|
104
|
+
if (typeof event.clientX !== 'undefined') {
|
|
105
|
+
startMouse = event.clientX;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function handeMouseUp(event: MouseEvent) {
|
|
110
|
+
if (typeof event.clientX !== 'undefined') {
|
|
111
|
+
endMouse = event.clientX;
|
|
112
|
+
if (startMouse - endMouse > 20) {
|
|
113
|
+
nextSlide();
|
|
114
|
+
} else {
|
|
115
|
+
if (endMouse - startMouse > 20) {
|
|
116
|
+
previousSlide();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function setWidthUnit(carouselWidth: string) {
|
|
123
|
+
widthUnits = carouselWidth.slice(-3);
|
|
124
|
+
if (/^-?\d+$/.test(widthUnits.at(0) ?? '')) {
|
|
125
|
+
widthUnits = widthUnits.slice(-2);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
onMount(() => {
|
|
130
|
+
if (carouselDiv) {
|
|
131
|
+
carouselWidth = getComputedStyle(carouselDiv).getPropertyValue('--carousel-width');
|
|
132
|
+
setWidthUnit(carouselWidth);
|
|
133
|
+
carouselDiv.addEventListener('touchstart', handleTouchStart);
|
|
134
|
+
carouselDiv.addEventListener('touchend', handleTouchEnd);
|
|
135
|
+
carouselDiv.addEventListener('mousedown', handleMouseDown);
|
|
136
|
+
carouselDiv.addEventListener('mouseup', handeMouseUp);
|
|
137
|
+
}
|
|
138
|
+
if (autoplay) {
|
|
139
|
+
intervalId = window.setInterval(nextSlide, autoplayInterval);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
onDestroy(() => {
|
|
144
|
+
if (autoplay) {
|
|
145
|
+
clearInterval(intervalId);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
</script>
|
|
149
|
+
|
|
150
|
+
<div class="carousel-container {classes ?? ''}" data-pw={testId}>
|
|
151
|
+
{#if views.length > 0}
|
|
152
|
+
<div class="carousel" bind:this={carouselDiv}>
|
|
153
|
+
<div class="slidesDiv" bind:this={slidesDiv}>
|
|
154
|
+
{#each views as view, index (index)}
|
|
155
|
+
<div class="current-slide">
|
|
156
|
+
{#if typeof view.properties === 'object'}
|
|
157
|
+
<view.component properties={view.properties} />
|
|
158
|
+
{:else}
|
|
159
|
+
<view.component />
|
|
160
|
+
{/if}
|
|
161
|
+
</div>
|
|
162
|
+
{/each}
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
{/if}
|
|
166
|
+
{#if showDots}
|
|
167
|
+
<div class="dots-wrapper">
|
|
168
|
+
<!-- eslint-disable-next-line -->
|
|
169
|
+
{#each views as _, index}
|
|
170
|
+
<div
|
|
171
|
+
class={activeSlideIndex == index ? 'active-dot' : 'dot'}
|
|
172
|
+
onclick={() => moveSlideToIndex(index)}
|
|
173
|
+
onkeydown={(event) => handleDotKeydown(event, index)}
|
|
174
|
+
role="button"
|
|
175
|
+
tabindex="0"
|
|
176
|
+
aria-label={`Go to slide ${index + 1}`}
|
|
177
|
+
aria-current={activeSlideIndex == index}
|
|
178
|
+
></div>
|
|
179
|
+
{/each}
|
|
180
|
+
</div>
|
|
181
|
+
{/if}
|
|
182
|
+
</div>
|
|
183
|
+
|
|
184
|
+
<style>
|
|
185
|
+
.carousel-container {
|
|
186
|
+
width: var(--carousel-width);
|
|
187
|
+
}
|
|
188
|
+
.current-slide {
|
|
189
|
+
width: var(--carousel-width, 300px);
|
|
190
|
+
height: var(--carousel-height, 100px);
|
|
191
|
+
flex-shrink: 0;
|
|
192
|
+
}
|
|
193
|
+
.carousel {
|
|
194
|
+
box-shadow: var(--carousel-shadow);
|
|
195
|
+
height: var(--carousel-height, 100px);
|
|
196
|
+
width: var(--carousel-width, 300px);
|
|
197
|
+
overflow: hidden;
|
|
198
|
+
border-radius: var(--carousel-border-radius, 0%);
|
|
199
|
+
}
|
|
200
|
+
.carousel:active {
|
|
201
|
+
cursor: grabbing;
|
|
202
|
+
}
|
|
203
|
+
.slidesDiv {
|
|
204
|
+
display: flex;
|
|
205
|
+
transform: translateX(0);
|
|
206
|
+
transition: transform 0.5s ease-in-out;
|
|
207
|
+
}
|
|
208
|
+
.dots-wrapper {
|
|
209
|
+
gap: var(--carousel-dot-gap, 10px);
|
|
210
|
+
padding-top: var(--carousel-dot-padding-top, 10px);
|
|
211
|
+
display: flex;
|
|
212
|
+
justify-content: center;
|
|
213
|
+
}
|
|
214
|
+
.dot {
|
|
215
|
+
width: var(--carousel-dot-width, 5px);
|
|
216
|
+
height: var(--carousel-dot-height, 5px);
|
|
217
|
+
border-radius: 50%;
|
|
218
|
+
background: var(--carousel-dot-color, currentColor);
|
|
219
|
+
cursor: pointer;
|
|
220
|
+
transition: 0.3s ease;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.active-dot {
|
|
224
|
+
width: var(--carousel-dot-width, 5px);
|
|
225
|
+
height: var(--carousel-dot-height, 5px);
|
|
226
|
+
border-radius: 50%;
|
|
227
|
+
cursor: pointer;
|
|
228
|
+
background: var(--carousel-active-dot-color, currentColor);
|
|
229
|
+
transition: 0.3s ease;
|
|
230
|
+
}
|
|
231
|
+
/*
|
|
232
|
+
@media only screen and (max-width: 324px) {
|
|
233
|
+
|
|
234
|
+
.carousel-container {
|
|
235
|
+
width:270px;
|
|
236
|
+
|
|
237
|
+
}
|
|
238
|
+
.current-slide {
|
|
239
|
+
width: 270px;
|
|
240
|
+
}
|
|
241
|
+
.carousel {
|
|
242
|
+
width:270px;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
@media only screen and (max-width: 269px) {
|
|
247
|
+
.carousel-container {
|
|
248
|
+
width:240px;
|
|
249
|
+
}
|
|
250
|
+
.current-slide {
|
|
251
|
+
width: 240px;
|
|
252
|
+
}
|
|
253
|
+
.carousel {
|
|
254
|
+
width:240px;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
} */
|
|
258
|
+
</style>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Component } from 'svelte';
|
|
2
|
+
export type CarouselView = {
|
|
3
|
+
properties?: Record<string, unknown>;
|
|
4
|
+
component: Component<Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
export type CarouselProperties = CarouselEventProperties & OptionalCarouselProperties & MandatoryCarouselProperties;
|
|
7
|
+
export type MandatoryCarouselProperties = {
|
|
8
|
+
views: CarouselView[];
|
|
9
|
+
};
|
|
10
|
+
export type OptionalCarouselProperties = {
|
|
11
|
+
autoplay?: boolean;
|
|
12
|
+
autoplayInterval?: number;
|
|
13
|
+
showDots?: boolean;
|
|
14
|
+
isScrollableLast?: boolean;
|
|
15
|
+
testId?: string;
|
|
16
|
+
classes?: string;
|
|
17
|
+
};
|
|
18
|
+
export type CarouselEventProperties = {
|
|
19
|
+
onkeydown?: (event: KeyboardEvent) => void;
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { CheckListItemProperties } from './properties';
|
|
3
|
+
import Checkbox from '../Checkbox/Checkbox.svelte';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
text,
|
|
7
|
+
checked = $bindable(false),
|
|
8
|
+
disabled = false,
|
|
9
|
+
checkboxLabel,
|
|
10
|
+
testId,
|
|
11
|
+
onclick,
|
|
12
|
+
classes
|
|
13
|
+
}: CheckListItemProperties = $props();
|
|
14
|
+
|
|
15
|
+
function handleClick(value: boolean): void {
|
|
16
|
+
checked = value;
|
|
17
|
+
onclick?.(checked);
|
|
18
|
+
}
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<div class="container {classes ?? ''}" class:disabled data-pw={testId}>
|
|
22
|
+
<div class="checkbox-wrapper">
|
|
23
|
+
<Checkbox
|
|
24
|
+
text=""
|
|
25
|
+
bind:checked
|
|
26
|
+
{disabled}
|
|
27
|
+
onclick={handleClick}
|
|
28
|
+
{...typeof testId === 'string' ? { testId: `${testId}-checkbox` } : {}}
|
|
29
|
+
/>
|
|
30
|
+
</div>
|
|
31
|
+
{#if typeof checkboxLabel === 'function'}
|
|
32
|
+
{@render checkboxLabel()}
|
|
33
|
+
{:else}
|
|
34
|
+
<span class="text" class:checked>{text}</span>
|
|
35
|
+
{/if}
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
<style>
|
|
39
|
+
.container {
|
|
40
|
+
display: var(--check-list-item-display, flex);
|
|
41
|
+
align-items: var(--check-list-item-align-items, center);
|
|
42
|
+
width: var(--check-list-item-width, 100%);
|
|
43
|
+
padding: var(--check-list-item-padding);
|
|
44
|
+
gap: var(--check-list-item-gap, 8px);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.container.disabled {
|
|
48
|
+
opacity: var(--check-list-item-disabled-opacity, 0.4);
|
|
49
|
+
cursor: not-allowed;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.checkbox-wrapper {
|
|
53
|
+
flex-shrink: 0;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.text {
|
|
57
|
+
font-size: var(--check-list-item-text-size, 14px);
|
|
58
|
+
color: var(--check-list-item-text-color);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.text.checked {
|
|
62
|
+
color: var(--check-list-item-checked-text-color);
|
|
63
|
+
font-weight: var(--check-list-item-checked-font-weight);
|
|
64
|
+
}
|
|
65
|
+
</style>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export type CheckListItemProperties = MandatoryCheckListItemProperties & OptionalCheckListItemProperties & CheckListItemEventProperties;
|
|
3
|
+
export type MandatoryCheckListItemProperties = {
|
|
4
|
+
text: string;
|
|
5
|
+
};
|
|
6
|
+
export type OptionalCheckListItemProperties = {
|
|
7
|
+
checked?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
checkboxLabel?: Snippet;
|
|
10
|
+
testId?: string;
|
|
11
|
+
classes?: string;
|
|
12
|
+
};
|
|
13
|
+
export type CheckListItemEventProperties = {
|
|
14
|
+
onclick?: (checked: boolean) => void;
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { CheckboxProperties } from './properties';
|
|
3
|
+
import checkmarkSvg from '../assets/checkmark.svg?raw';
|
|
4
|
+
import minusSvg from '../assets/minus.svg?raw';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
text,
|
|
8
|
+
checked = $bindable(false),
|
|
9
|
+
disabled = false,
|
|
10
|
+
indeterminate = $bindable(false),
|
|
11
|
+
testId,
|
|
12
|
+
checkedIcon,
|
|
13
|
+
indeterminateIcon,
|
|
14
|
+
onclick,
|
|
15
|
+
classes
|
|
16
|
+
}: CheckboxProperties = $props();
|
|
17
|
+
|
|
18
|
+
function handleClick(): void {
|
|
19
|
+
if (disabled) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
checked = !checked;
|
|
23
|
+
if (indeterminate) {
|
|
24
|
+
indeterminate = false;
|
|
25
|
+
}
|
|
26
|
+
onclick?.(checked);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function handleKeyDown(e: KeyboardEvent): void {
|
|
30
|
+
if (e.key === ' ' || e.key === 'Enter') {
|
|
31
|
+
e.preventDefault();
|
|
32
|
+
handleClick();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
38
|
+
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
|
39
|
+
<label class="container {classes ?? ''}" class:disabled onclick={handleClick} data-pw={testId}>
|
|
40
|
+
<input
|
|
41
|
+
type="checkbox"
|
|
42
|
+
class="native-checkbox"
|
|
43
|
+
{checked}
|
|
44
|
+
{disabled}
|
|
45
|
+
tabindex={-1}
|
|
46
|
+
aria-hidden="true"
|
|
47
|
+
onclick={(e: MouseEvent) => e.stopPropagation()}
|
|
48
|
+
/>
|
|
49
|
+
<span
|
|
50
|
+
class="box"
|
|
51
|
+
class:checked
|
|
52
|
+
class:indeterminate
|
|
53
|
+
role="checkbox"
|
|
54
|
+
tabindex={disabled ? -1 : 0}
|
|
55
|
+
aria-checked={indeterminate ? 'mixed' : checked}
|
|
56
|
+
aria-disabled={disabled}
|
|
57
|
+
onkeydown={handleKeyDown}
|
|
58
|
+
>
|
|
59
|
+
{#if checked && !indeterminate}
|
|
60
|
+
{#if typeof checkedIcon === 'function'}
|
|
61
|
+
{@render checkedIcon()}
|
|
62
|
+
{:else}
|
|
63
|
+
<!-- eslint-disable svelte/no-at-html-tags -->
|
|
64
|
+
<span class="icon">{@html checkmarkSvg}</span>
|
|
65
|
+
{/if}
|
|
66
|
+
{/if}
|
|
67
|
+
{#if indeterminate}
|
|
68
|
+
{#if typeof indeterminateIcon === 'function'}
|
|
69
|
+
{@render indeterminateIcon()}
|
|
70
|
+
{:else}
|
|
71
|
+
<!-- eslint-disable svelte/no-at-html-tags -->
|
|
72
|
+
<span class="icon dash">{@html minusSvg}</span>
|
|
73
|
+
{/if}
|
|
74
|
+
{/if}
|
|
75
|
+
</span>
|
|
76
|
+
<span class="label" hidden={text.length === 0}>{text}</span>
|
|
77
|
+
</label>
|
|
78
|
+
|
|
79
|
+
<style>
|
|
80
|
+
.container {
|
|
81
|
+
display: var(--checkbox-container-display, inline-flex);
|
|
82
|
+
align-items: var(--checkbox-container-align-items, center);
|
|
83
|
+
gap: var(--checkbox-container-gap, 8px);
|
|
84
|
+
cursor: var(--checkbox-container-cursor, pointer);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.container.disabled {
|
|
88
|
+
opacity: var(--checkbox-disabled-opacity, 0.4);
|
|
89
|
+
cursor: var(--checkbox-disabled-cursor, not-allowed);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.native-checkbox {
|
|
93
|
+
position: absolute;
|
|
94
|
+
opacity: 0;
|
|
95
|
+
width: 0;
|
|
96
|
+
height: 0;
|
|
97
|
+
pointer-events: none;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.box {
|
|
101
|
+
display: inline-flex;
|
|
102
|
+
align-items: center;
|
|
103
|
+
justify-content: center;
|
|
104
|
+
width: var(--checkbox-size, 20px);
|
|
105
|
+
height: var(--checkbox-size, 20px);
|
|
106
|
+
border: var(--checkbox-border, 2px solid currentColor);
|
|
107
|
+
border-radius: var(--checkbox-border-radius, 6px);
|
|
108
|
+
background-color: var(--checkbox-background, transparent);
|
|
109
|
+
transition:
|
|
110
|
+
background-color var(--checkbox-transition, 0.2s),
|
|
111
|
+
border var(--checkbox-transition, 0.2s);
|
|
112
|
+
flex-shrink: 0;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.box:focus-visible {
|
|
116
|
+
outline: none;
|
|
117
|
+
box-shadow: var(--checkbox-focus-ring, 0 0 0 3px currentColor);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.container:not(.disabled) .box:hover {
|
|
121
|
+
border-color: var(--checkbox-hover-border-color, currentColor);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.box.checked {
|
|
125
|
+
background-color: var(--checkbox-checked-background, currentColor);
|
|
126
|
+
border: var(--checkbox-checked-border, 2px solid currentColor);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.box.indeterminate {
|
|
130
|
+
background-color: var(--checkbox-indeterminate-background, currentColor);
|
|
131
|
+
border: var(--checkbox-indeterminate-border, 2px solid currentColor);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.icon {
|
|
135
|
+
display: inline-flex;
|
|
136
|
+
align-items: center;
|
|
137
|
+
justify-content: center;
|
|
138
|
+
width: var(--checkbox-icon-size, 14px);
|
|
139
|
+
height: var(--checkbox-icon-size, 14px);
|
|
140
|
+
color: var(--checkbox-checkmark-color, white);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.icon :global(svg) {
|
|
144
|
+
width: 100%;
|
|
145
|
+
height: 100%;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.icon.dash {
|
|
149
|
+
color: var(--checkbox-dash-color, white);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.label {
|
|
153
|
+
font-size: var(--checkbox-label-font-size, 14px);
|
|
154
|
+
font-weight: var(--checkbox-label-font-weight, 400);
|
|
155
|
+
color: var(--checkbox-label-color, currentColor);
|
|
156
|
+
}
|
|
157
|
+
</style>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export type CheckboxProperties = MandatoryCheckboxProperties & OptionalCheckboxProperties & CheckboxEventProperties;
|
|
3
|
+
export type MandatoryCheckboxProperties = {
|
|
4
|
+
text: string;
|
|
5
|
+
};
|
|
6
|
+
export type OptionalCheckboxProperties = {
|
|
7
|
+
checked?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
indeterminate?: boolean;
|
|
10
|
+
testId?: string;
|
|
11
|
+
checkedIcon?: Snippet;
|
|
12
|
+
indeterminateIcon?: Snippet;
|
|
13
|
+
classes?: string;
|
|
14
|
+
};
|
|
15
|
+
export type CheckboxEventProperties = {
|
|
16
|
+
onclick?: (checked: boolean) => void;
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ChoiceboxProperties } from './properties';
|
|
3
|
+
|
|
4
|
+
let {
|
|
5
|
+
children,
|
|
6
|
+
selected = $bindable(false),
|
|
7
|
+
mode = 'radio',
|
|
8
|
+
disabled = false,
|
|
9
|
+
testId,
|
|
10
|
+
onclick,
|
|
11
|
+
classes
|
|
12
|
+
}: ChoiceboxProperties = $props();
|
|
13
|
+
|
|
14
|
+
function handleClick(): void {
|
|
15
|
+
if (disabled) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (mode === 'radio' && selected) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
selected = !selected;
|
|
22
|
+
onclick?.(selected);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function handleKeyDown(e: KeyboardEvent): void {
|
|
26
|
+
if (e.key === ' ' || e.key === 'Enter') {
|
|
27
|
+
e.preventDefault();
|
|
28
|
+
handleClick();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
|
34
|
+
<div
|
|
35
|
+
class="choicebox {classes ?? ''}"
|
|
36
|
+
class:selected
|
|
37
|
+
class:disabled
|
|
38
|
+
role={mode === 'radio' ? 'radio' : 'checkbox'}
|
|
39
|
+
aria-checked={selected}
|
|
40
|
+
aria-disabled={disabled}
|
|
41
|
+
tabindex={disabled ? -1 : 0}
|
|
42
|
+
onclick={handleClick}
|
|
43
|
+
onkeydown={handleKeyDown}
|
|
44
|
+
data-pw={testId}
|
|
45
|
+
>
|
|
46
|
+
{#if typeof children === 'function'}
|
|
47
|
+
{@render children()}
|
|
48
|
+
{/if}
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
<style>
|
|
52
|
+
.choicebox {
|
|
53
|
+
display: var(--choicebox-display, flex);
|
|
54
|
+
align-items: var(--choicebox-align-items, center);
|
|
55
|
+
padding: var(--choicebox-padding, 16px);
|
|
56
|
+
border: var(--choicebox-border, 2px solid currentColor);
|
|
57
|
+
border-radius: var(--choicebox-border-radius, 6px);
|
|
58
|
+
background: var(--choicebox-background, #ffffff);
|
|
59
|
+
gap: var(--choicebox-gap, 12px);
|
|
60
|
+
cursor: var(--choicebox-cursor, pointer);
|
|
61
|
+
font-family: var(--choicebox-font-family, inherit);
|
|
62
|
+
transition: var(--choicebox-transition, border-color 0.2s, background 0.2s);
|
|
63
|
+
-webkit-tap-highlight-color: transparent;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.choicebox:focus-visible {
|
|
67
|
+
outline: none;
|
|
68
|
+
box-shadow: var(--choicebox-focus-ring, 0 0 0 3px currentColor);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.choicebox:not(.disabled):hover {
|
|
72
|
+
border-color: var(--choicebox-hover-border-color, currentColor);
|
|
73
|
+
background: var(--choicebox-hover-background, var(--choicebox-background, #ffffff));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.choicebox.selected {
|
|
77
|
+
border-color: var(--choicebox-selected-border-color, currentColor);
|
|
78
|
+
background: var(--choicebox-selected-background, var(--choicebox-background, #ffffff));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.choicebox.disabled {
|
|
82
|
+
opacity: var(--choicebox-disabled-opacity, 0.4);
|
|
83
|
+
cursor: var(--choicebox-disabled-cursor, not-allowed);
|
|
84
|
+
}
|
|
85
|
+
</style>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export type ChoiceboxProperties = OptionalChoiceboxProperties & ChoiceboxEventProperties;
|
|
3
|
+
export type ChoiceboxMode = 'radio' | 'checkbox';
|
|
4
|
+
export type OptionalChoiceboxProperties = {
|
|
5
|
+
children?: Snippet;
|
|
6
|
+
selected?: boolean;
|
|
7
|
+
mode?: ChoiceboxMode;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
testId?: string;
|
|
10
|
+
classes?: string;
|
|
11
|
+
};
|
|
12
|
+
export type ChoiceboxEventProperties = {
|
|
13
|
+
onclick?: (selected: boolean) => void;
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|