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,357 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ModalProperties } from './properties';
|
|
3
|
+
import { onMount, onDestroy, untrack } from 'svelte';
|
|
4
|
+
import ModalAnimation from '../Animations/ModalAnimation.svelte';
|
|
5
|
+
import OverlayAnimation from '../Animations/OverlayAnimation.svelte';
|
|
6
|
+
import { createDebouncer } from '../utils';
|
|
7
|
+
import Button from '../Button/Button.svelte';
|
|
8
|
+
|
|
9
|
+
let overlayDiv: HTMLDivElement | null = $state(null);
|
|
10
|
+
let backPressed = false;
|
|
11
|
+
|
|
12
|
+
let {
|
|
13
|
+
size = 'fit-content',
|
|
14
|
+
align = 'center',
|
|
15
|
+
showOverlay = true,
|
|
16
|
+
supportHardwareBackPress = false,
|
|
17
|
+
enableTransition = true,
|
|
18
|
+
transitionType = 'ALL',
|
|
19
|
+
header = {},
|
|
20
|
+
footer,
|
|
21
|
+
debounceTime = 700,
|
|
22
|
+
leftImageTestId,
|
|
23
|
+
testId,
|
|
24
|
+
content,
|
|
25
|
+
footerSnippet,
|
|
26
|
+
onclose,
|
|
27
|
+
onheaderrightimageclick,
|
|
28
|
+
onheaderleftimageclick,
|
|
29
|
+
onprimarybuttonclick,
|
|
30
|
+
onsecondarybuttonclick,
|
|
31
|
+
onoverlayclick,
|
|
32
|
+
onkeydown,
|
|
33
|
+
classes
|
|
34
|
+
}: ModalProperties = $props();
|
|
35
|
+
|
|
36
|
+
// debounceTime is config captured once at init; untrack documents the intent
|
|
37
|
+
// and avoids the state_referenced_locally warning.
|
|
38
|
+
const debounce = untrack(() => createDebouncer(debounceTime));
|
|
39
|
+
|
|
40
|
+
function handlePopstate() {
|
|
41
|
+
backPressed = true;
|
|
42
|
+
onclose?.();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function handleRightImageClick(event: MouseEvent): void {
|
|
46
|
+
onheaderrightimageclick?.(event);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function handleLeftImageClick(event: MouseEvent): void {
|
|
50
|
+
onheaderleftimageclick?.(event);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function handlePrimaryButtonClick(event: MouseEvent): void {
|
|
54
|
+
onprimarybuttonclick?.(event);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function handleSecondaryButtonClick(event: MouseEvent): void {
|
|
58
|
+
onsecondarybuttonclick?.(event);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function handleOverlayClick(event: MouseEvent) {
|
|
62
|
+
if (event.target && event.target === overlayDiv) {
|
|
63
|
+
debounce(() => {
|
|
64
|
+
onoverlayclick?.();
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function handleKeyDown(event: KeyboardEvent): void {
|
|
70
|
+
onkeydown?.(event);
|
|
71
|
+
let key = event?.key;
|
|
72
|
+
if (key === 'Escape') {
|
|
73
|
+
onoverlayclick?.();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
onMount(() => {
|
|
78
|
+
document.body.style.overflow = 'hidden';
|
|
79
|
+
if (supportHardwareBackPress) {
|
|
80
|
+
history.pushState(null, '', window.location.href);
|
|
81
|
+
window.addEventListener('popstate', handlePopstate);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
onDestroy(() => {
|
|
86
|
+
if (typeof window !== 'undefined') {
|
|
87
|
+
document.body.style.overflow = '';
|
|
88
|
+
if (supportHardwareBackPress) {
|
|
89
|
+
if (!backPressed) {
|
|
90
|
+
history.back();
|
|
91
|
+
}
|
|
92
|
+
window.removeEventListener('popstate', handlePopstate);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
</script>
|
|
97
|
+
|
|
98
|
+
<svelte:window onkeydown={handleKeyDown} />
|
|
99
|
+
|
|
100
|
+
{#if typeof content === 'function'}
|
|
101
|
+
<OverlayAnimation>
|
|
102
|
+
<div
|
|
103
|
+
bind:this={overlayDiv}
|
|
104
|
+
class="modal {align} {showOverlay ? 'overlay-active' : 'overlay-inactive'} {classes ?? ''}"
|
|
105
|
+
onclick={handleOverlayClick}
|
|
106
|
+
{onkeydown}
|
|
107
|
+
role="button"
|
|
108
|
+
tabindex="0"
|
|
109
|
+
data-pw={testId}
|
|
110
|
+
>
|
|
111
|
+
<ModalAnimation enable={enableTransition} {align} {transitionType}>
|
|
112
|
+
<div class="modal-content {size}">
|
|
113
|
+
{#if (typeof header?.leftImage === 'string' && header.leftImage.length > 0) || (typeof header?.text === 'string' && header.text.length > 0) || (typeof header?.rightImage === 'string' && header.rightImage.length > 0)}
|
|
114
|
+
<div class="header">
|
|
115
|
+
{#if header.leftImage}
|
|
116
|
+
<div
|
|
117
|
+
onclick={handleLeftImageClick}
|
|
118
|
+
{onkeydown}
|
|
119
|
+
role="button"
|
|
120
|
+
tabindex="0"
|
|
121
|
+
data-pw={leftImageTestId}
|
|
122
|
+
>
|
|
123
|
+
<img class="header-left-img" src={header.leftImage} alt="" />
|
|
124
|
+
</div>
|
|
125
|
+
{/if}
|
|
126
|
+
{#if header.text}
|
|
127
|
+
<div class="header-text" data-pw={header.testId}>
|
|
128
|
+
{header.text}
|
|
129
|
+
</div>
|
|
130
|
+
{/if}
|
|
131
|
+
{#if header.rightImage}
|
|
132
|
+
<div
|
|
133
|
+
role="button"
|
|
134
|
+
tabindex="0"
|
|
135
|
+
onclick={handleRightImageClick}
|
|
136
|
+
{onkeydown}
|
|
137
|
+
data-pw={header.buttonTestId}
|
|
138
|
+
>
|
|
139
|
+
<img class="header-right-img" src={header.rightImage} alt="" />
|
|
140
|
+
</div>
|
|
141
|
+
{/if}
|
|
142
|
+
</div>
|
|
143
|
+
{/if}
|
|
144
|
+
<div class="slot-content">
|
|
145
|
+
{@render content?.()}
|
|
146
|
+
</div>
|
|
147
|
+
{#if typeof footerSnippet === 'function'}
|
|
148
|
+
<div class="footer-content">
|
|
149
|
+
{@render footerSnippet?.()}
|
|
150
|
+
</div>
|
|
151
|
+
{:else if typeof footer?.primaryButton === 'object' || typeof footer?.secondaryButton === 'object'}
|
|
152
|
+
<div class="footer-content">
|
|
153
|
+
<div class="footer-action-buttons">
|
|
154
|
+
{#if footer.secondaryButton}
|
|
155
|
+
<div class="footer-secondary-button">
|
|
156
|
+
<Button {...footer.secondaryButton} onclick={handleSecondaryButtonClick} />
|
|
157
|
+
</div>
|
|
158
|
+
{/if}
|
|
159
|
+
{#if footer.primaryButton}
|
|
160
|
+
<div class="footer-primary-button">
|
|
161
|
+
<Button {...footer.primaryButton} onclick={handlePrimaryButtonClick} />
|
|
162
|
+
</div>
|
|
163
|
+
{/if}
|
|
164
|
+
</div>
|
|
165
|
+
</div>
|
|
166
|
+
{/if}
|
|
167
|
+
</div>
|
|
168
|
+
</ModalAnimation>
|
|
169
|
+
</div>
|
|
170
|
+
</OverlayAnimation>
|
|
171
|
+
{/if}
|
|
172
|
+
|
|
173
|
+
<style>
|
|
174
|
+
.modal {
|
|
175
|
+
position: fixed;
|
|
176
|
+
top: 0;
|
|
177
|
+
bottom: 0;
|
|
178
|
+
left: 0;
|
|
179
|
+
right: 0;
|
|
180
|
+
width: var(--modal-width, 100vw);
|
|
181
|
+
height: var(--modal-height, 100vh);
|
|
182
|
+
display: flex;
|
|
183
|
+
flex-direction: column;
|
|
184
|
+
z-index: var(--modal-z-index, 15);
|
|
185
|
+
-webkit-tap-highlight-color: transparent;
|
|
186
|
+
margin: var(--modal-margin);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.overlay-active {
|
|
190
|
+
background-color: var(--modal-overlay-background-color, #00000066);
|
|
191
|
+
pointer-events: auto;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.overlay-inactive {
|
|
195
|
+
pointer-events: none;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.modal-content {
|
|
199
|
+
pointer-events: auto;
|
|
200
|
+
background-color: var(--modal-content-background-color, #ffffff);
|
|
201
|
+
cursor: auto;
|
|
202
|
+
display: flex;
|
|
203
|
+
flex-direction: column;
|
|
204
|
+
border-radius: var(--modal-border-radius, 8px);
|
|
205
|
+
overflow: var(--modal-content-overflow, auto);
|
|
206
|
+
border-top: var(--modal-content-border-top);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.slot-content {
|
|
210
|
+
display: var(--modal-display, flex);
|
|
211
|
+
overflow-y: var(--modal-overflow-y, scroll);
|
|
212
|
+
scrollbar-width: var(--modal-scrollbar-width, none);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.slot-content::-webkit-scrollbar {
|
|
216
|
+
display: none;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.center {
|
|
220
|
+
justify-content: var(--modal-center-justify-content, center);
|
|
221
|
+
align-items: var(--modal-center-align-items, center);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.bottom {
|
|
225
|
+
justify-content: var(--modal-bottom-justify-content, flex-end);
|
|
226
|
+
align-items: var(--modal-bottom-align-items);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.top {
|
|
230
|
+
justify-content: var(--modal-top-justify-content, flex-start);
|
|
231
|
+
align-items: var(--modal-top-align-items);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.small {
|
|
235
|
+
height: var(--modal-small-height, 20vh);
|
|
236
|
+
width: var(--modal-small-width);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.medium {
|
|
240
|
+
height: var(--modal-medium-height, 50vh);
|
|
241
|
+
width: var(--modal-medium-width);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.large {
|
|
245
|
+
height: var(--modal-large-height, 80vh);
|
|
246
|
+
width: var(--modal-large-width);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.fit-content {
|
|
250
|
+
height: fit-content;
|
|
251
|
+
max-height: var(--modal-fit-content-max-height, 80vh);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.header {
|
|
255
|
+
display: flex;
|
|
256
|
+
background-color: var(--modal-header-background-color, transparent);
|
|
257
|
+
padding: var(--modal-header-padding, 18px 20px);
|
|
258
|
+
border-radius: var(--modal-header-border-radius, 0px);
|
|
259
|
+
border-bottom: var(--modal-header-border-bottom, none);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.footer-content {
|
|
263
|
+
display: flex;
|
|
264
|
+
background-color: var(--modal-footer-background-color, transparent);
|
|
265
|
+
padding: var(--modal-footer-padding, 18px 20px);
|
|
266
|
+
border-radius: var(--modal-footer-border-radius, 0px);
|
|
267
|
+
border-top: var(--modal-footer-border-top, none);
|
|
268
|
+
justify-content: var(--modal-footer-justify-content, none);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.footer-action-buttons {
|
|
272
|
+
display: flex;
|
|
273
|
+
gap: var(--modal-footer-gap, 0px);
|
|
274
|
+
width: var(--modal-footer-action-buttons-width, fit-content);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.footer-secondary-button {
|
|
278
|
+
--button-max-height: var(--modal-footer-secondary-button-max-height);
|
|
279
|
+
--button-max-width: var(--modal-footer-secondary-button-max-width);
|
|
280
|
+
--button-font-family: var(--modal-footer-secondary-button-font-family);
|
|
281
|
+
--button-font-weight: var(--modal-footer-secondary-button-font-weight, 500);
|
|
282
|
+
--button-font-size: var(--modal-footer-secondary-button-font-size, 14px);
|
|
283
|
+
--button-color: var(--modal-footer-secondary-button-color, #e4e4e7);
|
|
284
|
+
--button-text-color: var(--modal-footer-secondary-button-text-color, #18181b);
|
|
285
|
+
--button-height: var(--modal-footer-secondary-button-height, fit-content);
|
|
286
|
+
--button-padding: var(--modal-footer-secondary-button-padding, 16px);
|
|
287
|
+
--button-margin: var(--modal-footer-secondary-button-margin);
|
|
288
|
+
--button-border-radius: var(--modal-footer-secondary-button-border-radius, 6px);
|
|
289
|
+
--button-width: var(--modal-footer-secondary-button-width, fit-content);
|
|
290
|
+
--button-cursor: var(--modal-footer-secondary-button-cursor, pointer);
|
|
291
|
+
--button-opacity: var(--modal-footer-secondary-button-opacity, 1);
|
|
292
|
+
--button-border: var(--modal-footer-secondary-button-border, none);
|
|
293
|
+
--button-justify-content: var(--modal-footer-secondary-button-justify-content, center);
|
|
294
|
+
--button-content-flex-direction: var(
|
|
295
|
+
--modal-footer-secondary-button-content-flex-direction,
|
|
296
|
+
row
|
|
297
|
+
);
|
|
298
|
+
--button-content-gap: var(--modal-footer-secondary-button-content-gap, 16px);
|
|
299
|
+
--button-visibility: var(--modal-footer-secondary-button-visibility, visible);
|
|
300
|
+
--button-box-shadow: var(--modal-footer-secondary-button-box-shadow, none);
|
|
301
|
+
order: var(--modal-secondary-button-order, none);
|
|
302
|
+
flex: var(--modal-footer-secondary-button-flex-value, none);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.footer-primary-button {
|
|
306
|
+
--button-max-height: var(--modal-footer-primary-button-max-height);
|
|
307
|
+
--button-max-width: var(--modal-footer-primary-button-max-width);
|
|
308
|
+
--button-font-family: var(--modal-footer-primary-button-font-family);
|
|
309
|
+
--button-font-weight: var(--modal-footer-primary-button-font-weight, 500);
|
|
310
|
+
--button-font-size: var(--modal-footer-primary-button-font-size, 14px);
|
|
311
|
+
--button-color: var(--modal-footer-primary-button-color, #18181b);
|
|
312
|
+
--button-text-color: var(--modal-footer-primary-button-text-color, white);
|
|
313
|
+
--button-height: var(--modal-footer-primary-button-height, fit-content);
|
|
314
|
+
--button-padding: var(--modal-footer-primary-button-padding, 16px);
|
|
315
|
+
--button-margin: var(--modal-footer-primary-button-margin);
|
|
316
|
+
--button-border-radius: var(--modal-footer-primary-button-border-radius, 6px);
|
|
317
|
+
--button-width: var(--modal-footer-primary-button-width, fit-content);
|
|
318
|
+
--button-cursor: var(--modal-footer-primary-button-cursor, pointer);
|
|
319
|
+
--button-opacity: var(--modal-footer-primary-button-opacity, 1);
|
|
320
|
+
--button-border: var(--modal-footer-primary-button-border, none);
|
|
321
|
+
--button-justify-content: var(--modal-footer-primary-button-justify-content, center);
|
|
322
|
+
--button-content-flex-direction: var(--modal-footer-primary-button-content-flex-direction, row);
|
|
323
|
+
--button-content-gap: var(--modal-footer-primary-button-content-gap, 16px);
|
|
324
|
+
--button-visibility: var(--modal-footer-primary-button-visibility, visible);
|
|
325
|
+
--button-box-shadow: var(--modal-footer-primary-button-box-shadow, none);
|
|
326
|
+
order: var(--modal-primary-button-order, none);
|
|
327
|
+
flex: var(--modal-footer-primary-button-flex-value, none);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
.header-text {
|
|
331
|
+
display: flex;
|
|
332
|
+
align-items: center;
|
|
333
|
+
flex: 1;
|
|
334
|
+
font-size: var(--modal-header-text-size, 16px);
|
|
335
|
+
font-weight: var(--modal-header-text-weight);
|
|
336
|
+
line-height: var(--modal-header-text-line-height);
|
|
337
|
+
letter-spacing: var(--modal-header-text-letter-spacing);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.header-left-img,
|
|
341
|
+
.header-right-img {
|
|
342
|
+
padding-top: var(--modal-header-img-top-padding, 5px);
|
|
343
|
+
cursor: pointer;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
.header-left-img {
|
|
347
|
+
margin: var(--modal-header-left-image-margin, 0px 18px 0px 0px);
|
|
348
|
+
width: var(--modal-header-left-image-width, 25px);
|
|
349
|
+
height: var(--modal-header-left-image-height, 25px);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
.header-right-img {
|
|
353
|
+
width: var(--modal-header-right-image-width, 25px);
|
|
354
|
+
height: var(--modal-header-right-image-height, 25px);
|
|
355
|
+
padding: var(--modal-header-right-image-padding);
|
|
356
|
+
}
|
|
357
|
+
</style>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ButtonProperties } from '../Button/properties';
|
|
2
|
+
import type { ModalTransition } from '../types';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
export type ModalSize = 'large' | 'medium' | 'small' | 'fit-content';
|
|
5
|
+
export type ModalAlign = 'top' | 'center' | 'bottom';
|
|
6
|
+
export type ModalProperties = ModalEventProperties & {
|
|
7
|
+
size?: ModalSize;
|
|
8
|
+
align?: ModalAlign;
|
|
9
|
+
showOverlay?: boolean;
|
|
10
|
+
supportHardwareBackPress?: boolean;
|
|
11
|
+
enableTransition?: boolean;
|
|
12
|
+
transitionType?: ModalTransition;
|
|
13
|
+
header?: {
|
|
14
|
+
leftImage?: string;
|
|
15
|
+
rightImage?: string;
|
|
16
|
+
text?: string;
|
|
17
|
+
testId?: string;
|
|
18
|
+
buttonTestId?: string;
|
|
19
|
+
};
|
|
20
|
+
footer?: {
|
|
21
|
+
primaryButton?: ButtonProperties;
|
|
22
|
+
secondaryButton?: ButtonProperties;
|
|
23
|
+
};
|
|
24
|
+
debounceTime?: number;
|
|
25
|
+
leftImageTestId?: string;
|
|
26
|
+
testId?: string;
|
|
27
|
+
content?: Snippet;
|
|
28
|
+
footerSnippet?: Snippet;
|
|
29
|
+
classes?: string;
|
|
30
|
+
};
|
|
31
|
+
export type ModalEventProperties = {
|
|
32
|
+
onclose?: () => void;
|
|
33
|
+
onheaderrightimageclick?: (event: MouseEvent) => void;
|
|
34
|
+
onheaderleftimageclick?: (event: MouseEvent) => void;
|
|
35
|
+
onprimarybuttonclick?: (event: MouseEvent) => void;
|
|
36
|
+
onsecondarybuttonclick?: (event: MouseEvent) => void;
|
|
37
|
+
onoverlayclick?: () => void;
|
|
38
|
+
onkeydown?: (event: KeyboardEvent) => void;
|
|
39
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { PaginationProperties } from './properties';
|
|
3
|
+
|
|
4
|
+
let {
|
|
5
|
+
totalPages,
|
|
6
|
+
currentPage = $bindable(1),
|
|
7
|
+
siblingCount = 1,
|
|
8
|
+
disabled = false,
|
|
9
|
+
testId,
|
|
10
|
+
onchange,
|
|
11
|
+
classes
|
|
12
|
+
}: PaginationProperties = $props();
|
|
13
|
+
|
|
14
|
+
function generatePages(total: number, current: number, siblings: number): (number | '...')[] {
|
|
15
|
+
const pages: (number | '...')[] = [];
|
|
16
|
+
pages.push(1);
|
|
17
|
+
|
|
18
|
+
const leftSibling = Math.max(2, current - siblings);
|
|
19
|
+
const rightSibling = Math.min(total - 1, current + siblings);
|
|
20
|
+
|
|
21
|
+
if (leftSibling > 2) {
|
|
22
|
+
pages.push('...');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
for (let i = leftSibling; i <= rightSibling; i++) {
|
|
26
|
+
pages.push(i);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (rightSibling < total - 1) {
|
|
30
|
+
pages.push('...');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (total > 1) {
|
|
34
|
+
pages.push(total);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return pages;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let pages = $derived(generatePages(totalPages, currentPage, siblingCount));
|
|
41
|
+
|
|
42
|
+
function goToPage(page: number): void {
|
|
43
|
+
if (disabled || page < 1 || page > totalPages || page === currentPage) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
currentPage = page;
|
|
47
|
+
onchange?.(page);
|
|
48
|
+
}
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<nav class="pagination {classes ?? ''}" class:disabled data-pw={testId}>
|
|
52
|
+
<button
|
|
53
|
+
class="page-button prev-button"
|
|
54
|
+
disabled={disabled || currentPage <= 1}
|
|
55
|
+
onclick={() => goToPage(currentPage - 1)}
|
|
56
|
+
aria-label="Previous page"
|
|
57
|
+
>
|
|
58
|
+
‹
|
|
59
|
+
</button>
|
|
60
|
+
|
|
61
|
+
{#each pages as page, i (i)}
|
|
62
|
+
{#if page === '...'}
|
|
63
|
+
<span class="ellipsis">…</span>
|
|
64
|
+
{:else}
|
|
65
|
+
<button
|
|
66
|
+
class="page-button"
|
|
67
|
+
class:active={page === currentPage}
|
|
68
|
+
{disabled}
|
|
69
|
+
onclick={() => goToPage(page)}
|
|
70
|
+
aria-label="Page {page}"
|
|
71
|
+
aria-current={page === currentPage ? 'page' : null}
|
|
72
|
+
>
|
|
73
|
+
{page}
|
|
74
|
+
</button>
|
|
75
|
+
{/if}
|
|
76
|
+
{/each}
|
|
77
|
+
|
|
78
|
+
<button
|
|
79
|
+
class="page-button next-button"
|
|
80
|
+
disabled={disabled || currentPage >= totalPages}
|
|
81
|
+
onclick={() => goToPage(currentPage + 1)}
|
|
82
|
+
aria-label="Next page"
|
|
83
|
+
>
|
|
84
|
+
›
|
|
85
|
+
</button>
|
|
86
|
+
</nav>
|
|
87
|
+
|
|
88
|
+
<style>
|
|
89
|
+
.pagination {
|
|
90
|
+
display: var(--pagination-display, flex);
|
|
91
|
+
gap: var(--pagination-gap, 4px);
|
|
92
|
+
align-items: var(--pagination-align-items, center);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.pagination.disabled {
|
|
96
|
+
opacity: var(--pagination-disabled-opacity, 0.5);
|
|
97
|
+
cursor: var(--pagination-disabled-cursor, not-allowed);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.page-button {
|
|
101
|
+
padding: var(--pagination-button-padding, 6px 10px);
|
|
102
|
+
font-size: var(--pagination-button-font-size, 14px);
|
|
103
|
+
font-weight: var(--pagination-button-font-weight, 400);
|
|
104
|
+
font-family: var(--pagination-button-font-family, inherit);
|
|
105
|
+
color: var(--pagination-button-color, currentColor);
|
|
106
|
+
background: var(--pagination-button-background, transparent);
|
|
107
|
+
border: var(--pagination-button-border, 1px solid currentColor);
|
|
108
|
+
border-radius: var(--pagination-button-border-radius, 6px);
|
|
109
|
+
cursor: var(--pagination-button-cursor, pointer);
|
|
110
|
+
min-width: var(--pagination-button-min-width, 36px);
|
|
111
|
+
height: var(--pagination-button-height, 36px);
|
|
112
|
+
display: flex;
|
|
113
|
+
align-items: center;
|
|
114
|
+
justify-content: center;
|
|
115
|
+
transition: var(--pagination-transition, background 0.15s ease, color 0.15s ease);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.page-button:hover:not(:disabled):not(.active) {
|
|
119
|
+
color: var(--pagination-button-hover-color, currentColor);
|
|
120
|
+
background: var(--pagination-button-hover-background, transparent);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.page-button.active {
|
|
124
|
+
color: var(--pagination-active-color, #ffffff);
|
|
125
|
+
background: var(--pagination-active-background, #18181b);
|
|
126
|
+
border: var(--pagination-active-border, 1px solid #18181b);
|
|
127
|
+
font-weight: var(--pagination-active-font-weight, 600);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.page-button:disabled {
|
|
131
|
+
opacity: var(--pagination-disabled-opacity, 0.5);
|
|
132
|
+
cursor: var(--pagination-disabled-cursor, not-allowed);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.pagination.disabled .page-button {
|
|
136
|
+
opacity: 1;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.ellipsis {
|
|
140
|
+
color: var(--pagination-ellipsis-color, currentColor);
|
|
141
|
+
font-size: var(--pagination-ellipsis-font-size, 14px);
|
|
142
|
+
min-width: var(--pagination-button-min-width, 36px);
|
|
143
|
+
height: var(--pagination-button-height, 36px);
|
|
144
|
+
display: flex;
|
|
145
|
+
align-items: center;
|
|
146
|
+
justify-content: center;
|
|
147
|
+
}
|
|
148
|
+
</style>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type PaginationProperties = MandatoryPaginationProperties & OptionalPaginationProperties & PaginationEventProperties;
|
|
2
|
+
export type MandatoryPaginationProperties = {
|
|
3
|
+
totalPages: number;
|
|
4
|
+
};
|
|
5
|
+
export type OptionalPaginationProperties = {
|
|
6
|
+
currentPage?: number;
|
|
7
|
+
siblingCount?: number;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
testId?: string;
|
|
10
|
+
classes?: string;
|
|
11
|
+
};
|
|
12
|
+
export type PaginationEventProperties = {
|
|
13
|
+
onchange?: (page: number) => void;
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|