@gravity-ui/page-constructor 6.9.1 → 6.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/build/cjs/blocks/CardLayout/schema.d.ts +76 -0
  2. package/build/cjs/blocks/ContentLayout/schema.d.ts +76 -0
  3. package/build/cjs/components/BackgroundImage/BackgroundImage.js +2 -2
  4. package/build/cjs/components/BackgroundImage/BackgroundImage.js.map +1 -1
  5. package/build/cjs/components/Image/Image.d.ts +4 -2
  6. package/build/cjs/components/Image/Image.js +22 -8
  7. package/build/cjs/components/Image/Image.js.map +1 -1
  8. package/build/cjs/components/Image/schema.d.ts +95 -0
  9. package/build/cjs/components/Image/schema.js +15 -0
  10. package/build/cjs/components/Image/schema.js.map +1 -1
  11. package/build/cjs/models/constructor-items/common.d.ts +13 -6
  12. package/build/cjs/models/constructor-items/common.js +8 -1
  13. package/build/cjs/models/constructor-items/common.js.map +1 -1
  14. package/build/cjs/schema/constants.d.ts +19 -0
  15. package/build/cjs/sub-blocks/BackgroundCard/schema.d.ts +19 -0
  16. package/build/esm/blocks/CardLayout/schema.d.ts +76 -0
  17. package/build/esm/blocks/ContentLayout/schema.d.ts +76 -0
  18. package/build/esm/components/BackgroundImage/BackgroundImage.js +2 -2
  19. package/build/esm/components/BackgroundImage/BackgroundImage.js.map +1 -1
  20. package/build/esm/components/Image/Image.d.ts +4 -2
  21. package/build/esm/components/Image/Image.js +21 -8
  22. package/build/esm/components/Image/Image.js.map +1 -1
  23. package/build/esm/components/Image/schema.d.ts +95 -0
  24. package/build/esm/components/Image/schema.js +15 -0
  25. package/build/esm/components/Image/schema.js.map +1 -1
  26. package/build/esm/models/constructor-items/common.d.ts +13 -6
  27. package/build/esm/models/constructor-items/common.js +7 -0
  28. package/build/esm/models/constructor-items/common.js.map +1 -1
  29. package/build/esm/schema/constants.d.ts +19 -0
  30. package/build/esm/sub-blocks/BackgroundCard/schema.d.ts +19 -0
  31. package/package.json +1 -1
  32. package/schema/index.js +1 -1
  33. package/server/models/constructor-items/common.d.ts +13 -6
  34. package/server/models/constructor-items/common.js +8 -1
  35. package/widget/index.js +1 -1
@@ -52,6 +52,25 @@ export declare const CardLayoutProps: {
52
52
  type: string;
53
53
  enum: string[];
54
54
  };
55
+ hide: {
56
+ oneOf: ({
57
+ type: string;
58
+ properties?: undefined;
59
+ } | {
60
+ type: string;
61
+ properties: {
62
+ mobile: {
63
+ type: string;
64
+ };
65
+ tablet: {
66
+ type: string;
67
+ };
68
+ desktop: {
69
+ type: string;
70
+ };
71
+ };
72
+ })[];
73
+ };
55
74
  };
56
75
  optionName: string;
57
76
  type: string;
@@ -89,6 +108,25 @@ export declare const CardLayoutProps: {
89
108
  type: string;
90
109
  enum: string[];
91
110
  };
111
+ hide: {
112
+ oneOf: ({
113
+ type: string;
114
+ properties?: undefined;
115
+ } | {
116
+ type: string;
117
+ properties: {
118
+ mobile: {
119
+ type: string;
120
+ };
121
+ tablet: {
122
+ type: string;
123
+ };
124
+ desktop: {
125
+ type: string;
126
+ };
127
+ };
128
+ })[];
129
+ };
92
130
  };
93
131
  optionName: string;
94
132
  type: string;
@@ -240,6 +278,25 @@ export declare const CardLayoutBlock: {
240
278
  type: string;
241
279
  enum: string[];
242
280
  };
281
+ hide: {
282
+ oneOf: ({
283
+ type: string;
284
+ properties?: undefined;
285
+ } | {
286
+ type: string;
287
+ properties: {
288
+ mobile: {
289
+ type: string;
290
+ };
291
+ tablet: {
292
+ type: string;
293
+ };
294
+ desktop: {
295
+ type: string;
296
+ };
297
+ };
298
+ })[];
299
+ };
243
300
  };
