@gravity-ui/page-constructor 6.8.1 → 6.8.2-alpha.1

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.
@@ -8,9 +8,9 @@ const Image_1 = tslib_1.__importDefault(require("../Image/Image.js"));
8
8
  exports.qaIdByDefault = 'background-image';
9
9
  const b = (0, utils_1.block)('storage-background-image');
10
10
  const BackgroundImage = (props) => {
11
- const { children, src, desktop, className, imageClassName, style, hide, qa } = props;
11
+ const { children, src, desktop, className, imageClassName, style, qa } = props;
12
12
  const qaAttributes = (0, utils_1.getQaAttrubutes)(qa || exports.qaIdByDefault);
13
- return ((0, jsx_runtime_1.jsxs)("div", { className: b(null, className), style: style, "data-qa": qa || exports.qaIdByDefault, children: [(src || desktop) && !hide && ((0, jsx_runtime_1.jsx)(Image_1.default, { ...props, className: b('img', imageClassName), qa: qaAttributes.image })), children && (0, jsx_runtime_1.jsx)("div", { className: b('container'), children: children })] }));
13
+ return ((0, jsx_runtime_1.jsxs)("div", { className: b(null, className), style: style, "data-qa": qa || exports.qaIdByDefault, children: [(src || desktop) && ((0, jsx_runtime_1.jsx)(Image_1.default, { ...props, className: b('img', imageClassName), qa: qaAttributes.image })), children && (0, jsx_runtime_1.jsx)("div", { className: b('container'), children: children })] }));
14
14
  };
15
15
  exports.default = BackgroundImage;
16
16
  //# sourceMappingURL=BackgroundImage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BackgroundImage.js","sourceRoot":"../../../../src","sources":["components/BackgroundImage/BackgroundImage.tsx"],"names":[],"mappings":";;;;;AAGA,gDAAmD;AACnD,sEAAmC;AAItB,QAAA,aAAa,GAAG,kBAAkB,CAAC;AAEhD,MAAM,CAAC,GAAG,IAAA,aAAK,EAAC,0BAA0B,CAAC,CAAC;AAE5C,MAAM,eAAe,GAAG,CAAC,KAAoD,EAAE,EAAE;IAC7E,MAAM,EAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAC,GAAG,KAAK,CAAC;IACnF,MAAM,YAAY,GAAG,IAAA,uBAAe,EAAC,EAAE,IAAI,qBAAa,CAAC,CAAC;IAE1D,OAAO,CACH,iCAAK,SAAS,EAAE,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,aAAW,EAAE,IAAI,qBAAa,aACzE,CAAC,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAC1B,uBAAC,eAAK,OAAK,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,KAAK,EAAE,cAAc,CAAC,EAAE,EAAE,EAAE,YAAY,CAAC,KAAK,GAAI,CACpF,EACA,QAAQ,IAAI,gCAAK,SAAS,EAAE,CAAC,CAAC,WAAW,CAAC,YAAG,QAAQ,GAAO,IAC3D,CACT,CAAC;AACN,CAAC,CAAC;AAEF,kBAAe,eAAe,CAAC","sourcesContent":["import * as React from 'react';\n\nimport {BackgroundImageProps} from '../../models';\nimport {block, getQaAttrubutes} from '../../utils';\nimport Image from '../Image/Image';\n\nimport './BackgroundImage.scss';\n\nexport const qaIdByDefault = 'background-image';\n\nconst b = block('storage-background-image');\n\nconst BackgroundImage = (props: React.PropsWithChildren<BackgroundImageProps>) => {\n const {children, src, desktop, className, imageClassName, style, hide, qa} = props;\n const qaAttributes = getQaAttrubutes(qa || qaIdByDefault);\n\n return (\n <div className={b(null, className)} style={style} data-qa={qa || qaIdByDefault}>\n {(src || desktop) && !hide && (\n <Image {...props} className={b('img', imageClassName)} qa={qaAttributes.image} />\n )}\n {children && <div className={b('container')}>{children}</div>}\n </div>\n );\n};\n\nexport default BackgroundImage;\n"]}
1
+ {"version":3,"file":"BackgroundImage.js","sourceRoot":"../../../../src","sources":["components/BackgroundImage/BackgroundImage.tsx"],"names":[],"mappings":";;;;;AAGA,gDAAmD;AACnD,sEAAmC;AAItB,QAAA,aAAa,GAAG,kBAAkB,CAAC;AAEhD,MAAM,CAAC,GAAG,IAAA,aAAK,EAAC,0BAA0B,CAAC,CAAC;AAE5C,MAAM,eAAe,GAAG,CAAC,KAAoD,EAAE,EAAE;IAC7E,MAAM,EAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,KAAK,EAAE,EAAE,EAAC,GAAG,KAAK,CAAC;IAC7E,MAAM,YAAY,GAAG,IAAA,uBAAe,EAAC,EAAE,IAAI,qBAAa,CAAC,CAAC;IAE1D,OAAO,CACH,iCAAK,SAAS,EAAE,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,aAAW,EAAE,IAAI,qBAAa,aACzE,CAAC,GAAG,IAAI,OAAO,CAAC,IAAI,CACjB,uBAAC,eAAK,OAAK,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,KAAK,EAAE,cAAc,CAAC,EAAE,EAAE,EAAE,YAAY,CAAC,KAAK,GAAI,CACpF,EACA,QAAQ,IAAI,gCAAK,SAAS,EAAE,CAAC,CAAC,WAAW,CAAC,YAAG,QAAQ,GAAO,IAC3D,CACT,CAAC;AACN,CAAC,CAAC;AAEF,kBAAe,eAAe,CAAC","sourcesContent":["import * as React from 'react';\n\nimport {BackgroundImageProps} from '../../models';\nimport {block, getQaAttrubutes} from '../../utils';\nimport Image from '../Image/Image';\n\nimport './BackgroundImage.scss';\n\nexport const qaIdByDefault = 'background-image';\n\nconst b = block('storage-background-image');\n\nconst BackgroundImage = (props: React.PropsWithChildren<BackgroundImageProps>) => {\n const {children, src, desktop, className, imageClassName, style, qa} = props;\n const qaAttributes = getQaAttrubutes(qa || qaIdByDefault);\n\n return (\n <div className={b(null, className)} style={style} data-qa={qa || qaIdByDefault}>\n {(src || desktop) && (\n <Image {...props} className={b('img', imageClassName)} qa={qaAttributes.image} />\n )}\n {children && <div className={b('container')}>{children}</div>}\n </div>\n );\n};\n\nexport default BackgroundImage;\n"]}
@@ -10,7 +10,9 @@ export interface ImageProps extends Partial<ImageObjectProps>, Partial<ImageDevi
10
10
  export interface DeviceSpecificFragmentProps extends QAProps {
11
11
  disableWebp: boolean;
12
12
  src: string;
13
- breakpoint: number;
13
+ maxBreakpoint?: number;
14
+ minBreakpoint?: number;
14
15
  }
15
- declare const Image: (props: ImageProps) => import("react/jsx-runtime").JSX.Element | null;
16
+ export declare const EMPTY_IMG = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxIiBoZWlnaHQ9IjEiPjwvc3ZnPg==";
17
+ declare const Image: (props: ImageProps) => import("react/jsx-runtime").JSX.Element;
16
18
  export default Image;
@@ -1,31 +1,45 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EMPTY_IMG = void 0;
3
4
  const tslib_1 = require("tslib");
4
5
  const jsx_runtime_1 = require("react/jsx-runtime");
5
6
  const React = tslib_1.__importStar(require("react"));
6
7
  const constants_1 = require("../../constants.js");
7
8
  const projectSettingsContext_1 = require("../../context/projectSettingsContext/index.js");
9
+ const models_1 = require("../../models/index.js");
8
10
  const utils_1 = require("../../utils/index.js");
9
11
  const imageCompress_1 = require("../../utils/imageCompress.js");
10
12
  const ImageBase_1 = tslib_1.__importDefault(require("../ImageBase/ImageBase.js"));
11
13
  const checkWebP = (src) => {
12
14
  return src.endsWith('.webp') ? src : src + '.webp';
13
15
  };
14
- const DeviceSpecificFragment = ({ disableWebp, src, breakpoint, qa, }) => ((0, jsx_runtime_1.jsxs)(React.Fragment, { children: [!disableWebp && ((0, jsx_runtime_1.jsx)("source", { srcSet: checkWebP(src), type: "image/webp", media: `(max-width: ${breakpoint}px)`, "data-qa": `${qa}-compressed` })), (0, jsx_runtime_1.jsx)("source", { srcSet: src, media: `(max-width: ${breakpoint}px)`, "data-qa": qa })] }));
16
+ exports.EMPTY_IMG = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxIiBoZWlnaHQ9IjEiPjwvc3ZnPg==';
17
+ const DeviceSpecificFragment = ({ disableWebp, src, maxBreakpoint, minBreakpoint, qa, }) => {
18
+ const media = [];
19
+ if (maxBreakpoint) {
20
+ media.push(`(max-width: ${maxBreakpoint}px)`);
21
+ }
22
+ if (minBreakpoint) {
23
+ media.push(`(min-width: ${minBreakpoint}px)`);
24
+ }
25
+ const mediaString = media.join(' and ');
26
+ return ((0, jsx_runtime_1.jsxs)(React.Fragment, { children: [!disableWebp && ((0, jsx_runtime_1.jsx)("source", { srcSet: checkWebP(src), type: "image/webp", media: mediaString, "data-qa": `${qa}-compressed` })), (0, jsx_runtime_1.jsx)("source", { srcSet: src, media: mediaString, "data-qa": qa })] }));
27
+ };
15
28
  const Image = (props) => {
16
29
  const projectSettings = React.useContext(projectSettingsContext_1.ProjectSettingsContext);
17
- const { src: imageSrc, alt, disableCompress, tablet, desktop, mobile, style, className, onClick, onLoad, containerClassName, qa, fetchPriority, loading, } = props;
30
+ const { src: imageSrc, alt, disableCompress, tablet, desktop, mobile, style, className, onClick, onLoad, containerClassName, qa, fetchPriority, loading, hide, } = props;
18
31
  const [imgLoadingError, setImgLoadingError] = React.useState(false);
19
32
  const src = imageSrc || desktop;
20
- if (!src) {
21
- return null;
22
- }
23
- const qaAttributes = (0, utils_1.getQaAttrubutes)(qa, 'mobile-webp-source', 'mobile-source', 'tablet-webp-source', 'tablet-source', 'desktop-source-compressed');
24
- const disableWebp = projectSettings.disableCompress ||
33
+ const hideDevices = typeof hide === 'boolean' || !hide
34
+ ? Object.values(models_1.Device).reduce((acc, device) => ({ ...acc, [device]: Boolean(hide) }), {})
35
+ : hide;
36
+ const qaAttributes = (0, utils_1.getQaAttrubutes)(qa, 'mobile-webp-source', 'mobile-source', 'tablet-webp-source', 'tablet-source', 'desktop-source', 'desktop-source-compressed');
37
+ const disableWebp = !src ||
38
+ projectSettings.disableCompress ||
25
39
  disableCompress ||
26
40
  !(0, imageCompress_1.isCompressible)(src) ||
27
41
  imgLoadingError;
28
- return ((0, jsx_runtime_1.jsxs)("picture", { className: containerClassName, "data-qa": qa, children: [mobile && ((0, jsx_runtime_1.jsx)(DeviceSpecificFragment, { src: mobile, disableWebp: disableWebp, breakpoint: constants_1.BREAKPOINTS.sm, qa: qaAttributes.mobileSource })), tablet && ((0, jsx_runtime_1.jsx)(DeviceSpecificFragment, { src: tablet, disableWebp: disableWebp, breakpoint: constants_1.BREAKPOINTS.md, qa: qaAttributes.tabletSource })), src && !disableWebp && ((0, jsx_runtime_1.jsx)("source", { srcSet: checkWebP(src), type: "image/webp", "data-qa": qaAttributes.desktopSourceCompressed })), (0, jsx_runtime_1.jsx)(ImageBase_1.default, { className: className, alt: alt, src: src, style: style, fetchPriority: fetchPriority, loading: loading, onClick: onClick, onError: () => setImgLoadingError(true), onLoad: onLoad })] }));
42
+ return ((0, jsx_runtime_1.jsxs)("picture", { className: containerClassName, "data-qa": qa, children: [(mobile || hideDevices.mobile) && ((0, jsx_runtime_1.jsx)(DeviceSpecificFragment, { src: mobile || exports.EMPTY_IMG, disableWebp: disableWebp || Boolean(hideDevices.mobile), maxBreakpoint: constants_1.BREAKPOINTS.sm, qa: qaAttributes.mobileSource })), (tablet || hideDevices.tablet) && ((0, jsx_runtime_1.jsx)(DeviceSpecificFragment, { src: tablet || exports.EMPTY_IMG, disableWebp: disableWebp || Boolean(hideDevices.tablet), maxBreakpoint: constants_1.BREAKPOINTS.md, minBreakpoint: constants_1.BREAKPOINTS.sm, qa: qaAttributes.tabletSource })), hideDevices.desktop && ((0, jsx_runtime_1.jsx)(DeviceSpecificFragment, { src: exports.EMPTY_IMG, disableWebp: true, minBreakpoint: constants_1.BREAKPOINTS.md, qa: qaAttributes.desktopSource })), src && !disableWebp && ((0, jsx_runtime_1.jsx)("source", { srcSet: checkWebP(src), type: "image/webp", "data-qa": qaAttributes.desktopSourceCompressed })), (0, jsx_runtime_1.jsx)(ImageBase_1.default, { className: className, alt: alt, src: src, style: style, fetchPriority: fetchPriority, loading: loading, onClick: onClick, onError: () => setImgLoadingError(true), onLoad: onLoad })] }));
29
43
  };
30
44
  exports.default = Image;
