@webstudio-is/react-sdk 0.7.0 → 0.7.2

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 (187) hide show
  1. package/lib/arg-types/utils.d.ts +4 -18
  2. package/lib/arg-types/utils.d.ts.map +1 -1
  3. package/lib/arg-types/utils.js +23 -16
  4. package/lib/component-utils/image.d.ts +107 -0
  5. package/lib/component-utils/image.d.ts.map +1 -0
  6. package/lib/component-utils/image.js +198 -0
  7. package/lib/component-utils/image.test.d.ts +2 -0
  8. package/lib/component-utils/image.test.d.ts.map +1 -0
  9. package/lib/component-utils/image.test.js +132 -0
  10. package/lib/components/body.props.json +104 -1847
  11. package/lib/components/body.stories.d.ts +2 -2
  12. package/lib/components/body.stories.d.ts.map +1 -1
  13. package/lib/components/body.stories.js +0 -5
  14. package/lib/components/bold.d.ts +2 -2
  15. package/lib/components/bold.d.ts.map +1 -1
  16. package/lib/components/bold.props.json +104 -1847
  17. package/lib/components/bold.stories.d.ts +3 -3
  18. package/lib/components/bold.stories.d.ts.map +1 -1
  19. package/lib/components/bold.stories.js +0 -5
  20. package/lib/components/box.props.json +108 -1899
  21. package/lib/components/box.stories.d.ts +5 -5
  22. package/lib/components/box.stories.d.ts.map +1 -1
  23. package/lib/components/box.stories.js +0 -5
  24. package/lib/components/button.d.ts +2 -2
  25. package/lib/components/button.d.ts.map +1 -1
  26. package/lib/components/button.props.json +117 -2065
  27. package/lib/components/button.stories.d.ts +3 -3
  28. package/lib/components/button.stories.d.ts.map +1 -1
  29. package/lib/components/button.stories.js +0 -5
  30. package/lib/components/component-type.d.ts +1 -1
  31. package/lib/components/component-type.d.ts.map +1 -1
  32. package/lib/components/form.d.ts +2 -2
  33. package/lib/components/form.d.ts.map +1 -1
  34. package/lib/components/form.props.json +112 -1991
  35. package/lib/components/form.stories.d.ts +3 -3
  36. package/lib/components/form.stories.d.ts.map +1 -1
  37. package/lib/components/form.stories.js +0 -5
  38. package/lib/components/heading.props.json +107 -1893
  39. package/lib/components/heading.stories.d.ts +5 -5
  40. package/lib/components/heading.stories.d.ts.map +1 -1
  41. package/lib/components/heading.stories.js +0 -5
  42. package/lib/components/image-dev.stories.d.ts +36 -0
  43. package/lib/components/image-dev.stories.d.ts.map +1 -0
  44. package/lib/components/image-dev.stories.js +102 -0
  45. package/lib/components/image.d.ts +10 -2
  46. package/lib/components/image.d.ts.map +1 -1
  47. package/lib/components/image.js +19 -9
  48. package/lib/components/image.props.json +140 -2098
  49. package/lib/components/image.stories.d.ts +11 -3
  50. package/lib/components/image.stories.d.ts.map +1 -1
  51. package/lib/components/image.stories.js +0 -5
  52. package/lib/components/image.ws.d.ts.map +1 -1
  53. package/lib/components/image.ws.js +15 -0
  54. package/lib/components/index.d.ts +3 -0
  55. package/lib/components/index.d.ts.map +1 -1
  56. package/lib/components/index.js +7 -1
  57. package/lib/components/input.d.ts +2 -2
  58. package/lib/components/input.d.ts.map +1 -1
  59. package/lib/components/input.props.json +138 -2474
  60. package/lib/components/input.stories.d.ts +3 -3
  61. package/lib/components/input.stories.d.ts.map +1 -1
  62. package/lib/components/input.stories.js +0 -5
  63. package/lib/components/italic.d.ts +2 -2
  64. package/lib/components/italic.d.ts.map +1 -1
  65. package/lib/components/italic.props.json +104 -1847
  66. package/lib/components/italic.stories.d.ts +3 -3
  67. package/lib/components/italic.stories.d.ts.map +1 -1
  68. package/lib/components/italic.stories.js +0 -5
  69. package/lib/components/link.d.ts +2 -2
  70. package/lib/components/link.d.ts.map +1 -1
  71. package/lib/components/link.props.json +116 -2040
  72. package/lib/components/link.stories.d.ts +5 -5
  73. package/lib/components/link.stories.d.ts.map +1 -1
  74. package/lib/components/link.stories.js +0 -5
  75. package/lib/components/meta.d.ts +7469 -12
  76. package/lib/components/meta.d.ts.map +1 -1
  77. package/lib/components/meta.js +34 -25
  78. package/lib/components/paragraph.d.ts +2 -2
  79. package/lib/components/paragraph.d.ts.map +1 -1
  80. package/lib/components/paragraph.props.json +104 -1847
  81. package/lib/components/paragraph.stories.d.ts +3 -3
  82. package/lib/components/paragraph.stories.d.ts.map +1 -1
  83. package/lib/components/paragraph.stories.js +0 -5
  84. package/lib/components/span.d.ts +3 -0
  85. package/lib/components/span.d.ts.map +1 -0
  86. package/lib/components/span.js +8 -0
  87. package/lib/components/span.props.json +491 -0
  88. package/lib/components/span.stories.d.ts +6 -0
  89. package/lib/components/span.stories.d.ts.map +1 -0
  90. package/lib/components/span.stories.js +14 -0
  91. package/lib/components/span.ws.d.ts +5 -0
  92. package/lib/components/span.ws.d.ts.map +1 -0
  93. package/lib/components/span.ws.js +14 -0
  94. package/lib/components/subscript.d.ts +3 -0
  95. package/lib/components/subscript.d.ts.map +1 -0
  96. package/lib/components/subscript.js +8 -0
  97. package/lib/components/subscript.props.json +491 -0
  98. package/lib/components/subscript.stories.d.ts +6 -0
  99. package/lib/components/subscript.stories.d.ts.map +1 -0
  100. package/lib/components/subscript.stories.js +14 -0
  101. package/lib/components/subscript.ws.d.ts +5 -0
  102. package/lib/components/subscript.ws.d.ts.map +1 -0
  103. package/lib/components/subscript.ws.js +14 -0
  104. package/lib/components/superscript.d.ts +3 -0
  105. package/lib/components/superscript.d.ts.map +1 -0
  106. package/lib/components/superscript.js +8 -0
  107. package/lib/components/superscript.props.json +491 -0
  108. package/lib/components/superscript.stories.d.ts +6 -0
  109. package/lib/components/superscript.stories.d.ts.map +1 -0
  110. package/lib/components/superscript.stories.js +14 -0
  111. package/lib/components/superscript.ws.d.ts +5 -0
  112. package/lib/components/superscript.ws.d.ts.map +1 -0
  113. package/lib/components/superscript.ws.js +14 -0
  114. package/lib/components/text-block.d.ts +2 -2
  115. package/lib/components/text-block.d.ts.map +1 -1
  116. package/lib/components/text-block.props.json +104 -1847
  117. package/lib/components/text-block.stories.d.ts +3 -3
  118. package/lib/components/text-block.stories.d.ts.map +1 -1
  119. package/lib/components/text-block.stories.js +0 -5
  120. package/lib/css/breakpoints.d.ts +1 -1
  121. package/lib/css/breakpoints.d.ts.map +1 -1
  122. package/lib/css/categories.d.ts +2 -2
  123. package/lib/css/get-browser-style.d.ts +1 -1
  124. package/lib/css/get-browser-style.d.ts.map +1 -1
  125. package/lib/css/get-browser-style.js +10 -5
  126. package/lib/css/index.d.ts +0 -5
  127. package/lib/css/index.d.ts.map +1 -1
  128. package/lib/css/index.js +0 -5
  129. package/lib/db/instance.d.ts +1 -1
  130. package/lib/db/instance.d.ts.map +1 -1
  131. package/lib/db/instance.js +2 -2
  132. package/lib/index.d.ts +1 -2
  133. package/lib/index.d.ts.map +1 -1
  134. package/lib/index.js +2 -3
  135. package/lib/pubsub/create.d.ts +1 -0
  136. package/lib/pubsub/create.d.ts.map +1 -1
  137. package/lib/pubsub/create.js +8 -0
  138. package/lib/remix/handle-request.server.d.ts.map +1 -1
  139. package/lib/remix/handle-request.server.js +1 -2
  140. package/lib/remix/root.d.ts.map +1 -1
  141. package/lib/remix/root.js +2 -2
  142. package/lib/tree/create-elements-tree.d.ts +7 -11
  143. package/lib/tree/create-elements-tree.d.ts.map +1 -1
  144. package/lib/tree/create-elements-tree.js +5 -10
  145. package/lib/tree/root.d.ts +4 -6
  146. package/lib/tree/root.d.ts.map +1 -1
  147. package/lib/tree/root.js +1 -23
  148. package/lib/tree/session-storage-polyfill.d.ts +2 -0
  149. package/lib/tree/session-storage-polyfill.d.ts.map +1 -0
  150. package/lib/tree/session-storage-polyfill.js +39 -0
  151. package/lib/tree/wrapper-component.d.ts +4 -4
  152. package/lib/tree/wrapper-component.d.ts.map +1 -1
  153. package/lib/tree/wrapper-component.js +5 -5
  154. package/package.json +21 -13
  155. package/lib/css/keyword-values.d.ts +0 -302
  156. package/lib/css/keyword-values.d.ts.map +0 -1
  157. package/lib/css/keyword-values.js +0 -6619
  158. package/lib/css/properties.d.ts +0 -3199
  159. package/lib/css/properties.d.ts.map +0 -1
  160. package/lib/css/properties.js +0 -3202
  161. package/lib/css/schema.d.ts +0 -283
  162. package/lib/css/schema.d.ts.map +0 -1
  163. package/lib/css/schema.js +0 -48
  164. package/lib/css/types.d.ts +0 -6
  165. package/lib/css/types.d.ts.map +0 -1
  166. package/lib/css/types.js +0 -2
  167. package/lib/css/units.d.ts +0 -2
  168. package/lib/css/units.d.ts.map +0 -1
  169. package/lib/css/units.js +0 -35
  170. package/lib/remix/constants.d.ts +0 -2
  171. package/lib/remix/constants.d.ts.map +0 -1
  172. package/lib/remix/constants.js +0 -4
  173. package/lib/remix/insert-critical-css.d.ts +0 -2
  174. package/lib/remix/insert-critical-css.d.ts.map +0 -1
  175. package/lib/remix/insert-critical-css.js +0 -9
  176. package/lib/stitches/index.d.ts +0 -3
  177. package/lib/stitches/index.d.ts.map +0 -1
  178. package/lib/stitches/index.js +0 -18
  179. package/lib/stitches/stitches.d.ts +0 -8
  180. package/lib/stitches/stitches.d.ts.map +0 -1
  181. package/lib/stitches/stitches.js +0 -38
  182. package/lib/stitches/to-css.d.ts +0 -8
  183. package/lib/stitches/to-css.d.ts.map +0 -1
  184. package/lib/stitches/to-css.js +0 -52
  185. package/lib/stitches/to-css.test.d.ts +0 -2
  186. package/lib/stitches/to-css.test.d.ts.map +0 -1
  187. package/lib/stitches/to-css.test.js +0 -82
@@ -1,10 +1,10 @@
1
- import React from "react";
1
+ /// <reference types="react" />
2
2
  import type { ComponentStory, ComponentMeta } from "@storybook/react";
3
- declare const _default: ComponentMeta<React.ForwardRefExoticComponent<Pick<React.ClassAttributes<HTMLHeadingElement> & React.HTMLAttributes<HTMLHeadingElement> & {
3
+ declare const _default: ComponentMeta<import("react").ForwardRefExoticComponent<Pick<import("react").ClassAttributes<HTMLHeadingElement> & import("react").HTMLAttributes<HTMLHeadingElement> & {
4
4
  tag?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | undefined;
5
- }, "key" | "tag" | keyof React.HTMLAttributes<HTMLHeadingElement>> & React.RefAttributes<HTMLHeadingElement>>>;
5
+ }, "key" | "tag" | keyof import("react").HTMLAttributes<HTMLHeadingElement>> & import("react").RefAttributes<HTMLHeadingElement>>>;
6
6
  export default _default;
7
- export declare const Heading: ComponentStory<React.ForwardRefExoticComponent<Pick<React.ClassAttributes<HTMLHeadingElement> & React.HTMLAttributes<HTMLHeadingElement> & {
7
+ export declare const Heading: ComponentStory<import("react").ForwardRefExoticComponent<Pick<import("react").ClassAttributes<HTMLHeadingElement> & import("react").HTMLAttributes<HTMLHeadingElement> & {
8
8
  tag?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | undefined;
9
- }, "key" | "tag" | keyof React.HTMLAttributes<HTMLHeadingElement>> & React.RefAttributes<HTMLHeadingElement>>>;
9
+ }, "key" | "tag" | keyof import("react").HTMLAttributes<HTMLHeadingElement>> & import("react").RefAttributes<HTMLHeadingElement>>>;
10
10
  //# sourceMappingURL=heading.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"heading.stories.d.ts","sourceRoot":"","sources":["../../src/components/heading.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;;;;AAItE,wBAI4C;AAM5C,eAAO,MAAM,OAAO;;8GAAoB,CAAC"}
1
+ {"version":3,"file":"heading.stories.d.ts","sourceRoot":"","sources":["../../src/components/heading.stories.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;;;;AAGtE,wBAG4C;AAM5C,eAAO,MAAM,OAAO;;kIAAoB,CAAC"}
@@ -1,16 +1,11 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.Heading = void 0;
7
4
  const jsx_runtime_1 = require("react/jsx-runtime");
8
5
  const heading_1 = require("./heading");
9
- const heading_props_json_1 = __importDefault(require("./heading.props.json"));
10
6
  exports.default = {
11
7
  title: "Components/Heading",
12
8
  component: heading_1.Heading,
13
- argTypes: heading_props_json_1.default,
14
9
  };
15
10
  const Template = (args) => ((0, jsx_runtime_1.jsx)(heading_1.Heading, { ...args }));
16
11
  exports.Heading = Template.bind({});
@@ -0,0 +1,36 @@
1
+ import React from "react";
2
+ import type { ComponentMeta, ComponentStory } from "@storybook/react";
3
+ import { type ImageLoader } from "../component-utils/image";
4
+ declare const _default: ComponentMeta<React.ForwardRefExoticComponent<Pick<React.ClassAttributes<HTMLImageElement> & React.ImgHTMLAttributes<HTMLImageElement> & {
5
+ quality?: number | undefined;
6
+ loader?: ImageLoader | undefined;
7
+ optimize?: boolean | undefined;
8
+ }, "key" | "quality" | "loader" | keyof React.ImgHTMLAttributes<HTMLImageElement> | "optimize"> & React.RefAttributes<HTMLImageElement>>>;
9
+ export default _default;
10
+ /**
11
+ * Load images depending on image width and device per pixel ratio.
12
+ **/
13
+ export declare const FixedWidthImage: ComponentStory<React.FunctionComponent>;
14
+ /**
15
+ * Preserve ratio using object-fit: cover. Load images depending on image width and device per pixel ratio.
16
+ **/
17
+ export declare const FixedWidthImageCover: ComponentStory<React.FunctionComponent>;
18
+ /**
19
+ * Load images depending on the viewport width.
20
+ **/
21
+ export declare const UnknownWidthImage: ComponentStory<React.FunctionComponent>;
22
+ /**
23
+ * Fit width of the parent container, has own aspect-ratio and object-fit=cover.
24
+ * Load images depending on the viewport width.
25
+ **/
26
+ export declare const AspectRatioImage: ComponentStory<React.FunctionComponent>;
27
+ /**
28
+ * Fill width and height of the relative parent container, object-fit=cover. Load images depending on the viewport width.
29
+ **/
30
+ export declare const FillParentImage: ComponentStory<React.FunctionComponent>;
31
+ /**
32
+ * "sizes" attribute explicitly equal to 100vw allowing to skip the default behavior.
33
+ * See DEFAULT_SIZES in the Image component. Load images depending on the viewport width.
34
+ **/
35
+ export declare const HeroImage: ComponentStory<React.FunctionComponent>;
36
+ //# sourceMappingURL=image-dev.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-dev.stories.d.ts","sourceRoot":"","sources":["../../src/components/image-dev.stories.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmD,MAAM,OAAO,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAItE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,0BAA0B,CAAC;;;;;;AAO5D,wBAE0C;AAgF1C;;IAEI;AACJ,eAAO,MAAM,eAAe,EAAE,cAAc,CAAC,KAAK,CAAC,iBAAiB,CAEnE,CAAC;AAEF;;IAEI;AACJ,eAAO,MAAM,oBAAoB,EAAE,cAAc,CAC/C,KAAK,CAAC,iBAAiB,CAQxB,CAAC;AAEF;;IAEI;AACJ,eAAO,MAAM,iBAAiB,EAAE,cAAc,CAC5C,KAAK,CAAC,iBAAiB,CACa,CAAC;AAEvC;;;IAGI;AACJ,eAAO,MAAM,gBAAgB,EAAE,cAAc,CAAC,KAAK,CAAC,iBAAiB,CAOpE,CAAC;AAEF;;IAEI;AACJ,eAAO,MAAM,eAAe,EAAE,cAAc,CAAC,KAAK,CAAC,iBAAiB,CAYnE,CAAC;AAEF;;;IAGI;AACJ,eAAO,MAAM,SAAS,EAAE,cAAc,CAAC,KAAK,CAAC,iBAAiB,CAU7D,CAAC"}
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.HeroImage = exports.FillParentImage = exports.AspectRatioImage = exports.UnknownWidthImage = exports.FixedWidthImageCover = exports.FixedWidthImage = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const warn_once_1 = __importDefault(require("warn-once"));
9
+ const image_1 = require("./image");
10
+ const image_ws_1 = __importDefault(require("./image.ws"));
11
+ // to not allow include local assets everywhere, just enable it for this file
12
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
13
+ // @ts-ignore
14
+ const logo_webp_1 = __importDefault(require("../../storybook-assets/logo.webp"));
15
+ exports.default = {
16
+ title: "Components/ImageDev",
17
+ };
18
+ /**
19
+ * In case you need to test img with real cloudflare trasforms
20
+ * set USE_CLOUDFLARE_IMAGE_TRANSFORM = true
21
+ **/
22
+ const USE_CLOUDFLARE_IMAGE_TRANSFORM = false;
23
+ // For cloudflare image transform testing, logo should be the most consistent image on the site
24
+ const REMOTE_SELF_DOMAIN_IMAGE = "https://webstudio.is/logo.webp";
25
+ const imageSrc = USE_CLOUDFLARE_IMAGE_TRANSFORM
26
+ ? REMOTE_SELF_DOMAIN_IMAGE
27
+ : logo_webp_1.default;
28
+ // In case of REMOTE_DEBUG
29
+ const cloudflareImageLoader = ({ width, src, quality }) => {
30
+ // No image transformation in development
31
+ const resizeOrigin = "https://webstudio.is";
32
+ const pathParams = [
33
+ `width=${width}`,
34
+ quality != null && `quality=${quality}`,
35
+ "format=auto",
36
+ ].filter(Boolean);
37
+ const pathname = `/cdn-cgi/image/${pathParams.join(",")}/${src}`;
38
+ const url = new URL(pathname, resizeOrigin);
39
+ return url.href;
40
+ };
41
+ const localImageLoader = ({ width, src, quality }) => {
42
+ // Just emulate like we really resize the image
43
+ const params = new URLSearchParams();
44
+ params.set("width", `${width}`);
45
+ params.set("quality", `${quality}`);
46
+ return `${src}?${params.toString()}`;
47
+ };
48
+ const imageLoader = USE_CLOUDFLARE_IMAGE_TRANSFORM
49
+ ? cloudflareImageLoader
50
+ : localImageLoader;
51
+ const ImageBase = (args) => {
52
+ (0, warn_once_1.default)(!(image_ws_1.default.defaultStyle?.maxWidth?.value === 100 &&
53
+ image_ws_1.default.defaultStyle?.maxWidth?.unit === "%"), "We expect that the image default style has maxWidth: 100%");
54
+ (0, warn_once_1.default)(image_ws_1.default.defaultStyle?.display?.value !== "block", "We expect that the image default style has display: block");
55
+ const style = {
56
+ maxWidth: "100%",
57
+ display: "block",
58
+ ...args.style,
59
+ };
60
+ return ((0, jsx_runtime_1.jsx)(image_1.Image, { ...args, optimize: true, loader: imageLoader, style: style }));
61
+ };
62
+ /**
63
+ * Load images depending on image width and device per pixel ratio.
64
+ **/
65
+ const FixedWidthImage = () => ((0, jsx_runtime_1.jsx)(ImageBase, { src: imageSrc, width: "300", height: "400" }));
66
+ exports.FixedWidthImage = FixedWidthImage;
67
+ /**
68
+ * Preserve ratio using object-fit: cover. Load images depending on image width and device per pixel ratio.
69
+ **/
70
+ const FixedWidthImageCover = () => ((0, jsx_runtime_1.jsx)(ImageBase, { src: imageSrc, width: "300", height: "400", style: { objectFit: "cover" } }));
71
+ exports.FixedWidthImageCover = FixedWidthImageCover;
72
+ /**
73
+ * Load images depending on the viewport width.
74
+ **/
75
+ const UnknownWidthImage = () => (0, jsx_runtime_1.jsx)(ImageBase, { src: imageSrc });
76
+ exports.UnknownWidthImage = UnknownWidthImage;
77
+ /**
78
+ * Fit width of the parent container, has own aspect-ratio and object-fit=cover.
79
+ * Load images depending on the viewport width.
80
+ **/
81
+ const AspectRatioImage = () => ((0, jsx_runtime_1.jsx)("div", { style: { width: "50%" }, children: (0, jsx_runtime_1.jsx)(ImageBase, { src: imageSrc, style: { aspectRatio: "2/1", objectFit: "cover", width: "100%" } }) }));
82
+ exports.AspectRatioImage = AspectRatioImage;
83
+ /**
84
+ * Fill width and height of the relative parent container, object-fit=cover. Load images depending on the viewport width.
85
+ **/
86
+ const FillParentImage = () => ((0, jsx_runtime_1.jsx)("div", { style: { width: "50%", aspectRatio: "2/1", position: "relative" }, children: (0, jsx_runtime_1.jsx)(ImageBase, { src: imageSrc, style: {
87
+ objectFit: "cover",
88
+ position: "absolute",
89
+ width: "100%",
90
+ height: "100%",
91
+ } }) }));
92
+ exports.FillParentImage = FillParentImage;
93
+ /**
94
+ * "sizes" attribute explicitly equal to 100vw allowing to skip the default behavior.
95
+ * See DEFAULT_SIZES in the Image component. Load images depending on the viewport width.
96
+ **/
97
+ const HeroImage = () => ((0, jsx_runtime_1.jsx)(ImageBase, { src: imageSrc, sizes: "100vw", style: {
98
+ aspectRatio: "3/1",
99
+ objectFit: "cover",
100
+ width: "100%",
101
+ } }));
102
+ exports.HeroImage = HeroImage;
@@ -1,3 +1,11 @@
1
- import React from "react";
2
- export declare const Image: React.ForwardRefExoticComponent<Pick<React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "key" | keyof React.ImgHTMLAttributes<HTMLImageElement>> & React.RefAttributes<HTMLImageElement>>;
1
+ import { type ComponentProps } from "react";
2
+ import { type ImageLoader } from "../component-utils/image";
3
+ declare const defaultTag = "img";
4
+ declare type ImageProps = ComponentProps<typeof defaultTag> & {
5
+ quality?: number;
6
+ loader?: ImageLoader;
7
+ optimize?: boolean;
8
+ };
9
+ export declare const Image: import("react").ForwardRefExoticComponent<Pick<ImageProps, "key" | "quality" | "loader" | keyof import("react").ImgHTMLAttributes<HTMLImageElement> | "optimize"> & import("react").RefAttributes<HTMLImageElement>>;
10
+ export {};
3
11
  //# sourceMappingURL=image.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/components/image.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2D,MAAM,OAAO,CAAC;AAMhF,eAAO,MAAM,KAAK,8NAEjB,CAAC"}
1
+ {"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/components/image.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AACzE,OAAO,EAAsB,KAAK,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEhF,QAAA,MAAM,UAAU,QAAQ,CAAC;AAEzB,aAAK,UAAU,GAAG,cAAc,CAAC,OAAO,UAAU,CAAC,GAAG;IACpD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,KAAK,sNAmBjB,CAAC"}
@@ -3,17 +3,31 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Image = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
+ const image_1 = require("../component-utils/image");
6
7
  const defaultTag = "img";
7
- exports.Image = (0, react_1.forwardRef)((props, ref) => (0, jsx_runtime_1.jsx)("img", { ...props, ref: ref }));
8
+ exports.Image = (0, react_1.forwardRef)(({ quality, loader, optimize, ...imageProps }, ref) => {
9
+ // Temporary set to false, to support previous image behaviour
10
+ const DEFAULT_OPTIMIZE = false;
11
+ const imageAttributes = (0, image_1.getImageAttributes)({
12
+ src: imageProps.src,
13
+ srcSet: imageProps.srcSet,
14
+ sizes: imageProps.sizes,
15
+ width: imageProps.width,
16
+ quality,
17
+ loader,
18
+ optimize: optimize ?? DEFAULT_OPTIMIZE,
19
+ }) ?? { src: imagePlaceholderSvg };
20
+ return ((0, jsx_runtime_1.jsx)("img", { ...imageProps, ...imageAttributes, decoding: "async", ref: ref }));
21
+ });
8
22
  exports.Image.defaultProps = {
9
23
  src: "",
24
+ width: "",
25
+ height: "",
10
26
  loading: "lazy",
11
- width: "auto",
12
- height: "auto",
13
27
  alt: "",
14
28
  };
15
29
  exports.Image.displayName = "Image";
16
- const imagePlaceholderSvg = `<svg
30
+ const imagePlaceholderSvg = `data:image/svg+xml;base64,${btoa(`<svg
17
31
  width="140"
18
32
  height="140"
19
33
  viewBox="0 0 600 600"
@@ -35,8 +49,4 @@ const imagePlaceholderSvg = `<svg
35
49
  d="M160 405V367.205L221.609 306.364L256.552 338.628L358.161 234L440 316.043V405H160Z"
36
50
  fill="#A2A2A2"
37
51
  />
38
- </svg>`;
39
- // Defining src here prevents analyzer from putting the image into the UI.
40
- // @todo it would be better to have the image hosted like a normal image,
41
- // the problem is inside sdk bundler doesn't know how to do that.
42
- exports.Image.defaultProps.src = `data:image/svg+xml;base64,${btoa(imagePlaceholderSvg)}`;
52
+ </svg>`)}`;