@unlayer/react-elements 0.1.14 → 0.1.15
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 +44 -20
- 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 +44 -20
- 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);
|
|
@@ -413,12 +426,14 @@ function normalizeLinkValue(value) {
|
|
|
413
426
|
if (typeof value !== "object") return void 0;
|
|
414
427
|
const v = value;
|
|
415
428
|
if ("url" in v) return v;
|
|
416
|
-
if ("name" in v && v.values && typeof v.values === "object") {
|
|
417
|
-
const inner = v.values;
|
|
429
|
+
if ("name" in v && (v.values && typeof v.values === "object" || v.attrs && typeof v.attrs === "object")) {
|
|
430
|
+
const inner = v.values && typeof v.values === "object" ? v.values : {};
|
|
431
|
+
const attrs = v.attrs && typeof v.attrs === "object" ? v.attrs : {};
|
|
432
|
+
const { href: attrsHref, target: attrsTarget, ...customAttrs } = attrs;
|
|
418
433
|
return {
|
|
419
|
-
url: inner.href
|
|
420
|
-
target: inner.target
|
|
421
|
-
...
|
|
434
|
+
url: inner.href || attrsHref || "",
|
|
435
|
+
target: inner.target || attrsTarget || "_blank",
|
|
436
|
+
...customAttrs
|
|
422
437
|
};
|
|
423
438
|
}
|
|
424
439
|
return void 0;
|
|
@@ -770,11 +785,11 @@ var Html = createItemComponent({
|
|
|
770
785
|
exporters: exporters.HtmlExporters
|
|
771
786
|
});
|
|
772
787
|
var Html_default = Html;
|
|
788
|
+
var { height: _placeholderHeight, ...defaultSrc } = exporters.ImageDefaults.src;
|
|
773
789
|
var DEFAULT_VALUES5 = {
|
|
774
790
|
...exporters.ImageDefaults,
|
|
775
|
-
// Override src with autoWidth/maxWidth for responsive rendering
|
|
776
791
|
src: {
|
|
777
|
-
...
|
|
792
|
+
...defaultSrc,
|
|
778
793
|
autoWidth: true,
|
|
779
794
|
maxWidth: "100%"
|
|
780
795
|
}
|
|
@@ -816,7 +831,7 @@ var Image = createItemComponent({
|
|
|
816
831
|
};
|
|
817
832
|
let displayPct;
|
|
818
833
|
let displayPx;
|
|
819
|
-
for (const candidate of [widthProp, maxWidthProp, userSrc.maxWidth]) {
|
|
834
|
+
for (const candidate of [widthProp, maxWidthProp, userSrc.maxWidth, userSrc.width]) {
|
|
820
835
|
if (candidate === void 0) continue;
|
|
821
836
|
const pct = asPercent(candidate);
|
|
822
837
|
if (pct) {
|
|
@@ -907,6 +922,17 @@ var Social = createItemComponent({
|
|
|
907
922
|
defaultValues: DEFAULT_VALUES8,
|
|
908
923
|
propMapper: (props) => {
|
|
909
924
|
const { icons, iconType, ...rest } = props;
|
|
925
|
+
const coerceSizes = (base) => {
|
|
926
|
+
for (const key of ["iconSize", "spacing"]) {
|
|
927
|
+
const v = base[key];
|
|
928
|
+
if (typeof v === "string") {
|
|
929
|
+
const m = /^(\d+(?:\.\d+)?)(?:px)?$/.exec(v.trim());
|
|
930
|
+
if (m) base[key] = parseFloat(m[1]);
|
|
931
|
+
else delete base[key];
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
return base;
|
|
935
|
+
};
|
|
910
936
|
if (Array.isArray(icons)) {
|
|
911
937
|
const mapped = icons.map((icon) => ({
|
|
912
938
|
name: icon.name,
|
|
@@ -921,7 +947,7 @@ var Social = createItemComponent({
|
|
|
921
947
|
iconType: iconType ?? base.icons?.iconType ?? "circle",
|
|
922
948
|
icons: mapped
|
|
923
949
|
};
|
|
924
|
-
return base;
|
|
950
|
+
return coerceSizes(base);
|
|
925
951
|
}
|
|
926
952
|
if (iconType !== void 0) {
|
|
927
953
|
const base = mapSemanticProps(
|
|
@@ -930,12 +956,10 @@ var Social = createItemComponent({
|
|
|
930
956
|
"Social"
|
|
931
957
|
);
|
|
932
958
|
base.icons = { ...DEFAULT_ICONS, ...base.icons, iconType };
|
|
933
|
-
return base;
|
|
959
|
+
return coerceSizes(base);
|
|
934
960
|
}
|
|
935
|
-
return
|
|
936
|
-
props,
|
|
937
|
-
DEFAULT_VALUES8,
|
|
938
|
-
"Social"
|
|
961
|
+
return coerceSizes(
|
|
962
|
+
mapSemanticProps(props, DEFAULT_VALUES8, "Social")
|
|
939
963
|
);
|
|
940
964
|
},
|
|
941
965
|
displayName: "Social",
|