244
301
  optionName: string;
245
302
  type: string;
@@ -277,6 +334,25 @@ export declare const CardLayoutBlock: {
277
334
  type: string;
278
335
  enum: string[];
279
336
  };
337
+ hide: {
338
+ oneOf: ({
339
+ type: string;
340
+ properties?: undefined;
341
+ } | {
342
+ type: string;
343
+ properties: {
344
+ mobile: {
345
+ type: string;
346
+ };
347
+ tablet: {
348
+ type: string;
349
+ };
350
+ desktop: {
351
+ type: string;
352
+ };
353
+ };
354
+ })[];
355
+ };
280
356
  };
281
357
  optionName: string;
282
358
  type: string;
@@ -50,6 +50,25 @@ export declare const ContentLayoutBlock: {
50
50
  type: string;
51
51
  enum: string[];
52
52
  };
53
+ hide: {
54
+ oneOf: ({
55
+ type: string;
56
+ properties?: undefined;
57
+ } | {
58
+ type: string;
59
+ properties: {
60
+ mobile: {
61
+ type: string;
62
+ };
63
+ tablet: {
64
+ type: string;
65
+ };
66
+ desktop: {
67
+ type: string;
68
+ };
69
+ };
70
+ })[];
71
+ };
53
72
  };
54
73
  } | {
55
74
  optionName: string;
@@ -84,6 +103,25 @@ export declare const ContentLayoutBlock: {
84
103
  type: string;
85
104
  enum: string[];
86
105
  };
106
+ hide: {
107
+ oneOf: ({
108
+ type: string;
109
+ properties?: undefined;
110
+ } | {
111
+ type: string;
112
+ properties: {
113
+ mobile: {
114
+ type: string;
115
+ };
116
+ tablet: {
117
+ type: string;
118
+ };
119
+ desktop: {
120
+ type: string;
121
+ };
122
+ };
123
+ })[];
124
+ };
87
125
  };
88
126
  })[];
89
127
  };
@@ -256,6 +294,25 @@ export declare const ContentLayoutBlock: {
256
294
  type: string;
257
295
  enum: string[];
258
296
  };
297
+ hide: {
298
+ oneOf: ({
299
+ type: string;
300
+ properties?: undefined;
301
+ } | {
302
+ type: string;
303
+ properties: {
304
+ mobile: {
305
+ type: string;
306
+ };
307
+ tablet: {
308
+ type: string;
309
+ };
310
+ desktop: {
311
+ type: string;
312
+ };
313
+ };
314
+ })[];
315
+ };
259
316
  };
260
317
  } | {
261
318
  optionName: string;
@@ -290,6 +347,25 @@ export declare const ContentLayoutBlock: {
290
347
  type: string;
291
348
  enum: string[];
292
349
  };
350
+ hide: {
351
+ oneOf: ({
352
+ type: string;
353
+ properties?: undefined;
354
+ } | {
355
+ type: string;
356
+ properties: {
357
+ mobile: {
358
+ type: string;
359
+ };
360
+ tablet: {
361
+ type: string;
362
+ };
363
+ desktop: {
364
+ type: string;
365
+ };
366
+ };
367
+ })[];
368
+ };
293
369
  };
294
370
  })[];
295
371
  };
@@ -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,GAAG,KAAK,CAAC;IACV,MAAM,CAAC,eAAe,EAAE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,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,CAAC;IAED,IAAI,aAAa,EAAE,CAAC;QAChB,KAAK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,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"]}
@@ -31,6 +31,25 @@ export declare const ImageDeviceProps: {
31
31
  type: string;
32
32
  enum: string[];
33
33
  };
34
+ hide: {
35
+ oneOf: ({
36
+ type: string;
37
+ properties?: undefined;
38
+ } | {
39
+ type: string;
40
+ properties: {
41
+ mobile: {
42
+ type: string;
43
+ };
44
+ tablet: {
45
+ type: string;
46
+ };
47
+ desktop: {
48
+ type: string;
49
+ };
50
+ };
51
+ })[];
52
+ };
34
53
  };
35
54
  };
