@gravity-ui/page-constructor 2.17.0 → 2.19.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/cjs/components/Anchor/Anchor.d.ts +2 -2
  3. package/build/cjs/components/Anchor/Anchor.js +1 -1
  4. package/build/cjs/components/Button/Button.css +3 -0
  5. package/build/cjs/components/Button/Button.js +4 -4
  6. package/build/cjs/grid/Col/Col.d.ts +1 -1
  7. package/build/cjs/internal-typings/global.d.ts +18 -16
  8. package/build/cjs/models/constructor-items/common.d.ts +2 -3
  9. package/build/cjs/sub-blocks/HubspotForm/HubspotFormContainer.d.ts +2 -1
  10. package/build/cjs/sub-blocks/HubspotForm/HubspotFormContainer.js +5 -2
  11. package/build/cjs/sub-blocks/HubspotForm/index.d.ts +1 -1
  12. package/build/cjs/sub-blocks/HubspotForm/index.js +6 -5
  13. package/build/esm/components/Anchor/Anchor.d.ts +2 -2
  14. package/build/esm/components/Anchor/Anchor.js +1 -1
  15. package/build/esm/components/Button/Button.css +3 -0
  16. package/build/esm/components/Button/Button.js +4 -4
  17. package/build/esm/grid/Col/Col.d.ts +1 -1
  18. package/build/esm/internal-typings/global.d.ts +18 -16
  19. package/build/esm/models/constructor-items/common.d.ts +2 -3
  20. package/build/esm/sub-blocks/HubspotForm/HubspotFormContainer.d.ts +2 -1
  21. package/build/esm/sub-blocks/HubspotForm/HubspotFormContainer.js +6 -3
  22. package/build/esm/sub-blocks/HubspotForm/index.d.ts +1 -1
  23. package/build/esm/sub-blocks/HubspotForm/index.js +7 -6
  24. package/package.json +4 -1
  25. package/server/models/constructor-items/common.d.ts +2 -3
  26. package/build/cjs/components/Anchor/__tests__/Anchor.test.d.ts +0 -1
  27. package/build/cjs/components/Anchor/__tests__/Anchor.test.js +0 -21
  28. package/build/cjs/components/AnimateBlock/__tests__/AnimateBlock.test.d.ts +0 -1
  29. package/build/cjs/components/AnimateBlock/__tests__/AnimateBlock.test.js +0 -36
  30. package/build/cjs/components/Author/__tests__/Author.test.d.ts +0 -1
  31. package/build/cjs/components/Author/__tests__/Author.test.js +0 -49
  32. package/build/cjs/components/BackLink/__tests__/BackLink.test.d.ts +0 -1
  33. package/build/cjs/components/BackLink/__tests__/BackLink.test.js +0 -63
  34. package/build/cjs/components/BlockBase/__tests__/BlockBase.test.d.ts +0 -1
  35. package/build/cjs/components/BlockBase/__tests__/BlockBase.test.js +0 -44
  36. package/build/cjs/components/Button/__tests__/Button.test.d.ts +0 -1
  37. package/build/cjs/components/Button/__tests__/Button.test.js +0 -91
  38. package/build/cjs/components/ButtonTabs/__tests__/ButtonTabs.test.d.ts +0 -1
  39. package/build/cjs/components/ButtonTabs/__tests__/ButtonTabs.test.js +0 -58
  40. package/build/esm/components/Anchor/__tests__/Anchor.test.d.ts +0 -1
  41. package/build/esm/components/Anchor/__tests__/Anchor.test.js +0 -18
  42. package/build/esm/components/AnimateBlock/__tests__/AnimateBlock.test.d.ts +0 -1
  43. package/build/esm/components/AnimateBlock/__tests__/AnimateBlock.test.js +0 -33
  44. package/build/esm/components/Author/__tests__/Author.test.d.ts +0 -1
  45. package/build/esm/components/Author/__tests__/Author.test.js +0 -46
  46. package/build/esm/components/BackLink/__tests__/BackLink.test.d.ts +0 -1
  47. package/build/esm/components/BackLink/__tests__/BackLink.test.js +0 -60
  48. package/build/esm/components/BlockBase/__tests__/BlockBase.test.d.ts +0 -1
  49. package/build/esm/components/BlockBase/__tests__/BlockBase.test.js +0 -41
  50. package/build/esm/components/Button/__tests__/Button.test.d.ts +0 -1
  51. package/build/esm/components/Button/__tests__/Button.test.js +0 -88
  52. package/build/esm/components/ButtonTabs/__tests__/ButtonTabs.test.d.ts +0 -1
  53. package/build/esm/components/ButtonTabs/__tests__/ButtonTabs.test.js +0 -55
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.18.0](https://github.com/gravity-ui/page-constructor/compare/v2.18.0...v2.18.0) (2023-05-15)
4
+
5
+
6
+ ### Features
7
+
8
+ * **HubspotForm:** add ref forwarding for HS form ([#332](https://github.com/gravity-ui/page-constructor/issues/332)) ([37b75d3](https://github.com/gravity-ui/page-constructor/commit/37b75d31c09e8dc061d718828bcccc72b037e106))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * config gulpfile for tests ([a5cb59d](https://github.com/gravity-ui/page-constructor/commit/a5cb59d0bc1e3a8c09babed0c5ace9a2253416c3))
14
+
3
15
  ## [2.17.0](https://github.com/gravity-ui/page-constructor/compare/v2.16.0...v2.17.0) (2023-05-12)
4
16
 
5
17
 
@@ -2,7 +2,7 @@ import { ClassNameProps } from '../../models';
2
2
  export declare const qaIdByDefault = "qa-anchor";
3
3
  export interface AnchorProps extends ClassNameProps {
4
4
  id: string;
5
- dataQa?: string;
5
+ qa?: string;
6
6
  }
7
- declare const Anchor: ({ id, className, dataQa }: AnchorProps) => JSX.Element;
7
+ declare const Anchor: ({ id, className, qa }: AnchorProps) => JSX.Element;
8
8
  export default Anchor;
@@ -7,5 +7,5 @@ const react_1 = tslib_1.__importDefault(require("react"));
7
7
  const utils_1 = require("../../utils");
8
8
  const b = (0, utils_1.block)('Anchor');
9
9
  exports.qaIdByDefault = 'qa-anchor';
10
- const Anchor = ({ id, className, dataQa }) => (react_1.default.createElement("div", { id: id, className: b(null, className), "data-qa": dataQa || exports.qaIdByDefault }));
10
+ const Anchor = ({ id, className, qa }) => (react_1.default.createElement("div", { id: id, className: b(null, className), "data-qa": qa || exports.qaIdByDefault }));
11
11
  exports.default = Anchor;
@@ -45,4 +45,7 @@ unpredictable css rules order in build */
45
45
  }
46
46
  .pc-button-block_size_xl {
47
47
  --btn-image-margin: 25px;
48
+ }
49
+ .pc-button-block_width_max .pc-button-block__text {
50
+ width: 100%;
48
51
  }
@@ -15,7 +15,7 @@ const b = (0, utils_1.block)('button-block');
15
15
  const Button = (props) => {
16
16
  const handleMetrika = (0, useMetrika_1.useMetrika)();
17
17
  const { lang, tld } = (0, react_1.useContext)(localeContext_1.LocaleContext);
18
- const { className, metrikaGoals, pixelEvents, analyticsEvents, size = 'l', theme = 'normal', url, img, onClick: onClickOrigin, text } = props, rest = tslib_1.__rest(props, ["className", "metrikaGoals", "pixelEvents", "analyticsEvents", "size", "theme", "url", "img", "onClick", "text"]);
18
+ const { className, metrikaGoals, pixelEvents, analyticsEvents, size = 'l', theme = 'normal', url, img, onClick: onClickOrigin, text, width } = props, rest = tslib_1.__rest(props, ["className", "metrikaGoals", "pixelEvents", "analyticsEvents", "size", "theme", "url", "img", "onClick", "text", "width"]);
19
19
  const defaultImgPosition = 'left';
20
20
  const handleAnalytics = (0, hooks_1.useAnalytics)(models_1.DefaultEventNames.Button, url);
21
21
  const onClick = (0, react_1.useCallback)((e) => {
@@ -29,8 +29,8 @@ const Button = (props) => {
29
29
  ? { url: img.url, position: img.position || defaultImgPosition, alt: img.alt }
30
30
  : { url: img, position: defaultImgPosition };
31
31
  const buttonClass = img
32
- ? b({ position: buttonImg.position, size, theme }, className)
33
- : b({ size, theme }, className);
32
+ ? b({ position: buttonImg.position, size, theme, width }, className)
33
+ : b({ size, theme, width }, className);
34
34
  const buttonProps = Object.assign(Object.assign({}, rest), { onClick });
35
35
  if (theme === 'app-store' || theme === 'google-play') {
36
36
  const platform = theme === 'app-store' ? uikit_1.Platform.IOS : uikit_1.Platform.ANDROID;
@@ -43,7 +43,7 @@ const Button = (props) => {
43
43
  image = undefined;
44
44
  }
45
45
  const buttonTheme = theme === 'scale' ? 'accent' : theme;
46
- return (react_1.default.createElement(uikit_1.Button, Object.assign({ className: buttonClass, view: (0, utils_2.toCommonView)(buttonTheme), size: (0, utils_2.toCommonSize)(size), href: url ? (0, utils_1.setUrlTld)(url, tld) : undefined }, buttonProps),
46
+ return (react_1.default.createElement(uikit_1.Button, Object.assign({ className: buttonClass, view: (0, utils_2.toCommonView)(buttonTheme), size: (0, utils_2.toCommonSize)(size), href: url ? (0, utils_1.setUrlTld)(url, tld) : undefined, width: width }, buttonProps),
47
47
  icon && buttonImg.position === 'left' ? icon : null,
48
48
  react_1.default.createElement("span", { className: b('content') },
49
49
  image && buttonImg.position === 'left' ? image : null,
@@ -7,4 +7,4 @@ export interface GridColumnProps extends GridColumnClassParams, Refable<HTMLDivE
7
7
  dataQa?: string;
8
8
  children?: React.ReactNode;
9
9
  }
10
- export declare const Col: React.ForwardRefExoticComponent<Pick<WithChildren<GridColumnProps>, "style" | "children" | "className" | "dataQa" | "reset" | "sizes" | "offsets" | "orders" | "hidden" | "visible" | "alignSelf" | "justifyContent"> & React.RefAttributes<HTMLDivElement>>;
10
+ export declare const Col: React.ForwardRefExoticComponent<Pick<WithChildren<GridColumnProps>, "style" | "children" | "className" | "reset" | "sizes" | "offsets" | "orders" | "hidden" | "visible" | "alignSelf" | "justifyContent" | "dataQa"> & React.RefAttributes<HTMLDivElement>>;
@@ -10,22 +10,17 @@ declare module '*.svg' {
10
10
  export default path;
11
11
  }
12
12
 
13
- interface CreateFormProps {
14
- portalId: string;
15
- formId: string;
16
- region?: string;
17
- target?: string;
18
- cssClass?: string;
19
- formInstanceId?: string;
20
- }
13
+ declare module '*.md';
21
14
 
22
- interface Window {
23
- hbspt?: {
24
- forms: {
25
- create: (args: CreateFormProps) => unknown;
26
- };
27
- };
28
- ymaps: Ymaps;
15
+ declare namespace Hbspt {
16
+ interface CreateFormProps {
17
+ portalId: string;
18
+ formId: string;
19
+ region?: string;
20
+ target?: string;
21
+ cssClass?: string;
22
+ formInstanceId?: string;
23
+ }
29
24
  }
30
25
 
31
26
  declare namespace Ymaps {
@@ -63,4 +58,11 @@ declare namespace Ymaps {
63
58
  }
64
59
  }
65
60
 
66
- declare module '*.md';
61
+ interface Window {
62
+ hbspt?: {
63
+ forms: {
64
+ create: (args: Hbspt.CreateFormProps) => unknown;
65
+ };
66
+ };
67
+ ymaps: Ymaps;
68
+ }
@@ -1,5 +1,5 @@
1
1
  import { CSSProperties, ReactNode } from 'react';
2
- import { ButtonSize, ButtonView } from '@gravity-ui/uikit';
2
+ import { ButtonView, ButtonProps as UikitButtonProps } from '@gravity-ui/uikit';
3
3
  import { ThemeSupporting } from '../../utils/theme';
4
4
  import { AnalyticsEventsBase, ClassNameProps, PixelEventType } from '../common';
5
5
  export declare enum AuthorType {
@@ -131,11 +131,10 @@ export interface FileLinkProps extends ClassNameProps {
131
131
  onClick?: () => void;
132
132
  }
133
133
  export type ButtonTheme = ButtonView | 'github' | 'app-store' | 'google-play' | 'scale' | 'monochrome';
134
- export interface ButtonProps extends AnalyticsEventsBase {
134
+ export interface ButtonProps extends AnalyticsEventsBase, Pick<UikitButtonProps, 'size' | 'width'> {
135
135
  text: string;
136
136
  url: string;
137
137
  primary?: boolean;
138
- size?: ButtonSize;
139
138
  theme?: ButtonTheme;
140
139
  img?: ButtonImageProps | string;
141
140
  metrikaGoals?: MetrikaGoal;
@@ -1,5 +1,6 @@
1
+ import React from 'react';
1
2
  import { HubspotFormProps } from '../../models';
2
3
  type HubspotFormContainerPropsKeys = 'className' | 'formId' | 'formInstanceId' | 'portalId' | 'region' | 'formClassName' | 'createDOMElement';
3
4
  type HubspotFormContainerProps = Pick<HubspotFormProps, HubspotFormContainerPropsKeys>;
4
- declare const HubspotFormContainer: (props: HubspotFormContainerProps) => JSX.Element;
5
+ declare const HubspotFormContainer: React.ForwardRefExoticComponent<HubspotFormContainerProps & React.RefAttributes<HTMLDivElement>>;
5
6
  export default HubspotFormContainer;
@@ -4,10 +4,12 @@ const tslib_1 = require("tslib");
4
4
  const react_1 = tslib_1.__importStar(require("react"));
5
5
  const hooks_1 = require("../../hooks");
6
6
  const loadHubspotScript_1 = tslib_1.__importDefault(require("./loadHubspotScript"));
7
- const HubspotFormContainer = (props) => {
7
+ const HubspotFormContainer = (0, react_1.forwardRef)((props, ref) => {
8
8
  const { className, formId, formInstanceId, portalId, region, formClassName, createDOMElement, } = props;
9
9
  const containerRef = (0, react_1.useRef)(null);
10
10
  const hsContainerRef = (0, react_1.useRef)();
11
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
12
+ (0, react_1.useImperativeHandle)(ref, () => containerRef.current);
11
13
  const containerId = formInstanceId
12
14
  ? `hubspot-form-${formId}-${formInstanceId}`
13
15
  : `hubspot-form-${formId}`;
@@ -45,5 +47,6 @@ const HubspotFormContainer = (props) => {
45
47
  };
46
48
  });
47
49
  return react_1.default.createElement("div", { className: className, id: containerId, ref: containerRef });
48
- };
50
+ });
51
+ HubspotFormContainer.displayName = 'HubspotFormContainer';
49
52
  exports.default = HubspotFormContainer;
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import { HubspotFormProps } from '../../models';
3
- declare const HubspotForm: React.FunctionComponent<HubspotFormProps>;
3
+ declare const HubspotForm: React.ForwardRefExoticComponent<HubspotFormProps & React.RefAttributes<HTMLDivElement>>;
4
4
  export default HubspotForm;
@@ -10,7 +10,7 @@ const models_1 = require("../../models");
10
10
  const utils_1 = require("../../utils");
11
11
  const HubspotFormContainer_1 = tslib_1.__importDefault(require("./HubspotFormContainer"));
12
12
  const b = (0, utils_1.block)('hubspot-form');
13
- const HubspotForm = (props) => {
13
+ const HubspotForm = (0, react_1.forwardRef)((props, ref) => {
14
14
  const { className, theme: themeProp, isMobile: isMobileProp, formId, formInstanceId, portalId, region, formClassName, pixelEvents,
15
15
  // hubspotEvents, // TODO: decide how to handle them
16
16
  analyticsEvents, onBeforeSubmit, onSubmit, onBeforeLoad, onLoad, createDOMElement, onSubmitError, } = props;
@@ -25,10 +25,10 @@ const HubspotForm = (props) => {
25
25
  onBeforeSubmit,
26
26
  onLoad,
27
27
  onSubmitError,
28
- onSubmit: (e) => {
28
+ onSubmit: (event) => {
29
29
  handleMetrika === null || handleMetrika === void 0 ? void 0 : handleMetrika({ pixelEvents });
30
30
  handleAnalytics(analyticsEvents);
31
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(e);
31
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(event);
32
32
  },
33
33
  }), [
34
34
  onBeforeLoad,
@@ -42,6 +42,7 @@ const HubspotForm = (props) => {
42
42
  onSubmitError,
43
43
  ]);
44
44
  (0, hooks_1.useHandleHubspotEvents)(handlers, formId);
45
- return (react_1.default.createElement(HubspotFormContainer_1.default, { createDOMElement: createDOMElement, key: [formClassName, formId, formInstanceId, portalId, region].join(), className: b({ theme, mobile }, className), formClassName: formClassName, formId: formId, portalId: portalId, formInstanceId: formInstanceId, region: region }));
46
- };
45
+ return (react_1.default.createElement(HubspotFormContainer_1.default, { createDOMElement: createDOMElement, key: [formClassName, formId, formInstanceId, portalId, region].join(), className: b({ theme, mobile }, className), formClassName: formClassName, formId: formId, portalId: portalId, formInstanceId: formInstanceId, region: region, ref: ref }));
46
+ });
47
+ HubspotForm.displayName = 'HubspotForm';
47
48
  exports.default = HubspotForm;
@@ -3,7 +3,7 @@ import './Anchor.css';
3
3
  export declare const qaIdByDefault = "qa-anchor";
4
4
  export interface AnchorProps extends ClassNameProps {
5
5
  id: string;
6
- dataQa?: string;
6
+ qa?: string;
7
7
  }
8
- declare const Anchor: ({ id, className, dataQa }: AnchorProps) => JSX.Element;
8
+ declare const Anchor: ({ id, className, qa }: AnchorProps) => JSX.Element;
9
9
  export default Anchor;
@@ -4,5 +4,5 @@ import { block } from '../../utils';
4
4
  import './Anchor.css';
5
5
  const b = block('Anchor');
6
6
  export const qaIdByDefault = 'qa-anchor';
7
- const Anchor = ({ id, className, dataQa }) => (React.createElement("div", { id: id, className: b(null, className), "data-qa": dataQa || qaIdByDefault }));
7
+ const Anchor = ({ id, className, qa }) => (React.createElement("div", { id: id, className: b(null, className), "data-qa": qa || qaIdByDefault }));
8
8
  export default Anchor;
@@ -45,4 +45,7 @@ unpredictable css rules order in build */
45
45
  }
46
46
  .pc-button-block_size_xl {
47
47
  --btn-image-margin: 25px;
48
+ }
49
+ .pc-button-block_width_max .pc-button-block__text {
50
+ width: 100%;
48
51
  }
@@ -14,7 +14,7 @@ const b = block('button-block');
14
14
  const Button = (props) => {
15
15
  const handleMetrika = useMetrika();
16
16
  const { lang, tld } = useContext(LocaleContext);
17
- const { className, metrikaGoals, pixelEvents, analyticsEvents, size = 'l', theme = 'normal', url, img, onClick: onClickOrigin, text } = props, rest = __rest(props, ["className", "metrikaGoals", "pixelEvents", "analyticsEvents", "size", "theme", "url", "img", "onClick", "text"]);
17
+ const { className, metrikaGoals, pixelEvents, analyticsEvents, size = 'l', theme = 'normal', url, img, onClick: onClickOrigin, text, width } = props, rest = __rest(props, ["className", "metrikaGoals", "pixelEvents", "analyticsEvents", "size", "theme", "url", "img", "onClick", "text", "width"]);
18
18
  const defaultImgPosition = 'left';
19
19
  const handleAnalytics = useAnalytics(DefaultEventNames.Button, url);
20
20
  const onClick = useCallback((e) => {
@@ -28,8 +28,8 @@ const Button = (props) => {
28
28
  ? { url: img.url, position: img.position || defaultImgPosition, alt: img.alt }
29
29
  : { url: img, position: defaultImgPosition };
30
30
  const buttonClass = img
31
- ? b({ position: buttonImg.position, size, theme }, className)
32
- : b({ size, theme }, className);
31
+ ? b({ position: buttonImg.position, size, theme, width }, className)
32
+ : b({ size, theme, width }, className);
33
33
  const buttonProps = Object.assign(Object.assign({}, rest), { onClick });
34
34
  if (theme === 'app-store' || theme === 'google-play') {
35
35
  const platform = theme === 'app-store' ? Platform.IOS : Platform.ANDROID;
@@ -42,7 +42,7 @@ const Button = (props) => {
42
42
  image = undefined;
43
43
  }
44
44
  const buttonTheme = theme === 'scale' ? 'accent' : theme;
45
- return (React.createElement(CommonButton, Object.assign({ className: buttonClass, view: toCommonView(buttonTheme), size: toCommonSize(size), href: url ? setUrlTld(url, tld) : undefined }, buttonProps),
45
+ return (React.createElement(CommonButton, Object.assign({ className: buttonClass, view: toCommonView(buttonTheme), size: toCommonSize(size), href: url ? setUrlTld(url, tld) : undefined, width: width }, buttonProps),
46
46
  icon && buttonImg.position === 'left' ? icon : null,
47
47
  React.createElement("span", { className: b('content') },
48
48
  image && buttonImg.position === 'left' ? image : null,
@@ -7,4 +7,4 @@ export interface GridColumnProps extends GridColumnClassParams, Refable<HTMLDivE
7
7
  dataQa?: string;
8
8
  children?: React.ReactNode;
9
9
  }
10
- export declare const Col: React.ForwardRefExoticComponent<Pick<WithChildren<GridColumnProps>, "style" | "children" | "className" | "dataQa" | "reset" | "sizes" | "offsets" | "orders" | "hidden" | "visible" | "alignSelf" | "justifyContent"> & React.RefAttributes<HTMLDivElement>>;
10
+ export declare const Col: React.ForwardRefExoticComponent<Pick<WithChildren<GridColumnProps>, "style" | "children" | "className" | "reset" | "sizes" | "offsets" | "orders" | "hidden" | "visible" | "alignSelf" | "justifyContent" | "dataQa"> & React.RefAttributes<HTMLDivElement>>;
@@ -10,22 +10,17 @@ declare module '*.svg' {
10
10
  export default path;
11
11
  }
12
12
 
13
- interface CreateFormProps {
14
- portalId: string;
15
- formId: string;
16
- region?: string;
17
- target?: string;
18
- cssClass?: string;
19
- formInstanceId?: string;
20
- }
13
+ declare module '*.md';
21
14
 
22
- interface Window {
23
- hbspt?: {
24
- forms: {
25
- create: (args: CreateFormProps) => unknown;
26
- };
27
- };
28
- ymaps: Ymaps;
15
+ declare namespace Hbspt {
16
+ interface CreateFormProps {
17
+ portalId: string;
18
+ formId: string;
19
+ region?: string;
20
+ target?: string;
21
+ cssClass?: string;
22
+ formInstanceId?: string;
23
+ }
29
24
  }
30
25
 
31
26
  declare namespace Ymaps {
@@ -63,4 +58,11 @@ declare namespace Ymaps {
63
58
  }
64
59
  }
65
60
 
66
- declare module '*.md';
61
+ interface Window {
62
+ hbspt?: {
63
+ forms: {
64
+ create: (args: Hbspt.CreateFormProps) => unknown;
65
+ };
66
+ };
67
+ ymaps: Ymaps;
68
+ }
@@ -1,5 +1,5 @@
1
1
  import { CSSProperties, ReactNode } from 'react';
2
- import { ButtonSize, ButtonView } from '@gravity-ui/uikit';
2
+ import { ButtonView, ButtonProps as UikitButtonProps } from '@gravity-ui/uikit';
3
3
  import { ThemeSupporting } from '../../utils/theme';
4
4
  import { AnalyticsEventsBase, ClassNameProps, PixelEventType } from '../common';
5
5
  export declare enum AuthorType {
@@ -131,11 +131,10 @@ export interface FileLinkProps extends ClassNameProps {
131
131
  onClick?: () => void;
132
132
  }
133
133
  export type ButtonTheme = ButtonView | 'github' | 'app-store' | 'google-play' | 'scale' | 'monochrome';
134
- export interface ButtonProps extends AnalyticsEventsBase {
134
+ export interface ButtonProps extends AnalyticsEventsBase, Pick<UikitButtonProps, 'size' | 'width'> {
135
135
  text: string;
136
136
  url: string;
137
137
  primary?: boolean;
138
- size?: ButtonSize;
139
138
  theme?: ButtonTheme;
140
139
  img?: ButtonImageProps | string;
141
140
  metrikaGoals?: MetrikaGoal;
@@ -1,5 +1,6 @@
1
+ import React from 'react';
1
2
  import { HubspotFormProps } from '../../models';
2
3
  type HubspotFormContainerPropsKeys = 'className' | 'formId' | 'formInstanceId' | 'portalId' | 'region' | 'formClassName' | 'createDOMElement';
3
4
  type HubspotFormContainerProps = Pick<HubspotFormProps, HubspotFormContainerPropsKeys>;
4
- declare const HubspotFormContainer: (props: HubspotFormContainerProps) => JSX.Element;
5
+ declare const HubspotFormContainer: React.ForwardRefExoticComponent<HubspotFormContainerProps & React.RefAttributes<HTMLDivElement>>;
5
6
  export default HubspotFormContainer;
@@ -1,10 +1,12 @@
1
- import React, { useRef } from 'react';
1
+ import React, { forwardRef, useImperativeHandle, useRef } from 'react';
2
2
  import { useMount } from '../../hooks';
3
3
  import loadHubspotScript from './loadHubspotScript';
4
- const HubspotFormContainer = (props) => {
4
+ const HubspotFormContainer = forwardRef((props, ref) => {
5
5
  const { className, formId, formInstanceId, portalId, region, formClassName, createDOMElement, } = props;
6
6
  const containerRef = useRef(null);
7
7
  const hsContainerRef = useRef();
8
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
9
+ useImperativeHandle(ref, () => containerRef.current);
8
10
  const containerId = formInstanceId
9
11
  ? `hubspot-form-${formId}-${formInstanceId}`
10
12
  : `hubspot-form-${formId}`;
@@ -42,5 +44,6 @@ const HubspotFormContainer = (props) => {
42
44
  };
43
45
  });
44
46
  return React.createElement("div", { className: className, id: containerId, ref: containerRef });
45
- };
47
+ });
48
+ HubspotFormContainer.displayName = 'HubspotFormContainer';
46
49
  export default HubspotFormContainer;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  import { HubspotFormProps } from '../../models';
3
3
  import './HubspotForm.css';
4
- declare const HubspotForm: React.FunctionComponent<HubspotFormProps>;
4
+ declare const HubspotForm: React.ForwardRefExoticComponent<HubspotFormProps & React.RefAttributes<HTMLDivElement>>;
5
5
  export default HubspotForm;
@@ -1,4 +1,4 @@
1
- import React, { useContext, useMemo } from 'react';
1
+ import React, { forwardRef, useContext, useMemo } from 'react';
2
2
  import { MobileContext } from '../../context/mobileContext';
3
3
  import { ThemeValueContext } from '../../context/theme/ThemeValueContext';
4
4
  import { useAnalytics, useHandleHubspotEvents } from '../../hooks';
@@ -8,7 +8,7 @@ import { block } from '../../utils';
8
8
  import HubspotFormContainer from './HubspotFormContainer';
9
9
  import './HubspotForm.css';
10
10
  const b = block('hubspot-form');
11
- const HubspotForm = (props) => {
11
+ const HubspotForm = forwardRef((props, ref) => {
12
12
  const { className, theme: themeProp, isMobile: isMobileProp, formId, formInstanceId, portalId, region, formClassName, pixelEvents,
13
13
  // hubspotEvents, // TODO: decide how to handle them
14
14
  analyticsEvents, onBeforeSubmit, onSubmit, onBeforeLoad, onLoad, createDOMElement, onSubmitError, } = props;
@@ -23,10 +23,10 @@ const HubspotForm = (props) => {
23
23
  onBeforeSubmit,
24
24
  onLoad,
25
25
  onSubmitError,
26
- onSubmit: (e) => {
26
+ onSubmit: (event) => {
27
27
  handleMetrika === null || handleMetrika === void 0 ? void 0 : handleMetrika({ pixelEvents });
28
28
  handleAnalytics(analyticsEvents);
29
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(e);
29
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(event);
30
30
  },
31
31
  }), [
32
32
  onBeforeLoad,
@@ -40,6 +40,7 @@ const HubspotForm = (props) => {
40
40
  onSubmitError,
41
41
  ]);
42
42
  useHandleHubspotEvents(handlers, formId);
43
- return (React.createElement(HubspotFormContainer, { createDOMElement: createDOMElement, key: [formClassName, formId, formInstanceId, portalId, region].join(), className: b({ theme, mobile }, className), formClassName: formClassName, formId: formId, portalId: portalId, formInstanceId: formInstanceId, region: region }));
44
- };
43
+ return (React.createElement(HubspotFormContainer, { createDOMElement: createDOMElement, key: [formClassName, formId, formInstanceId, portalId, region].join(), className: b({ theme, mobile }, className), formClassName: formClassName, formId: formId, portalId: portalId, formInstanceId: formInstanceId, region: region, ref: ref }));
44
+ });
45
+ HubspotForm.displayName = 'HubspotForm';
45
46
  export default HubspotForm;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/page-constructor",
3
- "version": "2.17.0",
3
+ "version": "2.19.0-alpha.0",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -138,5 +138,8 @@
138
138
  "*.{json,yaml,yml,md}": [
139
139
  "prettier --write"
140
140
  ]
141
+ },
142
+ "publishConfig": {
143
+ "tag": "alpha"
141
144
  }
142
145
  }
@@ -1,5 +1,5 @@
1
1
  import { CSSProperties, ReactNode } from 'react';
2
- import { ButtonSize, ButtonView } from '@gravity-ui/uikit';
2
+ import { ButtonView, ButtonProps as UikitButtonProps } from '@gravity-ui/uikit';
3
3
  import { ThemeSupporting } from '../../utils/theme';
4
4
  import { AnalyticsEventsBase, ClassNameProps, PixelEventType } from '../common';
5
5
  export declare enum AuthorType {
@@ -131,11 +131,10 @@ export interface FileLinkProps extends ClassNameProps {
131
131
  onClick?: () => void;
132
132
  }
133
133
  export type ButtonTheme = ButtonView | 'github' | 'app-store' | 'google-play' | 'scale' | 'monochrome';
134
- export interface ButtonProps extends AnalyticsEventsBase {
134
+ export interface ButtonProps extends AnalyticsEventsBase, Pick<UikitButtonProps, 'size' | 'width'> {
135
135
  text: string;
136
136
  url: string;
137
137
  primary?: boolean;
138
- size?: ButtonSize;
139
138
  theme?: ButtonTheme;
140
139
  img?: ButtonImageProps | string;
141
140
  metrikaGoals?: MetrikaGoal;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const react_1 = tslib_1.__importDefault(require("react"));
5
- const react_2 = require("@testing-library/react");
6
- const Anchor_1 = tslib_1.__importDefault(require("../Anchor"));
7
- const testId = 'anchor';
8
- const anchorId = 'anchorId';
9
- describe('Anchor', () => {
10
- test('Has id', async () => {
11
- (0, react_2.render)(react_1.default.createElement(Anchor_1.default, { id: anchorId, dataQa: testId }));
12
- const anchor = react_2.screen.getByTestId(testId);
13
- expect(anchor).toHaveAttribute('id', anchorId);
14
- });
15
- test('Has custom class', async () => {
16
- const className = 'custom-anchor-class';
17
- (0, react_2.render)(react_1.default.createElement(Anchor_1.default, { id: anchorId, className: className, dataQa: testId }));
18
- const anchor = react_2.screen.getByTestId(testId);
19
- expect(anchor).toHaveClass(className);
20
- });
21
- });
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const react_1 = tslib_1.__importDefault(require("react"));
5
- const react_2 = require("@testing-library/react");
6
- const user_event_1 = tslib_1.__importDefault(require("@testing-library/user-event"));
7
- const AnimateBlock_1 = tslib_1.__importDefault(require("../AnimateBlock"));
8
- const qaId = 'animate-block';
9
- describe('AnimateBlock', () => {
10
- test('render AnimateBlock by default', async () => {
11
- (0, react_2.render)(react_1.default.createElement(AnimateBlock_1.default, { qa: qaId }));
12
- const component = react_2.screen.getByTestId(qaId);
13
- expect(component).toBeInTheDocument();
14
- });
15
- test('add className', () => {
16
- const className = 'my-class';
17
- (0, react_2.render)(react_1.default.createElement(AnimateBlock_1.default, { qa: qaId, className: className }));
18
- const component = react_2.screen.getByTestId(qaId);
19
- expect(component).toHaveClass(className);
20
- });
21
- test('use passed style', () => {
22
- const style = { color: 'red' };
23
- (0, react_2.render)(react_1.default.createElement(AnimateBlock_1.default, { style: style, qa: qaId }));
24
- const component = react_2.screen.getByTestId(qaId);
25
- expect(component).toHaveStyle(style);
26
- });
27
- test('call onScroll', async () => {
28
- const onScroll = jest.fn();
29
- const user = user_event_1.default.setup();
30
- (0, react_2.render)(react_1.default.createElement("div", { style: { paddingTop: 100000 } },
31
- react_1.default.createElement(AnimateBlock_1.default, { onScroll: onScroll, qa: qaId })));
32
- const component = react_2.screen.getByTestId(qaId);
33
- await user.hover(component);
34
- expect(onScroll).toHaveBeenCalledTimes(1);
35
- });
36
- });
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const react_1 = tslib_1.__importDefault(require("react"));
5
- const react_2 = require("@testing-library/react");
6
- const models_1 = require("../../../models");
7
- const Author_1 = tslib_1.__importDefault(require("../Author"));
8
- const testId = 'author';
9
- const author = {
10
- firstName: 'John',
11
- secondName: 'Doe',
12
- description: 'Web designer',
13
- avatar: 'https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/img-gray.png',
14
- };
15
- describe('Author', () => {
16
- test('Render author by default', async () => {
17
- (0, react_2.render)(react_1.default.createElement(Author_1.default, { author: author, dataQa: testId }));
18
- const object = react_2.screen.getByTestId(testId);
19
- expect(object).toBeInTheDocument();
20
- });
21
- test('Has full name', async () => {
22
- const name = `${author.firstName} ${author.secondName}`;
23
- (0, react_2.render)(react_1.default.createElement(Author_1.default, { author: author, dataQa: testId }));
24
- const object = react_2.screen.getByText(name);
25
- expect(object).toBeInTheDocument();
26
- });
27
- test('Has first name only', async () => {
28
- const name = author.firstName;
29
- (0, react_2.render)(react_1.default.createElement(Author_1.default, { author: Object.assign(Object.assign({}, author), { secondName: '' }), dataQa: testId }));
30
- const object = react_2.screen.getByText(name);
31
- expect(object).toBeInTheDocument();
32
- });
33
- test('Has avatar', async () => {
34
- (0, react_2.render)(react_1.default.createElement(Author_1.default, { author: author, dataQa: testId }));
35
- const avatar = react_2.screen.getByRole('img');
36
- expect(avatar).toBeInTheDocument();
37
- expect(avatar).toHaveAttribute('src', author.avatar);
38
- });
39
- test('Has description', async () => {
40
- (0, react_2.render)(react_1.default.createElement(Author_1.default, { author: author, dataQa: testId }));
41
- const object = react_2.screen.getByText(author.description);
42
- expect(object).toBeInTheDocument();
43
- });
44
- test.each(new Array(models_1.AuthorType.Column, models_1.AuthorType.Line))('Render with given "%s" type', (type) => {
45
- (0, react_2.render)(react_1.default.createElement(Author_1.default, { author: author, dataQa: testId, type: type }));
46
- const object = react_2.screen.getByTestId(testId);
47
- expect(object).toHaveClass(`pc-author_type_${type}`);
48
- });
49
- });