@ohhwells/bridge 0.1.141 → 0.1.142
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/dist/index.cjs +41 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +41 -30
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1350,15 +1350,25 @@ function readAssignments(content) {
|
|
|
1350
1350
|
function cssLength(style, prop) {
|
|
1351
1351
|
return style.getPropertyValue(prop) || "0px";
|
|
1352
1352
|
}
|
|
1353
|
+
function withTransitionsSettled(el, read) {
|
|
1354
|
+
const prior = el.style.getPropertyValue("transition");
|
|
1355
|
+
const priority = el.style.getPropertyPriority("transition");
|
|
1356
|
+
el.style.setProperty("transition", "none", "important");
|
|
1357
|
+
try {
|
|
1358
|
+
return read(getComputedStyle(el));
|
|
1359
|
+
} finally {
|
|
1360
|
+
if (prior) el.style.setProperty("transition", prior, priority);
|
|
1361
|
+
else el.style.removeProperty("transition");
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1353
1364
|
function readVariantSample(el) {
|
|
1354
|
-
|
|
1355
|
-
return {
|
|
1365
|
+
return withTransitionsSettled(el, (style) => ({
|
|
1356
1366
|
background: style.backgroundColor,
|
|
1357
1367
|
color: style.color,
|
|
1358
1368
|
borderColor: style.borderTopColor,
|
|
1359
1369
|
borderWidth: style.borderTopWidth,
|
|
1360
1370
|
className: el.className || ""
|
|
1361
|
-
};
|
|
1371
|
+
}));
|
|
1362
1372
|
}
|
|
1363
1373
|
function readSizeSample(el) {
|
|
1364
1374
|
const style = getComputedStyle(el);
|
|
@@ -10281,38 +10291,39 @@ function deriveTemplateButtonStyle() {
|
|
|
10281
10291
|
el.querySelectorAll("[data-ohw-editable]").length <= 1
|
|
10282
10292
|
);
|
|
10283
10293
|
const isFilled = (el) => {
|
|
10284
|
-
const bg =
|
|
10294
|
+
const bg = withTransitionsSettled(el, (s) => s.backgroundColor);
|
|
10285
10295
|
if (!bg || bg === "transparent") return false;
|
|
10286
10296
|
const alpha = bg.match(/rgba?\([^)]*,\s*([\d.]+)\)$/);
|
|
10287
10297
|
return !alpha || parseFloat(alpha[1]) > 0;
|
|
10288
10298
|
};
|
|
10289
10299
|
const btn = candidates.find(isFilled) ?? candidates[0];
|
|
10290
10300
|
if (!btn) return null;
|
|
10291
|
-
|
|
10292
|
-
|
|
10293
|
-
|
|
10294
|
-
|
|
10295
|
-
|
|
10296
|
-
|
|
10297
|
-
|
|
10298
|
-
|
|
10299
|
-
|
|
10300
|
-
|
|
10301
|
-
|
|
10302
|
-
|
|
10303
|
-
|
|
10304
|
-
|
|
10305
|
-
|
|
10306
|
-
|
|
10307
|
-
|
|
10308
|
-
|
|
10309
|
-
|
|
10310
|
-
|
|
10311
|
-
|
|
10312
|
-
|
|
10313
|
-
|
|
10314
|
-
|
|
10315
|
-
|
|
10301
|
+
return withTransitionsSettled(btn, (cs) => {
|
|
10302
|
+
const filled = isFilled(btn);
|
|
10303
|
+
const corners = [
|
|
10304
|
+
cs.borderTopLeftRadius,
|
|
10305
|
+
cs.borderTopRightRadius,
|
|
10306
|
+
cs.borderBottomRightRadius,
|
|
10307
|
+
cs.borderBottomLeftRadius
|
|
10308
|
+
].map((v) => v || "0px");
|
|
10309
|
+
const radius = corners.every((v) => v === corners[0]) ? corners[0] : corners.join(" ");
|
|
10310
|
+
const px2 = (v) => parseFloat(v) || 0;
|
|
10311
|
+
const lineHeight = px2(cs.lineHeight) || px2(cs.fontSize) * 1.2;
|
|
10312
|
+
const contentH = btn.getBoundingClientRect().height - px2(cs.borderTopWidth) - px2(cs.borderBottomWidth);
|
|
10313
|
+
const impliedY = Math.round(Math.max(0, (contentH - lineHeight) / 2));
|
|
10314
|
+
const padY = Math.max(px2(cs.paddingTop), px2(cs.paddingBottom), impliedY);
|
|
10315
|
+
const padX = Math.max(px2(cs.paddingLeft), px2(cs.paddingRight));
|
|
10316
|
+
return {
|
|
10317
|
+
radius: radius || "10px",
|
|
10318
|
+
padding: `${padY}px ${padX}px`,
|
|
10319
|
+
...filled ? { background: cs.backgroundColor, color: cs.color } : {},
|
|
10320
|
+
fontFamily: cs.fontFamily || "",
|
|
10321
|
+
fontSize: cs.fontSize || "",
|
|
10322
|
+
fontWeight: cs.fontWeight || "",
|
|
10323
|
+
letterSpacing: cs.letterSpacing || "",
|
|
10324
|
+
textTransform: cs.textTransform || ""
|
|
10325
|
+
};
|
|
10326
|
+
});
|
|
10316
10327
|
}
|
|
10317
10328
|
var mounted = /* @__PURE__ */ new Map();
|
|
10318
10329
|
function findTemplateSection(id) {
|
|
@@ -31208,7 +31219,7 @@ function OhhwellsBridge() {
|
|
|
31208
31219
|
postToParent2({
|
|
31209
31220
|
type: "ow:ready",
|
|
31210
31221
|
version: "1",
|
|
31211
|
-
bridgeVersion: "0.1.
|
|
31222
|
+
bridgeVersion: "0.1.141",
|
|
31212
31223
|
path: pathname,
|
|
31213
31224
|
nodes: collectEditableNodes(editContentRef.current),
|
|
31214
31225
|
sections
|