@webtides/element-library 0.1.0 → 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 +16 -0
- package/custom-elements.json +489 -489
- package/package.json +3 -5
- package/src/components/carousel/carousel.changelog.md +6 -0
- package/src/components/carousel/glide/components/ShadowHtml.js +1 -1
- package/src/components/carousel/glide/components/glide-html.js +108 -0
- package/src/components/dialog/dialog.changelog.md +6 -0
- package/src/components/notification/notification.changelog.md +6 -0
- package/src/utils/body-scroll.js +43 -0
- package/src/utils/transitions.js +39 -0
- package/types/src/components/carousel/glide/components/ShadowHtml.d.ts +4 -1
- package/types/src/components/carousel/glide/components/glide-html.d.ts +12 -0
- package/web-types.json +211 -211
- package/patches/@glidejs+glide+3.6.2.patch +0 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webtides/element-library",
|
|
3
|
-
"version": "0.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,13 +39,13 @@
|
|
|
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",
|
|
45
46
|
"index.js",
|
|
46
47
|
"custom-elements.json",
|
|
47
48
|
"web-types.json",
|
|
48
|
-
"patches",
|
|
49
49
|
"CHANGELOG.md"
|
|
50
50
|
],
|
|
51
51
|
"repository": {
|
|
@@ -97,7 +97,6 @@
|
|
|
97
97
|
"husky": "^9.1.7",
|
|
98
98
|
"lint-staged": "^17.0.7",
|
|
99
99
|
"lit": "^3.3.3",
|
|
100
|
-
"patch-package": "^8.0.1",
|
|
101
100
|
"playwright": "^1.60.0",
|
|
102
101
|
"prettier": "^3.8.3",
|
|
103
102
|
"storybook": "^10.4.1",
|
|
@@ -117,8 +116,7 @@
|
|
|
117
116
|
"analyze:watch": "cem analyze --config custom-elements-manifest.config.mjs --outdir . --watch",
|
|
118
117
|
"build:types": "tsc -p tsconfig.json",
|
|
119
118
|
"prepack": "npm run analyze && npm run build:types",
|
|
120
|
-
"prepare": "husky && npm run analyze && npm run build:types"
|
|
121
|
-
"postinstall": "patch-package"
|
|
119
|
+
"prepare": "husky && npm run analyze && npm run build:types"
|
|
122
120
|
},
|
|
123
121
|
"lint-staged": {
|
|
124
122
|
"*.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.1] - 2026-06-04
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- The carousel now bundles in consumer projects. `ShadowHtml` deep-imported `@glidejs/glide/src/components/html`, whose pristine source does `import { exist, toArray } from '../utils/dom'` even though `dom.js` exports no `exist` — `esbuild`/Vite reject this as a hard error ("No matching export for import 'exist'"). `0.1.0` patched it via `patch-package`/`postinstall`, but a dependency's `postinstall` runs from its own nested directory and cannot reach the consumer's hoisted `@glidejs/glide`, so the patch never applied downstream (and the missing `patch-package` binary broke `npm install` outright). The fixed Glide `html.js` is now vendored as `glide/components/glide-html.js` (upstream verbatim minus the unused `exist` import) and `ShadowHtml` imports that copy, removing all reliance on patching consumers' `node_modules`.
|
|
20
|
+
|
|
15
21
|
## [0.1.0] - 2026-06-03
|
|
16
22
|
|
|
17
23
|
### Changed
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// Vendored from @glidejs/glide@3.6.2 (src/components/html.js), MIT License.
|
|
2
|
+
// https://github.com/glidejs/glide
|
|
3
|
+
//
|
|
4
|
+
// Only change vs. upstream: the unused `exist` named import was dropped — the
|
|
5
|
+
// pristine file does `import { exist, toArray } from '../utils/dom'`, but
|
|
6
|
+
// `dom.js` exports no `exist`, which bundlers such as esbuild/Vite reject as a
|
|
7
|
+
// hard error ("No matching export for import 'exist'"). The carousel deep-imports
|
|
8
|
+
// this component, so we vendor the fixed copy here instead of patching consumers'
|
|
9
|
+
// node_modules at install time. Relative util imports are re-pointed to the
|
|
10
|
+
// published package paths; the rest is upstream verbatim.
|
|
11
|
+
import { warn } from '@glidejs/glide/src/utils/log';
|
|
12
|
+
import { toArray } from '@glidejs/glide/src/utils/dom';
|
|
13
|
+
import { define } from '@glidejs/glide/src/utils/object';
|
|
14
|
+
import { isString } from '@glidejs/glide/src/utils/unit';
|
|
15
|
+
|
|
16
|
+
const TRACK_SELECTOR = '[data-glide-el="track"]';
|
|
17
|
+
|
|
18
|
+
export default function (Glide, Components, Events) {
|
|
19
|
+
const Html = {
|
|
20
|
+
/**
|
|
21
|
+
* Setup slider HTML nodes.
|
|
22
|
+
*
|
|
23
|
+
* @param {Glide} glide
|
|
24
|
+
*/
|
|
25
|
+
mount() {
|
|
26
|
+
this.root = Glide.selector;
|
|
27
|
+
this.track = this.root.querySelector(TRACK_SELECTOR);
|
|
28
|
+
this.collectSlides();
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Collect slides
|
|
33
|
+
*/
|
|
34
|
+
collectSlides() {
|
|
35
|
+
this.slides = toArray(this.wrapper.children).filter((slide) => {
|
|
36
|
+
return !slide.classList.contains(Glide.settings.classes.slide.clone);
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
define(Html, 'root', {
|
|
42
|
+
/**
|
|
43
|
+
* Gets node of the glide main element.
|
|
44
|
+
*
|
|
45
|
+
* @return {Object}
|
|
46
|
+
*/
|
|
47
|
+
get() {
|
|
48
|
+
return Html._r;
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Sets node of the glide main element.
|
|
53
|
+
*
|
|
54
|
+
* @return {Object}
|
|
55
|
+
*/
|
|
56
|
+
set(r) {
|
|
57
|
+
if (isString(r)) {
|
|
58
|
+
r = document.querySelector(r);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (r !== null) {
|
|
62
|
+
Html._r = r;
|
|
63
|
+
} else {
|
|
64
|
+
warn('Root element must be a existing Html node');
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
define(Html, 'track', {
|
|
70
|
+
/**
|
|
71
|
+
* Gets node of the glide track with slides.
|
|
72
|
+
*
|
|
73
|
+
* @return {Object}
|
|
74
|
+
*/
|
|
75
|
+
get() {
|
|
76
|
+
return Html._t;
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Sets node of the glide track with slides.
|
|
81
|
+
*
|
|
82
|
+
* @return {Object}
|
|
83
|
+
*/
|
|
84
|
+
set(t) {
|
|
85
|
+
Html._t = t;
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
define(Html, 'wrapper', {
|
|
90
|
+
/**
|
|
91
|
+
* Gets node of the slides wrapper.
|
|
92
|
+
*
|
|
93
|
+
* @return {Object}
|
|
94
|
+
*/
|
|
95
|
+
get() {
|
|
96
|
+
return Html.track.children[0];
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Add/remove/reorder dynamic slides
|
|
102
|
+
*/
|
|
103
|
+
Events.on('update', () => {
|
|
104
|
+
Html.collectSlides();
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
return Html;
|
|
108
|
+
}
|
|
@@ -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
|
+
}
|