@gravity-ui/blog-constructor 5.4.1 → 5.5.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.
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
2
  import { CTAProps } from '../../models/blocks';
3
- export declare const CTA: ({ items, paddingTop, paddingBottom }: CTAProps) => React.JSX.Element;
3
+ export declare const CTA: ({ items, paddingTop, paddingBottom, qa }: CTAProps) => React.JSX.Element;
@@ -10,7 +10,7 @@ const paddings_1 = require("../../models/paddings");
10
10
  const cn_1 = require("../../utils/cn");
11
11
  const common_1 = require("../../utils/common");
12
12
  const b = (0, cn_1.block)('cta');
13
- const CTA = ({ items, paddingTop, paddingBottom }) => {
13
+ const CTA = ({ items, paddingTop, paddingBottom, qa }) => {
14
14
  /**
15
15
  * @deprecated Metrika will be deleted after launch of analyticsEvents
16
16
  */
@@ -18,18 +18,19 @@ const CTA = ({ items, paddingTop, paddingBottom }) => {
18
18
  name: constants_1.BlogMetrikaGoalIds.cta,
19
19
  isCrossSite: true,
20
20
  };
21
+ const qaAttributes = (0, common_1.getQaAttributes)(qa, 'card');
21
22
  return (react_1.default.createElement(Wrapper_1.Wrapper, { paddings: {
22
23
  [paddings_1.PaddingsDirections.top]: paddingTop,
23
24
  [paddings_1.PaddingsDirections.bottom]: paddingBottom,
24
- }, className: b('content'), qa: "blog-cta-content" }, items.map((content, index) => {
25
+ }, className: b('content'), qa: qaAttributes.wrapper }, items.map((content, index) => {
25
26
  var _a;
26
27
  const contentData = (0, common_1.updateContentSizes)(content);
27
28
  (_a = contentData.links) === null || _a === void 0 ? void 0 : _a.forEach((link) => {
28
29
  // eslint-disable-next-line no-not-accumulator-reassign/no-not-accumulator-reassign
29
30
  link.metrikaGoals = (0, common_1.getBlogElementMetrika)(metrikaGoal, link.metrikaGoals);
30
31
  });
31
- return (react_1.default.createElement("div", { key: index, className: b('card'), "data-qa": "blog-cta-card" },
32
- react_1.default.createElement(page_constructor_1.Content, Object.assign({}, contentData))));
32
+ return (react_1.default.createElement("div", { key: index, className: b('card'), "data-qa": qaAttributes.card },
33
+ react_1.default.createElement(page_constructor_1.Content, Object.assign({}, contentData, { qa: qaAttributes.content }))));
33
34
  })));
34
35
  };
35
36
  exports.CTA = CTA;
@@ -4,7 +4,7 @@ exports.Search = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const react_1 = tslib_1.__importStar(require("react"));
6
6
  const uikit_1 = require("@gravity-ui/uikit");
7
- const lodash_1 = require("lodash");
7
+ const debounce_1 = tslib_1.__importDefault(require("lodash/debounce"));
8
8
  const useIsIPhone_1 = require("../../hooks/useIsIPhone");
9
9
  const i18n_1 = require("../../i18n");
10
10
  const Close_1 = require("../../icons/Close");
@@ -21,7 +21,7 @@ const AUTOFOCUS_TIMEOUT = 0;
21
21
  * @returns {JSX|null}
22
22
  */
23
23
  const Search = ({ className, initialValue, onSubmit, debounce = 300, placeholder = (0, i18n_1.i18)(i18n_1.Keyset.Search), size = 'm', autoFocus = false, value: externalValue, }) => {
24
- const handleChange = (0, lodash_1.debounce)(onSubmit, debounce);
24
+ const handleChange = (0, debounce_1.default)(onSubmit, debounce);
25
25
  const [value, setValue] = (0, react_1.useState)(initialValue);
26
26
  const inputRef = (0, react_1.useRef)(null);
27
27
  const isIPhone = (0, useIsIPhone_1.useIsIPhone)();
@@ -4,7 +4,7 @@ declare const _default: {
4
4
  "blog-layout-block": ({ fullWidth, mobileOrder, children, paddingTop, paddingBottom, }: import("react").PropsWithChildren<import("../models/blocks").LayoutProps>) => import("react").JSX.Element;
5
5
  "blog-media-block": ({ text, paddingTop, paddingBottom, ...mediaProps }: import("../models/blocks").MediaProps) => import("react").JSX.Element;
6
6
  "blog-banner-block": ({ color, imageSize, image, paddingTop, paddingBottom, qa, ...content }: import("../models/blocks").BannerProps) => import("react").JSX.Element;
7
- "blog-cta-block": ({ items, paddingTop, paddingBottom }: import("../models/blocks").CTAProps) => import("react").JSX.Element;
7
+ "blog-cta-block": ({ items, paddingTop, paddingBottom, qa }: import("../models/blocks").CTAProps) => import("react").JSX.Element;
8
8
  "blog-colored-text-block": ({ background, paddingTop, paddingBottom, qa, ...content }: import("../models/blocks").ColoredTextProps) => import("react").JSX.Element;
9
9
  "blog-author-block": (props: import("../models/blocks").AuthorProps) => import("react").JSX.Element | null;
10
10
  "blog-suggest-block": ({ paddingTop, paddingBottom }: import("../models/blocks").SuggestProps) => import("react").JSX.Element | null;
@@ -18,9 +18,8 @@ export type ColoredTextProps = ContentBlockProps & QAProps & {
18
18
  altText?: string;
19
19
  };
20
20
  } & PaddingsYFMProps;
21
- export type CTAProps = {
21
+ export type CTAProps = QAProps & {
22
22
  items: Array<ContentBlockProps>;
23
- columnCount?: number;
24
23
  } & PaddingsYFMProps;
25
24
  export type HeaderProps = HeaderBlockProps & PaddingsYFMProps;
26
25
  export type LayoutProps = {
@@ -4,7 +4,10 @@ exports.getQaAttributes = exports.scrollOnPageChange = exports.getFeedQueryParam
4
4
  const tslib_1 = require("tslib");
5
5
  const url_1 = require("url");
6
6
  const page_constructor_1 = require("@gravity-ui/page-constructor");
7
- const lodash_1 = require("lodash");
7
+ const camelCase_1 = tslib_1.__importDefault(require("lodash/camelCase"));
8
+ const debounce_1 = tslib_1.__importDefault(require("lodash/debounce"));
9
+ const flatten_1 = tslib_1.__importDefault(require("lodash/flatten"));
10
+ const memoize_1 = tslib_1.__importDefault(require("lodash/memoize"));
8
11
  const constants_1 = require("../blocks/constants");
9
12
  const i18n_1 = require("../i18n");
10
13
  const QA_ATTRIBUTES_KEYS = ['container', 'content', 'wrapper', 'image', 'button'];
@@ -35,7 +38,7 @@ const scrollToHash = (hash, browser) => {
35
38
  setTimeout(() => element.scrollIntoView({ behavior: browser === 'Yandex' ? 'auto' : 'smooth' }), 0);
36
39
  };
37
40
  exports.scrollToHash = scrollToHash;
38
- exports.getTags = (0, lodash_1.memoize)((tags, prefix) => {
41
+ exports.getTags = (0, memoize_1.default)((tags, prefix) => {
39
42
  return tags.map((_a) => {
40
43
  var { slug } = _a, tag = tslib_1.__rest(_a, ["slug"]);
41
44
  const queryParams = new URLSearchParams();
@@ -44,7 +47,7 @@ exports.getTags = (0, lodash_1.memoize)((tags, prefix) => {
44
47
  });
45
48
  });
46
49
  const stub = (postId) => postId;
47
- exports.postLikeStatus = (0, lodash_1.debounce)((postId, hasUserLike) => {
50
+ exports.postLikeStatus = (0, debounce_1.default)((postId, hasUserLike) => {
48
51
  (hasUserLike ? stub : stub)(postId);
49
52
  }, 300);
50
53
  const getTagFilterUrl = (tagId, prefix) => {
@@ -117,9 +120,9 @@ exports.scrollOnPageChange = scrollOnPageChange;
117
120
  const getQaAttributes = (qa, ...customKeys) => {
118
121
  const attributes = {};
119
122
  if (qa) {
120
- const keys = QA_ATTRIBUTES_KEYS.concat((0, lodash_1.flatten)(customKeys));
123
+ const keys = QA_ATTRIBUTES_KEYS.concat((0, flatten_1.default)(customKeys));
121
124
  keys.forEach((key) => {
122
- attributes[(0, lodash_1.camelCase)(key)] = `${qa}-${key}`;
125
+ attributes[(0, camelCase_1.default)(key)] = `${qa}-${key}`;
123
126
  });
124
127
  attributes.default = qa;
125
128
  }
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import { CTAProps } from '../../models/blocks';
3
3
  import './CTA.css';
4
- export declare const CTA: ({ items, paddingTop, paddingBottom }: CTAProps) => React.JSX.Element;
4
+ export declare const CTA: ({ items, paddingTop, paddingBottom, qa }: CTAProps) => React.JSX.Element;
@@ -4,10 +4,10 @@ import { Wrapper } from '../../components/Wrapper/Wrapper';
4
4
  import { BlogMetrikaGoalIds } from '../../constants';
5
5
  import { PaddingsDirections } from '../../models/paddings';
6
6
  import { block } from '../../utils/cn';
7
- import { getBlogElementMetrika, updateContentSizes } from '../../utils/common';
7
+ import { getBlogElementMetrika, getQaAttributes, updateContentSizes } from '../../utils/common';
8
8
  import './CTA.css';
9
9
  const b = block('cta');
10
- export const CTA = ({ items, paddingTop, paddingBottom }) => {
10
+ export const CTA = ({ items, paddingTop, paddingBottom, qa }) => {
11
11
  /**
12
12
  * @deprecated Metrika will be deleted after launch of analyticsEvents
13
13
  */
@@ -15,17 +15,18 @@ export const CTA = ({ items, paddingTop, paddingBottom }) => {
15
15
  name: BlogMetrikaGoalIds.cta,
16
16
  isCrossSite: true,
17
17
  };
18
+ const qaAttributes = getQaAttributes(qa, 'card');
18
19
  return (React.createElement(Wrapper, { paddings: {
19
20
  [PaddingsDirections.top]: paddingTop,
20
21
  [PaddingsDirections.bottom]: paddingBottom,
21
- }, className: b('content'), qa: "blog-cta-content" }, items.map((content, index) => {
22
+ }, className: b('content'), qa: qaAttributes.wrapper }, items.map((content, index) => {
22
23
  var _a;
23
24
  const contentData = updateContentSizes(content);
24
25
  (_a = contentData.links) === null || _a === void 0 ? void 0 : _a.forEach((link) => {
25
26
  // eslint-disable-next-line no-not-accumulator-reassign/no-not-accumulator-reassign
26
27
  link.metrikaGoals = getBlogElementMetrika(metrikaGoal, link.metrikaGoals);
27
28
  });
28
- return (React.createElement("div", { key: index, className: b('card'), "data-qa": "blog-cta-card" },
29
- React.createElement(Content, Object.assign({}, contentData))));
29
+ return (React.createElement("div", { key: index, className: b('card'), "data-qa": qaAttributes.card },
30
+ React.createElement(Content, Object.assign({}, contentData, { qa: qaAttributes.content }))));
30
31
  })));
31
32
  };
@@ -1,6 +1,6 @@
1
1
  import React, { useEffect, useMemo, useRef, useState } from 'react';
2
2
  import { Icon, TextInput } from '@gravity-ui/uikit';
3
- import { debounce as lodashDebounce } from 'lodash';
3
+ import lodashDebounce from 'lodash/debounce';
4
4
  import { useIsIPhone } from '../../hooks/useIsIPhone';
5
5
  import { Keyset, i18 } from '../../i18n';
6
6
  import { Close } from '../../icons/Close';
@@ -4,7 +4,7 @@ declare const _default: {
4
4
  "blog-layout-block": ({ fullWidth, mobileOrder, children, paddingTop, paddingBottom, }: import("react").PropsWithChildren<import("../models/blocks").LayoutProps>) => import("react").JSX.Element;
5
5
  "blog-media-block": ({ text, paddingTop, paddingBottom, ...mediaProps }: import("../models/blocks").MediaProps) => import("react").JSX.Element;
6
6
  "blog-banner-block": ({ color, imageSize, image, paddingTop, paddingBottom, qa, ...content }: import("../models/blocks").BannerProps) => import("react").JSX.Element;
7
- "blog-cta-block": ({ items, paddingTop, paddingBottom }: import("../models/blocks").CTAProps) => import("react").JSX.Element;
7
+ "blog-cta-block": ({ items, paddingTop, paddingBottom, qa }: import("../models/blocks").CTAProps) => import("react").JSX.Element;
8
8
  "blog-colored-text-block": ({ background, paddingTop, paddingBottom, qa, ...content }: import("../models/blocks").ColoredTextProps) => import("react").JSX.Element;
9
9
  "blog-author-block": (props: import("../models/blocks").AuthorProps) => import("react").JSX.Element | null;
10
10
  "blog-suggest-block": ({ paddingTop, paddingBottom }: import("../models/blocks").SuggestProps) => import("react").JSX.Element | null;
@@ -18,9 +18,8 @@ export type ColoredTextProps = ContentBlockProps & QAProps & {
18
18
  altText?: string;
19
19
  };
20
20
  } & PaddingsYFMProps;
21
- export type CTAProps = {
21
+ export type CTAProps = QAProps & {
22
22
  items: Array<ContentBlockProps>;
23
- columnCount?: number;
24
23
  } & PaddingsYFMProps;
25
24
  export type HeaderProps = HeaderBlockProps & PaddingsYFMProps;
26
25
  export type LayoutProps = {
@@ -1,7 +1,10 @@
1
1
  import { __rest } from "tslib";
2
2
  import { format, parse } from 'url';
3
3
  import { isNewMetrikaFormat, } from '@gravity-ui/page-constructor';
4
- import { camelCase, debounce, flatten, memoize } from 'lodash';
4
+ import camelCase from 'lodash/camelCase';
5
+ import debounce from 'lodash/debounce';
6
+ import flatten from 'lodash/flatten';
7
+ import memoize from 'lodash/memoize';
5
8
  import { CONTENT_DEFAULT_COL_SIZES, CONTENT_DEFAULT_SIZE, CONTENT_DEFAULT_THEME, DEFAULT_PAGE, DEFAULT_ROWS_PER_PAGE, } from '../blocks/constants';
6
9
  import { Keyset, i18 } from '../i18n';
7
10
  const QA_ATTRIBUTES_KEYS = ['container', 'content', 'wrapper', 'image', 'button'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/blog-constructor",
3
- "version": "5.4.1",
3
+ "version": "5.5.0",
4
4
  "description": "Gravity UI Blog Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -18,9 +18,8 @@ export type ColoredTextProps = ContentBlockProps & QAProps & {
18
18
  altText?: string;
19
19
  };
20
20
  } & PaddingsYFMProps;
21
- export type CTAProps = {
21
+ export type CTAProps = QAProps & {
22
22
  items: Array<ContentBlockProps>;
23
- columnCount?: number;
24
23
  } & PaddingsYFMProps;
25
24
  export type HeaderProps = HeaderBlockProps & PaddingsYFMProps;
26
25
  export type LayoutProps = {