31
45
  //# sourceMappingURL=Image.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Image.js","sourceRoot":"../../../../src","sources":["components/Image/Image.tsx"],"names":[],"mappings":";;;;AAAA,qDAA+B;AAE/B,kDAA4C;AAC5C,0FAA4E;AAE5E,gDAA4C;AAC5C,gEAAyD;AACzD,kFAA+C;AAgB/C,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,EAAE;IAC9B,OAAO,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,OAAO,CAAC;AACvD,CAAC,CAAC;AAEF,MAAM,sBAAsB,GAAG,CAAC,EAC5B,WAAW,EACX,GAAG,EACH,UAAU,EACV,EAAE,GACwB,EAAE,EAAE,CAAC,CAC/B,wBAAC,KAAK,CAAC,QAAQ,eACV,CAAC,WAAW,IAAI,CACb,mCACI,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,IAAI,EAAC,YAAY,EACjB,KAAK,EAAE,eAAe,UAAU,KAAK,aAC5B,GAAG,EAAE,aAAa,GAC7B,CACL,EACD,mCAAQ,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,eAAe,UAAU,KAAK,aAAW,EAAE,GAAI,IAC9D,CACpB,CAAC;AAEF,MAAM,KAAK,GAAG,CAAC,KAAiB,EAAE,EAAE;IAChC,MAAM,eAAe,GAAG,KAAK,CAAC,UAAU,CAAC,+CAAsB,CAAC,CAAC;IACjE,MAAM,EACF,GAAG,EAAE,QAAQ,EACb,GAAG,EACH,eAAe,EACf,MAAM,EACN,OAAO,EACP,MAAM,EACN,KAAK,EACL,SAAS,EACT,OAAO,EACP,MAAM,EACN,kBAAkB,EAClB,EAAE,EACF,aAAa,EACb,OAAO,GACV,GAA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AAC,kBAAkB,CAAC,IAAI,CAAC,EACvC,MAAM,EAAE,MAAM,GAChB,IACI,CACb,CAAC;AACN,CAAC,CAAC;AAEF,kBAAe,KAAK,CAAC","sourcesContent":["import * as React from 'react';\n\nimport {BREAKPOINTS} from '../../constants';\nimport {ProjectSettingsContext} from '../../context/projectSettingsContext';\nimport {ImageDeviceProps, ImageObjectProps, QAProps} from '../../models';\nimport {getQaAttrubutes} from '../../utils';\nimport {isCompressible} from '../../utils/imageCompress';\nimport ImageBase from '../ImageBase/ImageBase';\n\nexport interface ImageProps extends Partial<ImageObjectProps>, Partial<ImageDeviceProps>, QAProps {\n style?: React.CSSProperties;\n className?: string;\n onClick?: React.MouseEventHandler;\n onLoad?: React.ReactEventHandler<HTMLDivElement>;\n containerClassName?: string;\n}\n\nexport interface DeviceSpecificFragmentProps extends QAProps {\n disableWebp: boolean;\n src: string;\n breakpoint: number;\n}\n\nconst checkWebP = (src: string) => {\n return src.endsWith('.webp') ? src : src + '.webp';\n};\n\nconst DeviceSpecificFragment = ({\n disableWebp,\n src,\n breakpoint,\n qa,\n}: DeviceSpecificFragmentProps) => (\n <React.Fragment>\n {!disableWebp && (\n <source\n srcSet={checkWebP(src)}\n type=\"image/webp\"\n media={`(max-width: ${breakpoint}px)`}\n data-qa={`${qa}-compressed`}\n />\n )}\n <source srcSet={src} media={`(max-width: ${breakpoint}px)`} data-qa={qa} />\n </React.Fragment>\n);\n\nconst Image = (props: ImageProps) => {\n const projectSettings = React.useContext(ProjectSettingsContext);\n const {\n src: imageSrc,\n alt,\n disableCompress,\n tablet,\n desktop,\n mobile,\n style,\n className,\n onClick,\n onLoad,\n containerClassName,\n qa,\n fetchPriority,\n loading,\n } = props;\n const [imgLoadingError, setImgLoadingError] = React.useState(false);\n\n const src = imageSrc || desktop;\n\n if (!src) {\n return null;\n }\n\n const qaAttributes = getQaAttrubutes(\n qa,\n 'mobile-webp-source',\n 'mobile-source',\n 'tablet-webp-source',\n 'tablet-source',\n 'desktop-source-compressed',\n );\n\n const disableWebp =\n projectSettings.disableCompress ||\n disableCompress ||\n !isCompressible(src) ||\n imgLoadingError;\n\n return (\n <picture className={containerClassName} data-qa={qa}>\n {mobile && (\n <DeviceSpecificFragment\n src={mobile}\n disableWebp={disableWebp}\n breakpoint={BREAKPOINTS.sm}\n qa={qaAttributes.mobileSource}\n />\n )}\n {tablet && (\n <DeviceSpecificFragment\n src={tablet}\n disableWebp={disableWebp}\n breakpoint={BREAKPOINTS.md}\n qa={qaAttributes.tabletSource}\n />\n )}\n {src && !disableWebp && (\n <source\n srcSet={checkWebP(src)}\n type=\"image/webp\"\n data-qa={qaAttributes.desktopSourceCompressed}\n />\n )}\n <ImageBase\n className={className}\n alt={alt}\n src={src}\n style={style}\n fetchPriority={fetchPriority}\n loading={loading}\n onClick={onClick}\n onError={() => setImgLoadingError(true)}\n onLoad={onLoad}\n />\n </picture>\n );\n};\n\nexport default Image;\n"]}
1
+ {"version":3,"file":"Image.js","sourceRoot":"../../../../src","sources":["components/Image/Image.tsx"],"names":[],"mappings":";;;;;AAAA,qDAA+B;AAE/B,kDAA4C;AAC5C,0FAA4E;AAC5E,kDAAiF;AACjF,gDAA4C;AAC5C,gEAAyD;AACzD,kFAA+C;AAiB/C,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,EAAE;IAC9B,OAAO,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,OAAO,CAAC;AACvD,CAAC,CAAC;AAEW,QAAA,SAAS,GAClB,wHAAwH,CAAC;AAE7H,MAAM,sBAAsB,GAAG,CAAC,EAC5B,WAAW,EACX,GAAG,EACH,aAAa,EACb,aAAa,EACb,EAAE,GACwB,EAAE,EAAE;IAC9B,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,IAAI,aAAa,EAAE,CAAC;QAChB,KAAK,CAAC,IAAI,CAAC,eAAe,aAAa,KAAK,CAAC,CAAC;IAClD,CAA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AC,uBAAuB,GAC/C,CACL,EACD,uBAAC,mBAAS,IACN,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,EACvC,MAAM,EAAE,MAAM,GAChB,IACI,CACb,CAAC;AACN,CAAC,CAAC;AAEF,kBAAe,KAAK,CAAC","sourcesContent":["import * as React from 'react';\n\nimport {BREAKPOINTS} from '../../constants';\nimport {ProjectSettingsContext} from '../../context/projectSettingsContext';\nimport {Device, ImageDeviceProps, ImageObjectProps, QAProps} from '../../models';\nimport {getQaAttrubutes} from '../../utils';\nimport {isCompressible} from '../../utils/imageCompress';\nimport ImageBase from '../ImageBase/ImageBase';\n\nexport interface ImageProps extends Partial<ImageObjectProps>, Partial<ImageDeviceProps>, QAProps {\n style?: React.CSSProperties;\n className?: string;\n onClick?: React.MouseEventHandler;\n onLoad?: React.ReactEventHandler<HTMLDivElement>;\n containerClassName?: string;\n}\n\nexport interface DeviceSpecificFragmentProps extends QAProps {\n disableWebp: boolean;\n src: string;\n maxBreakpoint?: number;\n minBreakpoint?: number;\n}\n\nconst checkWebP = (src: string) => {\n return src.endsWith('.webp') ? src : src + '.webp';\n};\n\nexport const EMPTY_IMG =\n 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxIiBoZWlnaHQ9IjEiPjwvc3ZnPg==';\n\nconst DeviceSpecificFragment = ({\n disableWebp,\n src,\n maxBreakpoint,\n minBreakpoint,\n qa,\n}: DeviceSpecificFragmentProps) => {\n const media: string[] = [];\n\n if (maxBreakpoint) {\n media.push(`(max-width: ${maxBreakpoint}px)`);\n }\n\n if (minBreakpoint) {\n media.push(`(min-width: ${minBreakpoint}px)`);\n }\n\n const mediaString = media.join(' and ');\n\n return (\n <React.Fragment>\n {!disableWebp && (\n <source\n srcSet={checkWebP(src)}\n type=\"image/webp\"\n media={mediaString}\n data-qa={`${qa}-compressed`}\n />\n )}\n <source srcSet={src} media={mediaString} data-qa={qa} />\n </React.Fragment>\n );\n};\n\nconst Image = (props: ImageProps) => {\n const projectSettings = React.useContext(ProjectSettingsContext);\n const {\n src: imageSrc,\n alt,\n disableCompress,\n tablet,\n desktop,\n mobile,\n style,\n className,\n onClick,\n onLoad,\n containerClassName,\n qa,\n fetchPriority,\n loading,\n hide,\n } = props;\n const [imgLoadingError, setImgLoadingError] = React.useState(false);\n\n const src = imageSrc || desktop;\n\n const hideDevices =\n typeof hide === 'boolean' || !hide\n ? Object.values(Device).reduce(\n (acc, device) => ({...acc, [device]: Boolean(hide)}),\n {} as Record<Device, boolean>,\n )\n : hide;\n\n const qaAttributes = getQaAttrubutes(\n qa,\n 'mobile-webp-source',\n 'mobile-source',\n 'tablet-webp-source',\n 'tablet-source',\n 'desktop-source',\n 'desktop-source-compressed',\n );\n\n const disableWebp =\n !src ||\n projectSettings.disableCompress ||\n disableCompress ||\n !isCompressible(src) ||\n imgLoadingError;\n\n return (\n <picture className={containerClassName} data-qa={qa}>\n {(mobile || hideDevices.mobile) && (\n <DeviceSpecificFragment\n src={mobile || EMPTY_IMG}\n disableWebp={disableWebp || Boolean(hideDevices.mobile)}\n maxBreakpoint={BREAKPOINTS.sm}\n qa={qaAttributes.mobileSource}\n />\n )}\n {(tablet || hideDevices.tablet) && (\n <DeviceSpecificFragment\n src={tablet || EMPTY_IMG}\n disableWebp={disableWebp || Boolean(hideDevices.tablet)}\n maxBreakpoint={BREAKPOINTS.md}\n minBreakpoint={BREAKPOINTS.sm}\n qa={qaAttributes.tabletSource}\n />\n )}\n {hideDevices.desktop && (\n <DeviceSpecificFragment\n src={EMPTY_IMG}\n disableWebp\n minBreakpoint={BREAKPOINTS.md}\n qa={qaAttributes.desktopSource}\n />\n )}\n {src && !disableWebp && (\n <source\n srcSet={checkWebP(src)}\n type=\"image/webp\"\n data-qa={qaAttributes.desktopSourceCompressed}\n />\n )}\n <ImageBase\n className={className}\n alt={alt}\n src={src}\n style={style}\n fetchPriority={fetchPriority}\n loading={loading}\n onClick={onClick}\n onError={() => setImgLoadingError(true)}\n onLoad={onLoad}\n />\n </picture>\n );\n};\n\nexport default Image;\n"]}
@@ -100,7 +100,12 @@ interface LoopProps {
100
100
  start: number;
101
101
  end?: number;
102
102
  }
