@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.
Files changed (61) hide show
  1. package/dist/all.d.ts +16 -0
  2. package/dist/react-web.cjs.development.js +81 -28
  3. package/dist/react-web.cjs.development.js.map +1 -1
  4. package/dist/react-web.cjs.production.min.js +1 -1
  5. package/dist/react-web.cjs.production.min.js.map +1 -1
  6. package/dist/react-web.esm.js +81 -28
  7. package/dist/react-web.esm.js.map +1 -1
  8. package/dist/render/PlasmicImg/index.d.ts +16 -0
  9. package/lib/plasmic.css +0 -3
  10. package/package.json +1 -1
  11. package/skinny/dist/collection-utils-4dae6efa.js +292 -0
  12. package/skinny/dist/{collection-utils-976df07d.js.map → collection-utils-4dae6efa.js.map} +1 -1
  13. package/skinny/dist/collection-utils-57ec40f9.js +292 -0
  14. package/skinny/dist/{collection-utils-21ad9cae.js.map → collection-utils-57ec40f9.js.map} +1 -1
  15. package/skinny/dist/collection-utils-b0b8f30e.js +287 -234
  16. package/skinny/dist/props-utils-5c0ad25a.js +59 -0
  17. package/skinny/dist/{props-utils-6cf101b2.js.map → props-utils-5c0ad25a.js.map} +1 -1
  18. package/skinny/dist/props-utils-c632595f.js +53 -33
  19. package/skinny/dist/props-utils-fd5f444e.js +59 -0
  20. package/skinny/dist/{props-utils-1f98cfd3.js.map → props-utils-fd5f444e.js.map} +1 -1
  21. package/skinny/dist/react-utils-118d8539.js +186 -168
  22. package/skinny/dist/react-utils-2a2fd6c9.js +339 -0
  23. package/skinny/dist/react-utils-2a2fd6c9.js.map +1 -0
  24. package/skinny/dist/react-utils-675565b4.js +334 -0
  25. package/skinny/dist/react-utils-675565b4.js.map +1 -0
  26. package/skinny/dist/render/PlasmicImg/index.d.ts +16 -0
  27. package/skinny/dist/render/PlasmicImg/index.js +66 -19
  28. package/skinny/dist/render/PlasmicImg/index.js.map +1 -1
  29. package/skinny/dist/render/PlasmicImg.d.ts +62 -55
  30. package/skinny/dist/tslib.es6-00014098.js +143 -123
  31. package/skinny/dist/collection-utils-21ad9cae.js +0 -238
  32. package/skinny/dist/collection-utils-87ffc0ed.js +0 -238
  33. package/skinny/dist/collection-utils-87ffc0ed.js.map +0 -1
  34. package/skinny/dist/collection-utils-976df07d.js +0 -238
  35. package/skinny/dist/collection-utils-aadc3a43.js +0 -238
  36. package/skinny/dist/collection-utils-aadc3a43.js.map +0 -1
  37. package/skinny/dist/collection-utils-b8a2fd59.js +0 -238
  38. package/skinny/dist/collection-utils-b8a2fd59.js.map +0 -1
  39. package/skinny/dist/props-utils-1f98cfd3.js +0 -40
  40. package/skinny/dist/props-utils-40224c71.js +0 -40
  41. package/skinny/dist/props-utils-40224c71.js.map +0 -1
  42. package/skinny/dist/props-utils-69f9ba8b.js +0 -40
  43. package/skinny/dist/props-utils-69f9ba8b.js.map +0 -1
  44. package/skinny/dist/props-utils-6cf101b2.js +0 -39
  45. package/skinny/dist/props-utils-85691c9c.js +0 -40
  46. package/skinny/dist/props-utils-85691c9c.js.map +0 -1
  47. package/skinny/dist/react-utils-06bae09a.js +0 -254
  48. package/skinny/dist/react-utils-06bae09a.js.map +0 -1
  49. package/skinny/dist/react-utils-14af9d28.js +0 -172
  50. package/skinny/dist/react-utils-14af9d28.js.map +0 -1
  51. package/skinny/dist/react-utils-834a65c3.js +0 -254
  52. package/skinny/dist/react-utils-834a65c3.js.map +0 -1
  53. package/skinny/dist/react-utils-ae69f4e0.js +0 -254
  54. package/skinny/dist/react-utils-ae69f4e0.js.map +0 -1
  55. package/skinny/dist/react-utils-cca81efc.js +0 -245
  56. package/skinny/dist/react-utils-cca81efc.js.map +0 -1
  57. package/skinny/dist/stories/Button.d.ts +0 -29
  58. package/skinny/dist/stories/Header.d.ts +0 -10
  59. package/skinny/dist/stories/Page.d.ts +0 -10
  60. package/skinny/dist/tslib.es6-10d3f595.js +0 -132
  61. package/skinny/dist/tslib.es6-10d3f595.js.map +0 -1