36
55
  export declare const ImageBaseObjectProps: {
@@ -75,6 +94,25 @@ export declare const ImageBaseObjectProps: {
75
94
  type: string;
76
95
  enum: string[];
77
96
  };
97
+ hide: {
98
+ oneOf: ({
99
+ type: string;
100
+ properties?: undefined;
101
+ } | {
102
+ type: string;
103
+ properties: {
104
+ mobile: {
105
+ type: string;
106
+ };
107
+ tablet: {
108
+ type: string;
109
+ };
110
+ desktop: {
111
+ type: string;
112
+ };
113
+ };
114
+ })[];
115
+ };
78
116
  };
79
117
  };
80
118
  export declare const ImageObjectProps: {
@@ -120,6 +158,25 @@ export declare const ImageObjectProps: {
120
158
  type: string;
121
159
  enum: string[];
122
160
  };
161
+ hide: {
162
+ oneOf: ({
163
+ type: string;
164
+ properties?: undefined;
165
+ } | {
166
+ type: string;
167
+ properties: {
168
+ mobile: {
169
+ type: string;
170
+ };
171
+ tablet: {
172
+ type: string;
173
+ };
174
+ desktop: {
175
+ type: string;
176
+ };
177
+ };
178
+ })[];
179
+ };
123
180
  };
124
181
  };
125
182
  export declare const ImageProps: {
@@ -193,6 +250,25 @@ export declare const BackgroundImageProps: {
193
250
  type: string;
194
251
  enum: string[];
195
252
  };
253
+ hide: {
254
+ oneOf: ({
255
+ type: string;
256
+ properties?: undefined;
257
+ } | {
258
+ type: string;
259
+ properties: {
260
+ mobile: {
261
+ type: string;
262
+ };
263
+ tablet: {
264
+ type: string;
265
+ };
266
+ desktop: {
267
+ type: string;
268
+ };
269
+ };
270
+ })[];
271
+ };
196
272
  };
197
273
  } | {
198
274
  optionName: string;
@@ -227,6 +303,25 @@ export declare const BackgroundImageProps: {
227
303
  type: string;
228
304
  enum: string[];
229
305
  };
306
+ hide: {
307
+ oneOf: ({
308
+ type: string;
309
+ properties?: undefined;
310
+ } | {
311
+ type: string;
312
+ properties: {
313
+ mobile: {
314
+ type: string;
315
+ };
316
+ tablet: {
317
+ type: string;
318
+ };
319
+ desktop: {
320
+ type: string;
321
+ };
322
+ };
323
+ })[];
324
+ };
230
325
  };
231
326
  })[];
232
327
  };
@@ -19,6 +19,21 @@ const ImageBase = {
19
19
  type: 'string',
20
20
  enum: ['high', 'low', 'auto'],
21
21
  },
22
+ hide: {
23
+ oneOf: [
24
+ {
25
+ type: 'boolean',
26
+ },
27
+ {
28
+ type: 'object',
29
+ properties: {
30
+ mobile: { type: 'boolean' },
31
+ tablet: { type: 'boolean' },
32
+ desktop: { type: 'boolean' },
33
+ },
34
+ },
35
+ ],
36
+ },
22
37
  };
