@gravity-ui/page-constructor 6.8.2-alpha.0 → 6.9.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.
package/README.md CHANGED
@@ -14,24 +14,112 @@ For the format of input data and list of available blocks, see the [documentatio
14
14
  npm install @gravity-ui/page-constructor
15
15
  ```
16
16
 
17
- ## Required dependencies
17
+ ## Quick start
18
18
 
19
- Please note that to start using the package, your project must also have the following installed: `@diplodoc/transform`, `@gravity-ui/uikit`, `react`. Check out the `peerDependencies` section of `package.json` for accurate information.
19
+ First, we need a React project and some kind of server. For example, you can create a React project using Vite and an Express server, or you can create Next.js application - it will have a client and server side at once.
20
20
 
21
- ### Getting started
21
+ Install the required dependencies:
22
22
 
23
- The page constructor is imported as a React component. To make sure it runs properly, wrap it in `PageConstructorProvider`:
23
+ ```shell
24
+ npm install @gravity-ui/page-constructor @diplodoc/transform @gravity-ui/uikit
25
+ ```
24
26
 
25
- ```jsx
27
+ Insert the `Page Constructor` to the page. To work correctly, it must be wrapped in a `PageConstructorProvider`:
28
+
29
+ ```tsx
26
30
  import {PageConstructor, PageConstructorProvider} from '@gravity-ui/page-constructor';
31
+ import '@gravity-ui/page-constructor/styles/styles.scss';
32
+
33
+ const App = () => {
34
+ const content = {
35
+ blocks: [
36
+ {
37
+ type: 'header-block',
38
+ title: 'Hello world',
39
+ background: {color: '#f0f0f0'},
40
+ description:
41
+ '**Congratulations!** Have you built a [page-constructor](https://github.com/gravity-ui/page-constructor) into your website',
42
+ },
43
+ ],
44
+ };
45
+
46
+ return (
47
+ <PageConstructorProvider>
48
+ <PageConstructor content={content} />
49
+ </PageConstructorProvider>
50
+ );
51
+ };
27
52
 
28
- const Page: React.PropsWithChildren<PageProps> = ({content}) => (
29
- <PageConstructorProvider>
30
- <PageConstructor content={content} />
31
- </PageConstructorProvider>
32
- );
53
+ export default App;
54
+ ```
55
+
56
+ This was the simplest example of a connection. In order for YFM markup to work, you need to process content on the server and receive it on the client.
57
+
58
+ If your server is a separate application, then you need to install page-constructor:
59
+
60
+ ```shell
61
+ npm install @gravity-ui/page-constructor
62
+ ```
63
+
64
+ To process YFM in all base blocks, call the `contentTransformer` and pass the content and options there:
65
+
66
+ ```ts
67
+ const express = require('express');
68
+ const app = express();
69
+ const {contentTransformer} = require('@gravity-ui/page-constructor/server');
70
+
71
+ const content = {
72
+ blocks: [
73
+ {
74
+ type: 'header-block',
75
+ title: 'Hello world',
76
+ background: {color: '#f0f0f0'},
77
+ description:
78
+ '**Congratulations!** Have you built a [page-constructor](https://github.com/gravity-ui/page-constructor) into your website',
79
+ },
80
+ ],
81
+ };
82
+
83
+ app.get('/content', (req, res) => {
84
+ res.send({content: contentTransformer({content, options: {lang: 'en'}})});
85
+ });
86
+
87
+ app.listen(3000);
88
+ ```
89
+
90
+ On the client, add an endpoint call to receive content:
91
+
92
+ ```tsx
93
+ import {PageConstructor, PageConstructorProvider} from '@gravity-ui/page-constructor';
94
+ import '@gravity-ui/page-constructor/styles/styles.scss';
95
+ import {useEffect, useState} from 'react';
96
+
97
+ const App = () => {
98
+ const [content, setContent] = useState();
99
+
100
+ useEffect(() => {
101
+ (async () => {
102
+ const response = await fetch('http://localhost:3000/content').then((r) => r.json());
103
+ setContent(response.content);
104
+ })();
105
+ }, []);
106
+
107
+ return (
108
+ <PageConstructorProvider>
109
+ <PageConstructor content={content} />
110
+ </PageConstructorProvider>
111
+ );
112
+ };
113
+
114
+ export default App;
33
115
  ```
34
116
 
117
+ ### Ready-made template
118
+
119
+ To start a new project, you can use the [ready-made template on Next.js ](https://github.com/gravity-ui/page-constructor-website-template) which we have prepared.
120
+
121
+ ## Documentation
122
+
35
123
  ### Parameters
36
124
 
37
125
  ```typescript
@@ -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, qa } = props;
11
+ const { children, src, desktop, className, imageClassName, style, hide, 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) && ((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) && !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 })] }));
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,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"]}
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"]}
@@ -10,9 +10,7 @@ export interface ImageProps extends Partial<ImageObjectProps>, Partial<ImageDevi
10
10
  export interface DeviceSpecificFragmentProps extends QAProps {
11
11
  disableWebp: boolean;
12
12
  src: string;
13
- maxBreakpoint?: number;
14
- minBreakpoint?: number;
13
+ breakpoint: number;
15
14
  }
16
- export declare const EMPTY_IMG = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxIiBoZWlnaHQ9IjEiPjwvc3ZnPg==";
17
- declare const Image: (props: ImageProps) => import("react/jsx-runtime").JSX.Element;
15
+ declare const Image: (props: ImageProps) => import("react/jsx-runtime").JSX.Element | null;
18
16
  export default Image;
@@ -1,45 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EMPTY_IMG = void 0;
4
3
  const tslib_1 = require("tslib");
5
4
  const jsx_runtime_1 = require("react/jsx-runtime");
6
5
  const React = tslib_1.__importStar(require("react"));
7
6
  const constants_1 = require("../../constants.js");
8
7
  const projectSettingsContext_1 = require("../../context/projectSettingsContext/index.js");
9
- const models_1 = require("../../models/index.js");
10
8
  const utils_1 = require("../../utils/index.js");
11
9
  const imageCompress_1 = require("../../utils/imageCompress.js");
12
10
  const ImageBase_1 = tslib_1.__importDefault(require("../ImageBase/ImageBase.js"));
13
11
  const checkWebP = (src) => {
14
12
  return src.endsWith('.webp') ? src : src + '.webp';
15
13
  };
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
- };
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 })] }));
28
15
  const Image = (props) => {
29
16
  const projectSettings = React.useContext(projectSettingsContext_1.ProjectSettingsContext);
30
- const { src: imageSrc, alt, disableCompress, tablet, desktop, mobile, style, className, onClick, onLoad, containerClassName, qa, fetchPriority, loading, hide, } = props;
17
+ const { src: imageSrc, alt, disableCompress, tablet, desktop, mobile, style, className, onClick, onLoad, containerClassName, qa, fetchPriority, loading, } = props;
31
18
  const [imgLoadingError, setImgLoadingError] = React.useState(false);
32
19
  const src = imageSrc || desktop;
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 ||
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 ||
39
25
  disableCompress ||
40
26
  !(0, imageCompress_1.isCompressible)(src) ||
41
27
  imgLoadingError;
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, maxBreakpoint: constants_1.BREAKPOINTS.sm, qa: qaAttributes.mobileSource })), (tablet || hideDevices.tablet) && ((0, jsx_runtime_1.jsx)(DeviceSpecificFragment, { src: tablet || exports.EMPTY_IMG, disableWebp: disableWebp, 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: disableWebp, 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 })] }));
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 })] }));
43
29
  };
44
30
  exports.default = Image;
45
31
  //# 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;AAC5E,kDAAiF;AACjF,gDAA4C;AAC5C,gEAAyD;AAC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uBAAW,CAAC,EAAE,EAC7B,aAAa,EAAE,uBAAW,CAAC,EAAE,EAC7B,EAAE,EAAE,YAAY,CAAC,YAAY,GAC/B,CACL,EACA,WAAW,CAAC,OAAO,IAAI,CACpB,uBAAC,sBAAsB,IACnB,GAAG,EAAE,iBAAS,EACd,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,uBAAW,CAAC,EAAE,EAC7B,EAAE,EAAE,YAAY,CAAC,aAAa,GAChC,CACL,EACA,GAAG,IAAI,CAAC,WAAW,IAAI,CACpB,mCACI,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,IAAI,EAAC,YAAY,aACR,YAAY,CAAC,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}\n maxBreakpoint={BREAKPOINTS.sm}\n qa={qaAttributes.mobileSource}\n />\n )}\n {(tablet || hideDevices.tablet) && (\n <DeviceSpecificFragment\n src={tablet || EMPTY_IMG}\n disableWebp={disableWebp}\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={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"]}
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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AE,MAAM,EACX,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,uBAAW,CAAC,EAAE,EAC1B,EAAE,EAAE,YAAY,CAAC,YAAY,GAC/B,CACL,EACA,GAAG,IAAI,CAAC,WAAW,IAAI,CACpB,mCACI,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,IAAI,EAAC,YAAY,aACR,YAAY,CAAC,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 {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"]}
@@ -100,12 +100,7 @@ interface LoopProps {
100
100
  start: number;
101
101
  end?: number;
102
102
  }
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 {
103
+ export interface ImageInfoProps extends Pick<React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, 'aria-describedby' | 'loading'> {
109
104
  alt?: string;
110
105
  fetchPriority?: 'high' | 'low' | 'auto';
111
106
  disableCompress?: boolean;
@@ -114,18 +109,16 @@ export interface ImageObjectProps extends ImageInfoProps {
114
109
  src: string;
115
110
  }
116
111
  export interface ImageDeviceProps extends ImageInfoProps {
117
- [Device.Desktop]: string;
118
- [Device.Mobile]: string;
119
- [Device.Tablet]?: string;
120
- }
121
- export interface ImageDevicesVisibleProps {
122
- hide?: boolean | Partial<Record<Device, boolean>>;
112
+ desktop: string;
113
+ mobile: string;
114
+ tablet?: string;
123
115
  }
124
116
  export type ImageProps = string | ImageObjectProps | ImageDeviceProps;
125
117
  export type ThemedImage = ThemeSupporting<ImageProps>;
126
- export interface BackgroundImageProps extends React.HTMLProps<HTMLDivElement>, Partial<ImageDeviceProps>, Partial<ImageObjectProps>, QAProps, ImageDevicesVisibleProps {
118
+ export interface BackgroundImageProps extends React.HTMLProps<HTMLDivElement>, Partial<ImageDeviceProps>, Partial<ImageObjectProps>, QAProps {
127
119
  style?: React.CSSProperties;
128
120
  imageClassName?: string;
121
+ hide?: boolean;
129
122
  }
130
123
  export interface MediaVideoProps extends AnalyticsEventsBase {
131
124
  src: string[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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;
3
+ 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,11 +56,4 @@ 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 = {}));
66
59
  //# 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;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"]}
1
+ {"version":3,"file":"common.js","sourceRoot":"../../../../src","sources":["models/constructor-items/common.ts"],"names":[],"mappings":";;;AAOA,QAAQ;AACR,IAAY,UAGX;AAHD,WAAY,UAAU;IACl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;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"]}
@@ -74,8 +74,11 @@ function typografToHTML(text, lang, allowedTags = exports.DEFAULT_ALLOWED_TAGS)
74
74
  function typografToText(text, lang) {
75
75
  return text && sanitizeHtml(typograf(text, lang));
76
76
  }
77
+ const DEFAULT_MARKDOWN_OPTIONS = {
78
+ useCommonAnchorButtons: true,
79
+ };
77
80
  const transformMarkdown = (input, options) => {
78
- const { result } = (0, transform_1.default)(input ?? '', options);
81
+ const { result } = (0, transform_1.default)(input ?? '', { ...DEFAULT_MARKDOWN_OPTIONS, ...options });
79
82
  return result;
80
83
  };
81
84
  exports.transformMarkdown = transformMarkdown;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"../../../src","sources":["text-transform/utils.ts"],"names":[],"mappings":";;;AA4CA,4CAIC;AASD,4BAcC;AAED,oCAEC;AAED,wCAEC;AAED,wCAEC;AAOD,sCAYC;AASD,wCAqBC;;AApID,4EAAkE;AAClE,0EAAqC;AACrC,gEAAgD;AAMhD,IAAY,aAGX;AAHD,WAAY,aAAa;IACrB,8BAAa,CAAA;IACb,8BAAa,CAAA;AACjB,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB;AAMY,QAAA,oBAAoB,GAAG;IAChC,IAAI;IACJ,GAAG;IACH,GAAG;IACH,QAAQ;IACR,IAAI;IACJ,KAAK;IACL,KAAK;IACL,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,IAAI;CACP,CAAC;AACW,QAAA,cAAc,GAAG;IAC1B,OAAO,EAAE,CAAC,yBAAyB,EAAE,gCAAgC,CAAC;IACtE,QAAQ,EAAE;QACN,mBA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G,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAEpD,MAAM,CAAC,OAAO,CAAC,CAAC,SAAiB,EAAE,EAAE;QACjC,IAAI,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;YACpB,sGAAsG;YACtG,MAAM,CAAC,SAAS,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,CAAC;QAC7D,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import transformYFM, {Options, Output} from '@diplodoc/transform';\nimport sanitize from 'sanitize-html';\nimport Typograf, {TypografRule} from 'typograf';\n\nimport {Lang} from './types';\n\ntype AddRuleOptions = TypografRule;\n\nexport enum TransformType {\n Text = 'text',\n Html = 'html',\n}\n\ninterface TransformOptions extends Options {\n lang: Lang;\n}\n\nexport const DEFAULT_ALLOWED_TAGS = [\n 'br',\n 'b',\n 'i',\n 'strong',\n 'em',\n 'sup',\n 'sub',\n 'a',\n 'ul',\n 'ol',\n 'li',\n];\nexport const typografConfig = {\n enabled: ['common/nbsp/afterNumber', 'common/nbsp/afterParagraphMark'],\n disabled: [\n 'common/symbols/cf',\n 'ru/other/phone-number',\n 'common/space/afterColon',\n 'common/space/afterSemicolon',\n ],\n};\nexport const sanitizeStripOptions: sanitize.IOptions = {\n allowedTags: [],\n allowedAttributes: {},\n};\n\nexport function addTypografRules(options: AddRuleOptions[]) {\n options.forEach((option) => {\n Typograf.addRule(option);\n });\n}\n\nfunction enableRules(tp: Typograf) {\n const {disabled, enabled} = typografConfig;\n\n enabled.forEach((rule) => tp.enableRule(rule));\n disabled.forEach((rule) => tp.disableRule(rule));\n}\n\nexport function typograf(text: string, lang: Lang = 'ru') {\n const localeByLang = {\n ru: ['ru', 'en-US'],\n en: ['en-US', 'ru'],\n };\n\n const tp = new Typograf({\n locale: localeByLang[lang] || lang,\n htmlEntity: {type: 'name'},\n });\n\n enableRules(tp);\n\n return tp.execute(text);\n}\n\nexport function sanitizeHtml(html: string, options = sanitizeStripOptions) {\n return html && sanitize(html, options || sanitizeStripOptions);\n}\n\nexport function typografToHTML(text: string, lang: Lang, allowedTags = DEFAULT_ALLOWED_TAGS) {\n return text && typograf(sanitizeHtml(text, {allowedTags}), lang);\n}\n\nexport function typografToText(text: string, lang: Lang) {\n return text && sanitizeHtml(typograf(text, lang));\n}\n\nexport const transformMarkdown = (input: string, options: TransformOptions): Output['result'] => {\n const {result} = transformYFM(input ?? '', options);\n return result;\n};\n\nexport function fullTransform(\n input: string,\n {lang, ...options}: TransformOptions,\n): Output['result'] {\n const result = transformMarkdown(input, {lang, ...options});\n const {html, title} = result;\n\n return {\n ...result,\n html: typograf(html, lang),\n title: title && typograf(title, lang),\n };\n}\n\nexport interface TypografEntityParams {\n entity: Record<string, string>;\n fields: string[];\n lang: Lang;\n transformType: TransformType;\n}\n\nexport function typografEntity({\n entity,\n fields,\n lang = 'ru',\n transformType = TransformType.Text,\n}: TypografEntityParams) {\n const transformTypeMap = {\n text: typografToText,\n html: typografToHTML,\n };\n\n const transformer = transformTypeMap[transformType];\n\n fields.forEach((fieldName: string) => {\n if (entity[fieldName]) {\n // eslint-disable-next-line no-param-reassign, no-not-accumulator-reassign/no-not-accumulator-reassign\n entity[fieldName] = transformer(entity[fieldName], lang);\n }\n });\n\n return entity;\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"../../../src","sources":["text-transform/utils.ts"],"names":[],"mappings":";;;AA4CA,4CAIC;AASD,4BAcC;AAED,oCAEC;AAED,wCAEC;AAED,wCAEC;AAWD,sCAYC;AASD,wCAqBC;;AAxID,4EAAkE;AAClE,0EAAqC;AACrC,gEAAgD;AAMhD,IAAY,aAGX;AAHD,WAAY,aAAa;IACrB,8BAAa,CAAA;IACb,8BAAa,CAAA;AACjB,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB;AAMY,QAAA,oBAAoB,GAAG;IAChC,IAAI;IACJ,GAAG;IACH,GAAG;IACH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C1B,KAAK,EAAE,KAAK,IAAI,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC;KACxC,CAAC;AACN,CAAC;AASD,SAAgB,cAAc,CAAC,EAC3B,MAAM,EACN,MAAM,EACN,IAAI,GAAG,IAAI,EACX,aAAa,GAAG,aAAa,CAAC,IAAI,GACf;IACnB,MAAM,gBAAgB,GAAG;QACrB,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,cAAc;KACvB,CAAC;IAEF,MAAM,WAAW,GAAG,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAEpD,MAAM,CAAC,OAAO,CAAC,CAAC,SAAiB,EAAE,EAAE;QACjC,IAAI,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;YACpB,sGAAsG;YACtG,MAAM,CAAC,SAAS,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,CAAC;QAC7D,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import transformYFM, {Options, Output} from '@diplodoc/transform';\nimport sanitize from 'sanitize-html';\nimport Typograf, {TypografRule} from 'typograf';\n\nimport {Lang} from './types';\n\ntype AddRuleOptions = TypografRule;\n\nexport enum TransformType {\n Text = 'text',\n Html = 'html',\n}\n\ninterface TransformOptions extends Options {\n lang: Lang;\n}\n\nexport const DEFAULT_ALLOWED_TAGS = [\n 'br',\n 'b',\n 'i',\n 'strong',\n 'em',\n 'sup',\n 'sub',\n 'a',\n 'ul',\n 'ol',\n 'li',\n];\nexport const typografConfig = {\n enabled: ['common/nbsp/afterNumber', 'common/nbsp/afterParagraphMark'],\n disabled: [\n 'common/symbols/cf',\n 'ru/other/phone-number',\n 'common/space/afterColon',\n 'common/space/afterSemicolon',\n ],\n};\nexport const sanitizeStripOptions: sanitize.IOptions = {\n allowedTags: [],\n allowedAttributes: {},\n};\n\nexport function addTypografRules(options: AddRuleOptions[]) {\n options.forEach((option) => {\n Typograf.addRule(option);\n });\n}\n\nfunction enableRules(tp: Typograf) {\n const {disabled, enabled} = typografConfig;\n\n enabled.forEach((rule) => tp.enableRule(rule));\n disabled.forEach((rule) => tp.disableRule(rule));\n}\n\nexport function typograf(text: string, lang: Lang = 'ru') {\n const localeByLang = {\n ru: ['ru', 'en-US'],\n en: ['en-US', 'ru'],\n };\n\n const tp = new Typograf({\n locale: localeByLang[lang] || lang,\n htmlEntity: {type: 'name'},\n });\n\n enableRules(tp);\n\n return tp.execute(text);\n}\n\nexport function sanitizeHtml(html: string, options = sanitizeStripOptions) {\n return html && sanitize(html, options || sanitizeStripOptions);\n}\n\nexport function typografToHTML(text: string, lang: Lang, allowedTags = DEFAULT_ALLOWED_TAGS) {\n return text && typograf(sanitizeHtml(text, {allowedTags}), lang);\n}\n\nexport function typografToText(text: string, lang: Lang) {\n return text && sanitizeHtml(typograf(text, lang));\n}\n\nconst DEFAULT_MARKDOWN_OPTIONS: Partial<TransformOptions> = {\n useCommonAnchorButtons: true,\n};\n\nexport const transformMarkdown = (input: string, options: TransformOptions): Output['result'] => {\n const {result} = transformYFM(input ?? '', {...DEFAULT_MARKDOWN_OPTIONS, ...options});\n return result;\n};\n\nexport function fullTransform(\n input: string,\n {lang, ...options}: TransformOptions,\n): Output['result'] {\n const result = transformMarkdown(input, {lang, ...options});\n const {html, title} = result;\n\n return {\n ...result,\n html: typograf(html, lang),\n title: title && typograf(title, lang),\n };\n}\n\nexport interface TypografEntityParams {\n entity: Record<string, string>;\n fields: string[];\n lang: Lang;\n transformType: TransformType;\n}\n\nexport function typografEntity({\n entity,\n fields,\n lang = 'ru',\n transformType = TransformType.Text,\n}: TypografEntityParams) {\n const transformTypeMap = {\n text: typografToText,\n html: typografToHTML,\n };\n\n const transformer = transformTypeMap[transformType];\n\n fields.forEach((fieldName: string) => {\n if (entity[fieldName]) {\n // eslint-disable-next-line no-param-reassign, no-not-accumulator-reassign/no-not-accumulator-reassign\n entity[fieldName] = transformer(entity[fieldName], lang);\n }\n });\n\n return entity;\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, qa } = props;
8
+ const { children, src, desktop, className, imageClassName, style, hide, 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) && (_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) && !hide && (_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,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"]}
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"]}
@@ -10,9 +10,7 @@ export interface ImageProps extends Partial<ImageObjectProps>, Partial<ImageDevi
10
10
  export interface DeviceSpecificFragmentProps extends QAProps {
11
11
  disableWebp: boolean;
12
12
  src: string;
13
- maxBreakpoint?: number;
14
- minBreakpoint?: number;
13
+ breakpoint: number;
15
14
  }
16
- export declare const EMPTY_IMG = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxIiBoZWlnaHQ9IjEiPjwvc3ZnPg==";
17
- declare const Image: (props: ImageProps) => import("react/jsx-runtime").JSX.Element;
15
+ declare const Image: (props: ImageProps) => import("react/jsx-runtime").JSX.Element | null;
18
16
  export default Image;
@@ -2,40 +2,27 @@ 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";
6
5
  import { getQaAttrubutes } from "../../utils/index.js";
7
6
  import { isCompressible } from "../../utils/imageCompress.js";
8
7
  import ImageBase from "../ImageBase/ImageBase.js";
9
8
  const checkWebP = (src) => {
10
9
  return src.endsWith('.webp') ? src : src + '.webp';
11
10
  };
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
- };
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 })] }));
24
12
  const Image = (props) => {
25
13
  const projectSettings = React.useContext(ProjectSettingsContext);
26
- const { src: imageSrc, alt, disableCompress, tablet, desktop, mobile, style, className, onClick, onLoad, containerClassName, qa, fetchPriority, loading, hide, } = props;
14
+ const { src: imageSrc, alt, disableCompress, tablet, desktop, mobile, style, className, onClick, onLoad, containerClassName, qa, fetchPriority, loading, } = props;
27
15
  const [imgLoadingError, setImgLoadingError] = React.useState(false);
28
16
  const src = imageSrc || desktop;
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 ||
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 ||
35
22
  disableCompress ||
36
23
  !isCompressible(src) ||
37
24
  imgLoadingError;
38
- return (_jsxs("picture", { className: containerClassName, "data-qa": qa, children: [(mobile || hideDevices.mobile) && (_jsx(DeviceSpecificFragment, { src: mobile || EMPTY_IMG, disableWebp: disableWebp, maxBreakpoint: BREAKPOINTS.sm, qa: qaAttributes.mobileSource })), (tablet || hideDevices.tablet) && (_jsx(DeviceSpecificFragment, { src: tablet || EMPTY_IMG, disableWebp: disableWebp, maxBreakpoint: BREAKPOINTS.md, minBreakpoint: BREAKPOINTS.sm, qa: qaAttributes.tabletSource })), hideDevices.desktop && (_jsx(DeviceSpecificFragment, { src: EMPTY_IMG, disableWebp: disableWebp, 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 })] }));
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 })] }));
39
26
  };
40
27
  export default Image;
41
28
  //# 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;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,OAAO,CAAC;AACvD,CAAC,C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ACxB,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}\n maxBreakpoint={BREAKPOINTS.sm}\n qa={qaAttributes.mobileSource}\n />\n )}\n {(tablet || hideDevices.tablet) && (\n <DeviceSpecificFragment\n src={tablet || EMPTY_IMG}\n disableWebp={disableWebp}\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={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"]}
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,iBAA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AC,YAAY,GAC/B,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 {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"]}
@@ -100,12 +100,7 @@ interface LoopProps {
100
100
  start: number;
101
101
  end?: number;
102
102
  }
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 {
103
+ export interface ImageInfoProps extends Pick<React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, 'aria-describedby' | 'loading'> {
109
104
  alt?: string;
110
105
  fetchPriority?: 'high' | 'low' | 'auto';
111
106
  disableCompress?: boolean;
@@ -114,18 +109,16 @@ export interface ImageObjectProps extends ImageInfoProps {
114
109
  src: string;
115
110
  }
116
111
  export interface ImageDeviceProps extends ImageInfoProps {
117
- [Device.Desktop]: string;
118
- [Device.Mobile]: string;
119
- [Device.Tablet]?: string;
120
- }
121
- export interface ImageDevicesVisibleProps {
122
- hide?: boolean | Partial<Record<Device, boolean>>;
112
+ desktop: string;
113
+ mobile: string;
114
+ tablet?: string;
123
115
  }
124
116
  export type ImageProps = string | ImageObjectProps | ImageDeviceProps;
125
117
  export type ThemedImage = ThemeSupporting<ImageProps>;
126
- export interface BackgroundImageProps extends React.HTMLProps<HTMLDivElement>, Partial<ImageDeviceProps>, Partial<ImageObjectProps>, QAProps, ImageDevicesVisibleProps {
118
+ export interface BackgroundImageProps extends React.HTMLProps<HTMLDivElement>, Partial<ImageDeviceProps>, Partial<ImageObjectProps>, QAProps {
127
119
  style?: React.CSSProperties;
128
120
  imageClassName?: string;
121
+ hide?: boolean;
129
122
  }
130
123
  export interface MediaVideoProps extends AnalyticsEventsBase {
131
124
  src: string[];
@@ -53,11 +53,4 @@ 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 = {}));
63
56
  //# 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,+BA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GjC;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"]}
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"]}
@@ -63,8 +63,11 @@ export function typografToHTML(text, lang, allowedTags = DEFAULT_ALLOWED_TAGS) {
63
63
  export function typografToText(text, lang) {
64
64
  return text && sanitizeHtml(typograf(text, lang));
65
65
  }
66
+ const DEFAULT_MARKDOWN_OPTIONS = {
67
+ useCommonAnchorButtons: true,
68
+ };
66
69
  export const transformMarkdown = (input, options) => {
67
- const { result } = transformYFM(input ?? '', options);
70
+ const { result } = transformYFM(input ?? '', { ...DEFAULT_MARKDOWN_OPTIONS, ...options });
68
71
  return result;
69
72
  };
70
73
  export function fullTransform(input, { lang, ...options }) {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"../../../src","sources":["text-transform/utils.ts"],"names":[],"mappings":"AAAA,OAAO,YAA+B,MAAM,qBAAqB,CAAC;AAClE,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,QAAwB,MAAM,UAAU,CAAC;AAMhD,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACrB,8BAAa,CAAA;IACb,8BAAa,CAAA;AACjB,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB;AAMD,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAChC,IAAI;IACJ,GAAG;IACH,GAAG;IACH,QAAQ;IACR,IAAI;IACJ,KAAK;IACL,KAAK;IACL,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,IAAI;CACP,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC1B,OAAO,EAAE,CAAC,yBAAyB,EAAE,gCAAgC,CAAC;IACtE,QAAQ,EAAE;QACN,mBAAmB;QACnB,uBAAuB;QACvB,yBAAyB;QACzB,6BAA6B;KAChC;CACJ,CAAC;AACF,MAAM,CAAC,MAAM,oBAAoB,GAAsB;IACnD,WAAW,EAAE,EAAE;IACf,iBAAiB,EAAE,EAAE;CACxB,CAAC;AAEF,MAAM,UAAU,gBAAgB,CAAC,OAAyB;IACtD,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QACvB,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7B,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ClB,CAAC","sourcesContent":["import transformYFM, {Options, Output} from '@diplodoc/transform';\nimport sanitize from 'sanitize-html';\nimport Typograf, {TypografRule} from 'typograf';\n\nimport {Lang} from './types';\n\ntype AddRuleOptions = TypografRule;\n\nexport enum TransformType {\n Text = 'text',\n Html = 'html',\n}\n\ninterface TransformOptions extends Options {\n lang: Lang;\n}\n\nexport const DEFAULT_ALLOWED_TAGS = [\n 'br',\n 'b',\n 'i',\n 'strong',\n 'em',\n 'sup',\n 'sub',\n 'a',\n 'ul',\n 'ol',\n 'li',\n];\nexport const typografConfig = {\n enabled: ['common/nbsp/afterNumber', 'common/nbsp/afterParagraphMark'],\n disabled: [\n 'common/symbols/cf',\n 'ru/other/phone-number',\n 'common/space/afterColon',\n 'common/space/afterSemicolon',\n ],\n};\nexport const sanitizeStripOptions: sanitize.IOptions = {\n allowedTags: [],\n allowedAttributes: {},\n};\n\nexport function addTypografRules(options: AddRuleOptions[]) {\n options.forEach((option) => {\n Typograf.addRule(option);\n });\n}\n\nfunction enableRules(tp: Typograf) {\n const {disabled, enabled} = typografConfig;\n\n enabled.forEach((rule) => tp.enableRule(rule));\n disabled.forEach((rule) => tp.disableRule(rule));\n}\n\nexport function typograf(text: string, lang: Lang = 'ru') {\n const localeByLang = {\n ru: ['ru', 'en-US'],\n en: ['en-US', 'ru'],\n };\n\n const tp = new Typograf({\n locale: localeByLang[lang] || lang,\n htmlEntity: {type: 'name'},\n });\n\n enableRules(tp);\n\n return tp.execute(text);\n}\n\nexport function sanitizeHtml(html: string, options = sanitizeStripOptions) {\n return html && sanitize(html, options || sanitizeStripOptions);\n}\n\nexport function typografToHTML(text: string, lang: Lang, allowedTags = DEFAULT_ALLOWED_TAGS) {\n return text && typograf(sanitizeHtml(text, {allowedTags}), lang);\n}\n\nexport function typografToText(text: string, lang: Lang) {\n return text && sanitizeHtml(typograf(text, lang));\n}\n\nexport const transformMarkdown = (input: string, options: TransformOptions): Output['result'] => {\n const {result} = transformYFM(input ?? '', options);\n return result;\n};\n\nexport function fullTransform(\n input: string,\n {lang, ...options}: TransformOptions,\n): Output['result'] {\n const result = transformMarkdown(input, {lang, ...options});\n const {html, title} = result;\n\n return {\n ...result,\n html: typograf(html, lang),\n title: title && typograf(title, lang),\n };\n}\n\nexport interface TypografEntityParams {\n entity: Record<string, string>;\n fields: string[];\n lang: Lang;\n transformType: TransformType;\n}\n\nexport function typografEntity({\n entity,\n fields,\n lang = 'ru',\n transformType = TransformType.Text,\n}: TypografEntityParams) {\n const transformTypeMap = {\n text: typografToText,\n html: typografToHTML,\n };\n\n const transformer = transformTypeMap[transformType];\n\n fields.forEach((fieldName: string) => {\n if (entity[fieldName]) {\n // eslint-disable-next-line no-param-reassign, no-not-accumulator-reassign/no-not-accumulator-reassign\n entity[fieldName] = transformer(entity[fieldName], lang);\n }\n });\n\n return entity;\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"../../../src","sources":["text-transform/utils.ts"],"names":[],"mappings":"AAAA,OAAO,YAA+B,MAAM,qBAAqB,CAAC;AAClE,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,QAAwB,MAAM,UAAU,CAAC;AAMhD,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACrB,8BAAa,CAAA;IACb,8BAAa,CAAA;AACjB,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB;AAMD,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAChC,IAAI;IACJ,GAAG;IACH,GAAG;IACH,QAAQ;IACR,IAAI;IACJ,KAAK;IACL,KAAK;IACL,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,IAAI;CACP,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC1B,OAAO,EAAE,CAAC,yBAAyB,EAAE,gCAAgC,CAAC;IACtE,QAAQ,EAAE;QACN,mBAAmB;QACnB,uBAAuB;QACvB,yBAAyB;QACzB,6BAA6B;KAChC;CACJ,CAAC;AACF,MAAM,CAAC,MAAM,oBAAoB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AM,WAAW,GAAG,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAEpD,MAAM,CAAC,OAAO,CAAC,CAAC,SAAiB,EAAE,EAAE;QACjC,IAAI,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;YACpB,sGAAsG;YACtG,MAAM,CAAC,SAAS,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,CAAC;QAC7D,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import transformYFM, {Options, Output} from '@diplodoc/transform';\nimport sanitize from 'sanitize-html';\nimport Typograf, {TypografRule} from 'typograf';\n\nimport {Lang} from './types';\n\ntype AddRuleOptions = TypografRule;\n\nexport enum TransformType {\n Text = 'text',\n Html = 'html',\n}\n\ninterface TransformOptions extends Options {\n lang: Lang;\n}\n\nexport const DEFAULT_ALLOWED_TAGS = [\n 'br',\n 'b',\n 'i',\n 'strong',\n 'em',\n 'sup',\n 'sub',\n 'a',\n 'ul',\n 'ol',\n 'li',\n];\nexport const typografConfig = {\n enabled: ['common/nbsp/afterNumber', 'common/nbsp/afterParagraphMark'],\n disabled: [\n 'common/symbols/cf',\n 'ru/other/phone-number',\n 'common/space/afterColon',\n 'common/space/afterSemicolon',\n ],\n};\nexport const sanitizeStripOptions: sanitize.IOptions = {\n allowedTags: [],\n allowedAttributes: {},\n};\n\nexport function addTypografRules(options: AddRuleOptions[]) {\n options.forEach((option) => {\n Typograf.addRule(option);\n });\n}\n\nfunction enableRules(tp: Typograf) {\n const {disabled, enabled} = typografConfig;\n\n enabled.forEach((rule) => tp.enableRule(rule));\n disabled.forEach((rule) => tp.disableRule(rule));\n}\n\nexport function typograf(text: string, lang: Lang = 'ru') {\n const localeByLang = {\n ru: ['ru', 'en-US'],\n en: ['en-US', 'ru'],\n };\n\n const tp = new Typograf({\n locale: localeByLang[lang] || lang,\n htmlEntity: {type: 'name'},\n });\n\n enableRules(tp);\n\n return tp.execute(text);\n}\n\nexport function sanitizeHtml(html: string, options = sanitizeStripOptions) {\n return html && sanitize(html, options || sanitizeStripOptions);\n}\n\nexport function typografToHTML(text: string, lang: Lang, allowedTags = DEFAULT_ALLOWED_TAGS) {\n return text && typograf(sanitizeHtml(text, {allowedTags}), lang);\n}\n\nexport function typografToText(text: string, lang: Lang) {\n return text && sanitizeHtml(typograf(text, lang));\n}\n\nconst DEFAULT_MARKDOWN_OPTIONS: Partial<TransformOptions> = {\n useCommonAnchorButtons: true,\n};\n\nexport const transformMarkdown = (input: string, options: TransformOptions): Output['result'] => {\n const {result} = transformYFM(input ?? '', {...DEFAULT_MARKDOWN_OPTIONS, ...options});\n return result;\n};\n\nexport function fullTransform(\n input: string,\n {lang, ...options}: TransformOptions,\n): Output['result'] {\n const result = transformMarkdown(input, {lang, ...options});\n const {html, title} = result;\n\n return {\n ...result,\n html: typograf(html, lang),\n title: title && typograf(title, lang),\n };\n}\n\nexport interface TypografEntityParams {\n entity: Record<string, string>;\n fields: string[];\n lang: Lang;\n transformType: TransformType;\n}\n\nexport function typografEntity({\n entity,\n fields,\n lang = 'ru',\n transformType = TransformType.Text,\n}: TypografEntityParams) {\n const transformTypeMap = {\n text: typografToText,\n html: typografToHTML,\n };\n\n const transformer = transformTypeMap[transformType];\n\n fields.forEach((fieldName: string) => {\n if (entity[fieldName]) {\n // eslint-disable-next-line no-param-reassign, no-not-accumulator-reassign/no-not-accumulator-reassign\n entity[fieldName] = transformer(entity[fieldName], lang);\n }\n });\n\n return entity;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/page-constructor",
3
- "version": "6.8.2-alpha.0",
3
+ "version": "6.9.0",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
@@ -133,7 +133,7 @@
133
133
  "@babel/preset-typescript": "^7.26.0",
134
134
  "@commitlint/cli": "^19.6.1",
135
135
  "@commitlint/config-conventional": "^19.6.0",
136
- "@diplodoc/transform": "^4.10.8",
136
+ "@diplodoc/transform": "^4.57.1",
137
137
  "@gravity-ui/eslint-config": "^3.2.0",
138
138
  "@gravity-ui/gulp-utils": "^1.0.3",
139
139
  "@gravity-ui/icons": "^2.11.0",
@@ -100,12 +100,7 @@ interface LoopProps {
100
100
  start: number;
101
101
  end?: number;
102
102
  }
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 {
103
+ export interface ImageInfoProps extends Pick<React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, 'aria-describedby' | 'loading'> {
109
104
  alt?: string;
110
105
  fetchPriority?: 'high' | 'low' | 'auto';
111
106
  disableCompress?: boolean;
@@ -114,18 +109,16 @@ export interface ImageObjectProps extends ImageInfoProps {
114
109
  src: string;
115
110
  }
116
111
  export interface ImageDeviceProps extends ImageInfoProps {
117
- [Device.Desktop]: string;
118
- [Device.Mobile]: string;
119
- [Device.Tablet]?: string;
120
- }
121
- export interface ImageDevicesVisibleProps {
122
- hide?: boolean | Partial<Record<Device, boolean>>;
112
+ desktop: string;
113
+ mobile: string;
114
+ tablet?: string;
123
115
  }
124
116
  export type ImageProps = string | ImageObjectProps | ImageDeviceProps;
125
117
  export type ThemedImage = ThemeSupporting<ImageProps>;
126
- export interface BackgroundImageProps extends React.HTMLProps<HTMLDivElement>, Partial<ImageDeviceProps>, Partial<ImageObjectProps>, QAProps, ImageDevicesVisibleProps {
118
+ export interface BackgroundImageProps extends React.HTMLProps<HTMLDivElement>, Partial<ImageDeviceProps>, Partial<ImageObjectProps>, QAProps {
127
119
  style?: React.CSSProperties;
128
120
  imageClassName?: string;
121
+ hide?: boolean;
129
122
  }
130
123
  export interface MediaVideoProps extends AnalyticsEventsBase {
131
124
  src: string[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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;
3
+ 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,10 +56,3 @@ 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 = {}));
@@ -87,8 +87,11 @@ function typografToHTML(text, lang, allowedTags = exports.DEFAULT_ALLOWED_TAGS)
87
87
  function typografToText(text, lang) {
88
88
  return text && sanitizeHtml(typograf(text, lang));
89
89
  }
90
+ const DEFAULT_MARKDOWN_OPTIONS = {
91
+ useCommonAnchorButtons: true,
92
+ };
90
93
  const transformMarkdown = (input, options) => {
91
- const { result } = (0, transform_1.default)(input !== null && input !== void 0 ? input : '', options);
94
+ const { result } = (0, transform_1.default)(input !== null && input !== void 0 ? input : '', Object.assign(Object.assign({}, DEFAULT_MARKDOWN_OPTIONS), options));
92
95
  return result;
93
96
  };
94
97
  exports.transformMarkdown = transformMarkdown;
package/widget/index.js CHANGED
@@ -1 +1 @@
1
- export default "(self.webpackChunk_gravity_ui_page_constructor=self.webpackChunk_gravity_ui_page_constructor||[]).push([[6007],{56007:function(_,t,e){_.exports=function(_){\"use strict\";function t(_){return _&&\"object\"==typeof _&&\"default\"in _?_:{default:_}}var e=t(_),Y={name:\"zh\",weekdays:\"星期日_星期一_星期二_星期三_星期四_星期五_星期六\".split(\"_\"),weekdaysShort:\"周日_周一_周二_周三_周四_周五_周六\".split(\"_\"),weekdaysMin:\"日_一_二_三_四_五_六\".split(\"_\"),months:\"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月\".split(\"_\"),monthsShort:\"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月\".split(\"_\"),ordinal:function(_,t){return\"W\"===t?_+\"周\":_+\"日\"},weekStart:1,yearStart:4,formats:{LT:\"HH:mm\",LTS:\"HH:mm:ss\",L:\"YYYY/MM/DD\",LL:\"YYYY年M月D日\",LLL:\"YYYY年M月D日Ah点mm分\",LLLL:\"YYYY年M月D日ddddAh点mm分\",l:\"YYYY/M/D\",ll:\"YYYY年M月D日\",lll:\"YYYY年M月D日 HH:mm\",llll:\"YYYY年M月D日dddd HH:mm\"},relativeTime:{future:\"%s后\",past:\"%s前\",s:\"几秒\",m:\"1 分钟\",mm:\"%d 分钟\",h:\"1 小时\",hh:\"%d 小时\",d:\"1 天\",dd:\"%d 天\",M:\"1 个月\",MM:\"%d 个月\",y:\"1 年\",yy:\"%d 年\"},meridiem:function(_,t){var e=100*_+t;return e<600?\"凌晨\":e<900?\"早上\":e<1100?\"上午\":e<1300?\"中午\":e<1800?\"下午\":\"晚上\"}};return e.default.locale(Y,null,!0),Y}(e(74353))}}]);";
1
+ export default "(self.webpackChunk_gravity_ui_page_constructor=self.webpackChunk_gravity_ui_page_constructor||[]).push([[1349],{31349:function(_,t,Y){_.exports=function(_){\"use strict\";function t(_){return _&&\"object\"==typeof _&&\"default\"in _?_:{default:_}}var Y=t(_),e={name:\"zh-tw\",weekdays:\"星期日_星期一_星期二_星期三_星期四_星期五_星期六\".split(\"_\"),weekdaysShort:\"週日_週一_週二_週三_週四_週五_週六\".split(\"_\"),weekdaysMin:\"日_一_二_三_四_五_六\".split(\"_\"),months:\"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月\".split(\"_\"),monthsShort:\"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月\".split(\"_\"),ordinal:function(_,t){return\"W\"===t?_+\"週\":_+\"日\"},formats:{LT:\"HH:mm\",LTS:\"HH:mm:ss\",L:\"YYYY/MM/DD\",LL:\"YYYY年M月D日\",LLL:\"YYYY年M月D日 HH:mm\",LLLL:\"YYYY年M月D日dddd HH:mm\",l:\"YYYY/M/D\",ll:\"YYYY年M月D日\",lll:\"YYYY年M月D日 HH:mm\",llll:\"YYYY年M月D日dddd HH:mm\"},relativeTime:{future:\"%s內\",past:\"%s前\",s:\"幾秒\",m:\"1 分鐘\",mm:\"%d 分鐘\",h:\"1 小時\",hh:\"%d 小時\",d:\"1 天\",dd:\"%d 天\",M:\"1 個月\",MM:\"%d 個月\",y:\"1 年\",yy:\"%d 年\"},meridiem:function(_,t){var Y=100*_+t;return Y<600?\"凌晨\":Y<900?\"早上\":Y<1100?\"上午\":Y<1300?\"中午\":Y<1800?\"下午\":\"晚上\"}};return Y.default.locale(e,null,!0),e}(Y(74353))}}]);";