@unlayer/react-elements 0.1.14 → 0.1.16
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 +62 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -5
- package/dist/index.d.ts +19 -5
- package/dist/index.js +62 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -346,14 +346,27 @@ function mapSemanticProps(props, defaultValues, componentType) {
|
|
|
346
346
|
delete userProps.html;
|
|
347
347
|
delete result.html;
|
|
348
348
|
}
|
|
349
|
-
|
|
350
|
-
const v = userProps[key];
|
|
349
|
+
const canonicalizeLink = (v) => {
|
|
351
350
|
if (typeof v === "string") {
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
};
|
|
351
|
+
return { name: "web", values: { href: v, target: "_blank" } };
|
|
352
|
+
}
|
|
353
|
+
if (v && typeof v === "object" && "name" in v && v.attrs && typeof v.attrs === "object") {
|
|
354
|
+
const { href: attrsHref, target: attrsTarget, ...customAttrs } = v.attrs;
|
|
355
|
+
if (attrsHref !== void 0 || attrsTarget !== void 0) {
|
|
356
|
+
const linkValues = { ...v.values };
|
|
357
|
+
if (!linkValues.href && attrsHref !== void 0) linkValues.href = attrsHref;
|
|
358
|
+
if (!linkValues.target && attrsTarget !== void 0) linkValues.target = attrsTarget;
|
|
359
|
+
const next = { ...v, values: linkValues };
|
|
360
|
+
if (Object.keys(customAttrs).length) next.attrs = customAttrs;
|
|
361
|
+
else delete next.attrs;
|
|
362
|
+
return next;
|
|
363
|
+
}
|
|
356
364
|
}
|
|
365
|
+
return v;
|
|
366
|
+
};
|
|
367
|
+
for (const key of ["href", "action"]) {
|
|
368
|
+
if (userProps[key] !== void 0) userProps[key] = canonicalizeLink(userProps[key]);
|
|
369
|
+
if (result[key] !== void 0) result[key] = canonicalizeLink(result[key]);
|
|
357
370
|
}
|
|
358
371
|
normalizeCssProps(userProps);
|
|
359
372
|
const nestedGroups = analyzeNestedStructure(defaultValues);
|
|
@@ -402,6 +415,16 @@ function mapSemanticProps(props, defaultValues, componentType) {
|
|
|
402
415
|
if (Object.keys(collected).length > 0) {
|
|
403
416
|
final.border = { ...final.border || {}, ...collected };
|
|
404
417
|
}
|
|
418
|
+
if (final.border && typeof final.border === "object") {
|
|
419
|
+
const b = { ...final.border };
|
|
420
|
+
for (const key of Object.keys(b)) {
|
|
421
|
+
if (!/Width$/.test(key)) continue;
|
|
422
|
+
const v = b[key];
|
|
423
|
+
if (typeof v === "number") b[key] = `${v}px`;
|
|
424
|
+
else if (typeof v === "string" && /^\d+(?:\.\d+)?$/.test(v.trim())) b[key] = `${v.trim()}px`;
|
|
425
|
+
}
|
|
426
|
+
final.border = b;
|
|
427
|
+
}
|
|
405
428
|
}
|
|
406
429
|
return final;
|
|
407
430
|
}
|
|
@@ -413,12 +436,14 @@ function normalizeLinkValue(value) {
|
|
|
413
436
|
if (typeof value !== "object") return void 0;
|
|
414
437
|
const v = value;
|
|
415
438
|
if ("url" in v) return v;
|
|
416
|
-
if ("name" in v && v.values && typeof v.values === "object") {
|
|
417
|
-
const inner = v.values;
|
|
439
|
+
if ("name" in v && (v.values && typeof v.values === "object" || v.attrs && typeof v.attrs === "object")) {
|
|
440
|
+
const inner = v.values && typeof v.values === "object" ? v.values : {};
|
|
441
|
+
const attrs = v.attrs && typeof v.attrs === "object" ? v.attrs : {};
|
|
442
|
+
const { href: attrsHref, target: attrsTarget, ...customAttrs } = attrs;
|
|
418
443
|
return {
|
|
419
|
-
url: inner.href
|
|
420
|
-
target: inner.target
|
|
421
|
-
...
|
|
444
|
+
url: inner.href || attrsHref || "",
|
|
445
|
+
target: inner.target || attrsTarget || "_blank",
|
|
446
|
+
...customAttrs
|
|
422
447
|
};
|
|
423
448
|
}
|
|
424
449
|
return void 0;
|
|
@@ -770,11 +795,11 @@ var Html = createItemComponent({
|
|
|
770
795
|
exporters: exporters.HtmlExporters
|
|
771
796
|
});
|
|
772
797
|
var Html_default = Html;
|
|
798
|
+
var { height: _placeholderHeight, ...defaultSrc } = exporters.ImageDefaults.src;
|
|
773
799
|
var DEFAULT_VALUES5 = {
|
|
774
800
|
...exporters.ImageDefaults,
|
|
775
|
-
// Override src with autoWidth/maxWidth for responsive rendering
|
|
776
801
|
src: {
|
|
777
|
-
...
|
|
802
|
+
...defaultSrc,
|
|
778
803
|
autoWidth: true,
|
|
779
804
|
maxWidth: "100%"
|
|
780
805
|
}
|
|
@@ -816,7 +841,7 @@ var Image = createItemComponent({
|
|
|
816
841
|
};
|
|
817
842
|
let displayPct;
|
|
818
843
|
let displayPx;
|
|
819
|
-
for (const candidate of [widthProp, maxWidthProp, userSrc.maxWidth]) {
|
|
844
|
+
for (const candidate of [widthProp, maxWidthProp, userSrc.maxWidth, userSrc.width]) {
|
|
820
845
|
if (candidate === void 0) continue;
|
|
821
846
|
const pct = asPercent(candidate);
|
|
822
847
|
if (pct) {
|
|
@@ -907,6 +932,17 @@ var Social = createItemComponent({
|
|
|
907
932
|
defaultValues: DEFAULT_VALUES8,
|
|
908
933
|
propMapper: (props) => {
|
|
909
934
|
const { icons, iconType, ...rest } = props;
|
|
935
|
+
const coerceSizes = (base) => {
|
|
936
|
+
for (const key of ["iconSize", "spacing"]) {
|
|
937
|
+
const v = base[key];
|
|
938
|
+
if (typeof v === "string") {
|
|
939
|
+
const m = /^(\d+(?:\.\d+)?)(?:px)?$/.exec(v.trim());
|
|
940
|
+
if (m) base[key] = parseFloat(m[1]);
|
|
941
|
+
else delete base[key];
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
return base;
|
|
945
|
+
};
|
|
910
946
|
if (Array.isArray(icons)) {
|
|
911
947
|
const mapped = icons.map((icon) => ({
|
|
912
948
|
name: icon.name,
|
|
@@ -921,7 +957,7 @@ var Social = createItemComponent({
|
|
|
921
957
|
iconType: iconType ?? base.icons?.iconType ?? "circle",
|
|
922
958
|
icons: mapped
|
|
923
959
|
};
|
|
924
|
-
return base;
|
|
960
|
+
return coerceSizes(base);
|
|
925
961
|
}
|
|
926
962
|
if (iconType !== void 0) {
|
|
927
963
|
const base = mapSemanticProps(
|
|
@@ -930,12 +966,10 @@ var Social = createItemComponent({
|
|
|
930
966
|
"Social"
|
|
931
967
|
);
|
|
932
968
|
base.icons = { ...DEFAULT_ICONS, ...base.icons, iconType };
|
|
933
|
-
return base;
|
|
969
|
+
return coerceSizes(base);
|
|
934
970
|
}
|
|
935
|
-
return
|
|
936
|
-
props,
|
|
937
|
-
DEFAULT_VALUES8,
|
|
938
|
-
"Social"
|
|
971
|
+
return coerceSizes(
|
|
972
|
+
mapSemanticProps(props, DEFAULT_VALUES8, "Social")
|
|
939
973
|
);
|
|
940
974
|
},
|
|
941
975
|
displayName: "Social",
|
|
@@ -1206,10 +1240,17 @@ var Row = (props) => {
|
|
|
1206
1240
|
...semanticProps
|
|
1207
1241
|
} = props;
|
|
1208
1242
|
const mode = modeProp ?? _config?.mode ?? "web";
|
|
1209
|
-
let cells
|
|
1243
|
+
let cells;
|
|
1210
1244
|
if (layout) {
|
|
1211
1245
|
validateColumnLayout(layout, React__default.default.Children.count(children));
|
|
1212
1246
|
cells = layout.cells;
|
|
1247
|
+
} else if (propsCells) {
|
|
1248
|
+
cells = propsCells;
|
|
1249
|
+
} else {
|
|
1250
|
+
const columnCount = React__default.default.Children.toArray(children).filter(
|
|
1251
|
+
(c) => React__default.default.isValidElement(c) && /^Column$/.test(c.type?.displayName || c.type?.name || "")
|
|
1252
|
+
).length;
|
|
1253
|
+
cells = Array(Math.max(1, columnCount)).fill(1);
|
|
1213
1254
|
}
|
|
1214
1255
|
const safeBodyValues = { ...DEFAULT_BODY_VALUES, ...bodyValues };
|
|
1215
1256
|
const values = mapSemanticProps(
|