@threadlabs/looma 0.51.4 → 0.51.6
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/components/ui-card/ui-card.html +7 -0
- package/components/ui-disclosure/ui-disclosure.js +42 -1
- package/dist/index.js +1 -1
- package/docs/catalog.json +28 -1
- package/editor/index.js +44 -1
- package/package.json +1 -1
- package/styles/ui-card.css +5 -0
- package/vanilla/UiCard.d.ts +1 -0
- package/vanilla/UiCard.js +13 -13
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
<template component="ui-card">
|
|
2
2
|
<defs>
|
|
3
|
+
<prop name="fill" type="boolean" default="false"
|
|
4
|
+
>In a bounded flex column, grows into the remaining height. Put a filling Scroll Area in the body when its content needs to scroll independently.</prop>
|
|
3
5
|
<prop name="size" type="keyword" values="content, sm, md, lg" default="content"
|
|
4
6
|
>Optional size preset. content keeps the existing intrinsic sizing; the other sizes constrain the surface for compact, medium, or large content.</prop>
|
|
5
7
|
<prop name="variant" type="keyword" values="outlined, subtle, elevated" default="outlined"
|
|
@@ -80,6 +82,11 @@
|
|
|
80
82
|
--_ui-card-group-region-layout: initial;
|
|
81
83
|
}
|
|
82
84
|
|
|
85
|
+
:host([fill]) {
|
|
86
|
+
flex: 1;
|
|
87
|
+
min-block-size: 0;
|
|
88
|
+
}
|
|
89
|
+
|
|
83
90
|
.header:empty {
|
|
84
91
|
display: none !important;
|
|
85
92
|
}
|
|
@@ -42,18 +42,52 @@ export function connect(host) {
|
|
|
42
42
|
host.state.internalOpen = Boolean(external);
|
|
43
43
|
let groupName = "";
|
|
44
44
|
let disposed = false;
|
|
45
|
+
let motionFrame = 0;
|
|
46
|
+
let takeoverMotion;
|
|
47
|
+
const view = document.defaultView;
|
|
48
|
+
const reducedMotion = view?.matchMedia?.("(prefers-reduced-motion: reduce)");
|
|
49
|
+
const stopTakeoverMotion = () => {
|
|
50
|
+
view?.cancelAnimationFrame(motionFrame);
|
|
51
|
+
motionFrame = 0;
|
|
52
|
+
takeoverMotion?.cancel();
|
|
53
|
+
};
|
|
54
|
+
const onMotionPreferenceChange = () => { if (reducedMotion.matches) stopTakeoverMotion(); };
|
|
55
|
+
reducedMotion?.addEventListener("change", onMotionPreferenceChange);
|
|
56
|
+
// A consumer may hide a sibling when this panel takes over the remaining space.
|
|
57
|
+
// Flex interpolation alone cannot animate the resulting change of position.
|
|
58
|
+
const animateFillTakeover = () => {
|
|
59
|
+
if (motionFrame || !host.props.fill.value || !view || !host.element.animate) return;
|
|
60
|
+
const previousTop = host.refs.heading.getBoundingClientRect().top;
|
|
61
|
+
takeoverMotion?.cancel();
|
|
62
|
+
if (reducedMotion?.matches) return;
|
|
63
|
+
motionFrame = view.requestAnimationFrame(() => {
|
|
64
|
+
motionFrame = 0;
|
|
65
|
+
if (disposed || !host.element.isConnected) return;
|
|
66
|
+
const delta = previousTop - host.refs.heading.getBoundingClientRect().top;
|
|
67
|
+
if (Math.abs(delta) < 1) return;
|
|
68
|
+
const style = view.getComputedStyle(host.element);
|
|
69
|
+
const duration = style.transitionDuration.split(",")[0].trim();
|
|
70
|
+
const milliseconds = parseFloat(duration) * (duration.endsWith("ms") ? 1 : 1000);
|
|
71
|
+
if (!(milliseconds > 0)) return;
|
|
72
|
+
takeoverMotion = host.element.animate([{ translate: `0 ${delta}px` }, { translate: "0 0" }], {
|
|
73
|
+
duration: milliseconds, easing: style.transitionTimingFunction, fill: "none",
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
};
|
|
45
77
|
const member = {
|
|
46
78
|
isOpen: () => Boolean(host.state.internalOpen),
|
|
47
79
|
required: () => Boolean(host.props.requiredOpen.value),
|
|
48
80
|
disabled: () => Boolean(host.props.disabled.value),
|
|
49
81
|
open() {
|
|
50
82
|
if (disposed || host.state.internalOpen) return;
|
|
83
|
+
animateFillTakeover();
|
|
51
84
|
host.state.internalOpen = true;
|
|
52
85
|
syncGroup("programmatic", "programmatic");
|
|
53
86
|
host.dispatch("open", { open: true, reason: "programmatic", trigger: "programmatic" });
|
|
54
87
|
},
|
|
55
88
|
close(reason, how) {
|
|
56
89
|
if (!host.state.internalOpen) return;
|
|
90
|
+
animateFillTakeover();
|
|
57
91
|
host.state.internalOpen = false;
|
|
58
92
|
host.dispatch("close", { open: false, reason, trigger: how });
|
|
59
93
|
},
|
|
@@ -78,7 +112,10 @@ export function connect(host) {
|
|
|
78
112
|
const stop = host.effect(() => {
|
|
79
113
|
if (host.props.open.value !== external) {
|
|
80
114
|
external = host.props.open.value;
|
|
81
|
-
if (external || mayClose())
|
|
115
|
+
if (external || mayClose()) {
|
|
116
|
+
animateFillTakeover();
|
|
117
|
+
host.state.internalOpen = Boolean(external);
|
|
118
|
+
}
|
|
82
119
|
}
|
|
83
120
|
const level = Number(host.props.headingLevel.value);
|
|
84
121
|
host.state.headingRole = Number.isInteger(level) && level >= 2 && level <= 6 ? "heading" : null;
|
|
@@ -92,12 +129,14 @@ export function connect(host) {
|
|
|
92
129
|
const open = !host.state.internalOpen;
|
|
93
130
|
if (!open && !mayClose()) return;
|
|
94
131
|
const how = trigger();
|
|
132
|
+
animateFillTakeover();
|
|
95
133
|
host.state.internalOpen = open;
|
|
96
134
|
if (open) syncGroup("action", how);
|
|
97
135
|
host.dispatch(open ? "open" : "close", { open, reason: "action", trigger: how });
|
|
98
136
|
};
|
|
99
137
|
const onBeforematch = () => queueMicrotask(() => {
|
|
100
138
|
if (disposed || host.state.internalOpen) return;
|
|
139
|
+
animateFillTakeover();
|
|
101
140
|
host.state.internalOpen = true;
|
|
102
141
|
syncGroup("programmatic", "programmatic");
|
|
103
142
|
host.dispatch("open", { open: true, reason: "programmatic", trigger: "programmatic" });
|
|
@@ -111,6 +150,8 @@ export function connect(host) {
|
|
|
111
150
|
measureHeading();
|
|
112
151
|
return () => {
|
|
113
152
|
disposed = true;
|
|
153
|
+
stopTakeoverMotion();
|
|
154
|
+
reducedMotion?.removeEventListener("change", onMotionPreferenceChange);
|
|
114
155
|
headingObserver?.disconnect();
|
|
115
156
|
stop();
|
|
116
157
|
stopTracking();
|