@sveltia/ui 0.81.0 → 0.81.2
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/components/scroll/infinite-scroll.svelte +33 -5
- package/dist/components/text-editor/constants.d.ts +2 -1
- package/dist/components/text-editor/constants.js +2 -1
- package/dist/components/text-editor/shiki/version.d.ts +1 -1
- package/dist/components/text-editor/shiki/version.js +1 -1
- package/dist/components/toast/toast.svelte +79 -56
- package/dist/components/util/font-links.svelte +2 -2
- package/dist/components/util/fonts.js +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/self-hosted/fonts/material-symbols-outlined-latin-wght-normal.woff2 +0 -0
- package/dist/self-hosted/fonts/source-sans-3-latin-wght-normal.woff2 +0 -0
- package/package.json +5 -5
|
@@ -35,11 +35,36 @@
|
|
|
35
35
|
|
|
36
36
|
const loading = $derived(items.length > loadedItemSize);
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Get the nearest ancestor of the given element that scrolls vertically. An ancestor that can
|
|
40
|
+
* scroll but whose content fits, like one growing with the list or a horizontal scroller, doesn’t
|
|
41
|
+
* clip the element, and as the observer’s root it would let every chunk load at once. The heights
|
|
42
|
+
* are rounded separately, so a 1px difference doesn’t count as scrolling.
|
|
43
|
+
* @param {HTMLElement} element Element.
|
|
44
|
+
* @returns {HTMLElement | null} Scroll container, or `null` if the document itself scrolls.
|
|
45
|
+
*/
|
|
46
|
+
const getScrollContainer = (element) => {
|
|
47
|
+
for (let parent = element.parentElement; parent; parent = parent.parentElement) {
|
|
48
|
+
if (
|
|
49
|
+
parent.scrollHeight - parent.clientHeight > 1 &&
|
|
50
|
+
/^(auto|scroll)$/.test(getComputedStyle(parent).overflowY)
|
|
51
|
+
) {
|
|
52
|
+
return parent;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return null;
|
|
57
|
+
};
|
|
58
|
+
|
|
38
59
|
// Observe the spinner anew once each chunk is rendered: the observer only reports changes, so a
|
|
39
60
|
// spinner that stays in view because the chunk didn’t fill the viewport would stall the loading.
|
|
40
61
|
// Observing an element always reports its current state first. The observer is created here
|
|
41
62
|
// rather than when the component is set up, since `IntersectionObserver` doesn’t exist during
|
|
42
63
|
// server-side rendering, and it’s disconnected before the next chunk and on unmount.
|
|
64
|
+
// The next chunk starts loading while the spinner is still a little below the visible area, so
|
|
65
|
+
// the scrolling doesn’t stop at the end of each chunk. The margin only applies to the observer’s
|
|
66
|
+
// root, which has to be the scroll container: the viewport margin wouldn’t reveal a spinner
|
|
67
|
+
// clipped by a scrolling ancestor.
|
|
43
68
|
$effect(() => {
|
|
44
69
|
void loadedItemSize;
|
|
45
70
|
|
|
@@ -47,11 +72,14 @@
|
|
|
47
72
|
return undefined;
|
|
48
73
|
}
|
|
49
74
|
|
|
50
|
-
const observer = new IntersectionObserver(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
75
|
+
const observer = new IntersectionObserver(
|
|
76
|
+
([{ isIntersecting }]) => {
|
|
77
|
+
if (isIntersecting && loading) {
|
|
78
|
+
loadedItemSize += itemChunkSize;
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
{ root: getScrollContainer(spinner), rootMargin: '0px 0px 500px 0px' },
|
|
82
|
+
);
|
|
55
83
|
|
|
56
84
|
observer.observe(spinner);
|
|
57
85
|
|
|
@@ -58,7 +58,8 @@ export const TRANSFORMER_MAP: Record<Exclude<TextEditorNodeType, "paragraph">, T
|
|
|
58
58
|
export const DISABLED_MARKDOWN_TAGS: string[];
|
|
59
59
|
/**
|
|
60
60
|
* Tag of the Lexical update that imports a value set from outside, so the editor can tell it from a
|
|
61
|
-
* change made by the user.
|
|
61
|
+
* change made by the user. A custom node can check it with `$hasUpdateTag()` in its `createDOM()`
|
|
62
|
+
* method to tell whether it’s being rendered for an imported value.
|
|
62
63
|
*/
|
|
63
64
|
export const IMPORT_UPDATE_TAG: "sui-import";
|
|
64
65
|
/**
|
|
@@ -235,7 +235,8 @@ export const DISABLED_MARKDOWN_TAGS = ['*', '__', '***', '___'];
|
|
|
235
235
|
|
|
236
236
|
/**
|
|
237
237
|
* Tag of the Lexical update that imports a value set from outside, so the editor can tell it from a
|
|
238
|
-
* change made by the user.
|
|
238
|
+
* change made by the user. A custom node can check it with `$hasUpdateTag()` in its `createDOM()`
|
|
239
|
+
* method to tell whether it’s being rendered for an imported value.
|
|
239
240
|
*/
|
|
240
241
|
export const IMPORT_UPDATE_TAG = 'sui-import';
|
|
241
242
|
|
|
@@ -74,6 +74,30 @@
|
|
|
74
74
|
return true;
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Get the lane in the toast base for the toasts at the given position, creating it if needed.
|
|
79
|
+
* The toasts at the same position are stacked in their lane rather than laid on top of each
|
|
80
|
+
* other.
|
|
81
|
+
* @param {HTMLElement} base Toast base.
|
|
82
|
+
* @param {string} position Toast position, e.g. `bottom-right`.
|
|
83
|
+
* @returns {HTMLElement} Lane.
|
|
84
|
+
*/
|
|
85
|
+
const getLane = (base, position) => {
|
|
86
|
+
let lane = /** @type {HTMLElement[]} */ ([...base.children]).find(
|
|
87
|
+
(child) => child.dataset.position === position,
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
if (!lane) {
|
|
91
|
+
lane = document.createElement('div');
|
|
92
|
+
lane.setAttribute('role', 'none');
|
|
93
|
+
lane.className = `toast-lane ${position}`;
|
|
94
|
+
lane.dataset.position = position;
|
|
95
|
+
base.appendChild(lane);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return lane;
|
|
99
|
+
};
|
|
100
|
+
|
|
77
101
|
/**
|
|
78
102
|
* Toast base shared by all the toasts. It’s created by the first toast mounted and removed with
|
|
79
103
|
* the last one unmounted, rather than rendered by a component, so it doesn’t go away with the
|
|
@@ -292,7 +316,16 @@
|
|
|
292
316
|
|
|
293
317
|
// Make sure the base is in the topmost modal dialog, in case a dialog event has been missed
|
|
294
318
|
moveBase(popover);
|
|
295
|
-
|
|
319
|
+
|
|
320
|
+
// The newest toast goes next to the edge of the screen: last at the bottom, first at the top
|
|
321
|
+
const lane = getLane(popover, position);
|
|
322
|
+
|
|
323
|
+
if (position.startsWith('top-')) {
|
|
324
|
+
lane.prepend(toast);
|
|
325
|
+
} else {
|
|
326
|
+
lane.append(toast);
|
|
327
|
+
}
|
|
328
|
+
|
|
296
329
|
raiseBase(popover);
|
|
297
330
|
});
|
|
298
331
|
|
|
@@ -362,11 +395,6 @@
|
|
|
362
395
|
position: fixed;
|
|
363
396
|
inset: 16px;
|
|
364
397
|
z-index: 99999;
|
|
365
|
-
display: flex;
|
|
366
|
-
flex-direction: column;
|
|
367
|
-
justify-content: flex-end;
|
|
368
|
-
align-items: flex-end;
|
|
369
|
-
gap: 8px;
|
|
370
398
|
overflow: visible;
|
|
371
399
|
margin: 0;
|
|
372
400
|
border: 0;
|
|
@@ -387,10 +415,38 @@
|
|
|
387
415
|
bottom: calc(var(--sui-bottom-navigation-height) + 16px);
|
|
388
416
|
}
|
|
389
417
|
|
|
390
|
-
.toast {
|
|
418
|
+
:global(.sui.toast-base) > :global(.toast-lane) {
|
|
391
419
|
position: absolute;
|
|
420
|
+
display: flex;
|
|
421
|
+
flex-direction: column;
|
|
422
|
+
margin-block: -4px;
|
|
423
|
+
max-width: 100%;
|
|
424
|
+
}
|
|
425
|
+
:global(.sui.toast-base) > :global(.toast-lane.top-left), :global(.sui.toast-base) > :global(.toast-lane.top-center), :global(.sui.toast-base) > :global(.toast-lane.top-right) {
|
|
426
|
+
inset-block-start: 0;
|
|
427
|
+
}
|
|
428
|
+
:global(.sui.toast-base) > :global(.toast-lane.bottom-left), :global(.sui.toast-base) > :global(.toast-lane.bottom-center), :global(.sui.toast-base) > :global(.toast-lane.bottom-right) {
|
|
429
|
+
inset-block-end: 0;
|
|
430
|
+
}
|
|
431
|
+
:global(.sui.toast-base) > :global(.toast-lane.top-left), :global(.sui.toast-base) > :global(.toast-lane.bottom-left) {
|
|
432
|
+
inset-inline-start: 0;
|
|
433
|
+
align-items: flex-start;
|
|
434
|
+
}
|
|
435
|
+
:global(.sui.toast-base) > :global(.toast-lane.top-center), :global(.sui.toast-base) > :global(.toast-lane.bottom-center) {
|
|
436
|
+
inset-inline: 0;
|
|
437
|
+
align-items: center;
|
|
438
|
+
}
|
|
439
|
+
:global(.sui.toast-base) > :global(.toast-lane.top-right), :global(.sui.toast-base) > :global(.toast-lane.bottom-right) {
|
|
440
|
+
inset-inline-end: 0;
|
|
441
|
+
align-items: flex-end;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
.toast {
|
|
445
|
+
margin-block: 4px;
|
|
392
446
|
width: max-content;
|
|
393
447
|
max-width: 80dvw;
|
|
448
|
+
height: auto;
|
|
449
|
+
overflow: clip;
|
|
394
450
|
opacity: 1;
|
|
395
451
|
transition-duration: 250ms;
|
|
396
452
|
will-change: opacity;
|
|
@@ -408,54 +464,21 @@
|
|
|
408
464
|
opacity: 0;
|
|
409
465
|
pointer-events: none;
|
|
410
466
|
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
}
|
|
426
|
-
.toast.top-center:dir(rtl) {
|
|
427
|
-
transform: translateX(50%);
|
|
428
|
-
}
|
|
429
|
-
.toast.top-right {
|
|
430
|
-
inset-block-start: 0;
|
|
431
|
-
inset-block-end: auto;
|
|
432
|
-
inset-inline-start: auto;
|
|
433
|
-
inset-inline-end: 0;
|
|
434
|
-
}
|
|
435
|
-
.toast.bottom-left {
|
|
436
|
-
inset-block-start: auto;
|
|
437
|
-
inset-block-end: 0;
|
|
438
|
-
inset-inline-start: 0;
|
|
439
|
-
inset-inline-end: auto;
|
|
440
|
-
}
|
|
441
|
-
.toast.bottom-center {
|
|
442
|
-
inset-block-start: auto;
|
|
443
|
-
inset-block-end: 0;
|
|
444
|
-
inset-inline-start: 50%;
|
|
445
|
-
inset-inline-end: auto;
|
|
446
|
-
}
|
|
447
|
-
.toast.bottom-center:dir(ltr) {
|
|
448
|
-
transform: translateX(-50%);
|
|
449
|
-
}
|
|
450
|
-
.toast.bottom-center:dir(rtl) {
|
|
451
|
-
transform: translateX(50%);
|
|
452
|
-
}
|
|
453
|
-
.toast.bottom-right {
|
|
454
|
-
inset-block-start: auto;
|
|
455
|
-
inset-block-end: 0;
|
|
456
|
-
inset-inline-start: auto;
|
|
457
|
-
inset-inline-end: 0;
|
|
467
|
+
@supports (interpolate-size: allow-keywords) {
|
|
468
|
+
.toast {
|
|
469
|
+
interpolate-size: allow-keywords;
|
|
470
|
+
}
|
|
471
|
+
@starting-style {
|
|
472
|
+
.toast {
|
|
473
|
+
margin-block: 0;
|
|
474
|
+
height: 0;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
.toast[aria-hidden=true] {
|
|
478
|
+
margin-block: 0;
|
|
479
|
+
height: 0;
|
|
480
|
+
}
|
|
458
481
|
}
|
|
459
|
-
.toast
|
|
460
|
-
|
|
482
|
+
.toast:has(:global(.alert)) {
|
|
483
|
+
filter: drop-shadow(0 8px 8px var(--sui-popup-shadow-color));
|
|
461
484
|
}</style>
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
font-style: normal;
|
|
14
14
|
font-display: swap;
|
|
15
15
|
font-weight: 200 900;
|
|
16
|
-
src: url(https://cdn.jsdelivr.net/fontsource/fonts/source-sans-3:vf@5.3.
|
|
16
|
+
src: url(https://cdn.jsdelivr.net/fontsource/fonts/source-sans-3:vf@5.3.1/latin-wght-normal.woff2)
|
|
17
17
|
format('woff2-variations');
|
|
18
18
|
unicode-range:
|
|
19
19
|
U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
font-style: normal;
|
|
38
38
|
font-display: block;
|
|
39
39
|
font-weight: 400;
|
|
40
|
-
src: url(https://cdn.jsdelivr.net/fontsource/fonts/material-symbols-outlined:vf@5.3.
|
|
40
|
+
src: url(https://cdn.jsdelivr.net/fontsource/fonts/material-symbols-outlined:vf@5.3.9/latin-wght-normal.woff2)
|
|
41
41
|
format('woff2-variations');
|
|
42
42
|
unicode-range:
|
|
43
43
|
U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
|
|
@@ -47,7 +47,7 @@ export const FONTS = [
|
|
|
47
47
|
{
|
|
48
48
|
family: 'Source Sans 3',
|
|
49
49
|
packageName: '@fontsource-variable/source-sans-3',
|
|
50
|
-
version: '5.3.
|
|
50
|
+
version: '5.3.1',
|
|
51
51
|
cdnId: 'source-sans-3:vf',
|
|
52
52
|
subset: 'latin-wght-normal',
|
|
53
53
|
format: 'woff2-variations',
|
|
@@ -69,7 +69,7 @@ export const FONTS = [
|
|
|
69
69
|
{
|
|
70
70
|
family: 'Material Symbols Outlined',
|
|
71
71
|
packageName: '@fontsource-variable/material-symbols-outlined',
|
|
72
|
-
version: '5.3.
|
|
72
|
+
version: '5.3.9',
|
|
73
73
|
cdnId: 'material-symbols-outlined:vf',
|
|
74
74
|
subset: 'latin-wght-normal',
|
|
75
75
|
format: 'woff2-variations',
|
package/dist/index.d.ts
CHANGED
|
@@ -82,6 +82,7 @@ export { default as Modal } from "./components/util/modal.svelte";
|
|
|
82
82
|
export { default as Placeholder } from "./components/util/placeholder.svelte";
|
|
83
83
|
export { default as Popup } from "./components/util/popup.svelte";
|
|
84
84
|
export { default as VisibilityObserver } from "./components/util/visibility-observer.svelte";
|
|
85
|
+
export { IMPORT_UPDATE_TAG } from "./components/text-editor/constants.js";
|
|
85
86
|
export { loadCodeHighlighter } from "./components/text-editor/core.js";
|
|
86
87
|
export { setCodeHighlighterCacheEnabled } from "./components/text-editor/shiki/cache.js";
|
|
87
88
|
export { highlightCodeToHTML } from "./components/text-editor/shiki/facade.js";
|
package/dist/index.js
CHANGED
|
@@ -82,6 +82,7 @@ export { default as Modal } from './components/util/modal.svelte';
|
|
|
82
82
|
export { default as Placeholder } from './components/util/placeholder.svelte';
|
|
83
83
|
export { default as Popup } from './components/util/popup.svelte';
|
|
84
84
|
export { default as VisibilityObserver } from './components/util/visibility-observer.svelte';
|
|
85
|
+
export { IMPORT_UPDATE_TAG } from './components/text-editor/constants.js';
|
|
85
86
|
export { loadCodeHighlighter } from './components/text-editor/core.js';
|
|
86
87
|
export { setCodeHighlighterCacheEnabled } from './components/text-editor/shiki/cache.js';
|
|
87
88
|
export { highlightCodeToHTML } from './components/text-editor/shiki/facade.js';
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltia/ui",
|
|
3
|
-
"version": "0.81.
|
|
3
|
+
"version": "0.81.2",
|
|
4
4
|
"description": "A collection of Svelte components and utilities for building user interfaces.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
"lexical": "^0.52.0"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@fontsource-variable/material-symbols-outlined": "5.3.
|
|
70
|
-
"@fontsource-variable/source-sans-3": "5.3.
|
|
69
|
+
"@fontsource-variable/material-symbols-outlined": "5.3.9",
|
|
70
|
+
"@fontsource-variable/source-sans-3": "5.3.1",
|
|
71
71
|
"@fontsource/noto-mono": "5.3.0",
|
|
72
72
|
"@rollup/plugin-yaml": "^5.0.0",
|
|
73
73
|
"@sveltejs/adapter-auto": "^8.0.0",
|
|
@@ -81,11 +81,11 @@
|
|
|
81
81
|
"eslint-config-airbnb-extended": "^3.3.0",
|
|
82
82
|
"eslint-config-prettier": "^10.1.8",
|
|
83
83
|
"eslint-plugin-import": "^2.32.0",
|
|
84
|
-
"eslint-plugin-jsdoc": "^65.
|
|
84
|
+
"eslint-plugin-jsdoc": "^65.3.0",
|
|
85
85
|
"eslint-plugin-package-json": "^1.10.1",
|
|
86
86
|
"eslint-plugin-svelte": "^3.23.1",
|
|
87
87
|
"globals": "^17.13.0",
|
|
88
|
-
"happy-dom": "^
|
|
88
|
+
"happy-dom": "^21.0.1",
|
|
89
89
|
"oxlint": "^1.87.0",
|
|
90
90
|
"playwright": "^1.64.0",
|
|
91
91
|
"postcss": "^8.5.29",
|