package/dist/all.d.ts CHANGED
@@ -123,6 +123,22 @@ interface PlasmicImgProps extends ImgTagProps {
123
123
  * css height
124
124
  */
125
125
  displayHeight?: number | string;
126
+ /**
127
+ * css min-width
128
+ */
129
+ displayMinWidth?: number | string;
130
+ /**
131
+ * css min-height
132
+ */
133
+ displayMinHeight?: number | string;
134
+ /**
135
+ * css max-width
136
+ */
137
+ displayMaxWidth?: number | string;
138
+ /**
139
+ * css max-height
140
+ */
141
+ displayMaxHeight?: number | string;
126
142
  /**
127
143
  * For variable quality formats like jpg, the quality from 0 to 100
128
144
  */
@@ -812,11 +812,15 @@ var PlasmicImg = /*#__PURE__*/React__default.forwardRef(function PlasmicImg(prop
812
812
  className = props.className,
813
813
  displayWidth = props.displayWidth,
814
814
  displayHeight = props.displayHeight,
815
+ displayMinWidth = props.displayMinWidth,
816
+ displayMinHeight = props.displayMinHeight,
817
+ displayMaxWidth = props.displayMaxWidth,
818
+ displayMaxHeight = props.displayMaxHeight,
815
819
  quality = props.quality,
816
820
  loader = props.loader,
817
821
  containerRef = props.containerRef,
818
822
  style = props.style,
819
- rest = _objectWithoutPropertiesLoose(props, ["src", "className", "displayWidth", "displayHeight", "quality", "loader", "containerRef", "style"]);
823
+ rest = _objectWithoutPropertiesLoose(props, ["src", "className", "displayWidth", "displayHeight", "displayMinWidth", "displayMinHeight", "displayMaxWidth", "displayMaxHeight", "quality", "loader", "containerRef", "style"]);
820
824
 
821
825
  var _ref = typeof src === "string" || !src ? {
822
826
  fullWidth: undefined,
@@ -826,9 +830,8 @@ var PlasmicImg = /*#__PURE__*/React__default.forwardRef(function PlasmicImg(prop
826
830
  fullHeight = _ref.fullHeight;
827
831
 
828
832
  var srcStr = src ? typeof src === "string" ? src : src.src : ""; // Assume external image if either dimension is null and use usual <img>
829
- // (or if the image is an SVG)
830
833
 
831
- if (fullHeight == null || fullWidth == null || srcStr.endsWith(".svg")) {
834
+ if (fullHeight == null || fullWidth == null) {
832
835
  return React__default.createElement("img", Object.assign({
833
836
  src: srcStr,
834
837
  className: className,
@@ -838,6 +841,10 @@ var PlasmicImg = /*#__PURE__*/React__default.forwardRef(function PlasmicImg(prop
838
841
  }));
839
842
  }
840
843
 
844
+ if (isSvg(srcStr) && (displayHeight == null || displayHeight === "auto") && (displayWidth == null || displayWidth === "auto")) {
845
+ displayWidth = "100%";
846
+ }
847
+
841
848
  if (fullWidth && fullHeight && (!displayWidth || displayWidth === "auto") && !!getPixelLength(displayHeight)) {
842
849
  // If there's a pixel length specified for displayHeight but not displayWidth,
843
850
  // then we can derive the pixel length for displayWidth. Having an explicit
@@ -846,29 +853,79 @@ var PlasmicImg = /*#__PURE__*/React__default.forwardRef(function PlasmicImg(prop
846
853
  displayWidth = getPixelLength(displayHeight) * fullWidth / fullHeight;
847
854
  }
848
855
 
849
- var _getWidths = getWidths(displayWidth, fullWidth),
856
+ var _getWidths = getWidths(displayWidth, fullWidth, {
857
+ minWidth: displayMinWidth
858
+ }),
850
859
  sizes = _getWidths.sizes,
851
860
  widthDescs = _getWidths.widthDescs;
852
861
 
853
862
  var imageLoader = getImageLoader(loader);
854
863
  var spacerSvg = "<svg width=\"" + fullWidth + "\" height=\"" + fullHeight + "\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\"/>";
855
864
  var spacerSvgBase64 = typeof window === "undefined" ? Buffer.from(spacerSvg).toString("base64") : window.btoa(spacerSvg);
865
+
866
+ var wrapperStyle = _extends({}, style || {});
867
+
868
+ var spacerStyle = pick(style || {}, "objectFit", "objectPosition");
869
+
870
+ if (displayWidth != null && displayWidth !== "auto") {
871
+ // If width is set, set it on the wrapper along with min/max width
872
+ // and just use `width: 100%` on the spacer
873
+ spacerStyle.width = "100%";
874
+ wrapperStyle.width = displayWidth;
875
+ wrapperStyle.minWidth = displayMinWidth;
876
+ wrapperStyle.maxWidth = displayMaxWidth;
877
+ } else {
878
+ // Otherwise, we want auto sizing from the spacer, so set width there.
879
+ //
880
+ // But if we have min/max width, it should be set in the wrapper and it
881
+ // can be percentage values (and we add corresponding min/max width to
882
+ // 100% in the spacer). In general it ends up with the correct effect,
883
+ // but some edge cases might make `min-width: 100%` shrink the image more
884
+ // than it should.
885
+ spacerStyle.width = displayWidth;
886
+ wrapperStyle.width = "auto";
887
+
888
+ if (displayMinWidth) {
889
+ spacerStyle.minWidth = "100%";
890
+ wrapperStyle.minWidth = displayMinWidth;
891
+ }
892
+
893
+ if (displayMaxWidth != null && displayMaxWidth !== "none") {
894
+ spacerStyle.maxWidth = "100%";
895
+ wrapperStyle.maxWidth = displayMaxWidth;
896
+ }
897
+ }
898
+
899
+ if (displayHeight != null && displayHeight !== "auto") {
900
+ spacerStyle.height = "100%";
901
+ wrapperStyle.height = displayHeight;
902
+ wrapperStyle.minHeight = displayMinHeight;
903
+ wrapperStyle.maxHeight = displayMaxHeight;
904
+ } else {
905
+ spacerStyle.height = displayHeight;
906
+ wrapperStyle.height = "auto";
907
+
908
+ if (displayMinHeight) {
909
+ spacerStyle.minHeight = "100%";
910
+ wrapperStyle.minHeight = displayMinHeight;
911
+ }
912
+
913
+ if (displayMaxHeight != null && displayMaxHeight !== "none") {
914
+ spacerStyle.maxHeight = "100%";
915
+ wrapperStyle.maxHeight = displayMaxHeight;
916
+ }
917
+ }
918
+
856
919
  return React__default.createElement("div", {
857
920
  className: classNames$1(className, "__wab_img-wrapper"),
858
921
  ref: containerRef,
859
- style: _extends({}, style, {
860
- width: isPercentage(displayWidth) ? displayWidth : undefined,
861
- height: isPercentage(displayHeight) ? displayHeight : undefined
862
- })
922
+ style: wrapperStyle
863
923
  }, React__default.createElement("img", {
864
924
  alt: "",
865
925
  "aria-hidden": true,
866
926
  className: "__wab_img-spacer-svg",
867
927
  src: "data:image/svg+xml;base64," + spacerSvgBase64,
868
- style: _extends({
869
- width: isPercentage(displayWidth) ? "100%" : displayWidth,
870
- height: isPercentage(displayHeight) ? "100%" : displayHeight
871
- }, style ? pick(style, "objectFit", "objectPosition") : {})
928
+ style: spacerStyle
872
929
  }), makePicture({
873
930
  imageLoader: imageLoader,
874
931
  widthDescs: widthDescs,
@@ -923,7 +980,7 @@ function makePicture(opts) {
923
980
  width: wd.width
924
981
  }) + " " + wd.desc;
925
982
  }).join(", ") : undefined,
926
- sizes: imageLoader ? sizes : undefined,
983
+ sizes: imageLoader && imageLoader.supportsUrl(src) ? sizes : undefined,
927
984
  style: _extends({}, style ? pick(style, "objectFit", "objectPosition") : {}, {
928
985
  width: 0,
929
986
  height: 0
@@ -931,6 +988,10 @@ function makePicture(opts) {
931
988
  })));
932
989
  }
933
990
 
991
+ function isSvg(src) {
992
+ return src.endsWith(".svg") || src.startsWith("data:image/svg");
993
+ }
994
+
934
995
  function getClosestPresetSize(width, fullWidth) {
935
996
  var _ALL_SIZES$findIndex;
936
997
 
@@ -959,17 +1020,19 @@ function getClosestPresetSize(width, fullWidth) {
959
1020
  */
960
1021
 
961
1022
 
962
- function getWidths(width, fullWidth) {
1023
+ function getWidths(width, fullWidth, extra) {
1024
+ var minWidth = extra == null ? void 0 : extra.minWidth;
963
1025
  var pixelWidth = getPixelLength(width);
1026
+ var pixelMinWidth = getPixelLength(minWidth);
964
1027
 
965
- if (pixelWidth != null) {
1028
+ if (pixelWidth != null && (!minWidth || pixelMinWidth != null)) {
966
1029
  // If there's an exact width, then we just need to display it at 1x and 2x density
967
1030
  return {
968
1031
  widthDescs: [{
969
- width: getClosestPresetSize(pixelWidth, fullWidth),
1032
+ width: getClosestPresetSize(Math.max(pixelWidth, pixelMinWidth != null ? pixelMinWidth : 0), fullWidth),
970
1033
  desc: "1x"
971
1034
  }, {
972
- width: getClosestPresetSize(pixelWidth * 2, fullWidth),
1035
+ width: getClosestPresetSize(Math.max(pixelWidth, pixelMinWidth != null ? pixelMinWidth : 0) * 2, fullWidth),
973
1036
  desc: "2x"
974
1037
  }],
975
1038
  sizes: undefined
@@ -1015,16 +1078,6 @@ function getWidths(width, fullWidth) {
1015
1078
  };
1016
1079
  }
1017
1080
 
1018
- function isPercentage(width) {
1019
- var _parseNumeric;
1020
-
1021
- if (typeof width !== "string") {
1022
- return false;
1023
- }
1024
-
1025
- return ((_parseNumeric = parseNumeric(width)) == null ? void 0 : _parseNumeric.units) === "%";
1026
- }
1027
-
1028
1081
  function getPixelLength(length) {
1029
1082
  if (length == null || length == "") {
1030
1083
  return undefined;
@@ -1071,7 +1124,7 @@ function getImageLoader(loader) {
1071
1124
 
1072
1125
  var PLASMIC_IMAGE_LOADER = {
1073
1126
  supportsUrl: function supportsUrl(src) {
1074
- return src.startsWith("https://img.plasmic.app");
1127
+ return src.startsWith("https://img.plasmic.app") && !isSvg(src);
1075
1128
  },
1076
1129
  transformUrl: function transformUrl(opts) {
1077
1130
  var _opts$quality;