@sveltia/ui 0.81.0 → 0.81.1

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.
@@ -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(([{ isIntersecting }]) => {
51
- if (isIntersecting && loading) {
52
- loadedItemSize += itemChunkSize;
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
 
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Version of this package, used to resolve the prebuilt Shiki engine chunk from a CDN.
3
3
  */
4
- export const UI_VERSION: "0.81.0";
4
+ export const UI_VERSION: "0.81.1";
@@ -3,4 +3,4 @@
3
3
  /**
4
4
  * Version of this package, used to resolve the prebuilt Shiki engine chunk from a CDN.
5
5
  */
6
- export const UI_VERSION = '0.81.0';
6
+ export const UI_VERSION = '0.81.1';
@@ -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.0/latin-wght-normal.woff2)
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.8/latin-wght-normal.woff2)
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.0',
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.8',
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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltia/ui",
3
- "version": "0.81.0",
3
+ "version": "0.81.1",
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.8",
70
- "@fontsource-variable/source-sans-3": "5.3.0",
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.2.4",
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": "^20.14.6",
88
+ "happy-dom": "^21.0.1",
89
89
  "oxlint": "^1.87.0",
90
90
  "playwright": "^1.64.0",
91
91
  "postcss": "^8.5.29",