103
- export interface ImageInfoProps extends Pick<React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, 'aria-describedby' | 'loading'> {
103
+ export declare enum Device {
104
+ Desktop = "desktop",
105
+ Mobile = "mobile",
106
+ Tablet = "tablet"
107
+ }
108
+ export interface ImageInfoProps extends Pick<React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, 'aria-describedby' | 'loading'>, ImageDevicesVisibleProps {
104
109
  alt?: string;
105
110
  fetchPriority?: 'high' | 'low' | 'auto';
106
111
  disableCompress?: boolean;
@@ -109,16 +114,18 @@ export interface ImageObjectProps extends ImageInfoProps {
109
114
  src: string;
110
115
  }
111
116
  export interface ImageDeviceProps extends ImageInfoProps {
112
- desktop: string;
113
- mobile: string;
114
- tablet?: string;
117
+ [Device.Desktop]: string;
118
+ [Device.Mobile]: string;
119
+ [Device.Tablet]?: string;
120
+ }
121
+ export interface ImageDevicesVisibleProps {
122
+ hide?: boolean | Partial<Record<Device, boolean>>;
115
123
  }
116
124
  export type ImageProps = string | ImageObjectProps | ImageDeviceProps;
117
125
  export type ThemedImage = ThemeSupporting<ImageProps>;
118
- export interface BackgroundImageProps extends React.HTMLProps<HTMLDivElement>, Partial<ImageDeviceProps>, Partial<ImageObjectProps>, QAProps {
126
+ export interface BackgroundImageProps extends React.HTMLProps<HTMLDivElement>, Partial<ImageDeviceProps>, Partial<ImageObjectProps>, QAProps, ImageDevicesVisibleProps {
119
127
  style?: React.CSSProperties;
120
128
  imageClassName?: string;
121
- hide?: boolean;
122
129
  }
123
130
  export interface MediaVideoProps extends AnalyticsEventsBase {
124
131
  src: string[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QuoteType = exports.MediaVideoControlsType = exports.MediaVideoType = exports.CustomControlsButtonPositioning = exports.CustomControlsType = exports.PlayButtonThemes = exports.PlayButtonType = exports.PriceLabelColor = exports.PriceDetailsType = exports.AuthorType = void 0;
3
+ exports.Device = exports.QuoteType = exports.MediaVideoControlsType = exports.MediaVideoType = exports.CustomControlsButtonPositioning = exports.CustomControlsType = exports.PlayButtonThemes = exports.PlayButtonType = exports.PriceLabelColor = exports.PriceDetailsType = exports.AuthorType = void 0;
4
4
  // enums
5
5
  var AuthorType;
6
6
  (function (AuthorType) {
@@ -56,4 +56,11 @@ var QuoteType;
56
56
  QuoteType["Chevron"] = "chevron";
57
57
  QuoteType["EnglishDouble"] = "english-double";
58
58
  })(QuoteType || (exports.QuoteType = QuoteType = {}));
59
+ // images
60
+ var Device;
61
+ (function (Device) {
62
+ Device["Desktop"] = "desktop";
63
+ Device["Mobile"] = "mobile";
64
+ Device["Tablet"] = "tablet";
65
+ })(Device || (exports.Device = Device = {}));
59
66
  //# sourceMappingURL=common.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sourceRoot":"../../../../src","sources":["models/constructor-items/common.ts"],"names":[],"mappings":";;;AAOA,QAAQ;AACR,IAAY,UAGX;AAHD,WAAY,UAAU;IAClB,+BAAiB,CAAA;IACjB,2BAAa,CAAA;AACjB,CAAC,EAHW,UAAU,0BAAV,UAAU,QAGrB;AAED,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IACxB,+CAA2B,CAAA;IAC3B,yCAAqB,CAAA;AACzB,CAAC,EAHW,gBAAgB,gCAAhB,gBAAgB,QAG3B;AAED,IAAY,eAMX;AAND,WAAY,eAAe;IACvB,gCAAa,CAAA;IACb,kCAAe,CAAA;IACf,oCAAiB,CAAA;IACjB,oCAAiB,CAAA;IACjB,8BAAW,CAAA;AACf,CAAC,EANW,eAAe,+BAAf,eAAe,QAM1B;AAED,IAAY,cAGX;AAHD,WAAY,cAAc;IACtB,qCAAmB,CAAA;IACnB,+BAAa,CAAA;AACjB,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AAED,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IACxB,iCAAa,CAAA;IACb,iCAAa,CAAA;AACjB,CAAC,EAHW,gBAAgB,gCAAhB,gBAAgB,QAG3B;AAED,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC1B,yDAAmC,CAAA;IACnC,oEAA8C,CAAA;AAClD,CAAC,EAHW,kBAAkB,kCAAlB,kBAAkB,QAG7B;AAED,IAAY,+BAIX;AAJD,WAAY,+BAA+B;IACvC,gDAAa,CAAA;IACb,kDAAe,CAAA;IACf,oDAAiB,CAAA;AACrB,CAAC,EAJW,+BAA+B,+CAA/B,+BAA+B,QAI1C;AAED,IAAY,cAGX;AAHD,WAAY,cAAc;IACtB,qCAAmB,CAAA;IACnB,mCAAiB,CAAA;AACrB,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AAED,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAC9B,6CAAmB,CAAA;IACnB,2CAAiB,CAAA;AACrB,CAAC,EAHW,sBAAsB,sCAAtB,sBAAsB,QAGjC;AAED,IAAY,SAGX;AAHD,WAAY,SAAS;IACjB,gCAAmB,CAAA;IACnB,6CAAgC,CAAA;AACpC,CAAC,EAHW,SAAS,yBAAT,SAAS,QAGpB","sourcesContent":["import * as React from 'react';\n\nimport {ButtonView, ButtonProps as UikitButtonProps} from '@gravity-ui/uikit';\n\nimport {ThemeSupporting} from '../../utils';\nimport {AnalyticsEventsBase, AnalyticsEventsProp, ClassNameProps, QAProps} from '../common';\n\n// enums\nexport enum AuthorType {\n Column = 'column',\n Line = 'line',\n}\n\nexport enum PriceDetailsType {\n MARKED_LIST = 'marked-list',\n SETTINGS = 'settings',\n}\n\nexport enum PriceLabelColor {\n BLUE = 'blue',\n GREEN = 'green',\n YELLOW = 'yellow',\n PURPLE = 'purple',\n RED = 'red',\n}\n\nexport enum PlayButtonType {\n Default = 'default',\n Text = 'text',\n}\n\nexport enum PlayButtonThemes {\n Blue = 'blue',\n Grey = 'grey',\n}\n\nexport enum CustomControlsType {\n WithMuteButton = 'with-mute-button',\n WithPlayPauseButton = 'with-play-pause-button',\n}\n\nexport enum CustomControlsButtonPositioning {\n Left = 'left',\n Right = 'right',\n Center = 'center',\n}\n\nexport enum MediaVideoType {\n Default = 'default',\n Player = 'player',\n}\n\nexport enum MediaVideoControlsType {\n Default = 'default',\n Custom = 'custom',\n}\n\nexport enum QuoteType {\n Chevron = 'chevron', // « »\n EnglishDouble = 'english-double', // “ ”\n}\n\n// types\nexport type TextTheme = 'light' | 'dark';\nexport type TextSize = 'xs' | 's' | 'sm' | 'm' | 'l';\nexport type DividerSize = '0' | 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' | 'xxxl';\nexport type HeaderWidth = 's' | 'm' | 'l';\nexport type HeaderImageSize = 's' | 'm';\nexport type HeaderOffset = 'default' | 'large';\nexport type Justify = 'start' | 'center' | 'end';\nexport type ColumnsCount = 1 | 2 | 3 | 4;\nexport type LegendTableMarkerType = 'disk' | 'tick';\nexport type LinkTheme = 'file-link' | 'normal' | 'back' | 'underline';\nexport type MediaDirection = 'media-content' | 'content-media';\nexport type PriceDescriptionColor = 'cornflower' | 'black';\nexport type ContentSize = 's' | 'm' | 'l';\nexport type ContentTextSize = 's' | 'm' | 'l';\nexport type ContentTheme = 'default' | 'dark' | 'light';\nexport type FileLinkType = 'vertical' | 'horizontal';\nexport type ImageCardMargins = 's' | 'm';\nexport type LayoutItemContentMargin = 'm' | 'l';\n\n// modifiers\nexport interface Themable {\n theme?: TextTheme;\n}\n\nexport interface Justifyable {\n justify?: Justify;\n}\n\nexport interface Stylable {\n className?: string;\n}\n\nexport interface Animatable {\n animated?: boolean;\n}\n\nexport interface Tabbable {\n tabIndex?: number;\n}\n\nexport interface Roleable {\n role?: React.AriaRole;\n}\n\nexport interface AriaProps {\n ariaProps?: React.AriaAttributes;\n}\n\n//common props\nexport interface Background {\n image?: string;\n color?: string;\n}\n\nexport interface AnchorProps {\n text: string;\n url: string;\n}\n\n/**\n * @deprecated Component VideoBlock will be deleted, which uses this logic\n */\ninterface LoopProps {\n start: number;\n end?: number;\n}\n\n// images\n\nexport interface ImageInfoProps\n extends Pick<\n React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>,\n 'aria-describedby' | 'loading'\n > {\n alt?: string;\n fetchPriority?: 'high' | 'low' | 'auto';\n disableCompress?: boolean;\n}\n\nexport interface ImageObjectProps extends ImageInfoProps {\n src: string;\n}\n\nexport interface ImageDeviceProps extends ImageInfoProps {\n desktop: string;\n mobile: string;\n tablet?: string;\n}\n\nexport type ImageProps = string | ImageObjectProps | ImageDeviceProps;\nexport type ThemedImage = ThemeSupporting<ImageProps>;\n\nexport interface BackgroundImageProps\n extends React.HTMLProps<HTMLDivElement>,\n Partial<ImageDeviceProps>,\n Partial<ImageObjectProps>,\n QAProps {\n style?: React.CSSProperties;\n imageClassName?: string;\n hide?: boolean;\n}\n\n//components props\nexport interface MediaVideoProps extends AnalyticsEventsBase {\n src: string[];\n type?: MediaVideoType;\n loop?: LoopProps | boolean;\n muted?: boolean;\n autoplay?: boolean;\n elapsedTime?: number;\n playButton?: PlayButtonProps;\n controls?: MediaVideoControlsType;\n customControlsOptions?: CustomControlsOptions;\n ariaLabel?: string;\n contain?: boolean;\n}\n\n// links\nexport interface LinkProps extends AnalyticsEventsBase, Stylable, Tabbable {\n url: string;\n urlTitle?: string;\n text?: string;\n textSize?: TextSize;\n theme?: LinkTheme;\n colorTheme?: TextTheme;\n arrow?: boolean;\n target?: string;\n extraProps?: React.HTMLProps<HTMLAnchorElement>;\n}\n\nexport interface FileLinkProps extends ClassNameProps, Tabbable {\n href: string;\n text: React.ReactNode;\n type?: FileLinkType;\n textSize?: TextSize;\n theme?: ContentTheme;\n urlTitle?: string;\n onClick?: () => void;\n extraProps?: React.HTMLProps<HTMLAnchorElement>;\n}\n\n// buttons\nexport type ButtonTheme =\n | ButtonView\n | 'github'\n | 'app-store'\n | 'google-play'\n | 'scale'\n | 'monochrome';\n\nexport interface ButtonProps\n extends AnalyticsEventsBase,\n Pick<UikitButtonProps, 'size' | 'width' | 'extraProps'> {\n text: string;\n url: string;\n urlTitle?: string;\n primary?: boolean;\n theme?: ButtonTheme;\n img?: ButtonImageProps | string;\n target?: string;\n}\n\nexport type ButtonImagePosition = 'left' | 'right';\n\nexport interface ButtonImageProps {\n url: string;\n position?: ButtonImagePosition;\n alt?: string;\n}\n\nexport interface CustomControlsOptions {\n type?: CustomControlsType;\n muteButtonShown?: boolean;\n positioning?: CustomControlsButtonPositioning;\n}\n\nexport interface PlayButtonProps extends ClassNameProps {\n type?: PlayButtonType;\n theme?: PlayButtonThemes;\n text?: string;\n}\n\nexport type ThemedMediaVideoProps = ThemeSupporting<MediaVideoProps>;\n\nexport interface MediaComponentVideoProps extends AnalyticsEventsBase {\n video: MediaVideoProps;\n height?: number;\n ratio?: number | 'auto';\n previewImg?: string;\n}\n\nexport interface MediaComponentVideoIframeProps {\n videoIframe: string;\n}\n\nexport interface MediaComponentYoutubeProps {\n youtube: string;\n previewImg?: string;\n fullscreen?: boolean;\n}\n\nexport interface MediaComponentImageProps {\n image: ImageProps | ImageProps[] | ImageDeviceProps;\n video?: MediaVideoProps;\n parallax?: boolean;\n height?: number;\n disableImageSliderForArrayInput?: boolean;\n}\n\nexport interface MediaComponentDataLensProps {\n dataLens: DataLensProps;\n}\n\nexport interface MediaComponentIframeProps {\n iframe: IframeProps;\n margins?: boolean;\n}\n\nexport interface MediaProps\n extends Animatable,\n Partial<MediaComponentDataLensProps>,\n Partial<MediaComponentYoutubeProps>,\n Partial<MediaComponentVideoIframeProps>,\n Partial<MediaComponentImageProps>,\n Partial<MediaComponentIframeProps>,\n Partial<MediaComponentVideoProps> {\n color?: string;\n videoMicrodata?: {\n name?: string;\n description?: string;\n duration?: string;\n uploadDate?: string;\n contentUrl?: string;\n thumbnailUrl?: string;\n };\n}\n\nexport interface BackgroundMediaProps extends MediaProps, Animatable, QAProps {\n fullWidthMedia?: boolean;\n className?: string;\n mediaClassName?: string;\n}\n\nexport type Coordinate = number[];\n\nexport interface MapBaseProps {\n zoom?: number;\n className?: string;\n}\n\nexport interface GMapProps extends MapBaseProps {\n address: string;\n}\n\nexport interface YMapProps extends MapBaseProps {\n markers: YMapMarker[];\n id: string;\n}\n\nexport interface YMapMarker {\n address?: string;\n coordinate?: Coordinate;\n label?: YMapMarkerLabel;\n}\n\nexport interface YMapMarkerLabel {\n iconCaption?: string;\n iconContent?: string;\n iconColor?: string;\n preset?: string;\n}\n\nexport type MapProps = GMapProps | YMapProps;\n\nexport type ThemedMediaProps = ThemeSupporting<MediaProps>;\n\nexport interface DataLensObjectProps {\n id: string;\n theme: 'dark' | 'light';\n}\n\nexport interface IframeProps {\n src: string;\n width?: number;\n height?: number;\n title?: string;\n name?: string;\n}\n\nexport type DataLensProps = string | DataLensObjectProps;\n\nexport interface AuthorItem {\n firstName: string;\n secondName: string;\n description?: string;\n avatar?: ThemeSupporting<ImageProps> | JSX.Element;\n}\n\nexport interface HeaderBreadCrumbsProps extends ClassNameProps {\n items: {\n url: string;\n text: React.ReactNode;\n }[];\n theme?: TextTheme;\n analyticsEvents?: AnalyticsEventsProp;\n}\n\nexport interface TitleItemProps extends Justifyable, TitleItemBaseProps {\n navTitle?: string;\n anchor?: string;\n}\n\nexport interface TitleItemBaseProps {\n text: string;\n textSize?: TextSize;\n url?: string;\n urlTitle?: string;\n custom?: string | React.ReactNode;\n onClick?: () => void;\n}\n\nexport type MediaView = 'fit' | 'full';\n\n// card\nexport type MediaBorder = 'shadow' | 'line' | 'none';\nexport type CardBorder = MediaBorder;\nexport type ControlPosition = 'content' | 'footer';\n\nexport interface CardBaseProps {\n border?: CardBorder;\n}\n\nexport type CardLayoutProps = {\n controlPosition?: ControlPosition;\n};\n\n//price\nexport interface PriceDescriptionProps {\n title: string;\n detailedTitle?: string;\n description: string;\n label?: {\n color: PriceLabelColor;\n text?: string;\n size?: TextSize;\n };\n}\n\nexport interface PriceDetailsSettingsProps {\n title: string;\n description: string;\n}\n\nexport interface PriceDetailsListProps {\n text: string;\n}\n\nexport interface PriceDetailsProps {\n items?: PriceDetailsSettingsProps[] | PriceDetailsListProps[];\n}\n\nexport interface PriceItemProps\n extends PriceDetailsProps,\n PriceDescriptionProps,\n AnalyticsEventsBase {}\n\nexport interface PriceFoldableDetailsProps {\n title: string;\n size?: TextSize;\n titleColor?: PriceDescriptionColor;\n}\n\n/** @deprecated */\nexport interface PriceDetailedProps extends CardBaseProps {\n items: PriceItemProps[];\n description?: {\n titleSize?: TextSize;\n descriptionSize?: TextSize;\n titleColor?: PriceDescriptionColor;\n };\n details?: {\n titleSize?: TextSize;\n descriptionSize?: TextSize;\n };\n priceType?: PriceDetailsType;\n numberGroupItems?: 3 | 4 | 5;\n isCombined?: boolean;\n useMixedView?: boolean;\n foldable?: PriceFoldableDetailsProps;\n labelsDefaultText?: Record<PriceLabelColor, string>;\n}\n\nexport interface AuthorProps extends QAProps {\n author: AuthorItem;\n className?: string;\n authorContainerClassName?: string;\n type?: AuthorType;\n theme?: ContentTheme;\n}\n\nexport interface TitleProps {\n title?: TitleItemProps | string;\n subtitle?: string;\n}\n\nexport interface YandexFormProps extends AnalyticsEventsBase {\n id: number | string;\n containerId?: string;\n theme?: string;\n className?: string;\n headerHeight?: number;\n customFormOrigin?: string;\n customFormSection?: string;\n params?: {[key: string]: string};\n\n onSubmit?: () => void;\n onLoad?: () => void;\n}\n\nexport interface WithBorder {\n border?: MediaBorder;\n /**\n * @deprecated use custom class for media-component\n */\n disableShadow?: boolean;\n}\n"]}
1
+ {"version":3,"file":"common.js","sourceRoot":"../../../../src","sources":["models/constructor-items/common.ts"],"names":[],"mappings":";;;AAOA,QAAQ;AACR,IAAY,UAGX;AAHD,WAAY,UAAU;IAClB,+BAAiB,CAAA;IACjB,2BAAa,CAAA;AACjB,CAAC,EAHW,UAAU,0BAAV,UAAU,QAGrB;AAED,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IACxB,+CAA2B,CAAA;IAC3B,yCAAqB,CAAA;AACzB,CAAC,EAHW,gBAAgB,gCAAhB,gBAAgB,QAG3B;AAED,IAAY,eAMX;AAND,WAAY,eAAe;IACvB,gCAAa,CAAA;IACb,kCAAe,CAAA;IACf,oCAAiB,CAAA;IACjB,oCAAiB,CAAA;IACjB,8BAAW,CAAA;AACf,CAAC,EANW,eAAe,+BAAf,eAAe,QAM1B;AAED,IAAY,cAGX;AAHD,WAAY,cAAc;IACtB,qCAAmB,CAAA;IACnB,+BAAa,CAAA;AACjB,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AAED,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IACxB,iCAAa,CAAA;IACb,iCAAa,CAAA;AACjB,CAAC,EAHW,gBAAgB,gCAAhB,gBAAgB,QAG3B;AAED,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC1B,yDAAmC,CAAA;IACnC,oEAA8C,CAAA;AAClD,CAAC,EAHW,kBAAkB,kCAAlB,kBAAkB,QAG7B;AAED,IAAY,+BAIX;AAJD,WAAY,+BAA+B;IACvC,gDAAa,CAAA;IACb,kDAAe,CAAA;IACf,oDAAiB,CAAA;AACrB,CAAC,EAJW,+BAA+B,+CAA/B,+BAA+B,QAI1C;AAED,IAAY,cAGX;AAHD,WAAY,cAAc;IACtB,qCAAmB,CAAA;IACnB,mCAAiB,CAAA;AACrB,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AAED,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAC9B,6CAAmB,CAAA;IACnB,2CAAiB,CAAA;AACrB,CAAC,EAHW,sBAAsB,sCAAtB,sBAAsB,QAGjC;AAED,IAAY,SAGX;AAHD,WAAY,SAAS;IACjB,gCAAmB,CAAA;IACnB,6CAAgC,CAAA;AACpC,CAAC,EAHW,SAAS,yBAAT,SAAS,QAGpB;AAsED,SAAS;AAET,IAAY,MAIX;AAJD,WAAY,MAAM;IACd,6BAAmB,CAAA;IACnB,2BAAiB,CAAA;IACjB,2BAAiB,CAAA;AACrB,CAAC,EAJW,MAAM,sBAAN,MAAM,QAIjB","sourcesContent":["import * as React from 'react';\n\nimport {ButtonView, ButtonProps as UikitButtonProps} from '@gravity-ui/uikit';\n\nimport {ThemeSupporting} from '../../utils';\nimport {AnalyticsEventsBase, AnalyticsEventsProp, ClassNameProps, QAProps} from '../common';\n\n// enums\nexport enum AuthorType {\n Column = 'column',\n Line = 'line',\n}\n\nexport enum PriceDetailsType {\n MARKED_LIST = 'marked-list',\n SETTINGS = 'settings',\n}\n\nexport enum PriceLabelColor {\n BLUE = 'blue',\n GREEN = 'green',\n YELLOW = 'yellow',\n PURPLE = 'purple',\n RED = 'red',\n}\n\nexport enum PlayButtonType {\n Default = 'default',\n Text = 'text',\n}\n\nexport enum PlayButtonThemes {\n Blue = 'blue',\n Grey = 'grey',\n}\n\nexport enum CustomControlsType {\n WithMuteButton = 'with-mute-button',\n WithPlayPauseButton = 'with-play-pause-button',\n}\n\nexport enum CustomControlsButtonPositioning {\n Left = 'left',\n Right = 'right',\n Center = 'center',\n}\n\nexport enum MediaVideoType {\n Default = 'default',\n Player = 'player',\n}\n\nexport enum MediaVideoControlsType {\n Default = 'default',\n Custom = 'custom',\n}\n\nexport enum QuoteType {\n Chevron = 'chevron', // « »\n EnglishDouble = 'english-double', // “ ”\n}\n\n// types\nexport type TextTheme = 'light' | 'dark';\nexport type TextSize = 'xs' | 's' | 'sm' | 'm' | 'l';\nexport type DividerSize = '0' | 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' | 'xxxl';\nexport type HeaderWidth = 's' | 'm' | 'l';\nexport type HeaderImageSize = 's' | 'm';\nexport type HeaderOffset = 'default' | 'large';\nexport type Justify = 'start' | 'center' | 'end';\nexport type ColumnsCount = 1 | 2 | 3 | 4;\nexport type LegendTableMarkerType = 'disk' | 'tick';\nexport type LinkTheme = 'file-link' | 'normal' | 'back' | 'underline';\nexport type MediaDirection = 'media-content' | 'content-media';\nexport type PriceDescriptionColor = 'cornflower' | 'black';\nexport type ContentSize = 's' | 'm' | 'l';\nexport type ContentTextSize = 's' | 'm' | 'l';\nexport type ContentTheme = 'default' | 'dark' | 'light';\nexport type FileLinkType = 'vertical' | 'horizontal';\nexport type ImageCardMargins = 's' | 'm';\nexport type LayoutItemContentMargin = 'm' | 'l';\n\n// modifiers\nexport interface Themable {\n theme?: TextTheme;\n}\n\nexport interface Justifyable {\n justify?: Justify;\n}\n\nexport interface Stylable {\n className?: string;\n}\n\nexport interface Animatable {\n animated?: boolean;\n}\n\nexport interface Tabbable {\n tabIndex?: number;\n}\n\nexport interface Roleable {\n role?: React.AriaRole;\n}\n\nexport interface AriaProps {\n ariaProps?: React.AriaAttributes;\n}\n\n//common props\nexport interface Background {\n image?: string;\n color?: string;\n}\n\nexport interface AnchorProps {\n text: string;\n url: string;\n}\n\n/**\n * @deprecated Component VideoBlock will be deleted, which uses this logic\n */\ninterface LoopProps {\n start: number;\n end?: number;\n}\n\n// images\n\nexport enum Device {\n Desktop = 'desktop',\n Mobile = 'mobile',\n Tablet = 'tablet',\n}\n\nexport interface ImageInfoProps\n extends Pick<\n React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>,\n 'aria-describedby' | 'loading'\n >,\n ImageDevicesVisibleProps {\n alt?: string;\n fetchPriority?: 'high' | 'low' | 'auto';\n disableCompress?: boolean;\n}\n\nexport interface ImageObjectProps extends ImageInfoProps {\n src: string;\n}\n\nexport interface ImageDeviceProps extends ImageInfoProps {\n [Device.Desktop]: string;\n [Device.Mobile]: string;\n [Device.Tablet]?: string;\n}\n\nexport interface ImageDevicesVisibleProps {\n hide?: boolean | Partial<Record<Device, boolean>>;\n}\n\nexport type ImageProps = string | ImageObjectProps | ImageDeviceProps;\nexport type ThemedImage = ThemeSupporting<ImageProps>;\n\nexport interface BackgroundImageProps\n extends React.HTMLProps<HTMLDivElement>,\n Partial<ImageDeviceProps>,\n Partial<ImageObjectProps>,\n QAProps,\n ImageDevicesVisibleProps {\n style?: React.CSSProperties;\n imageClassName?: string;\n}\n\n//components props\nexport interface MediaVideoProps extends AnalyticsEventsBase {\n src: string[];\n type?: MediaVideoType;\n loop?: LoopProps | boolean;\n muted?: boolean;\n autoplay?: boolean;\n elapsedTime?: number;\n playButton?: PlayButtonProps;\n controls?: MediaVideoControlsType;\n customControlsOptions?: CustomControlsOptions;\n ariaLabel?: string;\n contain?: boolean;\n}\n\n// links\nexport interface LinkProps extends AnalyticsEventsBase, Stylable, Tabbable {\n url: string;\n urlTitle?: string;\n text?: string;\n textSize?: TextSize;\n theme?: LinkTheme;\n colorTheme?: TextTheme;\n arrow?: boolean;\n target?: string;\n extraProps?: React.HTMLProps<HTMLAnchorElement>;\n}\n\nexport interface FileLinkProps extends ClassNameProps, Tabbable {\n href: string;\n text: React.ReactNode;\n type?: FileLinkType;\n textSize?: TextSize;\n theme?: ContentTheme;\n urlTitle?: string;\n onClick?: () => void;\n extraProps?: React.HTMLProps<HTMLAnchorElement>;\n}\n\n// buttons\nexport type ButtonTheme =\n | ButtonView\n | 'github'\n | 'app-store'\n | 'google-play'\n | 'scale'\n | 'monochrome';\n\nexport interface ButtonProps\n extends AnalyticsEventsBase,\n Pick<UikitButtonProps, 'size' | 'width' | 'extraProps'> {\n text: string;\n url: string;\n urlTitle?: string;\n primary?: boolean;\n theme?: ButtonTheme;\n img?: ButtonImageProps | string;\n target?: string;\n}\n\nexport type ButtonImagePosition = 'left' | 'right';\n\nexport interface ButtonImageProps {\n url: string;\n position?: ButtonImagePosition;\n alt?: string;\n}\n\nexport interface CustomControlsOptions {\n type?: CustomControlsType;\n muteButtonShown?: boolean;\n positioning?: CustomControlsButtonPositioning;\n}\n\nexport interface PlayButtonProps extends ClassNameProps {\n type?: PlayButtonType;\n theme?: PlayButtonThemes;\n text?: string;\n}\n\nexport type ThemedMediaVideoProps = ThemeSupporting<MediaVideoProps>;\n\nexport interface MediaComponentVideoProps extends AnalyticsEventsBase {\n video: MediaVideoProps;\n height?: number;\n ratio?: number | 'auto';\n previewImg?: string;\n}\n\nexport interface MediaComponentVideoIframeProps {\n videoIframe: string;\n}\n\nexport interface MediaComponentYoutubeProps {\n youtube: string;\n previewImg?: string;\n fullscreen?: boolean;\n}\n\nexport interface MediaComponentImageProps {\n image: ImageProps | ImageProps[] | ImageDeviceProps;\n video?: MediaVideoProps;\n parallax?: boolean;\n height?: number;\n disableImageSliderForArrayInput?: boolean;\n}\n\nexport interface MediaComponentDataLensProps {\n dataLens: DataLensProps;\n}\n\nexport interface MediaComponentIframeProps {\n iframe: IframeProps;\n margins?: boolean;\n}\n\nexport interface MediaProps\n extends Animatable,\n Partial<MediaComponentDataLensProps>,\n Partial<MediaComponentYoutubeProps>,\n Partial<MediaComponentVideoIframeProps>,\n Partial<MediaComponentImageProps>,\n Partial<MediaComponentIframeProps>,\n Partial<MediaComponentVideoProps> {\n color?: string;\n videoMicrodata?: {\n name?: string;\n description?: string;\n duration?: string;\n uploadDate?: string;\n contentUrl?: string;\n thumbnailUrl?: string;\n };\n}\n\nexport interface BackgroundMediaProps extends MediaProps, Animatable, QAProps {\n fullWidthMedia?: boolean;\n className?: string;\n mediaClassName?: string;\n}\n\nexport type Coordinate = number[];\n\nexport interface MapBaseProps {\n zoom?: number;\n className?: string;\n}\n\nexport interface GMapProps extends MapBaseProps {\n address: string;\n}\n\nexport interface YMapProps extends MapBaseProps {\n markers: YMapMarker[];\n id: string;\n}\n\nexport interface YMapMarker {\n address?: string;\n coordinate?: Coordinate;\n label?: YMapMarkerLabel;\n}\n\nexport interface YMapMarkerLabel {\n iconCaption?: string;\n iconContent?: string;\n iconColor?: string;\n preset?: string;\n}\n\nexport type MapProps = GMapProps | YMapProps;\n\nexport type ThemedMediaProps = ThemeSupporting<MediaProps>;\n\nexport interface DataLensObjectProps {\n id: string;\n theme: 'dark' | 'light';\n}\n\nexport interface IframeProps {\n src: string;\n width?: number;\n height?: number;\n title?: string;\n name?: string;\n}\n\nexport type DataLensProps = string | DataLensObjectProps;\n\nexport interface AuthorItem {\n firstName: string;\n secondName: string;\n description?: string;\n avatar?: ThemeSupporting<ImageProps> | JSX.Element;\n}\n\nexport interface HeaderBreadCrumbsProps extends ClassNameProps {\n items: {\n url: string;\n text: React.ReactNode;\n }[];\n theme?: TextTheme;\n analyticsEvents?: AnalyticsEventsProp;\n}\n\nexport interface TitleItemProps extends Justifyable, TitleItemBaseProps {\n navTitle?: string;\n anchor?: string;\n}\n\nexport interface TitleItemBaseProps {\n text: string;\n textSize?: TextSize;\n url?: string;\n urlTitle?: string;\n custom?: string | React.ReactNode;\n onClick?: () => void;\n}\n\nexport type MediaView = 'fit' | 'full';\n\n// card\nexport type MediaBorder = 'shadow' | 'line' | 'none';\nexport type CardBorder = MediaBorder;\nexport type ControlPosition = 'content' | 'footer';\n\nexport interface CardBaseProps {\n border?: CardBorder;\n}\n\nexport type CardLayoutProps = {\n controlPosition?: ControlPosition;\n};\n\n//price\nexport interface PriceDescriptionProps {\n title: string;\n detailedTitle?: string;\n description: string;\n label?: {\n color: PriceLabelColor;\n text?: string;\n size?: TextSize;\n };\n}\n\nexport interface PriceDetailsSettingsProps {\n title: string;\n description: string;\n}\n\nexport interface PriceDetailsListProps {\n text: string;\n}\n\nexport interface PriceDetailsProps {\n items?: PriceDetailsSettingsProps[] | PriceDetailsListProps[];\n}\n\nexport interface PriceItemProps\n extends PriceDetailsProps,\n PriceDescriptionProps,\n AnalyticsEventsBase {}\n\nexport interface PriceFoldableDetailsProps {\n title: string;\n size?: TextSize;\n titleColor?: PriceDescriptionColor;\n}\n\n/** @deprecated */\nexport interface PriceDetailedProps extends CardBaseProps {\n items: PriceItemProps[];\n description?: {\n titleSize?: TextSize;\n descriptionSize?: TextSize;\n titleColor?: PriceDescriptionColor;\n };\n details?: {\n titleSize?: TextSize;\n descriptionSize?: TextSize;\n };\n priceType?: PriceDetailsType;\n numberGroupItems?: 3 | 4 | 5;\n isCombined?: boolean;\n useMixedView?: boolean;\n foldable?: PriceFoldableDetailsProps;\n labelsDefaultText?: Record<PriceLabelColor, string>;\n}\n\nexport interface AuthorProps extends QAProps {\n author: AuthorItem;\n className?: string;\n authorContainerClassName?: string;\n type?: AuthorType;\n theme?: ContentTheme;\n}\n\nexport interface TitleProps {\n title?: TitleItemProps | string;\n subtitle?: string;\n}\n\nexport interface YandexFormProps extends AnalyticsEventsBase {\n id: number | string;\n containerId?: string;\n theme?: string;\n className?: string;\n headerHeight?: number;\n customFormOrigin?: string;\n customFormSection?: string;\n params?: {[key: string]: string};\n\n onSubmit?: () => void;\n onLoad?: () => void;\n}\n\nexport interface WithBorder {\n border?: MediaBorder;\n /**\n * @deprecated use custom class for media-component\n */\n disableShadow?: boolean;\n}\n"]}
@@ -5,9 +5,9 @@ import './BackgroundImage.css';
5
5
  export const qaIdByDefault = 'background-image';
6
6
  const b = block('storage-background-image');
7
7
  const BackgroundImage = (props) => {
8
- const { children, src, desktop, className, imageClassName, style, hide, qa } = props;
8
+ const { children, src, desktop, className, imageClassName, style, qa } = props;
9
9
  const qaAttributes = getQaAttrubutes(qa || qaIdByDefault);
10
- return (_jsxs("div", { className: b(null, className), style: style, "data-qa": qa || qaIdByDefault, children: [(src || desktop) && !hide && (_jsx(Image, { ...props, className: b('img', imageClassName), qa: qaAttributes.image })), children && _jsx("div", { className: b('container'), children: children })] }));
10
+ return (_jsxs("div", { className: b(null, className), style: style, "data-qa": qa || qaIdByDefault, children: [(src || desktop) && (_jsx(Image, { ...props, className: b('img', imageClassName), qa: qaAttributes.image })), children && _jsx("div", { className: b('container'), children: children })] }));
11
11
  };
12
12
  export default BackgroundImage;
13
13
  //# sourceMappingURL=BackgroundImage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BackgroundImage.js","sourceRoot":"../../../../src","sources":["components/BackgroundImage/BackgroundImage.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAC,KAAK,EAAE,eAAe,EAAC,6BAAoB;AACnD,OAAO,KAAK,0BAAuB;AAEnC,OAAO,uBAAuB,CAAC;AAE/B,MAAM,CAAC,MAAM,aAAa,GAAG,kBAAkB,CAAC;AAEhD,MAAM,CAAC,GAAG,KAAK,CAAC,0BAA0B,CAAC,CAAC;AAE5C,MAAM,eAAe,GAAG,CAAC,KAAoD,EAAE,EAAE;IAC7E,MAAM,EAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAC,GAAG,KAAK,CAAC;IACnF,MAAM,YAAY,GAAG,eAAe,CAAC,EAAE,IAAI,aAAa,CAAC,CAAC;IAE1D,OAAO,CACH,eAAK,SAAS,EAAE,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,aAAW,EAAE,IAAI,aAAa,aACzE,CAAC,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAC1B,KAAC,KAAK,OAAK,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,KAAK,EAAE,cAAc,CAAC,EAAE,EAAE,EAAE,YAAY,CAAC,KAAK,GAAI,CACpF,EACA,QAAQ,IAAI,cAAK,SAAS,EAAE,CAAC,CAAC,WAAW,CAAC,YAAG,QAAQ,GAAO,IAC3D,CACT,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import * as React from 'react';\n\nimport {BackgroundImageProps} from '../../models';\nimport {block, getQaAttrubutes} from '../../utils';\nimport Image from '../Image/Image';\n\nimport './BackgroundImage.scss';\n\nexport const qaIdByDefault = 'background-image';\n\nconst b = block('storage-background-image');\n\nconst BackgroundImage = (props: React.PropsWithChildren<BackgroundImageProps>) => {\n const {children, src, desktop, className, imageClassName, style, hide, qa} = props;\n const qaAttributes = getQaAttrubutes(qa || qaIdByDefault);\n\n return (\n <div className={b(null, className)} style={style} data-qa={qa || qaIdByDefault}>\n {(src || desktop) && !hide && (\n <Image {...props} className={b('img', imageClassName)} qa={qaAttributes.image} />\n )}\n {children && <div className={b('container')}>{children}</div>}\n </div>\n );\n};\n\nexport default BackgroundImage;\n"]}
1
+ {"version":3,"file":"BackgroundImage.js","sourceRoot":"../../../../src","sources":["components/BackgroundImage/BackgroundImage.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAC,KAAK,EAAE,eAAe,EAAC,6BAAoB;AACnD,OAAO,KAAK,0BAAuB;AAEnC,OAAO,uBAAuB,CAAC;AAE/B,MAAM,CAAC,MAAM,aAAa,GAAG,kBAAkB,CAAC;AAEhD,MAAM,CAAC,GAAG,KAAK,CAAC,0BAA0B,CAAC,CAAC;AAE5C,MAAM,eAAe,GAAG,CAAC,KAAoD,EAAE,EAAE;IAC7E,MAAM,EAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,KAAK,EAAE,EAAE,EAAC,GAAG,KAAK,CAAC;IAC7E,MAAM,YAAY,GAAG,eAAe,CAAC,EAAE,IAAI,aAAa,CAAC,CAAC;IAE1D,OAAO,CACH,eAAK,SAAS,EAAE,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,aAAW,EAAE,IAAI,aAAa,aACzE,CAAC,GAAG,IAAI,OAAO,CAAC,IAAI,CACjB,KAAC,KAAK,OAAK,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,KAAK,EAAE,cAAc,CAAC,EAAE,EAAE,EAAE,YAAY,CAAC,KAAK,GAAI,CACpF,EACA,QAAQ,IAAI,cAAK,SAAS,EAAE,CAAC,CAAC,WAAW,CAAC,YAAG,QAAQ,GAAO,IAC3D,CACT,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import * as React from 'react';\n\nimport {BackgroundImageProps} from '../../models';\nimport {block, getQaAttrubutes} from '../../utils';\nimport Image from '../Image/Image';\n\nimport './BackgroundImage.scss';\n\nexport const qaIdByDefault = 'background-image';\n\nconst b = block('storage-background-image');\n\nconst BackgroundImage = (props: React.PropsWithChildren<BackgroundImageProps>) => {\n const {children, src, desktop, className, imageClassName, style, qa} = props;\n const qaAttributes = getQaAttrubutes(qa || qaIdByDefault);\n\n return (\n <div className={b(null, className)} style={style} data-qa={qa || qaIdByDefault}>\n {(src || desktop) && (\n <Image {...props} className={b('img', imageClassName)} qa={qaAttributes.image} />\n )}\n {children && <div className={b('container')}>{children}</div>}\n </div>\n );\n};\n\nexport default BackgroundImage;\n"]}
@@ -10,7 +10,9 @@ export interface ImageProps extends Partial<ImageObjectProps>, Partial<ImageDevi
10
10
  export interface DeviceSpecificFragmentProps extends QAProps {
11
11
  disableWebp: boolean;
12
12
  src: string;
13
- breakpoint: number;
13
+ maxBreakpoint?: number;
14
+ minBreakpoint?: number;
14
15
  }
15
- declare const Image: (props: ImageProps) => import("react/jsx-runtime").JSX.Element | null;
16
+ export declare const EMPTY_IMG = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxIiBoZWlnaHQ9IjEiPjwvc3ZnPg==";
17
+ declare const Image: (props: ImageProps) => import("react/jsx-runtime").JSX.Element;
16
18
  export default Image;
@@ -2,27 +2,40 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import * as React from 'react';
3
3
  import { BREAKPOINTS } from "../../constants.js";
4
4
  import { ProjectSettingsContext } from "../../context/projectSettingsContext/index.js";
5
+ import { Device } from "../../models/index.js";
5
6
  import { getQaAttrubutes } from "../../utils/index.js";
6
7
  import { isCompressible } from "../../utils/imageCompress.js";
7
8
  import ImageBase from "../ImageBase/ImageBase.js";
8
9
  const checkWebP = (src) => {
9
10
  return src.endsWith('.webp') ? src : src + '.webp';
10
11
  };
11
- const DeviceSpecificFragment = ({ disableWebp, src, breakpoint, qa, }) => (_jsxs(React.Fragment, { children: [!disableWebp && (_jsx("source", { srcSet: checkWebP(src), type: "image/webp", media: `(max-width: ${breakpoint}px)`, "data-qa": `${qa}-compressed` })), _jsx("source", { srcSet: src, media: `(max-width: ${breakpoint}px)`, "data-qa": qa })] }));
12
+ export const EMPTY_IMG = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxIiBoZWlnaHQ9IjEiPjwvc3ZnPg==';
13
+ const DeviceSpecificFragment = ({ disableWebp, src, maxBreakpoint, minBreakpoint, qa, }) => {
14
+ const media = [];
15
+ if (maxBreakpoint) {
16
+ media.push(`(max-width: ${maxBreakpoint}px)`);
17
+ }
18
+ if (minBreakpoint) {
19
+ media.push(`(min-width: ${minBreakpoint}px)`);
20
+ }
21
+ const mediaString = media.join(' and ');
22
+ return (_jsxs(React.Fragment, { children: [!disableWebp && (_jsx("source", { srcSet: checkWebP(src), type: "image/webp", media: mediaString, "data-qa": `${qa}-compressed` })), _jsx("source", { srcSet: src, media: mediaString, "data-qa": qa })] }));
23
+ };
12
24
  const Image = (props) => {
13
25
  const projectSettings = React.useContext(ProjectSettingsContext);
14
- const { src: imageSrc, alt, disableCompress, tablet, desktop, mobile, style, className, onClick, onLoad, containerClassName, qa, fetchPriority, loading, } = props;
26
+ const { src: imageSrc, alt, disableCompress, tablet, desktop, mobile, style, className, onClick, onLoad, containerClassName, qa, fetchPriority, loading, hide, } = props;
15
27
  const [imgLoadingError, setImgLoadingError] = React.useState(false);
16
28
  const src = imageSrc || desktop;
17
- if (!src) {
18
- return null;
19
- }
20
- const qaAttributes = getQaAttrubutes(qa, 'mobile-webp-source', 'mobile-source', 'tablet-webp-source', 'tablet-source', 'desktop-source-compressed');
21
- const disableWebp = projectSettings.disableCompress ||
29
+ const hideDevices = typeof hide === 'boolean' || !hide
30
+ ? Object.values(Device).reduce((acc, device) => ({ ...acc, [device]: Boolean(hide) }), {})
31
+ : hide;
32
+ const qaAttributes = getQaAttrubutes(qa, 'mobile-webp-source', 'mobile-source', 'tablet-webp-source', 'tablet-source', 'desktop-source', 'desktop-source-compressed');
33
+ const disableWebp = !src ||
34
+ projectSettings.disableCompress ||
22
35
  disableCompress ||
23
36
  !isCompressible(src) ||
24
37
  imgLoadingError;
25
- return (_jsxs("picture", { className: containerClassName, "data-qa": qa, children: [mobile && (_jsx(DeviceSpecificFragment, { src: mobile, disableWebp: disableWebp, breakpoint: BREAKPOINTS.sm, qa: qaAttributes.mobileSource })), tablet && (_jsx(DeviceSpecificFragment, { src: tablet, disableWebp: disableWebp, breakpoint: BREAKPOINTS.md, qa: qaAttributes.tabletSource })), src && !disableWebp && (_jsx("source", { srcSet: checkWebP(src), type: "image/webp", "data-qa": qaAttributes.desktopSourceCompressed })), _jsx(ImageBase, { className: className, alt: alt, src: src, style: style, fetchPriority: fetchPriority, loading: loading, onClick: onClick, onError: () => setImgLoadingError(true), onLoad: onLoad })] }));
38
+ return (_jsxs("picture", { className: containerClassName, "data-qa": qa, children: [(mobile || hideDevices.mobile) && (_jsx(DeviceSpecificFragment, { src: mobile || EMPTY_IMG, disableWebp: disableWebp || Boolean(hideDevices.mobile), maxBreakpoint: BREAKPOINTS.sm, qa: qaAttributes.mobileSource })), (tablet || hideDevices.tablet) && (_jsx(DeviceSpecificFragment, { src: tablet || EMPTY_IMG, disableWebp: disableWebp || Boolean(hideDevices.tablet), maxBreakpoint: BREAKPOINTS.md, minBreakpoint: BREAKPOINTS.sm, qa: qaAttributes.tabletSource })), hideDevices.desktop && (_jsx(DeviceSpecificFragment, { src: EMPTY_IMG, disableWebp: true, minBreakpoint: BREAKPOINTS.md, qa: qaAttributes.desktopSource })), src && !disableWebp && (_jsx("source", { srcSet: checkWebP(src), type: "image/webp", "data-qa": qaAttributes.desktopSourceCompressed })), _jsx(ImageBase, { className: className, alt: alt, src: src, style: style, fetchPriority: fetchPriority, loading: loading, onClick: onClick, onError: () => setImgLoadingError(true), onLoad: onLoad })] }));
26
39
  };
27
40
  export default Image;
28
41
  //# sourceMappingURL=Image.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Image.js","sourceRoot":"../../../../src","sources":["components/Image/Image.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAC,WAAW,EAAC,2BAAwB;AAC5C,OAAO,EAAC,sBAAsB,EAAC,sDAA6C;AAE5E,OAAO,EAAC,eAAe,EAAC,6BAAoB;AAC5C,OAAO,EAAC,cAAc,EAAC,qCAAkC;AACzD,OAAO,SAAS,kCAA+B;AAgB/C,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,EAAE;IAC9B,OAAO,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,OAAO,CAAC;AACvD,CAAC,CAAC;AAEF,MAAM,sBAAsB,GAAG,CAAC,EAC5B,WAAW,EACX,GAAG,EACH,UAAU,EACV,EAAE,GACwB,EAAE,EAAE,CAAC,CAC/B,MAAC,KAAK,CAAC,QAAQ,eACV,CAAC,WAAW,IAAI,CACb,iBACI,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,IAAI,EAAC,YAAY,EACjB,KAAK,EAAE,eAAe,UAAU,KAAK,aAC5B,GAAG,EAAE,aAAa,GAC7B,CACL,EACD,iBAAQ,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,eAAe,UAAU,KAAK,aAAW,EAAE,GAAI,IAC9D,CACpB,CAAC;AAEF,MAAM,KAAK,GAAG,CAAC,KAAiB,EAAE,EAAE;IAChC,MAAM,eAAe,GAAG,KAAK,CAAC,UAAU,CAAC,sBAAsB,CAAC,CAAC;IACjE,MA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E,GAAG,EACR,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,EACvC,MAAM,EAAE,MAAM,GAChB,IACI,CACb,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,KAAK,CAAC","sourcesContent":["import * as React from 'react';\n\nimport {BREAKPOINTS} from '../../constants';\nimport {ProjectSettingsContext} from '../../context/projectSettingsContext';\nimport {ImageDeviceProps, ImageObjectProps, QAProps} from '../../models';\nimport {getQaAttrubutes} from '../../utils';\nimport {isCompressible} from '../../utils/imageCompress';\nimport ImageBase from '../ImageBase/ImageBase';\n\nexport interface ImageProps extends Partial<ImageObjectProps>, Partial<ImageDeviceProps>, QAProps {\n style?: React.CSSProperties;\n className?: string;\n onClick?: React.MouseEventHandler;\n onLoad?: React.ReactEventHandler<HTMLDivElement>;\n containerClassName?: string;\n}\n\nexport interface DeviceSpecificFragmentProps extends QAProps {\n disableWebp: boolean;\n src: string;\n breakpoint: number;\n}\n\nconst checkWebP = (src: string) => {\n return src.endsWith('.webp') ? src : src + '.webp';\n};\n\nconst DeviceSpecificFragment = ({\n disableWebp,\n src,\n breakpoint,\n qa,\n}: DeviceSpecificFragmentProps) => (\n <React.Fragment>\n {!disableWebp && (\n <source\n srcSet={checkWebP(src)}\n type=\"image/webp\"\n media={`(max-width: ${breakpoint}px)`}\n data-qa={`${qa}-compressed`}\n />\n )}\n <source srcSet={src} media={`(max-width: ${breakpoint}px)`} data-qa={qa} />\n </React.Fragment>\n);\n\nconst Image = (props: ImageProps) => {\n const projectSettings = React.useContext(ProjectSettingsContext);\n const {\n src: imageSrc,\n alt,\n disableCompress,\n tablet,\n desktop,\n mobile,\n style,\n className,\n onClick,\n onLoad,\n containerClassName,\n qa,\n fetchPriority,\n loading,\n } = props;\n const [imgLoadingError, setImgLoadingError] = React.useState(false);\n\n const src = imageSrc || desktop;\n\n if (!src) {\n return null;\n }\n\n const qaAttributes = getQaAttrubutes(\n qa,\n 'mobile-webp-source',\n 'mobile-source',\n 'tablet-webp-source',\n 'tablet-source',\n 'desktop-source-compressed',\n );\n\n const disableWebp =\n projectSettings.disableCompress ||\n disableCompress ||\n !isCompressible(src) ||\n imgLoadingError;\n\n return (\n <picture className={containerClassName} data-qa={qa}>\n {mobile && (\n <DeviceSpecificFragment\n src={mobile}\n disableWebp={disableWebp}\n breakpoint={BREAKPOINTS.sm}\n qa={qaAttributes.mobileSource}\n />\n )}\n {tablet && (\n <DeviceSpecificFragment\n src={tablet}\n disableWebp={disableWebp}\n breakpoint={BREAKPOINTS.md}\n qa={qaAttributes.tabletSource}\n />\n )}\n {src && !disableWebp && (\n <source\n srcSet={checkWebP(src)}\n type=\"image/webp\"\n data-qa={qaAttributes.desktopSourceCompressed}\n />\n )}\n <ImageBase\n className={className}\n alt={alt}\n src={src}\n style={style}\n fetchPriority={fetchPriority}\n loading={loading}\n onClick={onClick}\n onError={() => setImgLoadingError(true)}\n onLoad={onLoad}\n />\n </picture>\n );\n};\n\nexport default Image;\n"]}
1
+ {"version":3,"file":"Image.js","sourceRoot":"../../../../src","sources":["components/Image/Image.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAC,WAAW,EAAC,2BAAwB;AAC5C,OAAO,EAAC,sBAAsB,EAAC,sDAA6C;AAC5E,OAAO,EAAC,MAAM,EAA8C,8BAAqB;AACjF,OAAO,EAAC,eAAe,EAAC,6BAAoB;AAC5C,OAAO,EAAC,cAAc,EAAC,qCAAkC;AACzD,OAAO,SAAS,kCAA+B;AAiB/C,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,EAAE;IAC9B,OAAO,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG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,GAC/B,CACL,EACA,WAAW,CAAC,OAAO,IAAI,CACpB,KAAC,sBAAsB,IACnB,GAAG,EAAE,SAAS,EACd,WAAW,QACX,aAAa,EAAE,WAAW,CAAC,EAAE,EAC7B,EAAE,EAAE,YAAY,CAAC,aAAa,GAChC,CACL,EACA,GAAG,IAAI,CAAC,WAAW,IAAI,CACpB,iBACI,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,IAAI,EAAC,YAAY,aACR,YAAY,CAAC,uBAAuB,GAC/C,CACL,EACD,KAAC,SAAS,IACN,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,EACvC,MAAM,EAAE,MAAM,GAChB,IACI,CACb,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,KAAK,CAAC","sourcesContent":["import * as React from 'react';\n\nimport {BREAKPOINTS} from '../../constants';\nimport {ProjectSettingsContext} from '../../context/projectSettingsContext';\nimport {Device, ImageDeviceProps, ImageObjectProps, QAProps} from '../../models';\nimport {getQaAttrubutes} from '../../utils';\nimport {isCompressible} from '../../utils/imageCompress';\nimport ImageBase from '../ImageBase/ImageBase';\n\nexport interface ImageProps extends Partial<ImageObjectProps>, Partial<ImageDeviceProps>, QAProps {\n style?: React.CSSProperties;\n className?: string;\n onClick?: React.MouseEventHandler;\n onLoad?: React.ReactEventHandler<HTMLDivElement>;\n containerClassName?: string;\n}\n\nexport interface DeviceSpecificFragmentProps extends QAProps {\n disableWebp: boolean;\n src: string;\n maxBreakpoint?: number;\n minBreakpoint?: number;\n}\n\nconst checkWebP = (src: string) => {\n return src.endsWith('.webp') ? src : src + '.webp';\n};\n\nexport const EMPTY_IMG =\n 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxIiBoZWlnaHQ9IjEiPjwvc3ZnPg==';\n\nconst DeviceSpecificFragment = ({\n disableWebp,\n src,\n maxBreakpoint,\n minBreakpoint,\n qa,\n}: DeviceSpecificFragmentProps) => {\n const media: string[] = [];\n\n if (maxBreakpoint) {\n media.push(`(max-width: ${maxBreakpoint}px)`);\n }\n\n if (minBreakpoint) {\n media.push(`(min-width: ${minBreakpoint}px)`);\n }\n\n const mediaString = media.join(' and ');\n\n return (\n <React.Fragment>\n {!disableWebp && (\n <source\n srcSet={checkWebP(src)}\n type=\"image/webp\"\n media={mediaString}\n data-qa={`${qa}-compressed`}\n />\n )}\n <source srcSet={src} media={mediaString} data-qa={qa} />\n </React.Fragment>\n );\n};\n\nconst Image = (props: ImageProps) => {\n const projectSettings = React.useContext(ProjectSettingsContext);\n const {\n src: imageSrc,\n alt,\n disableCompress,\n tablet,\n desktop,\n mobile,\n style,\n className,\n onClick,\n onLoad,\n containerClassName,\n qa,\n fetchPriority,\n loading,\n hide,\n } = props;\n const [imgLoadingError, setImgLoadingError] = React.useState(false);\n\n const src = imageSrc || desktop;\n\n const hideDevices =\n typeof hide === 'boolean' || !hide\n ? Object.values(Device).reduce(\n (acc, device) => ({...acc, [device]: Boolean(hide)}),\n {} as Record<Device, boolean>,\n )\n : hide;\n\n const qaAttributes = getQaAttrubutes(\n qa,\n 'mobile-webp-source',\n 'mobile-source',\n 'tablet-webp-source',\n 'tablet-source',\n 'desktop-source',\n 'desktop-source-compressed',\n );\n\n const disableWebp =\n !src ||\n projectSettings.disableCompress ||\n disableCompress ||\n !isCompressible(src) ||\n imgLoadingError;\n\n return (\n <picture className={containerClassName} data-qa={qa}>\n {(mobile || hideDevices.mobile) && (\n <DeviceSpecificFragment\n src={mobile || EMPTY_IMG}\n disableWebp={disableWebp || Boolean(hideDevices.mobile)}\n maxBreakpoint={BREAKPOINTS.sm}\n qa={qaAttributes.mobileSource}\n />\n )}\n {(tablet || hideDevices.tablet) && (\n <DeviceSpecificFragment\n src={tablet || EMPTY_IMG}\n disableWebp={disableWebp || Boolean(hideDevices.tablet)}\n maxBreakpoint={BREAKPOINTS.md}\n minBreakpoint={BREAKPOINTS.sm}\n qa={qaAttributes.tabletSource}\n />\n )}\n {hideDevices.desktop && (\n <DeviceSpecificFragment\n src={EMPTY_IMG}\n disableWebp\n minBreakpoint={BREAKPOINTS.md}\n qa={qaAttributes.desktopSource}\n />\n )}\n {src && !disableWebp && (\n <source\n srcSet={checkWebP(src)}\n type=\"image/webp\"\n data-qa={qaAttributes.desktopSourceCompressed}\n />\n )}\n <ImageBase\n className={className}\n alt={alt}\n src={src}\n style={style}\n fetchPriority={fetchPriority}\n loading={loading}\n onClick={onClick}\n onError={() => setImgLoadingError(true)}\n onLoad={onLoad}\n />\n </picture>\n );\n};\n\nexport default Image;\n"]}
@@ -100,7 +100,12 @@ interface LoopProps {
100
100
  start: number;
101
101
  end?: number;
102
102
  }
103
- export interface ImageInfoProps extends Pick<React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, 'aria-describedby' | 'loading'> {
103
+ export declare enum Device {
104
+ Desktop = "desktop",
105
+ Mobile = "mobile",
106
+ Tablet = "tablet"
107
+ }
108
+ export interface ImageInfoProps extends Pick<React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, 'aria-describedby' | 'loading'>, ImageDevicesVisibleProps {
104
109
  alt?: string;
105
110
  fetchPriority?: 'high' | 'low' | 'auto';
106
111
  disableCompress?: boolean;
@@ -109,16 +114,18 @@ export interface ImageObjectProps extends ImageInfoProps {
109
114
  src: string;
110
115
  }
111
116
  export interface ImageDeviceProps extends ImageInfoProps {
112
- desktop: string;
113
- mobile: string;
114
- tablet?: string;
117
+ [Device.Desktop]: string;
118
+ [Device.Mobile]: string;
119
+ [Device.Tablet]?: string;
120
+ }
121
+ export interface ImageDevicesVisibleProps {
122
+ hide?: boolean | Partial<Record<Device, boolean>>;
115
123
  }
116
124
  export type ImageProps = string | ImageObjectProps | ImageDeviceProps;
117
125
  export type ThemedImage = ThemeSupporting<ImageProps>;
118
- export interface BackgroundImageProps extends React.HTMLProps<HTMLDivElement>, Partial<ImageDeviceProps>, Partial<ImageObjectProps>, QAProps {
126
+ export interface BackgroundImageProps extends React.HTMLProps<HTMLDivElement>, Partial<ImageDeviceProps>, Partial<ImageObjectProps>, QAProps, ImageDevicesVisibleProps {
119
127
  style?: React.CSSProperties;
120
128
  imageClassName?: string;
121
- hide?: boolean;
122
129
  }
123
130
  export interface MediaVideoProps extends AnalyticsEventsBase {
124
131
  src: string[];
@@ -53,4 +53,11 @@ export var QuoteType;
53
53
  QuoteType["Chevron"] = "chevron";
54
54
  QuoteType["EnglishDouble"] = "english-double";
55
55
  })(QuoteType || (QuoteType = {}));
56
+ // images
57
+ export var Device;
58
+ (function (Device) {
59
+ Device["Desktop"] = "desktop";
60
+ Device["Mobile"] = "mobile";
61
+ Device["Tablet"] = "tablet";
62
+ })(Device || (Device = {}));
56
63
  //# sourceMappingURL=common.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sourceRoot":"../../../../src","sources":["models/constructor-items/common.ts"],"names":[],"mappings":"AAOA,QAAQ;AACR,MAAM,CAAN,IAAY,UAGX;AAHD,WAAY,UAAU;IAClB,+BAAiB,CAAA;IACjB,2BAAa,CAAA;AACjB,CAAC,EAHW,UAAU,KAAV,UAAU,QAGrB;AAED,MAAM,CAAN,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IACxB,+CAA2B,CAAA;IAC3B,yCAAqB,CAAA;AACzB,CAAC,EAHW,gBAAgB,KAAhB,gBAAgB,QAG3B;AAED,MAAM,CAAN,IAAY,eAMX;AAND,WAAY,eAAe;IACvB,gCAAa,CAAA;IACb,kCAAe,CAAA;IACf,oCAAiB,CAAA;IACjB,oCAAiB,CAAA;IACjB,8BAAW,CAAA;AACf,CAAC,EANW,eAAe,KAAf,eAAe,QAM1B;AAED,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACtB,qCAAmB,CAAA;IACnB,+BAAa,CAAA;AACjB,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB;AAED,MAAM,CAAN,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IACxB,iCAAa,CAAA;IACb,iCAAa,CAAA;AACjB,CAAC,EAHW,gBAAgB,KAAhB,gBAAgB,QAG3B;AAED,MAAM,CAAN,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC1B,yDAAmC,CAAA;IACnC,oEAA8C,CAAA;AAClD,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,QAG7B;AAED,MAAM,CAAN,IAAY,+BAIX;AAJD,WAAY,+BAA+B;IACvC,gDAAa,CAAA;IACb,kDAAe,CAAA;IACf,oDAAiB,CAAA;AACrB,CAAC,EAJW,+BAA+B,KAA/B,+BAA+B,QAI1C;AAED,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACtB,qCAAmB,CAAA;IACnB,mCAAiB,CAAA;AACrB,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB;AAED,MAAM,CAAN,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAC9B,6CAAmB,CAAA;IACnB,2CAAiB,CAAA;AACrB,CAAC,EAHW,sBAAsB,KAAtB,sBAAsB,QAGjC;AAED,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACjB,gCAAmB,CAAA;IACnB,6CAAgC,CAAA;AACpC,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB","sourcesContent":["import * as React from 'react';\n\nimport {ButtonView, ButtonProps as UikitButtonProps} from '@gravity-ui/uikit';\n\nimport {ThemeSupporting} from '../../utils';\nimport {AnalyticsEventsBase, AnalyticsEventsProp, ClassNameProps, QAProps} from '../common';\n\n// enums\nexport enum AuthorType {\n Column = 'column',\n Line = 'line',\n}\n\nexport enum PriceDetailsType {\n MARKED_LIST = 'marked-list',\n SETTINGS = 'settings',\n}\n\nexport enum PriceLabelColor {\n BLUE = 'blue',\n GREEN = 'green',\n YELLOW = 'yellow',\n PURPLE = 'purple',\n RED = 'red',\n}\n\nexport enum PlayButtonType {\n Default = 'default',\n Text = 'text',\n}\n\nexport enum PlayButtonThemes {\n Blue = 'blue',\n Grey = 'grey',\n}\n\nexport enum CustomControlsType {\n WithMuteButton = 'with-mute-button',\n WithPlayPauseButton = 'with-play-pause-button',\n}\n\nexport enum CustomControlsButtonPositioning {\n Left = 'left',\n Right = 'right',\n Center = 'center',\n}\n\nexport enum MediaVideoType {\n Default = 'default',\n Player = 'player',\n}\n\nexport enum MediaVideoControlsType {\n Default = 'default',\n Custom = 'custom',\n}\n\nexport enum QuoteType {\n Chevron = 'chevron', // « »\n EnglishDouble = 'english-double', // “ ”\n}\n\n// types\nexport type TextTheme = 'light' | 'dark';\nexport type TextSize = 'xs' | 's' | 'sm' | 'm' | 'l';\nexport type DividerSize = '0' | 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' | 'xxxl';\nexport type HeaderWidth = 's' | 'm' | 'l';\nexport type HeaderImageSize = 's' | 'm';\nexport type HeaderOffset = 'default' | 'large';\nexport type Justify = 'start' | 'center' | 'end';\nexport type ColumnsCount = 1 | 2 | 3 | 4;\nexport type LegendTableMarkerType = 'disk' | 'tick';\nexport type LinkTheme = 'file-link' | 'normal' | 'back' | 'underline';\nexport type MediaDirection = 'media-content' | 'content-media';\nexport type PriceDescriptionColor = 'cornflower' | 'black';\nexport type ContentSize = 's' | 'm' | 'l';\nexport type ContentTextSize = 's' | 'm' | 'l';\nexport type ContentTheme = 'default' | 'dark' | 'light';\nexport type FileLinkType = 'vertical' | 'horizontal';\nexport type ImageCardMargins = 's' | 'm';\nexport type LayoutItemContentMargin = 'm' | 'l';\n\n// modifiers\nexport interface Themable {\n theme?: TextTheme;\n}\n\nexport interface Justifyable {\n justify?: Justify;\n}\n\nexport interface Stylable {\n className?: string;\n}\n\nexport interface Animatable {\n animated?: boolean;\n}\n\nexport interface Tabbable {\n tabIndex?: number;\n}\n\nexport interface Roleable {\n role?: React.AriaRole;\n}\n\nexport interface AriaProps {\n ariaProps?: React.AriaAttributes;\n}\n\n//common props\nexport interface Background {\n image?: string;\n color?: string;\n}\n\nexport interface AnchorProps {\n text: string;\n url: string;\n}\n\n/**\n * @deprecated Component VideoBlock will be deleted, which uses this logic\n */\ninterface LoopProps {\n start: number;\n end?: number;\n}\n\n// images\n\nexport interface ImageInfoProps\n extends Pick<\n React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>,\n 'aria-describedby' | 'loading'\n > {\n alt?: string;\n fetchPriority?: 'high' | 'low' | 'auto';\n disableCompress?: boolean;\n}\n\nexport interface ImageObjectProps extends ImageInfoProps {\n src: string;\n}\n\nexport interface ImageDeviceProps extends ImageInfoProps {\n desktop: string;\n mobile: string;\n tablet?: string;\n}\n\nexport type ImageProps = string | ImageObjectProps | ImageDeviceProps;\nexport type ThemedImage = ThemeSupporting<ImageProps>;\n\nexport interface BackgroundImageProps\n extends React.HTMLProps<HTMLDivElement>,\n Partial<ImageDeviceProps>,\n Partial<ImageObjectProps>,\n QAProps {\n style?: React.CSSProperties;\n imageClassName?: string;\n hide?: boolean;\n}\n\n//components props\nexport interface MediaVideoProps extends AnalyticsEventsBase {\n src: string[];\n type?: MediaVideoType;\n loop?: LoopProps | boolean;\n muted?: boolean;\n autoplay?: boolean;\n elapsedTime?: number;\n playButton?: PlayButtonProps;\n controls?: MediaVideoControlsType;\n customControlsOptions?: CustomControlsOptions;\n ariaLabel?: string;\n contain?: boolean;\n}\n\n// links\nexport interface LinkProps extends AnalyticsEventsBase, Stylable, Tabbable {\n url: string;\n urlTitle?: string;\n text?: string;\n textSize?: TextSize;\n theme?: LinkTheme;\n colorTheme?: TextTheme;\n arrow?: boolean;\n target?: string;\n extraProps?: React.HTMLProps<HTMLAnchorElement>;\n}\n\nexport interface FileLinkProps extends ClassNameProps, Tabbable {\n href: string;\n text: React.ReactNode;\n type?: FileLinkType;\n textSize?: TextSize;\n theme?: ContentTheme;\n urlTitle?: string;\n onClick?: () => void;\n extraProps?: React.HTMLProps<HTMLAnchorElement>;\n}\n\n// buttons\nexport type ButtonTheme =\n | ButtonView\n | 'github'\n | 'app-store'\n | 'google-play'\n | 'scale'\n | 'monochrome';\n\nexport interface ButtonProps\n extends AnalyticsEventsBase,\n Pick<UikitButtonProps, 'size' | 'width' | 'extraProps'> {\n text: string;\n url: string;\n urlTitle?: string;\n primary?: boolean;\n theme?: ButtonTheme;\n img?: ButtonImageProps | string;\n target?: string;\n}\n\nexport type ButtonImagePosition = 'left' | 'right';\n\nexport interface ButtonImageProps {\n url: string;\n position?: ButtonImagePosition;\n alt?: string;\n}\n\nexport interface CustomControlsOptions {\n type?: CustomControlsType;\n muteButtonShown?: boolean;\n positioning?: CustomControlsButtonPositioning;\n}\n\nexport interface PlayButtonProps extends ClassNameProps {\n type?: PlayButtonType;\n theme?: PlayButtonThemes;\n text?: string;\n}\n\nexport type ThemedMediaVideoProps = ThemeSupporting<MediaVideoProps>;\n\nexport interface MediaComponentVideoProps extends AnalyticsEventsBase {\n video: MediaVideoProps;\n height?: number;\n ratio?: number | 'auto';\n previewImg?: string;\n}\n\nexport interface MediaComponentVideoIframeProps {\n videoIframe: string;\n}\n\nexport interface MediaComponentYoutubeProps {\n youtube: string;\n previewImg?: string;\n fullscreen?: boolean;\n}\n\nexport interface MediaComponentImageProps {\n image: ImageProps | ImageProps[] | ImageDeviceProps;\n video?: MediaVideoProps;\n parallax?: boolean;\n height?: number;\n disableImageSliderForArrayInput?: boolean;\n}\n\nexport interface MediaComponentDataLensProps {\n dataLens: DataLensProps;\n}\n\nexport interface MediaComponentIframeProps {\n iframe: IframeProps;\n margins?: boolean;\n}\n\nexport interface MediaProps\n extends Animatable,\n Partial<MediaComponentDataLensProps>,\n Partial<MediaComponentYoutubeProps>,\n Partial<MediaComponentVideoIframeProps>,\n Partial<MediaComponentImageProps>,\n Partial<MediaComponentIframeProps>,\n Partial<MediaComponentVideoProps> {\n color?: string;\n videoMicrodata?: {\n name?: string;\n description?: string;\n duration?: string;\n uploadDate?: string;\n contentUrl?: string;\n thumbnailUrl?: string;\n };\n}\n\nexport interface BackgroundMediaProps extends MediaProps, Animatable, QAProps {\n fullWidthMedia?: boolean;\n className?: string;\n mediaClassName?: string;\n}\n\nexport type Coordinate = number[];\n\nexport interface MapBaseProps {\n zoom?: number;\n className?: string;\n}\n\nexport interface GMapProps extends MapBaseProps {\n address: string;\n}\n\nexport interface YMapProps extends MapBaseProps {\n markers: YMapMarker[];\n id: string;\n}\n\nexport interface YMapMarker {\n address?: string;\n coordinate?: Coordinate;\n label?: YMapMarkerLabel;\n}\n\nexport interface YMapMarkerLabel {\n iconCaption?: string;\n iconContent?: string;\n iconColor?: string;\n preset?: string;\n}\n\nexport type MapProps = GMapProps | YMapProps;\n\nexport type ThemedMediaProps = ThemeSupporting<MediaProps>;\n\nexport interface DataLensObjectProps {\n id: string;\n theme: 'dark' | 'light';\n}\n\nexport interface IframeProps {\n src: string;\n width?: number;\n height?: number;\n title?: string;\n name?: string;\n}\n\nexport type DataLensProps = string | DataLensObjectProps;\n\nexport interface AuthorItem {\n firstName: string;\n secondName: string;\n description?: string;\n avatar?: ThemeSupporting<ImageProps> | JSX.Element;\n}\n\nexport interface HeaderBreadCrumbsProps extends ClassNameProps {\n items: {\n url: string;\n text: React.ReactNode;\n }[];\n theme?: TextTheme;\n analyticsEvents?: AnalyticsEventsProp;\n}\n\nexport interface TitleItemProps extends Justifyable, TitleItemBaseProps {\n navTitle?: string;\n anchor?: string;\n}\n\nexport interface TitleItemBaseProps {\n text: string;\n textSize?: TextSize;\n url?: string;\n urlTitle?: string;\n custom?: string | React.ReactNode;\n onClick?: () => void;\n}\n\nexport type MediaView = 'fit' | 'full';\n\n// card\nexport type MediaBorder = 'shadow' | 'line' | 'none';\nexport type CardBorder = MediaBorder;\nexport type ControlPosition = 'content' | 'footer';\n\nexport interface CardBaseProps {\n border?: CardBorder;\n}\n\nexport type CardLayoutProps = {\n controlPosition?: ControlPosition;\n};\n\n//price\nexport interface PriceDescriptionProps {\n title: string;\n detailedTitle?: string;\n description: string;\n label?: {\n color: PriceLabelColor;\n text?: string;\n size?: TextSize;\n };\n}\n\nexport interface PriceDetailsSettingsProps {\n title: string;\n description: string;\n}\n\nexport interface PriceDetailsListProps {\n text: string;\n}\n\nexport interface PriceDetailsProps {\n items?: PriceDetailsSettingsProps[] | PriceDetailsListProps[];\n}\n\nexport interface PriceItemProps\n extends PriceDetailsProps,\n PriceDescriptionProps,\n AnalyticsEventsBase {}\n\nexport interface PriceFoldableDetailsProps {\n title: string;\n size?: TextSize;\n titleColor?: PriceDescriptionColor;\n}\n\n/** @deprecated */\nexport interface PriceDetailedProps extends CardBaseProps {\n items: PriceItemProps[];\n description?: {\n titleSize?: TextSize;\n descriptionSize?: TextSize;\n titleColor?: PriceDescriptionColor;\n };\n details?: {\n titleSize?: TextSize;\n descriptionSize?: TextSize;\n };\n priceType?: PriceDetailsType;\n numberGroupItems?: 3 | 4 | 5;\n isCombined?: boolean;\n useMixedView?: boolean;\n foldable?: PriceFoldableDetailsProps;\n labelsDefaultText?: Record<PriceLabelColor, string>;\n}\n\nexport interface AuthorProps extends QAProps {\n author: AuthorItem;\n className?: string;\n authorContainerClassName?: string;\n type?: AuthorType;\n theme?: ContentTheme;\n}\n\nexport interface TitleProps {\n title?: TitleItemProps | string;\n subtitle?: string;\n}\n\nexport interface YandexFormProps extends AnalyticsEventsBase {\n id: number | string;\n containerId?: string;\n theme?: string;\n className?: string;\n headerHeight?: number;\n customFormOrigin?: string;\n customFormSection?: string;\n params?: {[key: string]: string};\n\n onSubmit?: () => void;\n onLoad?: () => void;\n}\n\nexport interface WithBorder {\n border?: MediaBorder;\n /**\n * @deprecated use custom class for media-component\n */\n disableShadow?: boolean;\n}\n"]}
1
+ {"version":3,"file":"common.js","sourceRoot":"../../../../src","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HD,WAAY,sBAAsB;IAC9B,6CAAmB,CAAA;IACnB,2CAAiB,CAAA;AACrB,CAAC,EAHW,sBAAsB,KAAtB,sBAAsB,QAGjC;AAED,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACjB,gCAAmB,CAAA;IACnB,6CAAgC,CAAA;AACpC,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB;AAsED,SAAS;AAET,MAAM,CAAN,IAAY,MAIX;AAJD,WAAY,MAAM;IACd,6BAAmB,CAAA;IACnB,2BAAiB,CAAA;IACjB,2BAAiB,CAAA;AACrB,CAAC,EAJW,MAAM,KAAN,MAAM,QAIjB","sourcesContent":["import * as React from 'react';\n\nimport {ButtonView, ButtonProps as UikitButtonProps} from '@gravity-ui/uikit';\n\nimport {ThemeSupporting} from '../../utils';\nimport {AnalyticsEventsBase, AnalyticsEventsProp, ClassNameProps, QAProps} from '../common';\n\n// enums\nexport enum AuthorType {\n Column = 'column',\n Line = 'line',\n}\n\nexport enum PriceDetailsType {\n MARKED_LIST = 'marked-list',\n SETTINGS = 'settings',\n}\n\nexport enum PriceLabelColor {\n BLUE = 'blue',\n GREEN = 'green',\n YELLOW = 'yellow',\n PURPLE = 'purple',\n RED = 'red',\n}\n\nexport enum PlayButtonType {\n Default = 'default',\n Text = 'text',\n}\n\nexport enum PlayButtonThemes {\n Blue = 'blue',\n Grey = 'grey',\n}\n\nexport enum CustomControlsType {\n WithMuteButton = 'with-mute-button',\n WithPlayPauseButton = 'with-play-pause-button',\n}\n\nexport enum CustomControlsButtonPositioning {\n Left = 'left',\n Right = 'right',\n Center = 'center',\n}\n\nexport enum MediaVideoType {\n Default = 'default',\n Player = 'player',\n}\n\nexport enum MediaVideoControlsType {\n Default = 'default',\n Custom = 'custom',\n}\n\nexport enum QuoteType {\n Chevron = 'chevron', // « »\n EnglishDouble = 'english-double', // “ ”\n}\n\n// types\nexport type TextTheme = 'light' | 'dark';\nexport type TextSize = 'xs' | 's' | 'sm' | 'm' | 'l';\nexport type DividerSize = '0' | 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' | 'xxxl';\nexport type HeaderWidth = 's' | 'm' | 'l';\nexport type HeaderImageSize = 's' | 'm';\nexport type HeaderOffset = 'default' | 'large';\nexport type Justify = 'start' | 'center' | 'end';\nexport type ColumnsCount = 1 | 2 | 3 | 4;\nexport type LegendTableMarkerType = 'disk' | 'tick';\nexport type LinkTheme = 'file-link' | 'normal' | 'back' | 'underline';\nexport type MediaDirection = 'media-content' | 'content-media';\nexport type PriceDescriptionColor = 'cornflower' | 'black';\nexport type ContentSize = 's' | 'm' | 'l';\nexport type ContentTextSize = 's' | 'm' | 'l';\nexport type ContentTheme = 'default' | 'dark' | 'light';\nexport type FileLinkType = 'vertical' | 'horizontal';\nexport type ImageCardMargins = 's' | 'm';\nexport type LayoutItemContentMargin = 'm' | 'l';\n\n// modifiers\nexport interface Themable {\n theme?: TextTheme;\n}\n\nexport interface Justifyable {\n justify?: Justify;\n}\n\nexport interface Stylable {\n className?: string;\n}\n\nexport interface Animatable {\n animated?: boolean;\n}\n\nexport interface Tabbable {\n tabIndex?: number;\n}\n\nexport interface Roleable {\n role?: React.AriaRole;\n}\n\nexport interface AriaProps {\n ariaProps?: React.AriaAttributes;\n}\n\n//common props\nexport interface Background {\n image?: string;\n color?: string;\n}\n\nexport interface AnchorProps {\n text: string;\n url: string;\n}\n\n/**\n * @deprecated Component VideoBlock will be deleted, which uses this logic\n */\ninterface LoopProps {\n start: number;\n end?: number;\n}\n\n// images\n\nexport enum Device {\n Desktop = 'desktop',\n Mobile = 'mobile',\n Tablet = 'tablet',\n}\n\nexport interface ImageInfoProps\n extends Pick<\n React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>,\n 'aria-describedby' | 'loading'\n >,\n ImageDevicesVisibleProps {\n alt?: string;\n fetchPriority?: 'high' | 'low' | 'auto';\n disableCompress?: boolean;\n}\n\nexport interface ImageObjectProps extends ImageInfoProps {\n src: string;\n}\n\nexport interface ImageDeviceProps extends ImageInfoProps {\n [Device.Desktop]: string;\n [Device.Mobile]: string;\n [Device.Tablet]?: string;\n}\n\nexport interface ImageDevicesVisibleProps {\n hide?: boolean | Partial<Record<Device, boolean>>;\n}\n\nexport type ImageProps = string | ImageObjectProps | ImageDeviceProps;\nexport type ThemedImage = ThemeSupporting<ImageProps>;\n\nexport interface BackgroundImageProps\n extends React.HTMLProps<HTMLDivElement>,\n Partial<ImageDeviceProps>,\n Partial<ImageObjectProps>,\n QAProps,\n ImageDevicesVisibleProps {\n style?: React.CSSProperties;\n imageClassName?: string;\n}\n\n//components props\nexport interface MediaVideoProps extends AnalyticsEventsBase {\n src: string[];\n type?: MediaVideoType;\n loop?: LoopProps | boolean;\n muted?: boolean;\n autoplay?: boolean;\n elapsedTime?: number;\n playButton?: PlayButtonProps;\n controls?: MediaVideoControlsType;\n customControlsOptions?: CustomControlsOptions;\n ariaLabel?: string;\n contain?: boolean;\n}\n\n// links\nexport interface LinkProps extends AnalyticsEventsBase, Stylable, Tabbable {\n url: string;\n urlTitle?: string;\n text?: string;\n textSize?: TextSize;\n theme?: LinkTheme;\n colorTheme?: TextTheme;\n arrow?: boolean;\n target?: string;\n extraProps?: React.HTMLProps<HTMLAnchorElement>;\n}\n\nexport interface FileLinkProps extends ClassNameProps, Tabbable {\n href: string;\n text: React.ReactNode;\n type?: FileLinkType;\n textSize?: TextSize;\n theme?: ContentTheme;\n urlTitle?: string;\n onClick?: () => void;\n extraProps?: React.HTMLProps<HTMLAnchorElement>;\n}\n\n// buttons\nexport type ButtonTheme =\n | ButtonView\n | 'github'\n | 'app-store'\n | 'google-play'\n | 'scale'\n | 'monochrome';\n\nexport interface ButtonProps\n extends AnalyticsEventsBase,\n Pick<UikitButtonProps, 'size' | 'width' | 'extraProps'> {\n text: string;\n url: string;\n urlTitle?: string;\n primary?: boolean;\n theme?: ButtonTheme;\n img?: ButtonImageProps | string;\n target?: string;\n}\n\nexport type ButtonImagePosition = 'left' | 'right';\n\nexport interface ButtonImageProps {\n url: string;\n position?: ButtonImagePosition;\n alt?: string;\n}\n\nexport interface CustomControlsOptions {\n type?: CustomControlsType;\n muteButtonShown?: boolean;\n positioning?: CustomControlsButtonPositioning;\n}\n\nexport interface PlayButtonProps extends ClassNameProps {\n type?: PlayButtonType;\n theme?: PlayButtonThemes;\n text?: string;\n}\n\nexport type ThemedMediaVideoProps = ThemeSupporting<MediaVideoProps>;\n\nexport interface MediaComponentVideoProps extends AnalyticsEventsBase {\n video: MediaVideoProps;\n height?: number;\n ratio?: number | 'auto';\n previewImg?: string;\n}\n\nexport interface MediaComponentVideoIframeProps {\n videoIframe: string;\n}\n\nexport interface MediaComponentYoutubeProps {\n youtube: string;\n previewImg?: string;\n fullscreen?: boolean;\n}\n\nexport interface MediaComponentImageProps {\n image: ImageProps | ImageProps[] | ImageDeviceProps;\n video?: MediaVideoProps;\n parallax?: boolean;\n height?: number;\n disableImageSliderForArrayInput?: boolean;\n}\n\nexport interface MediaComponentDataLensProps {\n dataLens: DataLensProps;\n}\n\nexport interface MediaComponentIframeProps {\n iframe: IframeProps;\n margins?: boolean;\n}\n\nexport interface MediaProps\n extends Animatable,\n Partial<MediaComponentDataLensProps>,\n Partial<MediaComponentYoutubeProps>,\n Partial<MediaComponentVideoIframeProps>,\n Partial<MediaComponentImageProps>,\n Partial<MediaComponentIframeProps>,\n Partial<MediaComponentVideoProps> {\n color?: string;\n videoMicrodata?: {\n name?: string;\n description?: string;\n duration?: string;\n uploadDate?: string;\n contentUrl?: string;\n thumbnailUrl?: string;\n };\n}\n\nexport interface BackgroundMediaProps extends MediaProps, Animatable, QAProps {\n fullWidthMedia?: boolean;\n className?: string;\n mediaClassName?: string;\n}\n\nexport type Coordinate = number[];\n\nexport interface MapBaseProps {\n zoom?: number;\n className?: string;\n}\n\nexport interface GMapProps extends MapBaseProps {\n address: string;\n}\n\nexport interface YMapProps extends MapBaseProps {\n markers: YMapMarker[];\n id: string;\n}\n\nexport interface YMapMarker {\n address?: string;\n coordinate?: Coordinate;\n label?: YMapMarkerLabel;\n}\n\nexport interface YMapMarkerLabel {\n iconCaption?: string;\n iconContent?: string;\n iconColor?: string;\n preset?: string;\n}\n\nexport type MapProps = GMapProps | YMapProps;\n\nexport type ThemedMediaProps = ThemeSupporting<MediaProps>;\n\nexport interface DataLensObjectProps {\n id: string;\n theme: 'dark' | 'light';\n}\n\nexport interface IframeProps {\n src: string;\n width?: number;\n height?: number;\n title?: string;\n name?: string;\n}\n\nexport type DataLensProps = string | DataLensObjectProps;\n\nexport interface AuthorItem {\n firstName: string;\n secondName: string;\n description?: string;\n avatar?: ThemeSupporting<ImageProps> | JSX.Element;\n}\n\nexport interface HeaderBreadCrumbsProps extends ClassNameProps {\n items: {\n url: string;\n text: React.ReactNode;\n }[];\n theme?: TextTheme;\n analyticsEvents?: AnalyticsEventsProp;\n}\n\nexport interface TitleItemProps extends Justifyable, TitleItemBaseProps {\n navTitle?: string;\n anchor?: string;\n}\n\nexport interface TitleItemBaseProps {\n text: string;\n textSize?: TextSize;\n url?: string;\n urlTitle?: string;\n custom?: string | React.ReactNode;\n onClick?: () => void;\n}\n\nexport type MediaView = 'fit' | 'full';\n\n// card\nexport type MediaBorder = 'shadow' | 'line' | 'none';\nexport type CardBorder = MediaBorder;\nexport type ControlPosition = 'content' | 'footer';\n\nexport interface CardBaseProps {\n border?: CardBorder;\n}\n\nexport type CardLayoutProps = {\n controlPosition?: ControlPosition;\n};\n\n//price\nexport interface PriceDescriptionProps {\n title: string;\n detailedTitle?: string;\n description: string;\n label?: {\n color: PriceLabelColor;\n text?: string;\n size?: TextSize;\n };\n}\n\nexport interface PriceDetailsSettingsProps {\n title: string;\n description: string;\n}\n\nexport interface PriceDetailsListProps {\n text: string;\n}\n\nexport interface PriceDetailsProps {\n items?: PriceDetailsSettingsProps[] | PriceDetailsListProps[];\n}\n\nexport interface PriceItemProps\n extends PriceDetailsProps,\n PriceDescriptionProps,\n AnalyticsEventsBase {}\n\nexport interface PriceFoldableDetailsProps {\n title: string;\n size?: TextSize;\n titleColor?: PriceDescriptionColor;\n}\n\n/** @deprecated */\nexport interface PriceDetailedProps extends CardBaseProps {\n items: PriceItemProps[];\n description?: {\n titleSize?: TextSize;\n descriptionSize?: TextSize;\n titleColor?: PriceDescriptionColor;\n };\n details?: {\n titleSize?: TextSize;\n descriptionSize?: TextSize;\n };\n priceType?: PriceDetailsType;\n numberGroupItems?: 3 | 4 | 5;\n isCombined?: boolean;\n useMixedView?: boolean;\n foldable?: PriceFoldableDetailsProps;\n labelsDefaultText?: Record<PriceLabelColor, string>;\n}\n\nexport interface AuthorProps extends QAProps {\n author: AuthorItem;\n className?: string;\n authorContainerClassName?: string;\n type?: AuthorType;\n theme?: ContentTheme;\n}\n\nexport interface TitleProps {\n title?: TitleItemProps | string;\n subtitle?: string;\n}\n\nexport interface YandexFormProps extends AnalyticsEventsBase {\n id: number | string;\n containerId?: string;\n theme?: string;\n className?: string;\n headerHeight?: number;\n customFormOrigin?: string;\n customFormSection?: string;\n params?: {[key: string]: string};\n\n onSubmit?: () => void;\n onLoad?: () => void;\n}\n\nexport interface WithBorder {\n border?: MediaBorder;\n /**\n * @deprecated use custom class for media-component\n */\n disableShadow?: boolean;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/page-constructor",
3
- "version": "6.8.1",
3
+ "version": "6.8.2-alpha.1",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
@@ -100,7 +100,12 @@ interface LoopProps {
100
100
  start: number;
101
101
  end?: number;
102
102
  }
103
- export interface ImageInfoProps extends Pick<React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, 'aria-describedby' | 'loading'> {
103
+ export declare enum Device {
104
+ Desktop = "desktop",
105
+ Mobile = "mobile",
106
+ Tablet = "tablet"
107
+ }
108
+ export interface ImageInfoProps extends Pick<React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, 'aria-describedby' | 'loading'>, ImageDevicesVisibleProps {
104
109
  alt?: string;
105
110
  fetchPriority?: 'high' | 'low' | 'auto';
106
111
  disableCompress?: boolean;
@@ -109,16 +114,18 @@ export interface ImageObjectProps extends ImageInfoProps {
109
114
  src: string;
110
115
  }
111
116
  export interface ImageDeviceProps extends ImageInfoProps {
112
- desktop: string;
113
- mobile: string;
114
- tablet?: string;
117
+ [Device.Desktop]: string;
118
+ [Device.Mobile]: string;
119
+ [Device.Tablet]?: string;
120
+ }
121
+ export interface ImageDevicesVisibleProps {
122
+ hide?: boolean | Partial<Record<Device, boolean>>;
115
123
  }
116
124
  export type ImageProps = string | ImageObjectProps | ImageDeviceProps;
117
125
  export type ThemedImage = ThemeSupporting<ImageProps>;
118
- export interface BackgroundImageProps extends React.HTMLProps<HTMLDivElement>, Partial<ImageDeviceProps>, Partial<ImageObjectProps>, QAProps {
126
+ export interface BackgroundImageProps extends React.HTMLProps<HTMLDivElement>, Partial<ImageDeviceProps>, Partial<ImageObjectProps>, QAProps, ImageDevicesVisibleProps {
119
127
  style?: React.CSSProperties;
120
128
  imageClassName?: string;
121
- hide?: boolean;
122
129
  }
123
130
  export interface MediaVideoProps extends AnalyticsEventsBase {
124
131
  src: string[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QuoteType = exports.MediaVideoControlsType = exports.MediaVideoType = exports.CustomControlsButtonPositioning = exports.CustomControlsType = exports.PlayButtonThemes = exports.PlayButtonType = exports.PriceLabelColor = exports.PriceDetailsType = exports.AuthorType = void 0;
3
+ exports.Device = exports.QuoteType = exports.MediaVideoControlsType = exports.MediaVideoType = exports.CustomControlsButtonPositioning = exports.CustomControlsType = exports.PlayButtonThemes = exports.PlayButtonType = exports.PriceLabelColor = exports.PriceDetailsType = exports.AuthorType = void 0;
4
4
  // enums
5
5
  var AuthorType;
6
6
  (function (AuthorType) {
@@ -56,3 +56,10 @@ var QuoteType;
56
56
  QuoteType["Chevron"] = "chevron";
57
57
  QuoteType["EnglishDouble"] = "english-double";
58
58
  })(QuoteType || (exports.QuoteType = QuoteType = {}));
59
+ // images
60
+ var Device;
61
+ (function (Device) {
62
+ Device["Desktop"] = "desktop";
63
+ Device["Mobile"] = "mobile";
64
+ Device["Tablet"] = "tablet";
65
+ })(Device || (exports.Device = Device = {}));