@plasmicapp/react-web 0.2.76 → 0.2.78

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 (64) hide show
  1. package/dist/all.d.ts +9 -6
  2. package/dist/react-web.cjs.development.js +37 -15
  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 +37 -15
  7. package/dist/react-web.esm.js.map +1 -1
  8. package/dist/render/PlasmicImg/index.d.ts +9 -6
  9. package/package.json +2 -2
  10. package/skinny/dist/{collection-utils-4dae6efa.js → collection-utils-21ad9cae.js} +4 -3
  11. package/skinny/dist/{collection-utils-4dae6efa.js.map → collection-utils-21ad9cae.js.map} +1 -1
  12. package/skinny/dist/{collection-utils-57ec40f9.js → collection-utils-87ffc0ed.js} +4 -3
  13. package/skinny/dist/{collection-utils-57ec40f9.js.map → collection-utils-87ffc0ed.js.map} +1 -1
  14. package/skinny/dist/collection-utils-96cde83c.js +238 -0
  15. package/skinny/dist/collection-utils-96cde83c.js.map +1 -0
  16. package/skinny/dist/collection-utils-976df07d.js +238 -0
  17. package/skinny/dist/collection-utils-976df07d.js.map +1 -0
  18. package/skinny/dist/collection-utils-aadc3a43.js +238 -0
  19. package/skinny/dist/collection-utils-aadc3a43.js.map +1 -0
  20. package/skinny/dist/collection-utils-b8a2fd59.js +238 -0
  21. package/skinny/dist/collection-utils-b8a2fd59.js.map +1 -0
  22. package/skinny/dist/index.js +3 -3
  23. package/skinny/dist/plume/checkbox/index.js +3 -3
  24. package/skinny/dist/plume/menu/index.js +4 -4
  25. package/skinny/dist/plume/menu-button/index.js +3 -3
  26. package/skinny/dist/plume/select/index.js +4 -4
  27. package/skinny/dist/plume/switch/index.js +3 -3
  28. package/skinny/dist/plume/triggered-overlay/index.js +3 -3
  29. package/skinny/dist/props-utils-1f98cfd3.js +40 -0
  30. package/skinny/dist/props-utils-1f98cfd3.js.map +1 -0
  31. package/skinny/dist/{props-utils-5c0ad25a.js → props-utils-40224c71.js} +3 -2
  32. package/skinny/dist/props-utils-40224c71.js.map +1 -0
  33. package/skinny/dist/props-utils-69f9ba8b.js +40 -0
  34. package/skinny/dist/props-utils-69f9ba8b.js.map +1 -0
  35. package/skinny/dist/{props-utils-fd5f444e.js → props-utils-6cf101b2.js} +2 -2
  36. package/skinny/dist/{props-utils-5c0ad25a.js.map → props-utils-6cf101b2.js.map} +1 -1
  37. package/skinny/dist/props-utils-754f655a.js +39 -0
  38. package/skinny/dist/{props-utils-fd5f444e.js.map → props-utils-754f655a.js.map} +1 -1
  39. package/skinny/dist/props-utils-85691c9c.js +40 -0
  40. package/skinny/dist/props-utils-85691c9c.js.map +1 -0
  41. package/skinny/dist/{react-utils-2a2fd6c9.js → react-utils-06bae09a.js} +14 -61
  42. package/skinny/dist/react-utils-06bae09a.js.map +1 -0
  43. package/skinny/dist/react-utils-14af9d28.js +172 -0
  44. package/skinny/dist/react-utils-14af9d28.js.map +1 -0
  45. package/skinny/dist/react-utils-7c01e440.js +172 -0
  46. package/skinny/dist/react-utils-7c01e440.js.map +1 -0
  47. package/skinny/dist/react-utils-834a65c3.js +254 -0
  48. package/skinny/dist/react-utils-834a65c3.js.map +1 -0
  49. package/skinny/dist/{react-utils-675565b4.js → react-utils-ae69f4e0.js} +3 -46
  50. package/skinny/dist/react-utils-ae69f4e0.js.map +1 -0
  51. package/skinny/dist/react-utils-cca81efc.js +245 -0
  52. package/skinny/dist/react-utils-cca81efc.js.map +1 -0
  53. package/skinny/dist/render/PlasmicImg/index.d.ts +9 -6
  54. package/skinny/dist/render/PlasmicImg/index.js +43 -17
  55. package/skinny/dist/render/PlasmicImg/index.js.map +1 -1
  56. package/skinny/dist/stories/Button.d.ts +29 -0
  57. package/skinny/dist/stories/Header.d.ts +10 -0
  58. package/skinny/dist/stories/Page.d.ts +10 -0
  59. package/skinny/dist/tslib.es6-10d3f595.js +132 -0
  60. package/skinny/dist/tslib.es6-10d3f595.js.map +1 -0
  61. package/skinny/dist/tslib.es6-d26ffe68.js +132 -0
  62. package/skinny/dist/tslib.es6-d26ffe68.js.map +1 -0
  63. package/skinny/dist/react-utils-2a2fd6c9.js.map +0 -1
  64. package/skinny/dist/react-utils-675565b4.js.map +0 -1
