@placeholderco/placeholder-ui 1.0.3 → 1.0.6
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/LICENSE +26 -26
- package/README.md +179 -179
- package/dist/display/Alert.svelte +179 -179
- package/dist/display/Avatar.svelte +166 -166
- package/dist/display/LinkCollection.svelte +161 -161
- package/dist/display/Paper.svelte +118 -118
- package/dist/form/Autocomplete.svelte +223 -191
- package/dist/form/Autocomplete.svelte.d.ts +3 -1
- package/dist/form/AutocompleteMulti.svelte +356 -0
- package/dist/form/AutocompleteMulti.svelte.d.ts +28 -0
- package/dist/form/Checkbox.svelte +201 -201
- package/dist/form/Chips.svelte +128 -128
- package/dist/form/ComboBox.svelte +158 -158
- package/dist/form/ComboBox.svelte.d.ts +1 -1
- package/dist/form/ComboBoxItemBuilder.svelte +460 -460
- package/dist/form/ComboBoxMulti.svelte +197 -197
- package/dist/form/ComboBoxMulti.svelte.d.ts +1 -1
- package/dist/form/CronBuilder.svelte +693 -693
- package/dist/form/DatePicker.svelte +672 -672
- package/dist/form/DateTimePicker.svelte +712 -712
- package/dist/form/FileInput.svelte +235 -235
- package/dist/form/FormGroup.svelte +68 -68
- package/dist/form/Number.svelte +238 -238
- package/dist/form/PasswordInput.svelte +252 -252
- package/dist/form/RadioGroup.svelte +210 -210
- package/dist/form/Rating.svelte +235 -235
- package/dist/form/SegmentedControl.svelte +149 -149
- package/dist/form/Select.svelte +590 -590
- package/dist/form/Select.svelte.d.ts +1 -1
- package/dist/form/SelectMulti.svelte +613 -613
- package/dist/form/SelectMulti.svelte.d.ts +1 -1
- package/dist/form/Slider.svelte +358 -358
- package/dist/form/Switch.svelte +147 -147
- package/dist/form/TextArea.svelte +148 -148
- package/dist/form/Textbox.svelte +228 -228
- package/dist/form/TimePicker.svelte +267 -267
- package/dist/icon/Icon.svelte +52 -52
- package/dist/icon/alert-octagon.svg +5 -5
- package/dist/icon/alert-triangle.svg +5 -5
- package/dist/icon/archive.svg +1 -1
- package/dist/icon/arrow-down.svg +1 -1
- package/dist/icon/arrow-left.svg +1 -1
- package/dist/icon/arrow-right.svg +1 -1
- package/dist/icon/arrow-up.svg +1 -1
- package/dist/icon/at.svg +1 -1
- package/dist/icon/bell.svg +1 -1
- package/dist/icon/bookmark.svg +1 -1
- package/dist/icon/calendar.svg +1 -1
- package/dist/icon/camera.svg +1 -1
- package/dist/icon/chart-bar.svg +1 -1
- package/dist/icon/chart-line.svg +1 -1
- package/dist/icon/chart-pie.svg +1 -1
- package/dist/icon/checkbox.svg +1 -1
- package/dist/icon/checklist.svg +1 -1
- package/dist/icon/circle-check.svg +1 -1
- package/dist/icon/circle-x.svg +1 -1
- package/dist/icon/clock.svg +1 -1
- package/dist/icon/credit-card.svg +1 -1
- package/dist/icon/dots-vertical.svg +1 -1
- package/dist/icon/dots.svg +1 -1
- package/dist/icon/external-link.svg +1 -1
- package/dist/icon/eye-off.svg +1 -1
- package/dist/icon/eye.svg +1 -1
- package/dist/icon/filter.svg +1 -1
- package/dist/icon/fingerprint.svg +1 -1
- package/dist/icon/flag.svg +1 -1
- package/dist/icon/heart.svg +1 -1
- package/dist/icon/home.svg +1 -1
- package/dist/icon/key.svg +1 -1
- package/dist/icon/list-check.svg +1 -1
- package/dist/icon/login.svg +1 -1
- package/dist/icon/logout.svg +1 -1
- package/dist/icon/map-pin.svg +1 -1
- package/dist/icon/maximize.svg +1 -1
- package/dist/icon/microphone.svg +1 -1
- package/dist/icon/minimize.svg +1 -1
- package/dist/icon/note.svg +1 -1
- package/dist/icon/player-pause.svg +1 -1
- package/dist/icon/printer.svg +1 -1
- package/dist/icon/qrcode.svg +1 -1
- package/dist/icon/send.svg +1 -1
- package/dist/icon/settings.svg +1 -1
- package/dist/icon/share.svg +1 -1
- package/dist/icon/shopping-cart.svg +1 -1
- package/dist/icon/sort-ascending.svg +1 -1
- package/dist/icon/sort-descending.svg +1 -1
- package/dist/icon/star.svg +1 -1
- package/dist/icon/tag.svg +1 -1
- package/dist/icon/trending-down.svg +1 -1
- package/dist/icon/trending-up.svg +1 -1
- package/dist/icon/upload.svg +1 -1
- package/dist/icon/volume-off.svg +1 -1
- package/dist/icon/volume.svg +1 -1
- package/dist/icon/world.svg +1 -1
- package/dist/icon/zoom-in.svg +1 -1
- package/dist/icon/zoom-out.svg +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/layout/AppShell.svelte +169 -169
- package/dist/layout/CustomNavbar.svelte +61 -61
- package/dist/layout/Navbar.svelte +206 -206
- package/dist/layout/NavbarItemDisplay.svelte +29 -29
- package/dist/layout/Sidenav.svelte +712 -712
- package/dist/styles/components.css +199 -199
- package/dist/styles/dark.css +146 -146
- package/dist/styles/index.css +116 -116
- package/dist/styles/reset.css +110 -110
- package/dist/styles/semantic.css +86 -86
- package/dist/styles/tokens.css +203 -197
- package/dist/styles/utilities.css +523 -523
- package/dist/ui/Accordion.svelte +289 -289
- package/dist/ui/ActionIcon.svelte +76 -76
- package/dist/ui/Badge.svelte +329 -279
- package/dist/ui/Breadcrumbs.svelte +131 -131
- package/dist/ui/Button.svelte +432 -370
- package/dist/ui/ButtonVariant.d.ts +1 -1
- package/dist/ui/Dialog.svelte +307 -307
- package/dist/ui/Drawer.svelte +524 -524
- package/dist/ui/Dropdown.svelte +97 -97
- package/dist/ui/Dropzone.svelte +122 -122
- package/dist/ui/Link.svelte +32 -32
- package/dist/ui/Loader.svelte +70 -70
- package/dist/ui/LoadingOverlay.svelte +53 -53
- package/dist/ui/Pagination.svelte +135 -135
- package/dist/ui/Popover.svelte +225 -225
- package/dist/ui/Progress.svelte +191 -191
- package/dist/ui/RingProgress.svelte +141 -141
- package/dist/ui/Skeleton.svelte +85 -85
- package/dist/ui/Stepper.svelte +355 -355
- package/dist/ui/Table.svelte +345 -345
- package/dist/ui/Tabs.svelte +146 -146
- package/dist/ui/ThemeSwitcher.svelte +39 -39
- package/dist/ui/Timeline.svelte +225 -225
- package/dist/ui/Toaster.svelte +6 -6
- package/dist/ui/Tooltip.svelte +434 -434
- package/package.json +14 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
export type ButtonVariant = 'white' | 'muted' | 'muted-subtle' | 'muted-selected' | 'secondary-selected' | 'danger' | 'danger-subtle' | 'auto-subtle' | 'auto-outline' | 'secondary' | 'secondary-outline' | 'secondary-subtle' | 'primary' | 'primary-outline' | 'primary-subtle' | 'accent' | 'accent-subtle';
|
|
1
|
+
export type ButtonVariant = 'white' | 'muted' | 'muted-subtle' | 'muted-selected' | 'secondary-selected' | 'danger' | 'danger-subtle' | 'auto-subtle' | 'auto-outline' | 'secondary' | 'secondary-outline' | 'secondary-subtle' | 'primary' | 'primary-outline' | 'primary-subtle' | 'accent' | 'accent-subtle' | 'success' | 'success-subtle' | 'warning' | 'warning-subtle';
|
package/dist/ui/Dialog.svelte
CHANGED
|
@@ -1,307 +1,307 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import Paper from '../display/Paper.svelte';
|
|
3
|
-
import { iconX } from '../icon/index.js';
|
|
4
|
-
import type { Snippet } from 'svelte';
|
|
5
|
-
import ActionIcon from './ActionIcon.svelte';
|
|
6
|
-
import { setContext } from 'svelte';
|
|
7
|
-
|
|
8
|
-
interface Props {
|
|
9
|
-
show: boolean;
|
|
10
|
-
allowImplicitClose?: boolean;
|
|
11
|
-
title?: string | undefined;
|
|
12
|
-
noPaper?: boolean;
|
|
13
|
-
preventOverflow?: boolean;
|
|
14
|
-
size?: 'sm' | 'md' | 'lg' | 'xl' | 'full';
|
|
15
|
-
class?: string;
|
|
16
|
-
footer?: Snippet;
|
|
17
|
-
children?: Snippet;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
let {
|
|
21
|
-
show = $bindable(false),
|
|
22
|
-
allowImplicitClose = true,
|
|
23
|
-
title = undefined,
|
|
24
|
-
noPaper = false,
|
|
25
|
-
preventOverflow = false,
|
|
26
|
-
size = 'md',
|
|
27
|
-
class: classes = '',
|
|
28
|
-
footer,
|
|
29
|
-
children
|
|
30
|
-
}: Props = $props();
|
|
31
|
-
|
|
32
|
-
let dialogElement: HTMLDialogElement | undefined = $state(undefined);
|
|
33
|
-
|
|
34
|
-
// Create context for dialog events
|
|
35
|
-
let hasOpenedBefore = $state(false);
|
|
36
|
-
let dialogContext = $state({
|
|
37
|
-
isOpen: show,
|
|
38
|
-
onOpen: () => {},
|
|
39
|
-
onClose: () => {},
|
|
40
|
-
onFirstOpen: () => {}
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
$effect(() => {
|
|
44
|
-
dialogContext.isOpen = show;
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
// Set context so child components can access dialog state
|
|
48
|
-
setContext('dialog', dialogContext);
|
|
49
|
-
|
|
50
|
-
$effect(() => {
|
|
51
|
-
if (dialogElement) {
|
|
52
|
-
if (show) {
|
|
53
|
-
dialogElement.showModal();
|
|
54
|
-
dialogContext.onOpen();
|
|
55
|
-
if (!hasOpenedBefore) {
|
|
56
|
-
hasOpenedBefore = true;
|
|
57
|
-
dialogContext.onFirstOpen();
|
|
58
|
-
}
|
|
59
|
-
} else {
|
|
60
|
-
dialogElement.close();
|
|
61
|
-
dialogContext.onClose();
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
$effect(() => {
|
|
67
|
-
if (!body) return;
|
|
68
|
-
|
|
69
|
-
if (show) {
|
|
70
|
-
body.style.overflow = 'hidden';
|
|
71
|
-
} else {
|
|
72
|
-
body.style.overflow = '';
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
const body = document.querySelector('body');
|
|
77
|
-
|
|
78
|
-
function onClose() {
|
|
79
|
-
if (allowImplicitClose) show = false;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function cancel(e: Event) {
|
|
83
|
-
e.stopImmediatePropagation();
|
|
84
|
-
}
|
|
85
|
-
</script>
|
|
86
|
-
|
|
87
|
-
{#snippet DialogInner()}
|
|
88
|
-
{#if title}
|
|
89
|
-
<div class="dialog-title">
|
|
90
|
-
<span class="font-bold">{title}</span>
|
|
91
|
-
{#if allowImplicitClose}
|
|
92
|
-
<ActionIcon
|
|
93
|
-
onclick={onClose}
|
|
94
|
-
variant="secondary-subtle"
|
|
95
|
-
class="flex !p-[0.3rem] mr-1 !leading-0"
|
|
96
|
-
svg={iconX}
|
|
97
|
-
size="1rem"
|
|
98
|
-
/>
|
|
99
|
-
{/if}
|
|
100
|
-
</div>
|
|
101
|
-
{/if}
|
|
102
|
-
<div
|
|
103
|
-
class="dialog-body
|
|
104
|
-
{preventOverflow ? 'overflow-y-auto' : 'overflow-visible'}
|
|
105
|
-
{!footer && 'no-footer'}"
|
|
106
|
-
>
|
|
107
|
-
{@render children?.()}
|
|
108
|
-
</div>
|
|
109
|
-
{#if footer}
|
|
110
|
-
<div class="dialog-footer">
|
|
111
|
-
{@render footer?.()}
|
|
112
|
-
</div>
|
|
113
|
-
{/if}
|
|
114
|
-
{/snippet}
|
|
115
|
-
|
|
116
|
-
{#if noPaper}
|
|
117
|
-
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
|
118
|
-
<dialog
|
|
119
|
-
bind:this={dialogElement}
|
|
120
|
-
onclose={onClose}
|
|
121
|
-
onmousedown={onClose}
|
|
122
|
-
class={`dialog ${size}`}
|
|
123
|
-
>
|
|
124
|
-
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
125
|
-
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
126
|
-
<div
|
|
127
|
-
class="dialog-inner {classes} dialog-no-paper"
|
|
128
|
-
onclick={cancel}
|
|
129
|
-
onmousedown={cancel}
|
|
130
|
-
onmouseup={cancel}
|
|
131
|
-
>
|
|
132
|
-
{@render DialogInner()}
|
|
133
|
-
</div>
|
|
134
|
-
</dialog>
|
|
135
|
-
{:else}
|
|
136
|
-
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
|
137
|
-
<dialog
|
|
138
|
-
bind:this={dialogElement}
|
|
139
|
-
onclose={onClose}
|
|
140
|
-
onmousedown={onClose}
|
|
141
|
-
class={`dialog ${size}`}
|
|
142
|
-
>
|
|
143
|
-
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
144
|
-
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
145
|
-
<div class="dialog-inner" onclick={cancel} onmousedown={cancel} onmouseup={cancel}>
|
|
146
|
-
<div class="dialog-paper {preventOverflow ? 'overflow-y-auto' : 'overflow-visible'} ">
|
|
147
|
-
<Paper containerClass={classes}>
|
|
148
|
-
{@render DialogInner()}
|
|
149
|
-
</Paper>
|
|
150
|
-
</div>
|
|
151
|
-
</div>
|
|
152
|
-
</dialog>
|
|
153
|
-
{/if}
|
|
154
|
-
|
|
155
|
-
<style>
|
|
156
|
-
@keyframes fadeIn {
|
|
157
|
-
from {
|
|
158
|
-
opacity: 0;
|
|
159
|
-
transform: translateY(-1em);
|
|
160
|
-
}
|
|
161
|
-
to {
|
|
162
|
-
opacity: 1;
|
|
163
|
-
transform: translateY(0em);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
@keyframes fadeOut {
|
|
167
|
-
from {
|
|
168
|
-
opacity: 1;
|
|
169
|
-
transform: translateY(0em);
|
|
170
|
-
}
|
|
171
|
-
to {
|
|
172
|
-
opacity: 0;
|
|
173
|
-
transform: translateY(-1em);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/* Keyframes for the backdrop pseudo-element */
|
|
178
|
-
@keyframes backdropFadeIn {
|
|
179
|
-
from {
|
|
180
|
-
background: hsl(0 0% 0% / 0%);
|
|
181
|
-
}
|
|
182
|
-
to {
|
|
183
|
-
background: hsl(0 0% 0% / 65%);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
@keyframes backdropFadeOut {
|
|
187
|
-
from {
|
|
188
|
-
background: hsl(0 0% 0% / 65%);
|
|
189
|
-
}
|
|
190
|
-
to {
|
|
191
|
-
background: hsl(0 0% 0% / 0%);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
dialog {
|
|
196
|
-
color: var(--pui-text-primary);
|
|
197
|
-
border: none;
|
|
198
|
-
background-color: transparent;
|
|
199
|
-
overflow: visible;
|
|
200
|
-
margin: auto;
|
|
201
|
-
|
|
202
|
-
animation: fadeOut var(--pui-transition-fast) forwards;
|
|
203
|
-
transition:
|
|
204
|
-
display var(--pui-transition-fast) allow-discrete,
|
|
205
|
-
overlay var(--pui-transition-fast) allow-discrete;
|
|
206
|
-
&::backdrop {
|
|
207
|
-
animation: backdropFadeOut var(--pui-transition-fast) forwards;
|
|
208
|
-
}
|
|
209
|
-
&[open] {
|
|
210
|
-
animation: fadeIn var(--pui-transition-fast) forwards;
|
|
211
|
-
&::backdrop {
|
|
212
|
-
animation: backdropFadeIn var(--pui-transition-fast) forwards;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
.dialog-title {
|
|
218
|
-
display: flex;
|
|
219
|
-
justify-content: space-between;
|
|
220
|
-
margin-bottom: var(--pui-spacing-2);
|
|
221
|
-
padding-bottom: var(--pui-spacing-1);
|
|
222
|
-
border-bottom: 1px solid var(--pui-border-default);
|
|
223
|
-
font-weight: var(--pui-font-weight-semibold);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
.dialog-body {
|
|
227
|
-
display: flex;
|
|
228
|
-
flex-direction: column;
|
|
229
|
-
min-width: 0;
|
|
230
|
-
flex-shrink: 1;
|
|
231
|
-
max-height: calc(100vh - 167px);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
.dialog-body.no-footer {
|
|
235
|
-
max-height: calc(100vh - 107px);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
.dialog-footer {
|
|
239
|
-
display: flex;
|
|
240
|
-
justify-content: flex-end;
|
|
241
|
-
padding: var(--pui-spacing-2) 0;
|
|
242
|
-
border-top: 1px solid var(--pui-border-default);
|
|
243
|
-
gap: var(--pui-spacing-2);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
.overflow-visible {
|
|
247
|
-
overflow: visible;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
.overflow-y-auto {
|
|
251
|
-
overflow-y: auto;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
.dialog-no-paper {
|
|
255
|
-
padding: var(--pui-spacing-4);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
.dialog-paper,
|
|
259
|
-
.dialog-no-paper {
|
|
260
|
-
display: flex;
|
|
261
|
-
flex-direction: column;
|
|
262
|
-
box-sizing: border-box;
|
|
263
|
-
border-radius: var(--pui-radius-base);
|
|
264
|
-
background: var(--pui-color-gray-100);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
:global(.dark .dialog-paper),
|
|
268
|
-
:global(.dark .dialog-no-paper) {
|
|
269
|
-
background-color: var(--pui-color-dark-200);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
dialog::backdrop {
|
|
273
|
-
background-color: var(--pui-bg-overlay);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
.dialog.sm {
|
|
277
|
-
width: 20rem;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
.dialog.md {
|
|
281
|
-
width: 30rem;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
.dialog.lg {
|
|
285
|
-
width: 40rem;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
.dialog.xl {
|
|
289
|
-
width: 50rem;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
.dialog.full {
|
|
293
|
-
width: 100%;
|
|
294
|
-
margin-top: auto;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
.dialog.full,
|
|
298
|
-
.dialog.full .dialog-inner,
|
|
299
|
-
.dialog.full :global(.paper),
|
|
300
|
-
.dialog.full :global(.dialog-paper) {
|
|
301
|
-
height: 100%;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
.dialog.full .dialog-body {
|
|
305
|
-
flex-grow: 1;
|
|
306
|
-
}
|
|
307
|
-
</style>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Paper from '../display/Paper.svelte';
|
|
3
|
+
import { iconX } from '../icon/index.js';
|
|
4
|
+
import type { Snippet } from 'svelte';
|
|
5
|
+
import ActionIcon from './ActionIcon.svelte';
|
|
6
|
+
import { setContext } from 'svelte';
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
show: boolean;
|
|
10
|
+
allowImplicitClose?: boolean;
|
|
11
|
+
title?: string | undefined;
|
|
12
|
+
noPaper?: boolean;
|
|
13
|
+
preventOverflow?: boolean;
|
|
14
|
+
size?: 'sm' | 'md' | 'lg' | 'xl' | 'full';
|
|
15
|
+
class?: string;
|
|
16
|
+
footer?: Snippet;
|
|
17
|
+
children?: Snippet;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let {
|
|
21
|
+
show = $bindable(false),
|
|
22
|
+
allowImplicitClose = true,
|
|
23
|
+
title = undefined,
|
|
24
|
+
noPaper = false,
|
|
25
|
+
preventOverflow = false,
|
|
26
|
+
size = 'md',
|
|
27
|
+
class: classes = '',
|
|
28
|
+
footer,
|
|
29
|
+
children
|
|
30
|
+
}: Props = $props();
|
|
31
|
+
|
|
32
|
+
let dialogElement: HTMLDialogElement | undefined = $state(undefined);
|
|
33
|
+
|
|
34
|
+
// Create context for dialog events
|
|
35
|
+
let hasOpenedBefore = $state(false);
|
|
36
|
+
let dialogContext = $state({
|
|
37
|
+
isOpen: show,
|
|
38
|
+
onOpen: () => {},
|
|
39
|
+
onClose: () => {},
|
|
40
|
+
onFirstOpen: () => {}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
$effect(() => {
|
|
44
|
+
dialogContext.isOpen = show;
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// Set context so child components can access dialog state
|
|
48
|
+
setContext('dialog', dialogContext);
|
|
49
|
+
|
|
50
|
+
$effect(() => {
|
|
51
|
+
if (dialogElement) {
|
|
52
|
+
if (show) {
|
|
53
|
+
dialogElement.showModal();
|
|
54
|
+
dialogContext.onOpen();
|
|
55
|
+
if (!hasOpenedBefore) {
|
|
56
|
+
hasOpenedBefore = true;
|
|
57
|
+
dialogContext.onFirstOpen();
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
dialogElement.close();
|
|
61
|
+
dialogContext.onClose();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
$effect(() => {
|
|
67
|
+
if (!body) return;
|
|
68
|
+
|
|
69
|
+
if (show) {
|
|
70
|
+
body.style.overflow = 'hidden';
|
|
71
|
+
} else {
|
|
72
|
+
body.style.overflow = '';
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const body = document.querySelector('body');
|
|
77
|
+
|
|
78
|
+
function onClose() {
|
|
79
|
+
if (allowImplicitClose) show = false;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function cancel(e: Event) {
|
|
83
|
+
e.stopImmediatePropagation();
|
|
84
|
+
}
|
|
85
|
+
</script>
|
|
86
|
+
|
|
87
|
+
{#snippet DialogInner()}
|
|
88
|
+
{#if title}
|
|
89
|
+
<div class="dialog-title">
|
|
90
|
+
<span class="font-bold">{title}</span>
|
|
91
|
+
{#if allowImplicitClose}
|
|
92
|
+
<ActionIcon
|
|
93
|
+
onclick={onClose}
|
|
94
|
+
variant="secondary-subtle"
|
|
95
|
+
class="flex !p-[0.3rem] mr-1 !leading-0"
|
|
96
|
+
svg={iconX}
|
|
97
|
+
size="1rem"
|
|
98
|
+
/>
|
|
99
|
+
{/if}
|
|
100
|
+
</div>
|
|
101
|
+
{/if}
|
|
102
|
+
<div
|
|
103
|
+
class="dialog-body
|
|
104
|
+
{preventOverflow ? 'overflow-y-auto' : 'overflow-visible'}
|
|
105
|
+
{!footer && 'no-footer'}"
|
|
106
|
+
>
|
|
107
|
+
{@render children?.()}
|
|
108
|
+
</div>
|
|
109
|
+
{#if footer}
|
|
110
|
+
<div class="dialog-footer">
|
|
111
|
+
{@render footer?.()}
|
|
112
|
+
</div>
|
|
113
|
+
{/if}
|
|
114
|
+
{/snippet}
|
|
115
|
+
|
|
116
|
+
{#if noPaper}
|
|
117
|
+
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
|
118
|
+
<dialog
|
|
119
|
+
bind:this={dialogElement}
|
|
120
|
+
onclose={onClose}
|
|
121
|
+
onmousedown={onClose}
|
|
122
|
+
class={`dialog ${size}`}
|
|
123
|
+
>
|
|
124
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
125
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
126
|
+
<div
|
|
127
|
+
class="dialog-inner {classes} dialog-no-paper"
|
|
128
|
+
onclick={cancel}
|
|
129
|
+
onmousedown={cancel}
|
|
130
|
+
onmouseup={cancel}
|
|
131
|
+
>
|
|
132
|
+
{@render DialogInner()}
|
|
133
|
+
</div>
|
|
134
|
+
</dialog>
|
|
135
|
+
{:else}
|
|
136
|
+
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
|
137
|
+
<dialog
|
|
138
|
+
bind:this={dialogElement}
|
|
139
|
+
onclose={onClose}
|
|
140
|
+
onmousedown={onClose}
|
|
141
|
+
class={`dialog ${size}`}
|
|
142
|
+
>
|
|
143
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
144
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
145
|
+
<div class="dialog-inner" onclick={cancel} onmousedown={cancel} onmouseup={cancel}>
|
|
146
|
+
<div class="dialog-paper {preventOverflow ? 'overflow-y-auto' : 'overflow-visible'} ">
|
|
147
|
+
<Paper containerClass={classes}>
|
|
148
|
+
{@render DialogInner()}
|
|
149
|
+
</Paper>
|
|
150
|
+
</div>
|
|
151
|
+
</div>
|
|
152
|
+
</dialog>
|
|
153
|
+
{/if}
|
|
154
|
+
|
|
155
|
+
<style>
|
|
156
|
+
@keyframes fadeIn {
|
|
157
|
+
from {
|
|
158
|
+
opacity: 0;
|
|
159
|
+
transform: translateY(-1em);
|
|
160
|
+
}
|
|
161
|
+
to {
|
|
162
|
+
opacity: 1;
|
|
163
|
+
transform: translateY(0em);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
@keyframes fadeOut {
|
|
167
|
+
from {
|
|
168
|
+
opacity: 1;
|
|
169
|
+
transform: translateY(0em);
|
|
170
|
+
}
|
|
171
|
+
to {
|
|
172
|
+
opacity: 0;
|
|
173
|
+
transform: translateY(-1em);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/* Keyframes for the backdrop pseudo-element */
|
|
178
|
+
@keyframes backdropFadeIn {
|
|
179
|
+
from {
|
|
180
|
+
background: hsl(0 0% 0% / 0%);
|
|
181
|
+
}
|
|
182
|
+
to {
|
|
183
|
+
background: hsl(0 0% 0% / 65%);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
@keyframes backdropFadeOut {
|
|
187
|
+
from {
|
|
188
|
+
background: hsl(0 0% 0% / 65%);
|
|
189
|
+
}
|
|
190
|
+
to {
|
|
191
|
+
background: hsl(0 0% 0% / 0%);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
dialog {
|
|
196
|
+
color: var(--pui-text-primary);
|
|
197
|
+
border: none;
|
|
198
|
+
background-color: transparent;
|
|
199
|
+
overflow: visible;
|
|
200
|
+
margin: auto;
|
|
201
|
+
|
|
202
|
+
animation: fadeOut var(--pui-transition-fast) forwards;
|
|
203
|
+
transition:
|
|
204
|
+
display var(--pui-transition-fast) allow-discrete,
|
|
205
|
+
overlay var(--pui-transition-fast) allow-discrete;
|
|
206
|
+
&::backdrop {
|
|
207
|
+
animation: backdropFadeOut var(--pui-transition-fast) forwards;
|
|
208
|
+
}
|
|
209
|
+
&[open] {
|
|
210
|
+
animation: fadeIn var(--pui-transition-fast) forwards;
|
|
211
|
+
&::backdrop {
|
|
212
|
+
animation: backdropFadeIn var(--pui-transition-fast) forwards;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.dialog-title {
|
|
218
|
+
display: flex;
|
|
219
|
+
justify-content: space-between;
|
|
220
|
+
margin-bottom: var(--pui-spacing-2);
|
|
221
|
+
padding-bottom: var(--pui-spacing-1);
|
|
222
|
+
border-bottom: 1px solid var(--pui-border-default);
|
|
223
|
+
font-weight: var(--pui-font-weight-semibold);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.dialog-body {
|
|
227
|
+
display: flex;
|
|
228
|
+
flex-direction: column;
|
|
229
|
+
min-width: 0;
|
|
230
|
+
flex-shrink: 1;
|
|
231
|
+
max-height: calc(100vh - 167px);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.dialog-body.no-footer {
|
|
235
|
+
max-height: calc(100vh - 107px);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.dialog-footer {
|
|
239
|
+
display: flex;
|
|
240
|
+
justify-content: flex-end;
|
|
241
|
+
padding: var(--pui-spacing-2) 0;
|
|
242
|
+
border-top: 1px solid var(--pui-border-default);
|
|
243
|
+
gap: var(--pui-spacing-2);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.overflow-visible {
|
|
247
|
+
overflow: visible;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.overflow-y-auto {
|
|
251
|
+
overflow-y: auto;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.dialog-no-paper {
|
|
255
|
+
padding: var(--pui-spacing-4);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.dialog-paper,
|
|
259
|
+
.dialog-no-paper {
|
|
260
|
+
display: flex;
|
|
261
|
+
flex-direction: column;
|
|
262
|
+
box-sizing: border-box;
|
|
263
|
+
border-radius: var(--pui-radius-base);
|
|
264
|
+
background: var(--pui-color-gray-100);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
:global(.dark .dialog-paper),
|
|
268
|
+
:global(.dark .dialog-no-paper) {
|
|
269
|
+
background-color: var(--pui-color-dark-200);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
dialog::backdrop {
|
|
273
|
+
background-color: var(--pui-bg-overlay);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.dialog.sm {
|
|
277
|
+
width: 20rem;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.dialog.md {
|
|
281
|
+
width: 30rem;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.dialog.lg {
|
|
285
|
+
width: 40rem;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.dialog.xl {
|
|
289
|
+
width: 50rem;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.dialog.full {
|
|
293
|
+
width: 100%;
|
|
294
|
+
margin-top: auto;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
.dialog.full,
|
|
298
|
+
.dialog.full .dialog-inner,
|
|
299
|
+
.dialog.full :global(.paper),
|
|
300
|
+
.dialog.full :global(.dialog-paper) {
|
|
301
|
+
height: 100%;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
.dialog.full .dialog-body {
|
|
305
|
+
flex-grow: 1;
|
|
306
|
+
}
|
|
307
|
+
</style>
|