23
38
  const StyleBase = {
24
39
  type: 'object',
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"../../../../src","sources":["components/Image/schema.ts"],"names":[],"mappings":";;;AAAA,4DAA2D;AAE9C,QAAA,eAAe,GACxB,kGAAkG,CAAC;AAEvG,MAAM,SAAS,GAAG;IACd,GAAG,EAAE;QACD,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,MAAM;KACtB;IACD,eAAe,EAAE;QACb,IAAI,EAAE,SAAS;KAClB;IACD,OAAO,EAAE;QACL,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC;KAC1B;IACD,aAAa,EAAE;QACX,I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G;IACtB,KAAK,EAAE;QACH;YACI,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,uBAAe;YACxB,UAAU,EAAE,KAAK;SACpB;QACD,IAAA,oBAAY,EAAC;YACT,GAAG,wBAAgB;YACnB,UAAU,EAAE,SAAS;SACxB,CAAC;QACF,IAAA,oBAAY,EAAC;YACT,GAAG,wBAAgB;YACnB,UAAU,EAAE,gBAAgB;SAC/B,CAAC;QACF;YACI,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,IAAA,oBAAY,EAAC;gBAChB,GAAG,wBAAgB;aACtB,CAAC;YACF,UAAU,EAAE,cAAc;SAC7B;QACD;YACI,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,IAAA,oBAAY,EAAC;gBAChB,GAAG,wBAAgB;aACtB,CAAC;YACF,UAAU,EAAE,qBAAqB;SACpC;KACJ;CACJ,CAAC;AAEW,QAAA,oBAAoB,GAAG;IAChC,KAAK,EAAE;QACH;YACI,GAAG,4BAAoB;YACvB,UAAU,EAAE,SAAS;SACxB;QACD;YACI,GAAG,wBAAgB;YACnB,UAAU,EAAE,gBAAgB;SAC/B;KACJ;CACJ,CAAC","sourcesContent":["import {filteredItem} from '../../schema/validators/utils';\n\nexport const imageUrlPattern =\n '^((http[s]?|ftp):\\\\/)?\\\\/?([^:\\\\/\\\\s]+)((\\\\/\\\\w+)*\\\\/)([\\\\w\\\\-\\\\.]+[^#?\\\\s]+)(.*)?(#[\\\\w\\\\-]+)?$';\n\nconst ImageBase = {\n alt: {\n type: 'string',\n contentType: 'text',\n },\n disableCompress: {\n type: 'boolean',\n },\n loading: {\n type: 'string',\n enum: ['eager', 'lazy'],\n },\n fetchPriority: {\n type: 'string',\n enum: ['high', 'low', 'auto'],\n },\n};\n\nconst StyleBase = {\n type: 'object',\n additionalProperties: false,\n required: [],\n properties: {\n backgroundColor: {type: 'string'},\n height: {type: ['string', 'number']},\n width: {type: ['string', 'number']},\n color: {type: 'string'},\n },\n};\n\nexport const ImageDeviceProps = {\n type: 'object',\n additionalProperties: false,\n required: ['desktop', 'mobile'],\n properties: {\n ...ImageBase,\n desktop: {type: 'string', pattern: imageUrlPattern},\n tablet: {\n type: 'string',\n pattern: imageUrlPattern,\n },\n mobile: {\n type: 'string',\n pattern: imageUrlPattern,\n },\n },\n};\n\nexport const ImageBaseObjectProps = {\n type: 'object',\n additionalProperties: false,\n properties: {\n ...ImageBase,\n src: {\n type: 'string',\n pattern: imageUrlPattern,\n },\n style: StyleBase,\n },\n};\n\nexport const ImageObjectProps = {\n ...ImageBaseObjectProps,\n required: ['src'],\n};\n\nexport const ImageProps = {\n oneOf: [\n {\n type: 'string',\n pattern: imageUrlPattern,\n optionName: 'url',\n },\n filteredItem({\n ...ImageObjectProps,\n optionName: 'options',\n }),\n filteredItem({\n ...ImageDeviceProps,\n optionName: 'device options',\n }),\n {\n type: 'array',\n items: filteredItem({\n ...ImageObjectProps,\n }),\n optionName: 'options list',\n },\n {\n type: 'array',\n items: filteredItem({\n ...ImageDeviceProps,\n }),\n optionName: 'device options list',\n },\n ],\n};\n\nexport const BackgroundImageProps = {\n anyOf: [\n {\n ...ImageBaseObjectProps,\n optionName: 'options',\n },\n {\n ...ImageDeviceProps,\n optionName: 'device options',\n },\n ],\n};\n"]}
1
+ {"version":3,"file":"schema.js","sourceRoot":"../../../../src","sources":["components/Image/schema.ts"],"names":[],"mappings":";;;AAAA,4DAA2D;AAE9C,QAAA,eAAe,GACxB,kGAAkG,CAAC;AAEvG,MAAM,SAAS,GAAG;IACd,GAAG,EAAE;QACD,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,MAAM;KACtB;IACD,eAAe,EAAE;QACb,IAAI,EAAE,SAAS;KAClB;IACD,OAAO,EAAE;QACL,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC;KAC1B;IACD,aAAa,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,MA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,EAAE;YACD,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,uBAAe;SAC3B;QACD,KAAK,EAAE,SAAS;KACnB;CACJ,CAAC;AAEW,QAAA,gBAAgB,GAAG;IAC5B,GAAG,4BAAoB;IACvB,QAAQ,EAAE,CAAC,KAAK,CAAC;CACpB,CAAC;AAEW,QAAA,UAAU,GAAG;IACtB,KAAK,EAAE;QACH;YACI,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,uBAAe;YACxB,UAAU,EAAE,KAAK;SACpB;QACD,IAAA,oBAAY,EAAC;YACT,GAAG,wBAAgB;YACnB,UAAU,EAAE,SAAS;SACxB,CAAC;QACF,IAAA,oBAAY,EAAC;YACT,GAAG,wBAAgB;YACnB,UAAU,EAAE,gBAAgB;SAC/B,CAAC;QACF;YACI,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,IAAA,oBAAY,EAAC;gBAChB,GAAG,wBAAgB;aACtB,CAAC;YACF,UAAU,EAAE,cAAc;SAC7B;QACD;YACI,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,IAAA,oBAAY,EAAC;gBAChB,GAAG,wBAAgB;aACtB,CAAC;YACF,UAAU,EAAE,qBAAqB;SACpC;KACJ;CACJ,CAAC;AAEW,QAAA,oBAAoB,GAAG;IAChC,KAAK,EAAE;QACH;YACI,GAAG,4BAAoB;YACvB,UAAU,EAAE,SAAS;SACxB;QACD;YACI,GAAG,wBAAgB;YACnB,UAAU,EAAE,gBAAgB;SAC/B;KACJ;CACJ,CAAC","sourcesContent":["import {filteredItem} from '../../schema/validators/utils';\n\nexport const imageUrlPattern =\n '^((http[s]?|ftp):\\\\/)?\\\\/?([^:\\\\/\\\\s]+)((\\\\/\\\\w+)*\\\\/)([\\\\w\\\\-\\\\.]+[^#?\\\\s]+)(.*)?(#[\\\\w\\\\-]+)?$';\n\nconst ImageBase = {\n alt: {\n type: 'string',\n contentType: 'text',\n },\n disableCompress: {\n type: 'boolean',\n },\n loading: {\n type: 'string',\n enum: ['eager', 'lazy'],\n },\n fetchPriority: {\n type: 'string',\n enum: ['high', 'low', 'auto'],\n },\n hide: {\n oneOf: [\n {\n type: 'boolean',\n },\n {\n type: 'object',\n properties: {\n mobile: {type: 'boolean'},\n tablet: {type: 'boolean'},\n desktop: {type: 'boolean'},\n },\n },\n ],\n },\n};\n\nconst StyleBase = {\n type: 'object',\n additionalProperties: false,\n required: [],\n properties: {\n backgroundColor: {type: 'string'},\n height: {type: ['string', 'number']},\n width: {type: ['string', 'number']},\n color: {type: 'string'},\n },\n};\n\nexport const ImageDeviceProps = {\n type: 'object',\n additionalProperties: false,\n required: ['desktop', 'mobile'],\n properties: {\n ...ImageBase,\n desktop: {type: 'string', pattern: imageUrlPattern},\n tablet: {\n type: 'string',\n pattern: imageUrlPattern,\n },\n mobile: {\n type: 'string',\n pattern: imageUrlPattern,\n },\n },\n};\n\nexport const ImageBaseObjectProps = {\n type: 'object',\n additionalProperties: false,\n properties: {\n ...ImageBase,\n src: {\n type: 'string',\n pattern: imageUrlPattern,\n },\n style: StyleBase,\n },\n};\n\nexport const ImageObjectProps = {\n ...ImageBaseObjectProps,\n required: ['src'],\n};\n\nexport const ImageProps = {\n oneOf: [\n {\n type: 'string',\n pattern: imageUrlPattern,\n optionName: 'url',\n },\n filteredItem({\n ...ImageObjectProps,\n optionName: 'options',\n }),\n filteredItem({\n ...ImageDeviceProps,\n optionName: 'device options',\n }),\n {\n type: 'array',\n items: filteredItem({\n ...ImageObjectProps,\n }),\n optionName: 'options list',\n },\n {\n type: 'array',\n items: filteredItem({\n ...ImageDeviceProps,\n }),\n optionName: 'device options list',\n },\n ],\n};\n\nexport const BackgroundImageProps = {\n anyOf: [\n {\n ...ImageBaseObjectProps,\n optionName: 'options',\n },\n {\n ...ImageDeviceProps,\n optionName: 'device options',\n },\n ],\n};\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