@webtides/element-library 0.1.1 → 0.1.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/CHANGELOG.md CHANGED
@@ -12,6 +12,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/) and this
12
12
 
13
13
  ## Unreleased
14
14
 
15
+ ## [0.1.2] - 2026-06-04
16
+
17
+ ### Packaging
18
+
19
+ - Fixed: the published tarball now ships the runtime `src/utils/*.js` files. The `files` allowlist in `package.json` included `src/components/**/*.js` but not `src/utils/**/*.js`, so `0.1.1` shipped only the `types/src/utils/*.d.ts` declarations while the runtime modules were dropped. Components that import them — `el-notification` and `el-dialog` (`../../utils/transitions.js`, `../../utils/body-scroll.js`) — failed to resolve those imports from the published package, breaking downstream builds (e.g. `nuxt build`). This is independent of the `patch-package` `postinstall` fix in `0.1.1`.
20
+
15
21
  ## [0.1.1] - 2026-06-04
16
22
 
17
23
  ### Packaging
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webtides/element-library",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "A set of web components built with @webtides/element-js",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -39,6 +39,7 @@
39
39
  "src/components/**/*.md",
40
40
  "!src/components/**/*.stories.js",
41
41
  "!src/components/**/*.test.*.js",
42
+ "src/utils/**/*.js",
42
43
  "src/themes/*.css",
43
44
  "types/**/*.d.ts",
44
45
  "all.js",
@@ -12,6 +12,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
12
12
 
13
13
  ## Unreleased
14
14
 
15
+ ## [0.1.2] - 2026-06-04
16
+
17
+ ### Fixed
18
+
19
+ - The published package now ships the runtime `src/utils/transitions.js` and `src/utils/body-scroll.js` this component imports; `0.1.1` shipped only their type declarations, so importing `el-dialog` from the published package failed to resolve `../../utils/*.js`. Fixed via the root `files` allowlist (see root [`CHANGELOG.md`](../../../CHANGELOG.md)).
20
+
15
21
  ## [0.1.0] - 2026-06-03
16
22
 
17
23
  ### Added
@@ -12,6 +12,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
12
12
 
13
13
  ## Unreleased
14
14
 
15
+ ## [0.1.2] - 2026-06-04
16
+
17
+ ### Fixed
18
+
19
+ - The published package now ships the runtime `src/utils/transitions.js` this component imports; `0.1.1` shipped only its type declaration, so importing `el-notification` from the published package failed to resolve `../../utils/transitions.js`. Fixed via the root `files` allowlist (see root [`CHANGELOG.md`](../../../CHANGELOG.md)).
20
+
15
21
  ## [0.1.0] - 2026-06-03
16
22
 
17
23
  ### Added
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Ref-counted body-scroll lock. The first caller to lock takes the lock (hiding overflow on the
3
+ * document element); it is only released once every caller has unlocked. This lets stacked overlays
4
+ * (e.g. multiple open dialogs) cooperate without one closing dialog re-enabling scrolling for
5
+ * another that is still open.
6
+ *
7
+ * Hiding the root overflow removes the scrollbar, which would otherwise widen the page content and
8
+ * cause a visible layout shift. To prevent that, the lock pads the document element by the width of
9
+ * the scrollbar it just removed (a no-op on overlay-scrollbar systems, where the width is 0).
10
+ */
11
+
12
+ let scrollLockCount = 0;
13
+ let previousRootOverflow = '';
14
+ let previousRootPaddingRight = '';
15
+
16
+ /** Locks scrolling on the document element, compensating for the removed scrollbar width. */
17
+ export function lockBodyScroll() {
18
+ if (scrollLockCount === 0) {
19
+ const root = document.documentElement;
20
+ // Measure the scrollbar before hiding it: viewport width minus the content (client) width.
21
+ const scrollbarWidth = window.innerWidth - root.clientWidth;
22
+
23
+ previousRootOverflow = root.style.overflow;
24
+ previousRootPaddingRight = root.style.paddingRight;
25
+
26
+ root.style.overflow = 'hidden';
27
+ if (scrollbarWidth > 0) {
28
+ const currentPaddingRight = parseFloat(getComputedStyle(root).paddingRight) || 0;
29
+ root.style.paddingRight = `${currentPaddingRight + scrollbarWidth}px`;
30
+ }
31
+ }
32
+ scrollLockCount += 1;
33
+ }
34
+
35
+ /** Releases one lock; restores the original overflow and padding once the last lock is released. */
36
+ export function unlockBodyScroll() {
37
+ scrollLockCount = Math.max(0, scrollLockCount - 1);
38
+ if (scrollLockCount === 0) {
39
+ const root = document.documentElement;
40
+ root.style.overflow = previousRootOverflow;
41
+ root.style.paddingRight = previousRootPaddingRight;
42
+ }
43
+ }
@@ -0,0 +1,39 @@
1
+ /** Largest comma-separated time (in seconds) from a computed transition value, e.g. "0.2s, 0.3s". */
2
+ function maxSeconds(value) {
3
+ return Math.max(0, ...value.split(',').map((part) => parseFloat(part) || 0));
4
+ }
5
+
6
+ /**
7
+ * Resolves once `element`'s running CSS transition finishes — or immediately when none is set
8
+ * (e.g. an unthemed component, or `prefers-reduced-motion` collapsing the duration to `0s`).
9
+ * @param {Element} element
10
+ * @returns {Promise<void>}
11
+ */
12
+ export function afterTransition(element) {
13
+ return new Promise((resolve) => {
14
+ const styles = getComputedStyle(element);
15
+ const duration = maxSeconds(styles.transitionDuration) + maxSeconds(styles.transitionDelay);
16
+ if (duration === 0) {
17
+ resolve();
18
+ return;
19
+ }
20
+ let settled = false;
21
+ const finish = () => {
22
+ if (settled) return;
23
+ settled = true;
24
+ element.removeEventListener('transitionend', onEnd);
25
+ resolve();
26
+ };
27
+ const onEnd = (event) => {
28
+ if (event.target === element) finish();
29
+ };
30
+ element.addEventListener('transitionend', onEnd);
31
+ // Safety net in case `transitionend` never fires (interrupted transition, hidden tab, …).
32
+ setTimeout(finish, duration * 1000 + 50);
33
+ });
34
+ }
35
+
36
+ /** Resolves after two animation frames — long enough for an enter starting-style to be committed. */
37
+ export function nextFrame() {
38
+ return new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(() => resolve())));
39
+ }
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
3
3
  "name": "@webtides/element-library",
4
- "version": "0.1.1",
4
+ "version": "0.1.2",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {