@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.
- package/lib/arg-types/utils.d.ts +4 -18
- package/lib/arg-types/utils.d.ts.map +1 -1
- package/lib/arg-types/utils.js +23 -16
- package/lib/component-utils/image.d.ts +107 -0
- package/lib/component-utils/image.d.ts.map +1 -0
- package/lib/component-utils/image.js +198 -0
- package/lib/component-utils/image.test.d.ts +2 -0
- package/lib/component-utils/image.test.d.ts.map +1 -0
- package/lib/component-utils/image.test.js +132 -0
- package/lib/components/body.props.json +104 -1847
- package/lib/components/body.stories.d.ts +2 -2
- package/lib/components/body.stories.d.ts.map +1 -1
- package/lib/components/body.stories.js +0 -5
- package/lib/components/bold.d.ts +2 -2
- package/lib/components/bold.d.ts.map +1 -1
- package/lib/components/bold.props.json +104 -1847
- package/lib/components/bold.stories.d.ts +3 -3
- package/lib/components/bold.stories.d.ts.map +1 -1
- package/lib/components/bold.stories.js +0 -5
- package/lib/components/box.props.json +108 -1899
- package/lib/components/box.stories.d.ts +5 -5
- package/lib/components/box.stories.d.ts.map +1 -1
- package/lib/components/box.stories.js +0 -5
- package/lib/components/button.d.ts +2 -2
- package/lib/components/button.d.ts.map +1 -1
- package/lib/components/button.props.json +117 -2065
- package/lib/components/button.stories.d.ts +3 -3
- package/lib/components/button.stories.d.ts.map +1 -1
- package/lib/components/button.stories.js +0 -5
- package/lib/components/component-type.d.ts +1 -1
- package/lib/components/component-type.d.ts.map +1 -1
- package/lib/components/form.d.ts +2 -2
- package/lib/components/form.d.ts.map +1 -1
- package/lib/components/form.props.json +112 -1991
- package/lib/components/form.stories.d.ts +3 -3
- package/lib/components/form.stories.d.ts.map +1 -1
- package/lib/components/form.stories.js +0 -5
- package/lib/components/heading.props.json +107 -1893
- package/lib/components/heading.stories.d.ts +5 -5
- package/lib/components/heading.stories.d.ts.map +1 -1
- package/lib/components/heading.stories.js +0 -5
- package/lib/components/image-dev.stories.d.ts +36 -0
- package/lib/components/image-dev.stories.d.ts.map +1 -0
- package/lib/components/image-dev.stories.js +102 -0
- package/lib/components/image.d.ts +10 -2
- package/lib/components/image.d.ts.map +1 -1
- package/lib/components/image.js +19 -9
- package/lib/components/image.props.json +140 -2098
- package/lib/components/image.stories.d.ts +11 -3
- package/lib/components/image.stories.d.ts.map +1 -1
- package/lib/components/image.stories.js +0 -5
- package/lib/components/image.ws.d.ts.map +1 -1
- package/lib/components/image.ws.js +15 -0
- package/lib/components/index.d.ts +3 -0
- package/lib/components/index.d.ts.map +1 -1
- package/lib/components/index.js +7 -1
- package/lib/components/input.d.ts +2 -2
- package/lib/components/input.d.ts.map +1 -1
- package/lib/components/input.props.json +138 -2474
- package/lib/components/input.stories.d.ts +3 -3
- package/lib/components/input.stories.d.ts.map +1 -1
- package/lib/components/input.stories.js +0 -5
- package/lib/components/italic.d.ts +2 -2
- package/lib/components/italic.d.ts.map +1 -1
- package/lib/components/italic.props.json +104 -1847
- package/lib/components/italic.stories.d.ts +3 -3
- package/lib/components/italic.stories.d.ts.map +1 -1
- package/lib/components/italic.stories.js +0 -5
- package/lib/components/link.d.ts +2 -2
- package/lib/components/link.d.ts.map +1 -1
- package/lib/components/link.props.json +116 -2040
- package/lib/components/link.stories.d.ts +5 -5
- package/lib/components/link.stories.d.ts.map +1 -1
- package/lib/components/link.stories.js +0 -5
- package/lib/components/meta.d.ts +7469 -12
- package/lib/components/meta.d.ts.map +1 -1
- package/lib/components/meta.js +34 -25
- package/lib/components/paragraph.d.ts +2 -2
- package/lib/components/paragraph.d.ts.map +1 -1
- package/lib/components/paragraph.props.json +104 -1847
- package/lib/components/paragraph.stories.d.ts +3 -3
- package/lib/components/paragraph.stories.d.ts.map +1 -1
- package/lib/components/paragraph.stories.js +0 -5
- package/lib/components/span.d.ts +3 -0
- package/lib/components/span.d.ts.map +1 -0
- package/lib/components/span.js +8 -0
- package/lib/components/span.props.json +491 -0
- package/lib/components/span.stories.d.ts +6 -0
- package/lib/components/span.stories.d.ts.map +1 -0
- package/lib/components/span.stories.js +14 -0
- package/lib/components/span.ws.d.ts +5 -0
- package/lib/components/span.ws.d.ts.map +1 -0
- package/lib/components/span.ws.js +14 -0
- package/lib/components/subscript.d.ts +3 -0
- package/lib/components/subscript.d.ts.map +1 -0
- package/lib/components/subscript.js +8 -0
- package/lib/components/subscript.props.json +491 -0
- package/lib/components/subscript.stories.d.ts +6 -0
- package/lib/components/subscript.stories.d.ts.map +1 -0
- package/lib/components/subscript.stories.js +14 -0
- package/lib/components/subscript.ws.d.ts +5 -0
- package/lib/components/subscript.ws.d.ts.map +1 -0
- package/lib/components/subscript.ws.js +14 -0
- package/lib/components/superscript.d.ts +3 -0
- package/lib/components/superscript.d.ts.map +1 -0
- package/lib/components/superscript.js +8 -0
- package/lib/components/superscript.props.json +491 -0
- package/lib/components/superscript.stories.d.ts +6 -0
- package/lib/components/superscript.stories.d.ts.map +1 -0
- package/lib/components/superscript.stories.js +14 -0
- package/lib/components/superscript.ws.d.ts +5 -0
- package/lib/components/superscript.ws.d.ts.map +1 -0
- package/lib/components/superscript.ws.js +14 -0
- package/lib/components/text-block.d.ts +2 -2
- package/lib/components/text-block.d.ts.map +1 -1
- package/lib/components/text-block.props.json +104 -1847
- package/lib/components/text-block.stories.d.ts +3 -3
- package/lib/components/text-block.stories.d.ts.map +1 -1
- package/lib/components/text-block.stories.js +0 -5
- package/lib/css/breakpoints.d.ts +1 -1
- package/lib/css/breakpoints.d.ts.map +1 -1
- package/lib/css/categories.d.ts +2 -2
- package/lib/css/get-browser-style.d.ts +1 -1
- package/lib/css/get-browser-style.d.ts.map +1 -1
- package/lib/css/get-browser-style.js +10 -5
- package/lib/css/index.d.ts +0 -5
- package/lib/css/index.d.ts.map +1 -1
- package/lib/css/index.js +0 -5
- package/lib/db/instance.d.ts +1 -1
- package/lib/db/instance.d.ts.map +1 -1
- package/lib/db/instance.js +2 -2
- package/lib/index.d.ts +1 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -3
- package/lib/pubsub/create.d.ts +1 -0
- package/lib/pubsub/create.d.ts.map +1 -1
- package/lib/pubsub/create.js +8 -0
- package/lib/remix/handle-request.server.d.ts.map +1 -1
- package/lib/remix/handle-request.server.js +1 -2
- package/lib/remix/root.d.ts.map +1 -1
- package/lib/remix/root.js +2 -2
- package/lib/tree/create-elements-tree.d.ts +7 -11
- package/lib/tree/create-elements-tree.d.ts.map +1 -1
- package/lib/tree/create-elements-tree.js +5 -10
- package/lib/tree/root.d.ts +4 -6
- package/lib/tree/root.d.ts.map +1 -1
- package/lib/tree/root.js +1 -23
- package/lib/tree/session-storage-polyfill.d.ts +2 -0
- package/lib/tree/session-storage-polyfill.d.ts.map +1 -0
- package/lib/tree/session-storage-polyfill.js +39 -0
- package/lib/tree/wrapper-component.d.ts +4 -4
- package/lib/tree/wrapper-component.d.ts.map +1 -1
- package/lib/tree/wrapper-component.js +5 -5
- package/package.json +21 -13
- package/lib/css/keyword-values.d.ts +0 -302
- package/lib/css/keyword-values.d.ts.map +0 -1
- package/lib/css/keyword-values.js +0 -6619
- package/lib/css/properties.d.ts +0 -3199
- package/lib/css/properties.d.ts.map +0 -1
- package/lib/css/properties.js +0 -3202
- package/lib/css/schema.d.ts +0 -283
- package/lib/css/schema.d.ts.map +0 -1
- package/lib/css/schema.js +0 -48
- package/lib/css/types.d.ts +0 -6
- package/lib/css/types.d.ts.map +0 -1
- package/lib/css/types.js +0 -2
- package/lib/css/units.d.ts +0 -2
- package/lib/css/units.d.ts.map +0 -1
- package/lib/css/units.js +0 -35
- package/lib/remix/constants.d.ts +0 -2
- package/lib/remix/constants.d.ts.map +0 -1
- package/lib/remix/constants.js +0 -4
- package/lib/remix/insert-critical-css.d.ts +0 -2
- package/lib/remix/insert-critical-css.d.ts.map +0 -1
- package/lib/remix/insert-critical-css.js +0 -9
- package/lib/stitches/index.d.ts +0 -3
- package/lib/stitches/index.d.ts.map +0 -1
- package/lib/stitches/index.js +0 -18
- package/lib/stitches/stitches.d.ts +0 -8
- package/lib/stitches/stitches.d.ts.map +0 -1
- package/lib/stitches/stitches.js +0 -38
- package/lib/stitches/to-css.d.ts +0 -8
- package/lib/stitches/to-css.d.ts.map +0 -1
- package/lib/stitches/to-css.js +0 -52
- package/lib/stitches/to-css.test.d.ts +0 -2
- package/lib/stitches/to-css.test.d.ts.map +0 -1
- package/lib/stitches/to-css.test.js +0 -82
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import type { ComponentStory, ComponentMeta } from "@storybook/react";
|
|
3
|
-
declare const _default: ComponentMeta<
|
|
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
|
|
5
|
+
}, "key" | "tag" | keyof import("react").HTMLAttributes<HTMLHeadingElement>> & import("react").RefAttributes<HTMLHeadingElement>>>;
|
|
6
6
|
export default _default;
|
|
7
|
-
export declare const Heading: ComponentStory<
|
|
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
|
|
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,
|
|
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
|
|
2
|
-
|
|
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,
|
|
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"}
|
package/lib/components/image.js
CHANGED
|
@@ -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)((
|
|
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>`)}`;
|