package/dist/all.d.ts CHANGED
@@ -91,12 +91,15 @@ declare function PlasmicIcon(props: React.ComponentProps<"svg"> & {
91
91
  * Responsive `<img/>` replacement, based on `next/image`
92
92
  */
93
93
 
94
- declare type ImageLoader = (opts: {
95
- src: string;
96
- width: number;
97
- quality?: number;
98
- format?: "webp";
99
- }) => string;
94
+ interface ImageLoader {
95
+ supportsUrl: (url: string) => boolean;
96
+ transformUrl: (opts: {
97
+ src: string;
98
+ width?: number;
99
+ quality?: number;
100
+ format?: "webp";
101
+ }) => string;
102
+ }
100
103
  declare type ImgTagProps = Omit<React__default.ComponentProps<"img">, "src" | "srcSet" | "ref" | "style">;
101
104
  interface PlasmicImgProps extends ImgTagProps {
102
105
  /**
@@ -889,10 +889,10 @@ function makePicture(opts) {
889
889
  ref = opts.ref;
890
890
  return React__default.createElement("picture", {
891
891
  className: "__wab_picture"
892
- }, imageLoader && React__default.createElement("source", {
892
+ }, imageLoader && imageLoader.supportsUrl(src) && React__default.createElement("source", {
893
893
  type: "image/webp",
894
894
  srcSet: widthDescs.map(function (wd) {
895
- return imageLoader({
895
+ return imageLoader.transformUrl({
896
896
  src: src,
897
897
  quality: quality,
898
898
  width: wd.width,
@@ -903,13 +903,13 @@ function makePicture(opts) {
903
903
  ref: ref,
904
904
  className: className,
905
905
  decoding: "async",
906
- src: imageLoader ? imageLoader({
906
+ src: imageLoader && imageLoader.supportsUrl(src) ? imageLoader.transformUrl({
907
907
  src: src,
908
908
  quality: quality,
909
909
  width: widthDescs[widthDescs.length - 1].width
910
910
  }) : src,
911
- srcSet: imageLoader ? widthDescs.map(function (wd) {
912
- return imageLoader({
911
+ srcSet: imageLoader && imageLoader.supportsUrl(src) ? widthDescs.map(function (wd) {
912
+ return imageLoader.transformUrl({
913
913
  src: src,
914
914
  quality: quality,
915
915
  width: wd.width
@@ -920,12 +920,20 @@ function makePicture(opts) {
920
920
  })));
921
921
  }
922
922
 
923
- function getClosestPresetSize(width) {
923
+ function getClosestPresetSize(width, fullWidth) {
924
924
  var _ALL_SIZES$find;
925
925
 
926
- return (_ALL_SIZES$find = ALL_SIZES.find(function (w) {
926
+ var nextBigger = (_ALL_SIZES$find = ALL_SIZES.find(function (w) {
927
927
  return w >= width;
928
928
  })) != null ? _ALL_SIZES$find : ALL_SIZES[ALL_SIZES.length - 1];
929
+
930
+ if (nextBigger >= fullWidth / 2) {
931
+ // If the requested width is larger than half the fullWidth,
932
+ // we just use the original width instead
933
+ return undefined;
934
+ }
935
+
936
+ return nextBigger;
929
937
  }
930
938
  /**
931
939
  * Computes the appropriate srcSet and sizes to use
@@ -939,10 +947,10 @@ function getWidths(width, fullWidth) {
939
947
  // If there's an exact width, then we just need to display it at 1x and 2x density
940
948
  return {
941
949
  widthDescs: [{
942
- width: getClosestPresetSize(pixelWidth),
950
+ width: getClosestPresetSize(pixelWidth, fullWidth),
943
951
  desc: "1x"
944
952
  }, {
945
- width: getClosestPresetSize(pixelWidth * 2),
953
+ width: getClosestPresetSize(pixelWidth * 2, fullWidth),
946
954
  desc: "2x"
947
955
  }],
948
956
  sizes: undefined
@@ -960,7 +968,7 @@ function getWidths(width, fullWidth) {
960
968
  // is offer 1x
961
969
  return {
962
970
  widthDescs: [{
963
- width: getClosestPresetSize(fullWidth),
971
+ width: getClosestPresetSize(fullWidth, fullWidth),
964
972
  desc: "1x"
965
973
  }],
966
974
  sizes: undefined
@@ -968,9 +976,15 @@ function getWidths(width, fullWidth) {
968
976
  }
969
977
 
970
978
  return {
971
- widthDescs: usefulSizes.map(function (size) {
979
+ widthDescs: usefulSizes.map(function (size, i) {
972
980
  return {
973
- width: size,
981
+ width: // If this is the last (buggest) useful width, but it is
982
+ // still within the bounds set by DEVICE_SIZES, then just
983
+ // use the original, unresized image. This means if we match
984
+ // the largest size, we use unresized and best quality image.
985
+ // We only do this, though, if fullWidth is "reasonable" --
986
+ // smaller than the largest size we would consider.
987
+ i === usefulSizes.length - 1 && fullWidth < DEVICE_SIZES[DEVICE_SIZES.length - 1] ? undefined : size,
974
988
  desc: size + "w"
975
989
  };
976
990
  }),
@@ -1032,10 +1046,18 @@ function getImageLoader(loader) {
1032
1046
  }
1033
1047
  }
1034
1048
 
1035
- var PLASMIC_IMAGE_LOADER = function PLASMIC_IMAGE_LOADER(opts) {
1036
- var _opts$quality;
1049
+ var PLASMIC_IMAGE_LOADER = {
1050
+ supportsUrl: function supportsUrl(src) {
1051
+ return src.startsWith("https://img.plasmic.app");
1052
+ },
1053
+ transformUrl: function transformUrl(opts) {
1054
+ var _opts$quality;
1037
1055
 
1038
- return opts.src + "?w=" + opts.width + "&q=" + ((_opts$quality = opts.quality) != null ? _opts$quality : 75) + (opts.format ? "&f=" + opts.format : "");
1056
+ var params = [opts.width ? "w=" + opts.width : undefined, "q=" + ((_opts$quality = opts.quality) != null ? _opts$quality : 75), opts.format ? "f=" + opts.format : undefined].filter(function (x) {
1057
+ return !!x;
1058
+ });
1059
+ return opts.src + "?" + params.join("&");
1060
+ }
1039
1061
  };
1040
1062
 
1041
1063
  function PlasmicLink(props) {