@webtides/element-library 0.1.1 → 0.2.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/CHANGELOG.md CHANGED
@@ -12,6 +12,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/) and this
12
12
 
13
13
  ## Unreleased
14
14
 
15
+ ## [0.2.0] - 2026-06-10
16
+
17
+ ### Packaging
18
+
19
+ - Added: a new `@webtides/element-library/catalog` export — the recommended way to consume this library under **server-side rendering** with `@webtides/element-js-ssr-renderer`. `catalog.js` is a generated, bundler-traceable `Catalog` (`{ "el-button": () => import("./src/components/button/button.js"), … }`) covering all 26 components. Because it ships **inside the package**, its specifiers are package-internal relative paths that resolve in any consumer's bundle regardless of `node_modules` layout, so SSR works on every target (plain Node, Nitro, edge/Workers, webpack, Vite) with no consumer codegen and no hand-written import map: `import catalog from "@webtides/element-library/catalog"` then pass it to the renderer's `resolve`. Distinct from `./all` (a client-side side-effect bundle that registers every component for hydration) — the catalog defines nothing and runs no `define()`, it only tells the SSR renderer how to load each class. Regenerated automatically on release via the `prepack` hook (and on demand with `npm run gen:catalog`), so it can never drift from the components; a Node SSR smoke test (`npm run test:catalog`, run in CI) verifies a known tag still resolves to its class through the renderer.
20
+
21
+ ## [0.1.2] - 2026-06-04
22
+
23
+ ### Packaging
24
+
25
+ - 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`.
26
+
15
27
  ## [0.1.1] - 2026-06-04
16
28
 
17
29
  ### Packaging
package/catalog.js ADDED
@@ -0,0 +1,35 @@
1
+ // Generated by @webtides/element-js-ssr-renderer — do not edit by hand.
2
+ // Source: manifest custom-elements.json (26 components)
3
+ // A static, bundler-traceable Catalog. Pass it straight to `resolve` — no wrapper:
4
+ // import catalog from "./catalog.js";
5
+ // elementSSR({ resolve: catalog });
6
+
7
+ /** @type {import("@webtides/element-js-ssr-renderer").Catalog} */
8
+ export default {
9
+ "el-accordion": () => import("./src/components/accordion/accordion.js"),
10
+ "el-accordion-group": () => import("./src/components/accordion-group/accordion-group.js"),
11
+ "el-amount-field": () => import("./src/components/amount-field/amount-field.js"),
12
+ "el-button": () => import("./src/components/button/button.js"),
13
+ "el-carousel": () => import("./src/components/carousel/carousel.js"),
14
+ "el-checkbox-field": () => import("./src/components/checkbox-field/checkbox-field.js"),
15
+ "el-dialog": () => import("./src/components/dialog/dialog.js"),
16
+ "el-dropdown": () => import("./src/components/dropdown/dropdown.js"),
17
+ "el-form-field": () => import("./src/components/form-field/form-field.js"),
18
+ "el-input-field": () => import("./src/components/input-field/input-field.js"),
19
+ "el-lazy-src": () => import("./src/components/lazy-src/lazy-src.js"),
20
+ "el-notification": () => import("./src/components/notification/notification.js"),
21
+ "el-password-field": () => import("./src/components/password-field/password-field.js"),
22
+ "el-radio-field": () => import("./src/components/radio-field/radio-field.js"),
23
+ "el-scroll-to": () => import("./src/components/scroll-to/scroll-to.js"),
24
+ "el-scroll-to-top": () => import("./src/components/scroll-to-top/scroll-to-top.js"),
25
+ "el-select-field": () => import("./src/components/select-field/select-field.js"),
26
+ "el-slider": () => import("./src/components/slider/slider.js"),
27
+ "el-sticky": () => import("./src/components/sticky/sticky.js"),
28
+ "el-svg-use": () => import("./src/components/svg-use/svg-use.js"),
29
+ "el-switch-field": () => import("./src/components/switch-field/switch-field.js"),
30
+ "el-tab-group": () => import("./src/components/tab-group/tab-group.js"),
31
+ "el-tab-link": () => import("./src/components/tab-link/tab-link.js"),
32
+ "el-tab-panel": () => import("./src/components/tab-panel/tab-panel.js"),
33
+ "el-textarea-field": () => import("./src/components/textarea-field/textarea-field.js"),
34
+ "el-transition-classes": () => import("./src/components/transition-classes/transition-classes.js"),
35
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webtides/element-library",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "A set of web components built with @webtides/element-js",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -15,6 +15,7 @@
15
15
  "types": "./types/all.d.ts",
16
16
  "default": "./all.js"
17
17
  },
18
+ "./catalog": "./catalog.js",
18
19
  "./*": {
19
20
  "types": "./types/src/components/*/*.d.ts",
20
21
  "default": "./src/components/*/*.js"
@@ -39,9 +40,11 @@
39
40
  "src/components/**/*.md",
40
41
  "!src/components/**/*.stories.js",
41
42
  "!src/components/**/*.test.*.js",
43
+ "src/utils/**/*.js",
42
44
  "src/themes/*.css",
43
45
  "types/**/*.d.ts",
44
46
  "all.js",
47
+ "catalog.js",
45
48
  "index.js",
46
49
  "custom-elements.json",
47
50
  "web-types.json",
@@ -85,6 +88,7 @@
85
88
  "@vitest/browser-playwright": "^4.1.8",
86
89
  "@vitest/coverage-istanbul": "^4.1.8",
87
90
  "@vitest/ui": "^4.1.8",
91
+ "@webtides/element-js-ssr-renderer": "^0.1.0",
88
92
  "axe-core": "^4.12.0",
89
93
  "custom-element-jet-brains-integration": "^1.7.0",
90
94
  "eslint": "^10.4.1",
@@ -114,7 +118,9 @@
114
118
  "analyze": "cem analyze --config custom-elements-manifest.config.mjs --outdir .",
115
119
  "analyze:watch": "cem analyze --config custom-elements-manifest.config.mjs --outdir . --watch",
116
120
  "build:types": "tsc -p tsconfig.json",
117
- "prepack": "npm run analyze && npm run build:types",
121
+ "gen:catalog": "npx -y @webtides/element-js-ssr-renderer catalog --manifest custom-elements.json -o catalog.js && prettier --write catalog.js",
122
+ "test:catalog": "npm run gen:catalog && node test/catalog.smoke.mjs",
123
+ "prepack": "npm run analyze && npm run build:types && npm run gen:catalog",
118
124
  "prepare": "husky && npm run analyze && npm run build:types"
119
125
  },
120
126
  "lint-staged": {
@@ -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.2.0",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {