@plasmicapp/react-web 0.2.79 → 0.2.83
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/all.d.ts +17 -1
- package/dist/react-web.cjs.development.js +108 -40
- package/dist/react-web.cjs.development.js.map +1 -1
- package/dist/react-web.cjs.production.min.js +1 -1
- package/dist/react-web.cjs.production.min.js.map +1 -1
- package/dist/react-web.esm.js +108 -40
- package/dist/react-web.esm.js.map +1 -1
- package/dist/render/PlasmicImg/index.d.ts +17 -1
- package/lib/plasmic.css +0 -3
- package/package.json +1 -1
- package/skinny/dist/collection-utils-4dae6efa.js +292 -0
- package/skinny/dist/{collection-utils-976df07d.js.map → collection-utils-4dae6efa.js.map} +1 -1
- package/skinny/dist/collection-utils-57ec40f9.js +292 -0
- package/skinny/dist/{collection-utils-21ad9cae.js.map → collection-utils-57ec40f9.js.map} +1 -1
- package/skinny/dist/collection-utils-b0b8f30e.js +287 -234
- package/skinny/dist/props-utils-5c0ad25a.js +59 -0
- package/skinny/dist/{props-utils-6cf101b2.js.map → props-utils-5c0ad25a.js.map} +1 -1
- package/skinny/dist/props-utils-c632595f.js +53 -33
- package/skinny/dist/props-utils-fd5f444e.js +59 -0
- package/skinny/dist/{props-utils-1f98cfd3.js.map → props-utils-fd5f444e.js.map} +1 -1
- package/skinny/dist/react-utils-118d8539.js +186 -168
- package/skinny/dist/react-utils-2a2fd6c9.js +339 -0
- package/skinny/dist/react-utils-2a2fd6c9.js.map +1 -0
- package/skinny/dist/react-utils-675565b4.js +334 -0
- package/skinny/dist/react-utils-675565b4.js.map +1 -0
- package/skinny/dist/render/PlasmicImg/index.d.ts +17 -1
- package/skinny/dist/render/PlasmicImg/index.js +90 -33
- package/skinny/dist/render/PlasmicImg/index.js.map +1 -1
- package/skinny/dist/render/PlasmicImg.d.ts +62 -55
- package/skinny/dist/tslib.es6-00014098.js +143 -123
- package/skinny/dist/collection-utils-21ad9cae.js +0 -238
- package/skinny/dist/collection-utils-87ffc0ed.js +0 -238
- package/skinny/dist/collection-utils-87ffc0ed.js.map +0 -1
- package/skinny/dist/collection-utils-976df07d.js +0 -238
- package/skinny/dist/collection-utils-aadc3a43.js +0 -238
- package/skinny/dist/collection-utils-aadc3a43.js.map +0 -1
- package/skinny/dist/collection-utils-b8a2fd59.js +0 -238
- package/skinny/dist/collection-utils-b8a2fd59.js.map +0 -1
- package/skinny/dist/props-utils-1f98cfd3.js +0 -40
- package/skinny/dist/props-utils-40224c71.js +0 -40
- package/skinny/dist/props-utils-40224c71.js.map +0 -1
- package/skinny/dist/props-utils-69f9ba8b.js +0 -40
- package/skinny/dist/props-utils-69f9ba8b.js.map +0 -1
- package/skinny/dist/props-utils-6cf101b2.js +0 -39
- package/skinny/dist/props-utils-85691c9c.js +0 -40
- package/skinny/dist/props-utils-85691c9c.js.map +0 -1
- package/skinny/dist/react-utils-06bae09a.js +0 -254
- package/skinny/dist/react-utils-06bae09a.js.map +0 -1
- package/skinny/dist/react-utils-14af9d28.js +0 -172
- package/skinny/dist/react-utils-14af9d28.js.map +0 -1
- package/skinny/dist/react-utils-834a65c3.js +0 -254
- package/skinny/dist/react-utils-834a65c3.js.map +0 -1
- package/skinny/dist/react-utils-ae69f4e0.js +0 -254
- package/skinny/dist/react-utils-ae69f4e0.js.map +0 -1
- package/skinny/dist/react-utils-cca81efc.js +0 -245
- package/skinny/dist/react-utils-cca81efc.js.map +0 -1
- package/skinny/dist/stories/Button.d.ts +0 -29
- package/skinny/dist/stories/Header.d.ts +0 -10
- package/skinny/dist/stories/Page.d.ts +0 -10
- package/skinny/dist/tslib.es6-10d3f595.js +0 -132
- package/skinny/dist/tslib.es6-10d3f595.js.map +0 -1
package/dist/react-web.esm.js
CHANGED
|
@@ -805,23 +805,26 @@ var PlasmicImg = /*#__PURE__*/React__default.forwardRef(function PlasmicImg(prop
|
|
|
805
805
|
className = props.className,
|
|
806
806
|
displayWidth = props.displayWidth,
|
|
807
807
|
displayHeight = props.displayHeight,
|
|
808
|
+
displayMinWidth = props.displayMinWidth,
|
|
809
|
+
displayMinHeight = props.displayMinHeight,
|
|
810
|
+
displayMaxWidth = props.displayMaxWidth,
|
|
811
|
+
displayMaxHeight = props.displayMaxHeight,
|
|
808
812
|
quality = props.quality,
|
|
809
813
|
loader = props.loader,
|
|
810
814
|
containerRef = props.containerRef,
|
|
811
815
|
style = props.style,
|
|
812
|
-
rest = _objectWithoutPropertiesLoose(props, ["src", "className", "displayWidth", "displayHeight", "quality", "loader", "containerRef", "style"]);
|
|
816
|
+
rest = _objectWithoutPropertiesLoose(props, ["src", "className", "displayWidth", "displayHeight", "displayMinWidth", "displayMinHeight", "displayMaxWidth", "displayMaxHeight", "quality", "loader", "containerRef", "style"]);
|
|
813
817
|
|
|
814
|
-
var _ref = typeof src === "string" ? {
|
|
818
|
+
var _ref = typeof src === "string" || !src ? {
|
|
815
819
|
fullWidth: undefined,
|
|
816
820
|
fullHeight: undefined
|
|
817
821
|
} : src,
|
|
818
822
|
fullWidth = _ref.fullWidth,
|
|
819
823
|
fullHeight = _ref.fullHeight;
|
|
820
824
|
|
|
821
|
-
var srcStr = typeof src === "string" ? src : src.src; // Assume external image if either dimension is null and use usual <img>
|
|
822
|
-
// (or if the image is an SVG)
|
|
825
|
+
var srcStr = src ? typeof src === "string" ? src : src.src : ""; // Assume external image if either dimension is null and use usual <img>
|
|
823
826
|
|
|
824
|
-
if (fullHeight == null || fullWidth == null
|
|
827
|
+
if (fullHeight == null || fullWidth == null) {
|
|
825
828
|
return React__default.createElement("img", Object.assign({
|
|
826
829
|
src: srcStr,
|
|
827
830
|
className: className,
|
|
@@ -831,29 +834,91 @@ var PlasmicImg = /*#__PURE__*/React__default.forwardRef(function PlasmicImg(prop
|
|
|
831
834
|
}));
|
|
832
835
|
}
|
|
833
836
|
|
|
834
|
-
|
|
837
|
+
if (isSvg(srcStr) && (displayHeight == null || displayHeight === "auto") && (displayWidth == null || displayWidth === "auto")) {
|
|
838
|
+
displayWidth = "100%";
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
if (fullWidth && fullHeight && (!displayWidth || displayWidth === "auto") && !!getPixelLength(displayHeight)) {
|
|
842
|
+
// If there's a pixel length specified for displayHeight but not displayWidth,
|
|
843
|
+
// then we can derive the pixel length for displayWidth. Having an explicit
|
|
844
|
+
// displayWidth makes this a fixed-size image, which makes it possible for us to
|
|
845
|
+
// generate better markup!
|
|
846
|
+
displayWidth = getPixelLength(displayHeight) * fullWidth / fullHeight;
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
var _getWidths = getWidths(displayWidth, fullWidth, {
|
|
850
|
+
minWidth: displayMinWidth
|
|
851
|
+
}),
|
|
835
852
|
sizes = _getWidths.sizes,
|
|
836
853
|
widthDescs = _getWidths.widthDescs;
|
|
837
854
|
|
|
838
855
|
var imageLoader = getImageLoader(loader);
|
|
839
856
|
var spacerSvg = "<svg width=\"" + fullWidth + "\" height=\"" + fullHeight + "\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\"/>";
|
|
840
857
|
var spacerSvgBase64 = typeof window === "undefined" ? Buffer.from(spacerSvg).toString("base64") : window.btoa(spacerSvg);
|
|
858
|
+
|
|
859
|
+
var wrapperStyle = _extends({}, style || {});
|
|
860
|
+
|
|
861
|
+
var spacerStyle = pick(style || {}, "objectFit", "objectPosition");
|
|
862
|
+
|
|
863
|
+
if (displayWidth != null && displayWidth !== "auto") {
|
|
864
|
+
// If width is set, set it on the wrapper along with min/max width
|
|
865
|
+
// and just use `width: 100%` on the spacer
|
|
866
|
+
spacerStyle.width = "100%";
|
|
867
|
+
wrapperStyle.width = displayWidth;
|
|
868
|
+
wrapperStyle.minWidth = displayMinWidth;
|
|
869
|
+
wrapperStyle.maxWidth = displayMaxWidth;
|
|
870
|
+
} else {
|
|
871
|
+
// Otherwise, we want auto sizing from the spacer, so set width there.
|
|
872
|
+
//
|
|
873
|
+
// But if we have min/max width, it should be set in the wrapper and it
|
|
874
|
+
// can be percentage values (and we add corresponding min/max width to
|
|
875
|
+
// 100% in the spacer). In general it ends up with the correct effect,
|
|
876
|
+
// but some edge cases might make `min-width: 100%` shrink the image more
|
|
877
|
+
// than it should.
|
|
878
|
+
spacerStyle.width = displayWidth;
|
|
879
|
+
wrapperStyle.width = "auto";
|
|
880
|
+
|
|
881
|
+
if (displayMinWidth) {
|
|
882
|
+
spacerStyle.minWidth = "100%";
|
|
883
|
+
wrapperStyle.minWidth = displayMinWidth;
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
if (displayMaxWidth != null && displayMaxWidth !== "none") {
|
|
887
|
+
spacerStyle.maxWidth = "100%";
|
|
888
|
+
wrapperStyle.maxWidth = displayMaxWidth;
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
if (displayHeight != null && displayHeight !== "auto") {
|
|
893
|
+
spacerStyle.height = "100%";
|
|
894
|
+
wrapperStyle.height = displayHeight;
|
|
895
|
+
wrapperStyle.minHeight = displayMinHeight;
|
|
896
|
+
wrapperStyle.maxHeight = displayMaxHeight;
|
|
897
|
+
} else {
|
|
898
|
+
spacerStyle.height = displayHeight;
|
|
899
|
+
wrapperStyle.height = "auto";
|
|
900
|
+
|
|
901
|
+
if (displayMinHeight) {
|
|
902
|
+
spacerStyle.minHeight = "100%";
|
|
903
|
+
wrapperStyle.minHeight = displayMinHeight;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
if (displayMaxHeight != null && displayMaxHeight !== "none") {
|
|
907
|
+
spacerStyle.maxHeight = "100%";
|
|
908
|
+
wrapperStyle.maxHeight = displayMaxHeight;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
|
|
841
912
|
return React__default.createElement("div", {
|
|
842
913
|
className: classNames$1(className, "__wab_img-wrapper"),
|
|
843
914
|
ref: containerRef,
|
|
844
|
-
style:
|
|
845
|
-
width: isPercentage(displayWidth) ? displayWidth : undefined,
|
|
846
|
-
height: isPercentage(displayHeight) ? displayHeight : undefined
|
|
847
|
-
})
|
|
915
|
+
style: wrapperStyle
|
|
848
916
|
}, React__default.createElement("img", {
|
|
849
917
|
alt: "",
|
|
850
918
|
"aria-hidden": true,
|
|
851
919
|
className: "__wab_img-spacer-svg",
|
|
852
920
|
src: "data:image/svg+xml;base64," + spacerSvgBase64,
|
|
853
|
-
style:
|
|
854
|
-
width: isPercentage(displayWidth) ? "100%" : displayWidth,
|
|
855
|
-
height: isPercentage(displayHeight) ? "100%" : displayHeight
|
|
856
|
-
}, style ? pick(style, "objectFit", "objectPosition") : {})
|
|
921
|
+
style: spacerStyle
|
|
857
922
|
}), makePicture({
|
|
858
923
|
imageLoader: imageLoader,
|
|
859
924
|
widthDescs: widthDescs,
|
|
@@ -908,11 +973,18 @@ function makePicture(opts) {
|
|
|
908
973
|
width: wd.width
|
|
909
974
|
}) + " " + wd.desc;
|
|
910
975
|
}).join(", ") : undefined,
|
|
911
|
-
sizes: imageLoader ? sizes : undefined,
|
|
912
|
-
style: style ? pick(style, "objectFit", "objectPosition") :
|
|
976
|
+
sizes: imageLoader && imageLoader.supportsUrl(src) ? sizes : undefined,
|
|
977
|
+
style: _extends({}, style ? pick(style, "objectFit", "objectPosition") : {}, {
|
|
978
|
+
width: 0,
|
|
979
|
+
height: 0
|
|
980
|
+
})
|
|
913
981
|
})));
|
|
914
982
|
}
|
|
915
983
|
|
|
984
|
+
function isSvg(src) {
|
|
985
|
+
return src.endsWith(".svg") || src.startsWith("data:image/svg");
|
|
986
|
+
}
|
|
987
|
+
|
|
916
988
|
function getClosestPresetSize(width, fullWidth) {
|
|
917
989
|
var _ALL_SIZES$findIndex;
|
|
918
990
|
|
|
@@ -941,17 +1013,19 @@ function getClosestPresetSize(width, fullWidth) {
|
|
|
941
1013
|
*/
|
|
942
1014
|
|
|
943
1015
|
|
|
944
|
-
function getWidths(width, fullWidth) {
|
|
945
|
-
var
|
|
1016
|
+
function getWidths(width, fullWidth, extra) {
|
|
1017
|
+
var minWidth = extra == null ? void 0 : extra.minWidth;
|
|
1018
|
+
var pixelWidth = getPixelLength(width);
|
|
1019
|
+
var pixelMinWidth = getPixelLength(minWidth);
|
|
946
1020
|
|
|
947
|
-
if (pixelWidth != null) {
|
|
1021
|
+
if (pixelWidth != null && (!minWidth || pixelMinWidth != null)) {
|
|
948
1022
|
// If there's an exact width, then we just need to display it at 1x and 2x density
|
|
949
1023
|
return {
|
|
950
1024
|
widthDescs: [{
|
|
951
|
-
width: getClosestPresetSize(pixelWidth, fullWidth),
|
|
1025
|
+
width: getClosestPresetSize(Math.max(pixelWidth, pixelMinWidth != null ? pixelMinWidth : 0), fullWidth),
|
|
952
1026
|
desc: "1x"
|
|
953
1027
|
}, {
|
|
954
|
-
width: getClosestPresetSize(pixelWidth * 2, fullWidth),
|
|
1028
|
+
width: getClosestPresetSize(Math.max(pixelWidth, pixelMinWidth != null ? pixelMinWidth : 0) * 2, fullWidth),
|
|
955
1029
|
desc: "2x"
|
|
956
1030
|
}],
|
|
957
1031
|
sizes: undefined
|
|
@@ -977,15 +1051,19 @@ function getWidths(width, fullWidth) {
|
|
|
977
1051
|
}
|
|
978
1052
|
|
|
979
1053
|
return {
|
|
980
|
-
widthDescs: usefulSizes.map(function (size
|
|
1054
|
+
widthDescs: usefulSizes.map(function (size) {
|
|
981
1055
|
return {
|
|
982
|
-
width:
|
|
1056
|
+
width: getClosestPresetSize(size, fullWidth),
|
|
1057
|
+
// If this is the last (buggest) useful width, but it is
|
|
983
1058
|
// still within the bounds set by DEVICE_SIZES, then just
|
|
984
1059
|
// use the original, unresized image. This means if we match
|
|
985
1060
|
// the largest size, we use unresized and best quality image.
|
|
986
1061
|
// We only do this, though, if fullWidth is "reasonable" --
|
|
987
1062
|
// smaller than the largest size we would consider.
|
|
988
|
-
i === usefulSizes.length - 1 &&
|
|
1063
|
+
// i === usefulSizes.length - 1 &&
|
|
1064
|
+
// fullWidth < DEVICE_SIZES[DEVICE_SIZES.length - 1]
|
|
1065
|
+
// ? undefined
|
|
1066
|
+
// : size,
|
|
989
1067
|
desc: size + "w"
|
|
990
1068
|
};
|
|
991
1069
|
}),
|
|
@@ -993,26 +1071,16 @@ function getWidths(width, fullWidth) {
|
|
|
993
1071
|
};
|
|
994
1072
|
}
|
|
995
1073
|
|
|
996
|
-
function
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
if (typeof width !== "string") {
|
|
1000
|
-
return false;
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
return ((_parseNumeric = parseNumeric(width)) == null ? void 0 : _parseNumeric.units) === "%";
|
|
1004
|
-
}
|
|
1005
|
-
|
|
1006
|
-
function getPixelWidth(width) {
|
|
1007
|
-
if (width == null || width == "") {
|
|
1074
|
+
function getPixelLength(length) {
|
|
1075
|
+
if (length == null || length == "") {
|
|
1008
1076
|
return undefined;
|
|
1009
1077
|
}
|
|
1010
1078
|
|
|
1011
|
-
if (typeof
|
|
1012
|
-
return
|
|
1079
|
+
if (typeof length === "number") {
|
|
1080
|
+
return length;
|
|
1013
1081
|
}
|
|
1014
1082
|
|
|
1015
|
-
var parsed = parseNumeric(
|
|
1083
|
+
var parsed = parseNumeric(length);
|
|
1016
1084
|
|
|
1017
1085
|
if (parsed && (!parsed.units || parsed.units === "px")) {
|
|
1018
1086
|
return parsed.num;
|
|
@@ -1049,7 +1117,7 @@ function getImageLoader(loader) {
|
|
|
1049
1117
|
|
|
1050
1118
|
var PLASMIC_IMAGE_LOADER = {
|
|
1051
1119
|
supportsUrl: function supportsUrl(src) {
|
|
1052
|
-
return src.startsWith("https://img.plasmic.app");
|
|
1120
|
+
return src.startsWith("https://img.plasmic.app") && !isSvg(src);
|
|
1053
1121
|
},
|
|
1054
1122
|
transformUrl: function transformUrl(opts) {
|
|
1055
1123
|
var _opts$quality;
|