svelte-multiselect 11.2.3 → 11.3.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/dist/CircleSpinner.svelte.d.ts +3 -3
- package/dist/CmdPalette.svelte +20 -13
- package/dist/CmdPalette.svelte.d.ts +61 -14
- package/dist/CodeExample.svelte +10 -3
- package/dist/CodeExample.svelte.d.ts +6 -3
- package/dist/CopyButton.svelte +26 -4
- package/dist/CopyButton.svelte.d.ts +4 -4
- package/dist/FileDetails.svelte +3 -3
- package/dist/FileDetails.svelte.d.ts +6 -3
- package/dist/GitHubCorner.svelte.d.ts +3 -3
- package/dist/Icon.svelte.d.ts +4 -4
- package/dist/MultiSelect.svelte +86 -62
- package/dist/MultiSelect.svelte.d.ts +9 -9
- package/dist/Nav.svelte +447 -0
- package/dist/Nav.svelte.d.ts +42 -0
- package/dist/PrevNext.svelte +11 -10
- package/dist/PrevNext.svelte.d.ts +16 -15
- package/dist/Toggle.svelte +4 -8
- package/dist/Toggle.svelte.d.ts +5 -10
- package/dist/Wiggle.svelte.d.ts +3 -3
- package/dist/attachments.d.ts +9 -6
- package/dist/attachments.js +124 -35
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/types.d.ts +4 -20
- package/dist/utils.d.ts +3 -8
- package/dist/utils.js +24 -48
- package/package.json +19 -19
- package/readme.md +4 -6
- package/dist/RadioButtons.svelte +0 -67
- package/dist/RadioButtons.svelte.d.ts +0 -51
package/dist/Nav.svelte
ADDED
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
<script
|
|
2
|
+
lang="ts"
|
|
3
|
+
generics="Route extends string | [string, string] | [string, string[]] = string | [string, string] | [string, string[]]"
|
|
4
|
+
>import { Icon } from './';
|
|
5
|
+
import { click_outside } from './';
|
|
6
|
+
let { routes = [], children, link, menu_props, link_props, page, labels, ...rest } = $props();
|
|
7
|
+
let is_open = $state(false);
|
|
8
|
+
let hovered_dropdown = $state(null);
|
|
9
|
+
let focused_item_index = $state(-1);
|
|
10
|
+
let is_touch_device = $state(false);
|
|
11
|
+
const panel_id = `nav-menu-${crypto.randomUUID()}`;
|
|
12
|
+
// Detect touch device
|
|
13
|
+
$effect(() => {
|
|
14
|
+
if (typeof globalThis !== `undefined`) {
|
|
15
|
+
is_touch_device = `ontouchstart` in globalThis || navigator.maxTouchPoints > 0;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
function close_menus() {
|
|
19
|
+
is_open = false;
|
|
20
|
+
hovered_dropdown = null;
|
|
21
|
+
focused_item_index = -1;
|
|
22
|
+
}
|
|
23
|
+
function toggle_dropdown(href, focus_first = false) {
|
|
24
|
+
const is_opening = hovered_dropdown !== href;
|
|
25
|
+
hovered_dropdown = hovered_dropdown === href ? null : href;
|
|
26
|
+
focused_item_index = is_opening && focus_first ? 0 : -1;
|
|
27
|
+
// Focus management for keyboard users
|
|
28
|
+
if (is_opening && focus_first) {
|
|
29
|
+
setTimeout(() => {
|
|
30
|
+
const dropdown = document.querySelector(`.dropdown-wrapper[data-href="${href}"]`);
|
|
31
|
+
const first_link = dropdown?.querySelector(`.dropdown a`);
|
|
32
|
+
if (first_link instanceof HTMLElement) {
|
|
33
|
+
first_link.focus();
|
|
34
|
+
}
|
|
35
|
+
}, 0);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function onkeydown(event) {
|
|
39
|
+
if (event.key === `Escape`)
|
|
40
|
+
close_menus();
|
|
41
|
+
}
|
|
42
|
+
function handle_dropdown_keydown(event, href, sub_routes) {
|
|
43
|
+
const { key } = event;
|
|
44
|
+
if (key === `Enter` || key === ` `) {
|
|
45
|
+
event.preventDefault();
|
|
46
|
+
toggle_dropdown(href, true);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
// Arrow key navigation within open dropdown
|
|
50
|
+
if (hovered_dropdown === href && (key === `ArrowDown` || key === `ArrowUp`)) {
|
|
51
|
+
event.preventDefault();
|
|
52
|
+
const direction = key === `ArrowDown` ? 1 : -1;
|
|
53
|
+
const new_index = Math.max(0, Math.min(sub_routes.length - 1, focused_item_index + direction));
|
|
54
|
+
focused_item_index = new_index;
|
|
55
|
+
const dropdown = document.querySelector(`.dropdown-wrapper[data-href="${href}"]`);
|
|
56
|
+
const links = dropdown?.querySelectorAll(`.dropdown a`);
|
|
57
|
+
if (links?.[new_index] instanceof HTMLElement) {
|
|
58
|
+
links[new_index].focus();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// Open dropdown with ArrowDown when closed
|
|
62
|
+
if (hovered_dropdown !== href && key === `ArrowDown`) {
|
|
63
|
+
event.preventDefault();
|
|
64
|
+
toggle_dropdown(href, true);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function handle_dropdown_item_keydown(event, href) {
|
|
68
|
+
if (event.key === `Escape`) {
|
|
69
|
+
event.preventDefault();
|
|
70
|
+
close_menus();
|
|
71
|
+
// Return focus to dropdown toggle button
|
|
72
|
+
document
|
|
73
|
+
.querySelector(`.dropdown-wrapper[data-href="${href}"]`)
|
|
74
|
+
?.querySelector(`.dropdown-toggle`)
|
|
75
|
+
?.focus();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function is_current(path) {
|
|
79
|
+
if (path === `/`)
|
|
80
|
+
return page?.url.pathname === `/` ? `page` : undefined;
|
|
81
|
+
// Match exact path or path followed by / to avoid partial matches
|
|
82
|
+
// e.g. /tc-periodic-v2 should not match /tc-periodic
|
|
83
|
+
const pathname = page?.url.pathname;
|
|
84
|
+
const exact_match = pathname === path;
|
|
85
|
+
const prefix_match = pathname?.startsWith(path + `/`);
|
|
86
|
+
return exact_match || prefix_match ? `page` : undefined;
|
|
87
|
+
}
|
|
88
|
+
const is_child_current = (sub_routes) => sub_routes.some((child_path) => is_current(child_path) === `page`);
|
|
89
|
+
function format_label(text, remove_parent = false) {
|
|
90
|
+
const custom_label = labels?.[text];
|
|
91
|
+
if (custom_label)
|
|
92
|
+
return { label: custom_label, style: `` };
|
|
93
|
+
if (remove_parent)
|
|
94
|
+
text = text.split(`/`).filter(Boolean).pop() ?? text;
|
|
95
|
+
const label = text.replace(/^\//, ``).replaceAll(`-`, ` `);
|
|
96
|
+
return { label, style: `text-transform: capitalize` };
|
|
97
|
+
}
|
|
98
|
+
function parse_route(route) {
|
|
99
|
+
if (typeof route === `string`)
|
|
100
|
+
return { href: route, label: route };
|
|
101
|
+
const [first, second] = route;
|
|
102
|
+
return Array.isArray(second)
|
|
103
|
+
? { href: first, label: first, children: second }
|
|
104
|
+
: { href: first, label: second };
|
|
105
|
+
}
|
|
106
|
+
</script>
|
|
107
|
+
|
|
108
|
+
<svelte:window {onkeydown} />
|
|
109
|
+
|
|
110
|
+
<nav
|
|
111
|
+
{...rest}
|
|
112
|
+
{@attach click_outside({ callback: close_menus })}
|
|
113
|
+
class="bleed-1400 {rest.class ?? ``}"
|
|
114
|
+
>
|
|
115
|
+
<button
|
|
116
|
+
class="burger-button"
|
|
117
|
+
onclick={() => is_open = !is_open}
|
|
118
|
+
aria-label="Toggle navigation menu"
|
|
119
|
+
aria-expanded={is_open}
|
|
120
|
+
aria-controls={panel_id}
|
|
121
|
+
>
|
|
122
|
+
<span class="burger-line"></span>
|
|
123
|
+
<span class="burger-line"></span>
|
|
124
|
+
<span class="burger-line"></span>
|
|
125
|
+
</button>
|
|
126
|
+
|
|
127
|
+
<div
|
|
128
|
+
id={panel_id}
|
|
129
|
+
class="menu"
|
|
130
|
+
class:open={is_open}
|
|
131
|
+
tabindex="0"
|
|
132
|
+
role="menu"
|
|
133
|
+
{onkeydown}
|
|
134
|
+
{...menu_props}
|
|
135
|
+
>
|
|
136
|
+
{#each routes as route (JSON.stringify(route))}
|
|
137
|
+
{@const { href, label, children: sub_routes } = parse_route(route)}
|
|
138
|
+
|
|
139
|
+
{#if sub_routes}
|
|
140
|
+
<!-- Dropdown menu item -->
|
|
141
|
+
{@const parent = format_label(label)}
|
|
142
|
+
{@const child_is_active = is_child_current(sub_routes)}
|
|
143
|
+
{@const parent_page_exists = sub_routes.includes(href)}
|
|
144
|
+
{@const filtered_sub_routes = sub_routes.filter((route) => route !== href)}
|
|
145
|
+
<div
|
|
146
|
+
class="dropdown-wrapper"
|
|
147
|
+
class:active={child_is_active}
|
|
148
|
+
data-href={href}
|
|
149
|
+
role="group"
|
|
150
|
+
aria-current={child_is_active ? `true` : undefined}
|
|
151
|
+
onmouseenter={() => !is_touch_device && (hovered_dropdown = href)}
|
|
152
|
+
onmouseleave={() => !is_touch_device && (hovered_dropdown = null)}
|
|
153
|
+
onfocusin={() => (hovered_dropdown = href)}
|
|
154
|
+
onfocusout={(event) => {
|
|
155
|
+
const next = event.relatedTarget as Node | null
|
|
156
|
+
if (!next || !(event.currentTarget as HTMLElement).contains(next)) {
|
|
157
|
+
hovered_dropdown = null
|
|
158
|
+
}
|
|
159
|
+
}}
|
|
160
|
+
>
|
|
161
|
+
<div class="dropdown-trigger-wrapper">
|
|
162
|
+
<svelte:element
|
|
163
|
+
this={parent_page_exists ? `a` : `span`}
|
|
164
|
+
href={parent_page_exists ? href : undefined}
|
|
165
|
+
class="dropdown-trigger"
|
|
166
|
+
aria-current={is_current(href)}
|
|
167
|
+
onclick={close_menus}
|
|
168
|
+
role={parent_page_exists ? undefined : `button`}
|
|
169
|
+
style={parent.style}
|
|
170
|
+
>
|
|
171
|
+
{@html parent.label}
|
|
172
|
+
</svelte:element>
|
|
173
|
+
<button
|
|
174
|
+
class="dropdown-toggle"
|
|
175
|
+
aria-label="Toggle {parent.label} submenu"
|
|
176
|
+
aria-expanded={hovered_dropdown === href}
|
|
177
|
+
aria-haspopup="true"
|
|
178
|
+
onclick={() => toggle_dropdown(href, false)}
|
|
179
|
+
onkeydown={(event) => handle_dropdown_keydown(event, href, filtered_sub_routes)}
|
|
180
|
+
>
|
|
181
|
+
<Icon
|
|
182
|
+
icon="ChevronExpand"
|
|
183
|
+
style="width: 0.8em; height: 0.8em"
|
|
184
|
+
/>
|
|
185
|
+
</button>
|
|
186
|
+
</div>
|
|
187
|
+
<div
|
|
188
|
+
class="dropdown"
|
|
189
|
+
class:visible={hovered_dropdown === href}
|
|
190
|
+
role="menu"
|
|
191
|
+
tabindex="-1"
|
|
192
|
+
onmouseenter={() => !is_touch_device && (hovered_dropdown = href)}
|
|
193
|
+
onmouseleave={() => !is_touch_device && (hovered_dropdown = null)}
|
|
194
|
+
onfocusin={() => (hovered_dropdown = href)}
|
|
195
|
+
onfocusout={(event) => {
|
|
196
|
+
const next = event.relatedTarget as Node | null
|
|
197
|
+
if (!next || !(event.currentTarget as HTMLElement).contains(next)) {
|
|
198
|
+
hovered_dropdown = null
|
|
199
|
+
}
|
|
200
|
+
}}
|
|
201
|
+
>
|
|
202
|
+
{#each filtered_sub_routes as child_href (child_href)}
|
|
203
|
+
{@const child = format_label(child_href, true)}
|
|
204
|
+
{#if link}
|
|
205
|
+
{@render link({ href: child_href, label: child.label })}
|
|
206
|
+
{:else}
|
|
207
|
+
<a
|
|
208
|
+
href={child_href}
|
|
209
|
+
role="menuitem"
|
|
210
|
+
aria-current={is_current(child_href)}
|
|
211
|
+
onclick={close_menus}
|
|
212
|
+
onkeydown={(event) => handle_dropdown_item_keydown(event, href)}
|
|
213
|
+
{...link_props}
|
|
214
|
+
style={`${child.style}; ${link_props?.style ?? ``}`}
|
|
215
|
+
>
|
|
216
|
+
{@html child.label}
|
|
217
|
+
</a>
|
|
218
|
+
{/if}
|
|
219
|
+
{/each}
|
|
220
|
+
</div>
|
|
221
|
+
</div>
|
|
222
|
+
{:else}
|
|
223
|
+
<!-- Regular link item -->
|
|
224
|
+
{@const regular = format_label(label)}
|
|
225
|
+
{#if link}
|
|
226
|
+
{@render link({ href, label })}
|
|
227
|
+
{:else}
|
|
228
|
+
<a
|
|
229
|
+
{href}
|
|
230
|
+
aria-current={is_current(href)}
|
|
231
|
+
onclick={close_menus}
|
|
232
|
+
{...link_props}
|
|
233
|
+
style={`${regular.style}; ${link_props?.style ?? ``}`}
|
|
234
|
+
>
|
|
235
|
+
{@html regular.label}
|
|
236
|
+
</a>
|
|
237
|
+
{/if}
|
|
238
|
+
{/if}
|
|
239
|
+
{/each}
|
|
240
|
+
|
|
241
|
+
{@render children?.({ is_open, panel_id, routes })}
|
|
242
|
+
</div>
|
|
243
|
+
</nav>
|
|
244
|
+
|
|
245
|
+
<style>
|
|
246
|
+
nav {
|
|
247
|
+
position: relative;
|
|
248
|
+
margin: -0.75em auto 1.25em;
|
|
249
|
+
--nav-border-radius: 6pt;
|
|
250
|
+
--nav-surface-bg: light-dark(#fff, #1a1a1a);
|
|
251
|
+
--nav-surface-border: light-dark(rgba(128, 128, 128, 0.25), rgba(200, 200, 200, 0.2));
|
|
252
|
+
--nav-surface-shadow: light-dark(
|
|
253
|
+
0 2px 8px rgba(0, 0, 0, 0.15),
|
|
254
|
+
0 4px 12px rgba(0, 0, 0, 0.5)
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
.menu {
|
|
258
|
+
display: flex;
|
|
259
|
+
gap: 1em;
|
|
260
|
+
place-content: center;
|
|
261
|
+
flex-wrap: wrap;
|
|
262
|
+
padding: 0.5em;
|
|
263
|
+
}
|
|
264
|
+
.menu > a {
|
|
265
|
+
line-height: 1.3;
|
|
266
|
+
padding: 1pt 5pt;
|
|
267
|
+
border-radius: var(--nav-border-radius);
|
|
268
|
+
text-decoration: none;
|
|
269
|
+
color: inherit;
|
|
270
|
+
transition: background-color 0.2s;
|
|
271
|
+
}
|
|
272
|
+
.menu > a:hover {
|
|
273
|
+
background-color: var(--nav-link-bg-hover);
|
|
274
|
+
}
|
|
275
|
+
.menu > a[aria-current='page'] {
|
|
276
|
+
color: var(--nav-link-active-color);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/* Dropdown styles */
|
|
280
|
+
.dropdown-wrapper {
|
|
281
|
+
position: relative;
|
|
282
|
+
}
|
|
283
|
+
.dropdown-wrapper.active .dropdown-trigger {
|
|
284
|
+
color: var(--nav-link-active-color);
|
|
285
|
+
}
|
|
286
|
+
.dropdown-wrapper::after {
|
|
287
|
+
content: '';
|
|
288
|
+
position: absolute;
|
|
289
|
+
top: 100%;
|
|
290
|
+
left: 0;
|
|
291
|
+
right: 0;
|
|
292
|
+
height: var(--nav-dropdown-margin, 3pt);
|
|
293
|
+
}
|
|
294
|
+
.dropdown-trigger-wrapper {
|
|
295
|
+
display: flex;
|
|
296
|
+
align-items: center;
|
|
297
|
+
gap: 0;
|
|
298
|
+
border-radius: var(--nav-border-radius);
|
|
299
|
+
transition: background-color 0.2s;
|
|
300
|
+
}
|
|
301
|
+
.dropdown-trigger-wrapper:hover {
|
|
302
|
+
background-color: var(--nav-link-bg-hover);
|
|
303
|
+
}
|
|
304
|
+
.dropdown-trigger {
|
|
305
|
+
line-height: 1.3;
|
|
306
|
+
padding: 1pt 5pt;
|
|
307
|
+
text-decoration: none;
|
|
308
|
+
color: inherit;
|
|
309
|
+
border-radius: var(--nav-border-radius) 0 0 var(--nav-border-radius);
|
|
310
|
+
}
|
|
311
|
+
.dropdown-trigger[aria-current='page'] {
|
|
312
|
+
color: var(--nav-link-active-color);
|
|
313
|
+
}
|
|
314
|
+
.dropdown-toggle {
|
|
315
|
+
padding: 1pt 3pt;
|
|
316
|
+
border: none;
|
|
317
|
+
background: transparent;
|
|
318
|
+
color: inherit;
|
|
319
|
+
cursor: pointer;
|
|
320
|
+
display: flex;
|
|
321
|
+
align-items: center;
|
|
322
|
+
justify-content: center;
|
|
323
|
+
border-radius: 0 var(--nav-border-radius) var(--nav-border-radius) 0;
|
|
324
|
+
}
|
|
325
|
+
.dropdown {
|
|
326
|
+
position: absolute;
|
|
327
|
+
top: 100%;
|
|
328
|
+
left: 0;
|
|
329
|
+
margin: var(--nav-dropdown-margin, 3pt 0 0 0);
|
|
330
|
+
min-width: max-content;
|
|
331
|
+
background-color: var(--nav-dropdown-bg, var(--nav-surface-bg));
|
|
332
|
+
border: 1px solid var(--nav-dropdown-border-color, var(--nav-surface-border));
|
|
333
|
+
border-radius: var(--nav-border-radius, 6pt);
|
|
334
|
+
box-shadow: var(--nav-dropdown-shadow, var(--nav-surface-shadow));
|
|
335
|
+
padding: var(--nav-dropdown-padding, 2pt 3pt);
|
|
336
|
+
display: none;
|
|
337
|
+
flex-direction: column;
|
|
338
|
+
gap: var(--nav-dropdown-gap, 5pt);
|
|
339
|
+
z-index: var(--nav-dropdown-z-index, 100);
|
|
340
|
+
}
|
|
341
|
+
.dropdown.visible {
|
|
342
|
+
display: flex;
|
|
343
|
+
}
|
|
344
|
+
.dropdown a {
|
|
345
|
+
padding: var(--nav-dropdown-link-padding, 1pt 4pt);
|
|
346
|
+
border-radius: var(--nav-border-radius);
|
|
347
|
+
text-decoration: none;
|
|
348
|
+
color: inherit;
|
|
349
|
+
white-space: nowrap;
|
|
350
|
+
transition: background-color 0.2s;
|
|
351
|
+
}
|
|
352
|
+
.dropdown a:hover {
|
|
353
|
+
background-color: var(--nav-link-bg-hover);
|
|
354
|
+
}
|
|
355
|
+
.dropdown a[aria-current='page'] {
|
|
356
|
+
color: var(--nav-link-active-color);
|
|
357
|
+
}
|
|
358
|
+
/* Mobile burger button */
|
|
359
|
+
.burger-button {
|
|
360
|
+
display: none;
|
|
361
|
+
position: fixed;
|
|
362
|
+
top: 1rem;
|
|
363
|
+
left: 1rem;
|
|
364
|
+
flex-direction: column;
|
|
365
|
+
justify-content: space-around;
|
|
366
|
+
width: 1.4rem;
|
|
367
|
+
height: 1.4rem;
|
|
368
|
+
background: transparent;
|
|
369
|
+
padding: 0;
|
|
370
|
+
z-index: var(--nav-toggle-btn-z-index, 10);
|
|
371
|
+
}
|
|
372
|
+
.burger-line {
|
|
373
|
+
height: 0.18rem;
|
|
374
|
+
background-color: var(--text-color);
|
|
375
|
+
border-radius: 8px;
|
|
376
|
+
transition: all 0.2s linear;
|
|
377
|
+
transform-origin: 1px;
|
|
378
|
+
}
|
|
379
|
+
.burger-button[aria-expanded='true'] .burger-line:first-child {
|
|
380
|
+
transform: rotate(45deg);
|
|
381
|
+
}
|
|
382
|
+
.burger-button[aria-expanded='true'] .burger-line:nth-child(2) {
|
|
383
|
+
opacity: 0;
|
|
384
|
+
}
|
|
385
|
+
.burger-button[aria-expanded='true'] .burger-line:nth-child(3) {
|
|
386
|
+
transform: rotate(-45deg);
|
|
387
|
+
}
|
|
388
|
+
/* Mobile styles */
|
|
389
|
+
@media (max-width: 767px) {
|
|
390
|
+
.burger-button {
|
|
391
|
+
display: flex;
|
|
392
|
+
}
|
|
393
|
+
.menu {
|
|
394
|
+
position: fixed;
|
|
395
|
+
top: 3rem;
|
|
396
|
+
left: 1rem;
|
|
397
|
+
background-color: var(--nav-surface-bg);
|
|
398
|
+
border: 1px solid var(--nav-surface-border);
|
|
399
|
+
box-shadow: var(--nav-surface-shadow);
|
|
400
|
+
opacity: 0;
|
|
401
|
+
visibility: hidden;
|
|
402
|
+
transition: all 0.3s ease;
|
|
403
|
+
z-index: var(--nav-mobile-z-index, 2);
|
|
404
|
+
flex-direction: column;
|
|
405
|
+
align-items: stretch;
|
|
406
|
+
justify-content: flex-start;
|
|
407
|
+
gap: 0.2em;
|
|
408
|
+
max-width: 90vw;
|
|
409
|
+
border-radius: 6px;
|
|
410
|
+
}
|
|
411
|
+
.menu.open {
|
|
412
|
+
opacity: 1;
|
|
413
|
+
visibility: visible;
|
|
414
|
+
}
|
|
415
|
+
.menu > a,
|
|
416
|
+
.dropdown-wrapper {
|
|
417
|
+
padding: 2pt 8pt;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/* Mobile dropdown styles - show as expandable section */
|
|
421
|
+
.dropdown-wrapper {
|
|
422
|
+
flex-direction: column;
|
|
423
|
+
align-items: stretch;
|
|
424
|
+
}
|
|
425
|
+
.dropdown-trigger-wrapper {
|
|
426
|
+
display: flex;
|
|
427
|
+
align-items: center;
|
|
428
|
+
justify-content: space-between;
|
|
429
|
+
}
|
|
430
|
+
.dropdown-trigger {
|
|
431
|
+
flex: 1;
|
|
432
|
+
border-radius: var(--nav-border-radius);
|
|
433
|
+
}
|
|
434
|
+
.dropdown-toggle {
|
|
435
|
+
padding: 4pt 8pt;
|
|
436
|
+
border-radius: var(--nav-border-radius);
|
|
437
|
+
}
|
|
438
|
+
.dropdown {
|
|
439
|
+
position: static;
|
|
440
|
+
border: none;
|
|
441
|
+
box-shadow: none;
|
|
442
|
+
margin-top: 0.25em;
|
|
443
|
+
padding: 0 0 0 1em;
|
|
444
|
+
background-color: transparent;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
</style>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Page } from '@sveltejs/kit';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
4
|
+
declare function $$render<Route extends string | [string, string] | [string, string[]] = string | [string, string] | [string, string[]]>(): {
|
|
5
|
+
props: {
|
|
6
|
+
routes: Route[];
|
|
7
|
+
children?: Snippet<[{
|
|
8
|
+
is_open: boolean;
|
|
9
|
+
panel_id: string;
|
|
10
|
+
routes: Route[];
|
|
11
|
+
}]>;
|
|
12
|
+
link?: Snippet<[{
|
|
13
|
+
href: string;
|
|
14
|
+
label: string;
|
|
15
|
+
}]>;
|
|
16
|
+
menu_props?: HTMLAttributes<HTMLDivElement>;
|
|
17
|
+
link_props?: HTMLAttributes<HTMLAnchorElement>;
|
|
18
|
+
page?: Page;
|
|
19
|
+
labels?: Record<string, string>;
|
|
20
|
+
} & Omit<HTMLAttributes<HTMLElement>, "children">;
|
|
21
|
+
exports: {};
|
|
22
|
+
bindings: "";
|
|
23
|
+
slots: {};
|
|
24
|
+
events: {};
|
|
25
|
+
};
|
|
26
|
+
declare class __sveltets_Render<Route extends string | [string, string] | [string, string[]] = string | [string, string] | [string, string[]]> {
|
|
27
|
+
props(): ReturnType<typeof $$render<Route>>['props'];
|
|
28
|
+
events(): ReturnType<typeof $$render<Route>>['events'];
|
|
29
|
+
slots(): ReturnType<typeof $$render<Route>>['slots'];
|
|
30
|
+
bindings(): "";
|
|
31
|
+
exports(): {};
|
|
32
|
+
}
|
|
33
|
+
interface $$IsomorphicComponent {
|
|
34
|
+
new <Route extends string | [string, string] | [string, string[]] = string | [string, string] | [string, string[]]>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<Route>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<Route>['props']>, ReturnType<__sveltets_Render<Route>['events']>, ReturnType<__sveltets_Render<Route>['slots']>> & {
|
|
35
|
+
$$bindings?: ReturnType<__sveltets_Render<Route>['bindings']>;
|
|
36
|
+
} & ReturnType<__sveltets_Render<Route>['exports']>;
|
|
37
|
+
<Route extends string | [string, string] | [string, string[]] = string | [string, string] | [string, string[]]>(internal: unknown, props: ReturnType<__sveltets_Render<Route>['props']> & {}): ReturnType<__sveltets_Render<Route>['exports']>;
|
|
38
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
39
|
+
}
|
|
40
|
+
declare const Nav: $$IsomorphicComponent;
|
|
41
|
+
type Nav<Route extends string | [string, string] | [string, string[]] = string | [string, string] | [string, string[]]> = InstanceType<typeof Nav<Route>>;
|
|
42
|
+
export default Nav;
|
package/dist/PrevNext.svelte
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
<script lang="ts">let { items = [], node = `nav`, current = ``, log = `errors`, nav_options = { replace_state: true, no_scroll: true }, titles = { prev: `← Previous`, next: `Next →` }, onkeyup = ({ prev, next }) => ({
|
|
2
|
-
ArrowLeft: prev[0],
|
|
3
|
-
ArrowRight: next[0],
|
|
4
|
-
}), prev_snippet, children, between, next_snippet, ...rest } = $props();
|
|
1
|
+
<script lang="ts" generics="Item extends [string, unknown] = [string, unknown]">let { items = [], node = `nav`, current = ``, log = `errors`, nav_options = { replace_state: true, no_scroll: true }, titles = { prev: `← Previous`, next: `Next →` }, onkeyup = ({ prev, next }) => ({ ArrowLeft: prev[0], ArrowRight: next[0] }), prev_snippet, children, between, next_snippet, min_items = 3, link_props, ...rest } = $props();
|
|
5
2
|
// Convert items to consistent [key, value] format
|
|
6
3
|
let items_arr = $derived((items ?? []).map((itm) => (typeof itm === `string` ? [itm, itm] : itm)));
|
|
7
4
|
// Calculate prev/next items with wraparound
|
|
@@ -11,8 +8,8 @@ let next = $derived(items_arr[idx + 1] ?? items_arr[0]);
|
|
|
11
8
|
// Validation and logging
|
|
12
9
|
$effect.pre(() => {
|
|
13
10
|
if (log !== `silent`) {
|
|
14
|
-
if (items_arr.length <
|
|
15
|
-
console.warn(`PrevNext received ${items_arr.length} items - minimum of
|
|
11
|
+
if (items_arr.length < min_items && log === `verbose`) {
|
|
12
|
+
console.warn(`PrevNext received ${items_arr.length} items - minimum of ${min_items} expected`);
|
|
16
13
|
}
|
|
17
14
|
if (idx < 0 && log === `errors`) {
|
|
18
15
|
const valid = items_arr.map(([key]) => key);
|
|
@@ -23,9 +20,13 @@ $effect.pre(() => {
|
|
|
23
20
|
function handle_keyup(event) {
|
|
24
21
|
if (!onkeyup)
|
|
25
22
|
return;
|
|
23
|
+
if ((items_arr?.length ?? 0) < min_items)
|
|
24
|
+
return;
|
|
25
|
+
if (!prev || !next)
|
|
26
|
+
return;
|
|
26
27
|
const key_map = onkeyup({ prev, next });
|
|
27
28
|
const to = key_map[event.key];
|
|
28
|
-
if (to) {
|
|
29
|
+
if (to !== undefined) {
|
|
29
30
|
const { replace_state, no_scroll } = nav_options;
|
|
30
31
|
const [scroll_x, scroll_y] = no_scroll
|
|
31
32
|
? [window.scrollX, window.scrollY]
|
|
@@ -41,7 +42,7 @@ export {};
|
|
|
41
42
|
|
|
42
43
|
<svelte:window onkeyup={handle_keyup} />
|
|
43
44
|
|
|
44
|
-
{#if items_arr.length
|
|
45
|
+
{#if items_arr.length >= min_items}
|
|
45
46
|
<svelte:element this={node} class="prev-next" {...rest}>
|
|
46
47
|
<!-- ensures `prev` is a defined [key, value] tuple.
|
|
47
48
|
Due to prior normalization of the `items` prop, any defined `prev` item
|
|
@@ -55,7 +56,7 @@ export {};
|
|
|
55
56
|
{:else}
|
|
56
57
|
<div>
|
|
57
58
|
{#if titles.prev}<span>{@html titles.prev}</span>{/if}
|
|
58
|
-
<a href={prev[0]}>{prev[0]}</a>
|
|
59
|
+
<a {...link_props} href={prev[0]}>{prev[0]}</a>
|
|
59
60
|
</div>
|
|
60
61
|
{/if}
|
|
61
62
|
{/if}
|
|
@@ -68,7 +69,7 @@ export {};
|
|
|
68
69
|
{:else}
|
|
69
70
|
<div>
|
|
70
71
|
{#if titles.next}<span>{@html titles.next}</span>{/if}
|
|
71
|
-
<a href={next[0]}>{next[0]}</a>
|
|
72
|
+
<a {...link_props} href={next[0]}>{next[0]}</a>
|
|
72
73
|
</div>
|
|
73
74
|
{/if}
|
|
74
75
|
{/if}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
|
|
3
|
-
declare function $$render<
|
|
4
|
-
props: {
|
|
5
|
-
|
|
6
|
-
items?: T[];
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
declare function $$render<Item extends [string, unknown] = [string, unknown]>(): {
|
|
4
|
+
props: Omit<HTMLAttributes<HTMLElement>, "children" | "onkeyup"> & {
|
|
5
|
+
items?: (string | Item)[];
|
|
7
6
|
node?: string;
|
|
8
7
|
current?: string;
|
|
9
8
|
log?: `verbose` | `errors` | `silent`;
|
|
@@ -18,7 +17,7 @@ declare function $$render<T extends Item>(): {
|
|
|
18
17
|
onkeyup?: ((obj: {
|
|
19
18
|
prev: Item;
|
|
20
19
|
next: Item;
|
|
21
|
-
}) => Record<string, string>) | null;
|
|
20
|
+
}) => Record<string, string | undefined>) | null;
|
|
22
21
|
prev_snippet?: Snippet<[{
|
|
23
22
|
item: Item;
|
|
24
23
|
}]>;
|
|
@@ -30,26 +29,28 @@ declare function $$render<T extends Item>(): {
|
|
|
30
29
|
next_snippet?: Snippet<[{
|
|
31
30
|
item: Item;
|
|
32
31
|
}]>;
|
|
32
|
+
min_items?: number;
|
|
33
|
+
link_props?: HTMLAttributes<HTMLAnchorElement>;
|
|
33
34
|
};
|
|
34
35
|
exports: {};
|
|
35
36
|
bindings: "";
|
|
36
37
|
slots: {};
|
|
37
38
|
events: {};
|
|
38
39
|
};
|
|
39
|
-
declare class __sveltets_Render<
|
|
40
|
-
props(): ReturnType<typeof $$render<
|
|
41
|
-
events(): ReturnType<typeof $$render<
|
|
42
|
-
slots(): ReturnType<typeof $$render<
|
|
40
|
+
declare class __sveltets_Render<Item extends [string, unknown] = [string, unknown]> {
|
|
41
|
+
props(): ReturnType<typeof $$render<Item>>['props'];
|
|
42
|
+
events(): ReturnType<typeof $$render<Item>>['events'];
|
|
43
|
+
slots(): ReturnType<typeof $$render<Item>>['slots'];
|
|
43
44
|
bindings(): "";
|
|
44
45
|
exports(): {};
|
|
45
46
|
}
|
|
46
47
|
interface $$IsomorphicComponent {
|
|
47
|
-
new <
|
|
48
|
-
$$bindings?: ReturnType<__sveltets_Render<
|
|
49
|
-
} & ReturnType<__sveltets_Render<
|
|
50
|
-
<
|
|
48
|
+
new <Item extends [string, unknown] = [string, unknown]>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<Item>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<Item>['props']>, ReturnType<__sveltets_Render<Item>['events']>, ReturnType<__sveltets_Render<Item>['slots']>> & {
|
|
49
|
+
$$bindings?: ReturnType<__sveltets_Render<Item>['bindings']>;
|
|
50
|
+
} & ReturnType<__sveltets_Render<Item>['exports']>;
|
|
51
|
+
<Item extends [string, unknown] = [string, unknown]>(internal: unknown, props: ReturnType<__sveltets_Render<Item>['props']> & {}): ReturnType<__sveltets_Render<Item>['exports']>;
|
|
51
52
|
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
52
53
|
}
|
|
53
54
|
declare const PrevNext: $$IsomorphicComponent;
|
|
54
|
-
type PrevNext<
|
|
55
|
+
type PrevNext<Item extends [string, unknown] = [string, unknown]> = InstanceType<typeof PrevNext<Item>>;
|
|
55
56
|
export default PrevNext;
|
package/dist/Toggle.svelte
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
<script lang="ts">let { checked = $bindable(false),
|
|
1
|
+
<script lang="ts">let { checked = $bindable(false), onkeydown, children, input_props, ...rest } = $props();
|
|
2
2
|
// normally input type=checkbox toggles on space bar, this handler also responds to enter
|
|
3
3
|
function handle_keydown(event) {
|
|
4
4
|
onkeydown?.(event);
|
|
5
5
|
if (event.key === `Enter`) {
|
|
6
6
|
event.preventDefault();
|
|
7
|
-
|
|
7
|
+
const target = event.target;
|
|
8
|
+
target.click(); // simulate real user toggle so 'change' is dispatched
|
|
8
9
|
}
|
|
9
10
|
}
|
|
10
11
|
export {};
|
|
@@ -15,13 +16,8 @@ export {};
|
|
|
15
16
|
<input
|
|
16
17
|
type="checkbox"
|
|
17
18
|
bind:checked
|
|
18
|
-
{
|
|
19
|
-
{required}
|
|
19
|
+
{...input_props}
|
|
20
20
|
onkeydown={handle_keydown}
|
|
21
|
-
{onchange}
|
|
22
|
-
{onblur}
|
|
23
|
-
{onclick}
|
|
24
|
-
style={input_style}
|
|
25
21
|
/>
|
|
26
22
|
<span></span>
|
|
27
23
|
</label>
|
package/dist/Toggle.svelte.d.ts
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
type $$ComponentProps = HTMLAttributes<HTMLLabelElement> & {
|
|
3
4
|
checked?: boolean;
|
|
4
|
-
required?: boolean;
|
|
5
|
-
input_style?: string;
|
|
6
|
-
id?: string | null;
|
|
7
|
-
onclick?: (event: MouseEvent) => void;
|
|
8
|
-
onchange?: (event: Event) => void;
|
|
9
|
-
onblur?: (event: FocusEvent) => void;
|
|
10
5
|
onkeydown?: (event: KeyboardEvent) => void;
|
|
11
6
|
children?: Snippet<[]>;
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
declare const Toggle: import("svelte").Component
|
|
7
|
+
input_props?: HTMLAttributes<HTMLInputElement>;
|
|
8
|
+
};
|
|
9
|
+
declare const Toggle: import("svelte").Component<$$ComponentProps, {}, "checked">;
|
|
15
10
|
type Toggle = ReturnType<typeof Toggle>;
|
|
16
11
|
export default Toggle;
|
package/dist/Wiggle.svelte.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
|
|
2
|
+
type $$ComponentProps = {
|
|
3
3
|
wiggle?: boolean;
|
|
4
4
|
angle?: number;
|
|
5
5
|
scale?: number;
|
|
@@ -9,7 +9,7 @@ interface Props {
|
|
|
9
9
|
stiffness?: number;
|
|
10
10
|
damping?: number;
|
|
11
11
|
children?: Snippet;
|
|
12
|
-
}
|
|
13
|
-
declare const Wiggle: import("svelte").Component
|
|
12
|
+
};
|
|
13
|
+
declare const Wiggle: import("svelte").Component<$$ComponentProps, {}, "wiggle">;
|
|
14
14
|
type Wiggle = ReturnType<typeof Wiggle>;
|
|
15
15
|
export default Wiggle;
|