motion-dom 11.14.3 → 11.16.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.
@@ -0,0 +1,32 @@
1
+ let pendingRules = {};
2
+ let style = null;
3
+ const css = {
4
+ set: (selector, values) => {
5
+ pendingRules[selector] = values;
6
+ },
7
+ commit: () => {
8
+ if (!style) {
9
+ style = document.createElement("style");
10
+ style.id = "motion-view";
11
+ }
12
+ let cssText = "";
13
+ for (const selector in pendingRules) {
14
+ const rule = pendingRules[selector];
15
+ cssText += `${selector} {\n`;
16
+ for (const [property, value] of Object.entries(rule)) {
17
+ cssText += ` ${property}: ${value};\n`;
18
+ }
19
+ cssText += "}\n";
20
+ }
21
+ style.textContent = cssText;
22
+ document.head.appendChild(style);
23
+ pendingRules = {};
24
+ },
25
+ remove: () => {
26
+ if (style && style.parentElement) {
27
+ style.parentElement.removeChild(style);
28
+ }
29
+ },
30
+ };
31
+
32
+ export { css };
@@ -0,0 +1,8 @@
1
+ function getLayerName(pseudoElement) {
2
+ const match = pseudoElement.match(/::view-transition-(old|new|group|image-pair)\((.*?)\)/);
3
+ if (!match)
4
+ return null;
5
+ return { layer: match[2], type: match[1] };
6
+ }
7
+
8
+ export { getLayerName };
@@ -0,0 +1,13 @@
1
+ function filterViewAnimations(animation) {
2
+ var _a;
3
+ const { effect } = animation;
4
+ if (!effect)
5
+ return false;
6
+ return (effect.target === document.documentElement &&
7
+ ((_a = effect.pseudoElement) === null || _a === void 0 ? void 0 : _a.startsWith("::view-transition")));
8
+ }
9
+ function getViewAnimations() {
10
+ return document.getAnimations().filter(filterViewAnimations);
11
+ }
12
+
13
+ export { getViewAnimations };
@@ -0,0 +1,5 @@
1
+ function hasTarget(target, targets) {
2
+ return targets.has(target) && Object.keys(targets.get(target)).length > 0;
3
+ }
4
+
5
+ export { hasTarget };