@plasmicapp/react-web 0.2.82 → 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 +16 -0
- package/dist/react-web.cjs.development.js +81 -28
- 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 +81 -28
- package/dist/react-web.esm.js.map +1 -1
- package/dist/render/PlasmicImg/index.d.ts +16 -0
- 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 +16 -0
- package/skinny/dist/render/PlasmicImg/index.js +66 -19
- 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,11 +805,15 @@ 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
818
|
var _ref = typeof src === "string" || !src ? {
|
|
815
819
|
fullWidth: undefined,
|
|
@@ -819,9 +823,8 @@ var PlasmicImg = /*#__PURE__*/React__default.forwardRef(function PlasmicImg(prop
|
|
|
819
823
|
fullHeight = _ref.fullHeight;
|
|
820
824
|
|
|
821
825
|
var srcStr = src ? 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)
|
|
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,6 +834,10 @@ var PlasmicImg = /*#__PURE__*/React__default.forwardRef(function PlasmicImg(prop
|
|
|
831
834
|
}));
|
|
832
835
|
}
|
|
833
836
|
|
|
837
|
+
if (isSvg(srcStr) && (displayHeight == null || displayHeight === "auto") && (displayWidth == null || displayWidth === "auto")) {
|
|
838
|
+
displayWidth = "100%";
|
|
839
|
+
}
|
|
840
|
+
|
|
834
841
|
if (fullWidth && fullHeight && (!displayWidth || displayWidth === "auto") && !!getPixelLength(displayHeight)) {
|
|
835
842
|
// If there's a pixel length specified for displayHeight but not displayWidth,
|
|
836
843
|
// then we can derive the pixel length for displayWidth. Having an explicit
|
|
@@ -839,29 +846,79 @@ var PlasmicImg = /*#__PURE__*/React__default.forwardRef(function PlasmicImg(prop
|
|
|
839
846
|
displayWidth = getPixelLength(displayHeight) * fullWidth / fullHeight;
|
|
840
847
|
}
|
|
841
848
|
|
|
842
|
-
var _getWidths = getWidths(displayWidth, fullWidth
|
|
849
|
+
var _getWidths = getWidths(displayWidth, fullWidth, {
|
|
850
|
+
minWidth: displayMinWidth
|
|
851
|
+
}),
|
|
843
852
|
sizes = _getWidths.sizes,
|
|
844
853
|
widthDescs = _getWidths.widthDescs;
|
|
845
854
|
|
|
846
855
|
var imageLoader = getImageLoader(loader);
|
|
847
856
|
var spacerSvg = "<svg width=\"" + fullWidth + "\" height=\"" + fullHeight + "\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\"/>";
|
|
848
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
|
+
|
|
849
912
|
return React__default.createElement("div", {
|
|
850
913
|
className: classNames$1(className, "__wab_img-wrapper"),
|
|
851
914
|
ref: containerRef,
|
|
852
|
-
style:
|
|
853
|
-
width: isPercentage(displayWidth) ? displayWidth : undefined,
|
|
854
|
-
height: isPercentage(displayHeight) ? displayHeight : undefined
|
|
855
|
-
})
|
|
915
|
+
style: wrapperStyle
|
|
856
916
|
}, React__default.createElement("img", {
|
|
857
917
|
alt: "",
|
|
858
918
|
"aria-hidden": true,
|
|
859
919
|
className: "__wab_img-spacer-svg",
|
|
860
920
|
src: "data:image/svg+xml;base64," + spacerSvgBase64,
|
|
861
|
-
style:
|
|
862
|
-
width: isPercentage(displayWidth) ? "100%" : displayWidth,
|
|
863
|
-
height: isPercentage(displayHeight) ? "100%" : displayHeight
|
|
864
|
-
}, style ? pick(style, "objectFit", "objectPosition") : {})
|
|
921
|
+
style: spacerStyle
|
|
865
922
|
}), makePicture({
|
|
866
923
|
imageLoader: imageLoader,
|
|
867
924
|
widthDescs: widthDescs,
|
|
@@ -916,7 +973,7 @@ function makePicture(opts) {
|
|
|
916
973
|
width: wd.width
|
|
917
974
|
}) + " " + wd.desc;
|
|
918
975
|
}).join(", ") : undefined,
|
|
919
|
-
sizes: imageLoader ? sizes : undefined,
|
|
976
|
+
sizes: imageLoader && imageLoader.supportsUrl(src) ? sizes : undefined,
|
|
920
977
|
style: _extends({}, style ? pick(style, "objectFit", "objectPosition") : {}, {
|
|
921
978
|
width: 0,
|
|
922
979
|
height: 0
|
|
@@ -924,6 +981,10 @@ function makePicture(opts) {
|
|
|
924
981
|
})));
|
|
925
982
|
}
|
|
926
983
|
|
|
984
|
+
function isSvg(src) {
|
|
985
|
+
return src.endsWith(".svg") || src.startsWith("data:image/svg");
|
|
986
|
+
}
|
|
987
|
+
|
|
927
988
|
function getClosestPresetSize(width, fullWidth) {
|
|
928
989
|
var _ALL_SIZES$findIndex;
|
|
929
990
|
|
|
@@ -952,17 +1013,19 @@ function getClosestPresetSize(width, fullWidth) {
|
|
|
952
1013
|
*/
|
|
953
1014
|
|
|
954
1015
|
|
|
955
|
-
function getWidths(width, fullWidth) {
|
|
1016
|
+
function getWidths(width, fullWidth, extra) {
|
|
1017
|
+
var minWidth = extra == null ? void 0 : extra.minWidth;
|
|
956
1018
|
var pixelWidth = getPixelLength(width);
|
|
1019
|
+
var pixelMinWidth = getPixelLength(minWidth);
|
|
957
1020
|
|
|
958
|
-
if (pixelWidth != null) {
|
|
1021
|
+
if (pixelWidth != null && (!minWidth || pixelMinWidth != null)) {
|
|
959
1022
|
// If there's an exact width, then we just need to display it at 1x and 2x density
|
|
960
1023
|
return {
|
|
961
1024
|
widthDescs: [{
|
|
962
|
-
width: getClosestPresetSize(pixelWidth, fullWidth),
|
|
1025
|
+
width: getClosestPresetSize(Math.max(pixelWidth, pixelMinWidth != null ? pixelMinWidth : 0), fullWidth),
|
|
963
1026
|
desc: "1x"
|
|
964
1027
|
}, {
|
|
965
|
-
width: getClosestPresetSize(pixelWidth * 2, fullWidth),
|
|
1028
|
+
width: getClosestPresetSize(Math.max(pixelWidth, pixelMinWidth != null ? pixelMinWidth : 0) * 2, fullWidth),
|
|
966
1029
|
desc: "2x"
|
|
967
1030
|
}],
|
|
968
1031
|
sizes: undefined
|
|
@@ -1008,16 +1071,6 @@ function getWidths(width, fullWidth) {
|
|
|
1008
1071
|
};
|
|
1009
1072
|
}
|
|
1010
1073
|
|
|
1011
|
-
function isPercentage(width) {
|
|
1012
|
-
var _parseNumeric;
|
|
1013
|
-
|
|
1014
|
-
if (typeof width !== "string") {
|
|
1015
|
-
return false;
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
return ((_parseNumeric = parseNumeric(width)) == null ? void 0 : _parseNumeric.units) === "%";
|
|
1019
|
-
}
|
|
1020
|
-
|
|
1021
1074
|
function getPixelLength(length) {
|
|
1022
1075
|
if (length == null || length == "") {
|
|
1023
1076
|
return undefined;
|
|
@@ -1064,7 +1117,7 @@ function getImageLoader(loader) {
|
|
|
1064
1117
|
|
|
1065
1118
|
var PLASMIC_IMAGE_LOADER = {
|
|
1066
1119
|
supportsUrl: function supportsUrl(src) {
|
|
1067
|
-
return src.startsWith("https://img.plasmic.app");
|
|
1120
|
+
return src.startsWith("https://img.plasmic.app") && !isSvg(src);
|
|
1068
1121
|
},
|
|
1069
1122
|
transformUrl: function transformUrl(opts) {
|
|
1070
1123
|
var _opts$quality;
|