@gravity-ui/page-constructor 4.15.1-alpha.0 → 4.15.2
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/build/cjs/blocks/Header/Header.css +2 -4
- package/build/cjs/blocks/HeaderSlider/schema.js +2 -2
- package/build/cjs/blocks/Info/schema.js +2 -2
- package/build/cjs/blocks/Media/schema.js +3 -2
- package/build/cjs/blocks/Questions/schema.js +2 -2
- package/build/cjs/blocks/Slider/Slider.js +6 -4
- package/build/cjs/blocks/Slider/utils.js +2 -2
- package/build/cjs/blocks/Tabs/schema.js +2 -2
- package/build/cjs/components/BalancedMasonry/BalancedMasonry.js +6 -4
- package/build/cjs/components/CardBase/CardBase.d.ts +1 -0
- package/build/cjs/components/CardBase/CardBase.js +7 -6
- package/build/cjs/components/FullWidthBackground/FullWidthBackground.js +2 -2
- package/build/cjs/components/Image/Image.d.ts +5 -0
- package/build/cjs/components/Image/Image.js +7 -8
- package/build/cjs/components/Map/GoogleMap.js +2 -2
- package/build/cjs/components/Map/YMap/YandexMap.js +2 -2
- package/build/cjs/components/Media/Image/Image.js +2 -2
- package/build/cjs/components/OverflowScroller/OverflowScroller.js +2 -2
- package/build/cjs/components/ReactPlayer/ReactPlayer.js +2 -2
- package/build/cjs/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.js +2 -2
- package/build/cjs/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +2 -2
- package/build/cjs/editor/components/BlockForm/BlockForm.js +4 -3
- package/build/cjs/editor/components/PagePropsForm/PagePropsForm.js +2 -2
- package/build/cjs/editor/dynamic-forms-custom/components/OneOfCustom/OneOfCustom.js +2 -2
- package/build/cjs/editor/dynamic-forms-custom/config.js +2 -2
- package/build/cjs/editor/dynamic-forms-custom/hooks/useOneOf.js +5 -4
- package/build/cjs/editor/store/utils.js +2 -2
- package/build/cjs/editor/utils/index.js +2 -2
- package/build/cjs/hooks/useFocus.js +2 -2
- package/build/cjs/hooks/useHeightCalculator.js +2 -2
- package/build/cjs/hooks/useWindowBreakpoint.js +2 -2
- package/build/cjs/navigation/components/Navigation/Navigation.js +2 -2
- package/build/cjs/navigation/components/NavigationItem/NavigationItem.css +3 -0
- package/build/cjs/navigation/components/NavigationItem/NavigationItem.js +2 -2
- package/build/cjs/navigation/components/NavigationPopup/NavigationPopup.css +0 -1
- package/build/cjs/navigation/schema.js +3 -2
- package/build/cjs/sub-blocks/BackgroundCard/schema.js +2 -2
- package/build/cjs/sub-blocks/BasicCard/schema.js +2 -2
- package/build/cjs/sub-blocks/LayoutItem/schema.js +2 -2
- package/build/cjs/sub-blocks/PriceDetailed/CombinedPriceDetailed/CombinedPriceDetailed.js +4 -4
- package/build/cjs/text-transform/config.js +2 -0
- package/build/cjs/text-transform/transformers.js +4 -3
- package/build/cjs/text-transform/utils.d.ts +0 -2
- package/build/cjs/text-transform/utils.js +26 -7
- package/build/cjs/utils/blocks.js +5 -3
- package/build/esm/blocks/Header/Header.css +2 -4
- package/build/esm/blocks/HeaderSlider/schema.js +2 -2
- package/build/esm/blocks/Info/schema.js +2 -2
- package/build/esm/blocks/Media/schema.js +1 -1
- package/build/esm/blocks/Questions/schema.js +2 -2
- package/build/esm/blocks/Slider/Slider.js +6 -4
- package/build/esm/blocks/Slider/utils.js +2 -2
- package/build/esm/blocks/Tabs/schema.js +2 -2
- package/build/esm/components/BalancedMasonry/BalancedMasonry.js +6 -4
- package/build/esm/components/CardBase/CardBase.d.ts +1 -0
- package/build/esm/components/CardBase/CardBase.js +8 -7
- package/build/esm/components/FullWidthBackground/FullWidthBackground.js +2 -2
- package/build/esm/components/Image/Image.d.ts +5 -0
- package/build/esm/components/Image/Image.js +7 -8
- package/build/esm/components/Map/GoogleMap.js +2 -2
- package/build/esm/components/Map/YMap/YandexMap.js +2 -2
- package/build/esm/components/Media/Image/Image.js +2 -2
- package/build/esm/components/OverflowScroller/OverflowScroller.js +2 -2
- package/build/esm/components/ReactPlayer/ReactPlayer.js +2 -2
- package/build/esm/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.js +2 -2
- package/build/esm/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +2 -2
- package/build/esm/editor/components/BlockForm/BlockForm.js +4 -3
- package/build/esm/editor/components/PagePropsForm/PagePropsForm.js +2 -2
- package/build/esm/editor/dynamic-forms-custom/components/OneOfCustom/OneOfCustom.js +2 -2
- package/build/esm/editor/dynamic-forms-custom/config.js +2 -2
- package/build/esm/editor/dynamic-forms-custom/hooks/useOneOf.js +5 -4
- package/build/esm/editor/store/utils.js +2 -2
- package/build/esm/editor/utils/index.js +2 -2
- package/build/esm/hooks/useFocus.js +2 -2
- package/build/esm/hooks/useHeightCalculator.js +2 -2
- package/build/esm/hooks/useWindowBreakpoint.js +2 -2
- package/build/esm/navigation/components/Navigation/Navigation.js +2 -2
- package/build/esm/navigation/components/NavigationItem/NavigationItem.css +3 -0
- package/build/esm/navigation/components/NavigationItem/NavigationItem.js +1 -1
- package/build/esm/navigation/components/NavigationPopup/NavigationPopup.css +0 -1
- package/build/esm/navigation/schema.js +1 -1
- package/build/esm/sub-blocks/BackgroundCard/schema.js +2 -2
- package/build/esm/sub-blocks/BasicCard/schema.js +2 -2
- package/build/esm/sub-blocks/LayoutItem/schema.js +1 -1
- package/build/esm/sub-blocks/PriceDetailed/CombinedPriceDetailed/CombinedPriceDetailed.js +4 -4
- package/build/esm/text-transform/config.js +2 -0
- package/build/esm/text-transform/transformers.js +4 -3
- package/build/esm/text-transform/utils.d.ts +0 -2
- package/build/esm/text-transform/utils.js +25 -5
- package/build/esm/utils/blocks.js +2 -1
- package/package.json +1 -1
- package/server/text-transform/config.js +2 -0
- package/server/text-transform/transformers.js +4 -3
- package/server/text-transform/utils.d.ts +0 -2
- package/server/text-transform/utils.js +26 -7
- package/server/utils/blocks.js +7 -3
- package/widget/index.js +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useCallback, useContext, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { Spin } from '@gravity-ui/uikit';
|
|
3
|
-
import
|
|
3
|
+
import debounce from 'lodash/debounce';
|
|
4
4
|
import { LocaleContext } from '../../../context/localeContext/localeContext';
|
|
5
5
|
import { MapsContext } from '../../../context/mapsContext/mapsContext';
|
|
6
6
|
import { MobileContext } from '../../../context/mobileContext';
|
|
@@ -47,7 +47,7 @@ const YandexMap = (props) => {
|
|
|
47
47
|
})();
|
|
48
48
|
}, [apiKey, lang, scriptSrc, containerId, zoom, nonce, attemptsIndex, setLoading]);
|
|
49
49
|
useEffect(() => {
|
|
50
|
-
const updateSize =
|
|
50
|
+
const updateSize = debounce(() => {
|
|
51
51
|
if (ref.current) {
|
|
52
52
|
setHeight(Math.round(getMapHeight(ref.current.offsetWidth, isMobile)));
|
|
53
53
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import debounce from 'lodash/debounce';
|
|
3
3
|
import { animated, config, useSpring } from 'react-spring';
|
|
4
4
|
import SliderBlock from '../../../blocks/Slider/Slider';
|
|
5
5
|
import { SliderType } from '../../../models';
|
|
@@ -23,7 +23,7 @@ const Image = (props) => {
|
|
|
23
23
|
useEffect(() => {
|
|
24
24
|
if (parallax) {
|
|
25
25
|
const handleScroll = () => setScrollY(window.scrollY);
|
|
26
|
-
const debouncedHandler =
|
|
26
|
+
const debouncedHandler = debounce(handleScroll, 5);
|
|
27
27
|
window.addEventListener('scroll', debouncedHandler, { passive: true });
|
|
28
28
|
return () => window.removeEventListener('scroll', debouncedHandler);
|
|
29
29
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { createRef } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import debounce from 'lodash/debounce';
|
|
3
3
|
import { ToggleArrow } from '..';
|
|
4
4
|
import { block } from '../../utils';
|
|
5
5
|
import './OverflowScroller.css';
|
|
@@ -17,7 +17,7 @@ export default class OverflowScroller extends React.Component {
|
|
|
17
17
|
this.containerRef = createRef();
|
|
18
18
|
this.wrapperRef = createRef();
|
|
19
19
|
// eslint-disable-next-line @typescript-eslint/member-ordering, react/sort-comp
|
|
20
|
-
this.checkOverflow =
|
|
20
|
+
this.checkOverflow = debounce(() => {
|
|
21
21
|
if (this.containerRef &&
|
|
22
22
|
this.containerRef.current &&
|
|
23
23
|
this.wrapperRef &&
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { Fragment, useCallback, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState, } from 'react';
|
|
2
2
|
import { Icon } from '@gravity-ui/uikit';
|
|
3
|
-
import
|
|
3
|
+
import debounce from 'lodash/debounce';
|
|
4
4
|
import ReactPlayer from 'react-player';
|
|
5
5
|
import { MetrikaContext } from '../../context/metrikaContext';
|
|
6
6
|
import { MobileContext } from '../../context/mobileContext';
|
|
@@ -75,7 +75,7 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
75
75
|
}
|
|
76
76
|
}, [elapsedTime, playerRef, started]);
|
|
77
77
|
useEffect(() => {
|
|
78
|
-
const updateSize =
|
|
78
|
+
const updateSize = debounce(() => {
|
|
79
79
|
if (ref.current) {
|
|
80
80
|
// We need to get parent's width does not equal 0
|
|
81
81
|
const parentElement = getParentElement(ref.current);
|
package/build/esm/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import pick from 'lodash/pick';
|
|
3
3
|
import BlockBase from '../../../../components/BlockBase/BlockBase';
|
|
4
4
|
import { BlockDecoration } from '../../../../customization/BlockDecoration';
|
|
5
5
|
import { block } from '../../../../utils';
|
|
@@ -7,7 +7,7 @@ import './ConstructorBlock.css';
|
|
|
7
7
|
const b = block('constructor-block');
|
|
8
8
|
export const ConstructorBlock = ({ index = 0, data, children, }) => {
|
|
9
9
|
const { type, indent } = data;
|
|
10
|
-
const blockBaseProps = useMemo(() =>
|
|
10
|
+
const blockBaseProps = useMemo(() => pick(data, ['anchor', 'visible', 'resetPaddings']), [data]);
|
|
11
11
|
const { top, bottom } = indent || { top: 'l', bottom: 'l' };
|
|
12
12
|
return (React.createElement(BlockDecoration, Object.assign({ type: type, index: index }, blockBaseProps),
|
|
13
13
|
React.createElement(BlockBase, Object.assign({ className: b({ type, indentTop: top, indentBottom: bottom }) }, blockBaseProps), children)));
|
package/build/esm/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { Fragment, useContext } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import get from 'lodash/get';
|
|
3
3
|
import { InnerContext } from '../../../../context/innerContext';
|
|
4
4
|
import { BlockDecoration } from '../../../../customization/BlockDecoration';
|
|
5
5
|
import { getBlockKey } from '../../../../utils';
|
|
@@ -20,7 +20,7 @@ export const ConstructorBlocks = ({ items }) => {
|
|
|
20
20
|
}
|
|
21
21
|
if ('loadable' in item && item.loadable) {
|
|
22
22
|
const { source, serviceId, params } = item.loadable;
|
|
23
|
-
const config =
|
|
23
|
+
const config = get(loadables, source);
|
|
24
24
|
if (!config) {
|
|
25
25
|
return null;
|
|
26
26
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import React, { Fragment, memo, useMemo } from 'react';
|
|
3
3
|
import { DynamicField, SimpleVerticalAccordeon } from '@gravity-ui/dynamic-forms';
|
|
4
|
-
import
|
|
4
|
+
import isEqual from 'lodash/isEqual';
|
|
5
|
+
import noop from 'lodash/noop';
|
|
5
6
|
import { Form as FinalForm, FormSpy } from 'react-final-form';
|
|
6
7
|
import { dynamicConfig } from '../../dynamic-forms-custom/config';
|
|
7
8
|
import usePreviousValue from '../../hooks/usePreviousValue';
|
|
@@ -13,10 +14,10 @@ export const BlockForm = memo((_a) => {
|
|
|
13
14
|
if (!active) {
|
|
14
15
|
return (React.createElement(SimpleVerticalAccordeon, { open: false, name: type, title: spec.viewSpec.layoutTitle || type, onOpenChange: onSelect }, ' '));
|
|
15
16
|
}
|
|
16
|
-
return (React.createElement(FinalForm, { initialValues: initialValues, onSubmit:
|
|
17
|
+
return (React.createElement(FinalForm, { initialValues: initialValues, onSubmit: noop }, () => (React.createElement(Fragment, null,
|
|
17
18
|
React.createElement(FormSpy, { onChange: ({ values }) => {
|
|
18
19
|
// fix for FormSpy onChange called twice without content changes
|
|
19
|
-
if (!
|
|
20
|
+
if (!isEqual(values.content, prevContent)) {
|
|
20
21
|
onChange(Object.assign({ type }, values.content));
|
|
21
22
|
}
|
|
22
23
|
}, subscription: { values: true } }),
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { memo, useMemo } from 'react';
|
|
2
2
|
import { DynamicField } from '@gravity-ui/dynamic-forms';
|
|
3
|
-
import
|
|
3
|
+
import noop from 'lodash/noop';
|
|
4
4
|
import { Form as FinalForm, FormSpy } from 'react-final-form';
|
|
5
5
|
import { dynamicConfig } from '../../dynamic-forms-custom/config';
|
|
6
6
|
export const PagePropsForm = memo(({ data: content, spec, onChange }) => {
|
|
7
7
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
8
8
|
const initialValues = useMemo(() => ({ content }), []);
|
|
9
|
-
return (React.createElement(FinalForm, { initialValues: initialValues, onSubmit:
|
|
9
|
+
return (React.createElement(FinalForm, { initialValues: initialValues, onSubmit: noop }, () => (React.createElement("div", null,
|
|
10
10
|
React.createElement(FormSpy, { onChange: ({ values }) => onChange(Object.assign({}, values.content)), subscription: { values: true } }),
|
|
11
11
|
React.createElement(DynamicField, { name: "content", spec: spec, config: dynamicConfig })))));
|
|
12
12
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import { Controller, GroupIndent, SpecTypes, transformArrOut, } from '@gravity-ui/dynamic-forms';
|
|
3
3
|
import Ajv from 'ajv';
|
|
4
|
-
import
|
|
4
|
+
import isEmpty from 'lodash/isEmpty';
|
|
5
5
|
import { block } from '../../../../utils';
|
|
6
6
|
import { getSpecTypeDefaultValue, useOneOf } from '../../hooks/useOneOf';
|
|
7
7
|
import './OneOfCustom.css';
|
|
@@ -17,7 +17,7 @@ const getOneOfCustomSpecDefaultType = (spec) => { var _a, _b; return ((_b = (_a
|
|
|
17
17
|
// dynamic-forms pass {} as default value for required properties of all types
|
|
18
18
|
// this function replaces {} with default value accordingly to selected OneOf option spec type
|
|
19
19
|
const getControllerDefautValue = (value, valueSpecType) => {
|
|
20
|
-
const isDefaultValue = typeof value === 'object' &&
|
|
20
|
+
const isDefaultValue = typeof value === 'object' && isEmpty(value);
|
|
21
21
|
const defaultValue = valueSpecType ? getSpecTypeDefaultValue(valueSpecType) : undefined;
|
|
22
22
|
return isDefaultValue ? defaultValue : value;
|
|
23
23
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { dynamicConfig as libConfig } from '@gravity-ui/dynamic-forms';
|
|
2
|
-
import
|
|
2
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
3
3
|
import { OneOfCustom } from './components/OneOfCustom/OneOfCustom';
|
|
4
4
|
const getDynamicConfig = () => {
|
|
5
|
-
const dynamicConfig =
|
|
5
|
+
const dynamicConfig = cloneDeep(libConfig);
|
|
6
6
|
dynamicConfig.object.inputs['oneof_custom'] = { Component: OneOfCustom, independent: true };
|
|
7
7
|
return dynamicConfig;
|
|
8
8
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { SpecTypes, } from '@gravity-ui/dynamic-forms';
|
|
3
3
|
import { RadioButton, Select } from '@gravity-ui/uikit';
|
|
4
|
-
import
|
|
4
|
+
import isObjectLike from 'lodash/isObjectLike';
|
|
5
|
+
import some from 'lodash/some';
|
|
5
6
|
const MAX_TAB_TITLE_LENGTH = 20;
|
|
6
7
|
export const getSpecTypeDefaultValue = (type) => {
|
|
7
8
|
switch (type) {
|
|
@@ -18,10 +19,10 @@ export const getSpecTypeDefaultValue = (type) => {
|
|
|
18
19
|
export const useOneOf = ({ props, onTogglerChange }) => {
|
|
19
20
|
const { name, input, spec, Layout } = props;
|
|
20
21
|
const { order, disabled, oneOfParams } = spec.viewSpec;
|
|
21
|
-
const specProperties = React.useMemo(() => (
|
|
22
|
+
const specProperties = React.useMemo(() => (isObjectLike(spec.properties) ? spec.properties : {}), [spec.properties]);
|
|
22
23
|
const [oneOfValue, setOneOfValue] = React.useState(() => {
|
|
23
24
|
let valueKeys;
|
|
24
|
-
if (
|
|
25
|
+
if (isObjectLike(input.value)) {
|
|
25
26
|
const keys = Object.keys(input.value);
|
|
26
27
|
if (keys.length) {
|
|
27
28
|
valueKeys = keys;
|
|
@@ -54,7 +55,7 @@ export const useOneOf = ({ props, onTogglerChange }) => {
|
|
|
54
55
|
if ((oneOfParams === null || oneOfParams === void 0 ? void 0 : oneOfParams.toggler) !== 'radio' &&
|
|
55
56
|
((oneOfParams === null || oneOfParams === void 0 ? void 0 : oneOfParams.toggler) === 'select' ||
|
|
56
57
|
options.length > 3 ||
|
|
57
|
-
|
|
58
|
+
some(options, ({ title }) => title.length > MAX_TAB_TITLE_LENGTH))) {
|
|
58
59
|
return (React.createElement(Select, { width: "max", value: [oneOfValue], onUpdate: onOneOfChange, options: options, disabled: disabled, filterable: options.length > 7, qa: name }));
|
|
59
60
|
}
|
|
60
61
|
return (React.createElement(RadioButton, { value: oneOfValue, onChange: (event) => onOneOfChange([event.target.value]), disabled: disabled, qa: name }, options.map(({ value, title }) => (React.createElement(RadioButton.Option, { key: value, value: value }, title)))));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
2
2
|
export const changeBlocksOrder = (array, oldIndex, newIndex) => {
|
|
3
3
|
const result = [...array];
|
|
4
4
|
const element = result.splice(oldIndex, 1)[0];
|
|
@@ -7,7 +7,7 @@ export const changeBlocksOrder = (array, oldIndex, newIndex) => {
|
|
|
7
7
|
};
|
|
8
8
|
export const duplicateBlock = (array, index) => {
|
|
9
9
|
const result = [...array];
|
|
10
|
-
result.splice(index + 1, 0,
|
|
10
|
+
result.splice(index + 1, 0, cloneDeep(result[index]));
|
|
11
11
|
return result;
|
|
12
12
|
};
|
|
13
13
|
export const getNewBlockIndex = (id, orderedBlocksCount) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import capitalize from 'lodash/capitalize';
|
|
2
2
|
import { ViewModeItem } from '../types';
|
|
3
|
-
export const formatBlockName = (name) =>
|
|
3
|
+
export const formatBlockName = (name) => capitalize(name).replace(/(block|-)/g, ' ');
|
|
4
4
|
export const addCustomDecorator = (decorators, custom = {}) => {
|
|
5
5
|
const customDecorators = custom.decorators || {};
|
|
6
6
|
return Object.assign(Object.assign({}, custom), { decorators: Object.assign(Object.assign({}, customDecorators), { block: [...(customDecorators.block || []), ...decorators] }) });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useContext, useEffect, useState } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import noop from 'lodash/noop';
|
|
3
3
|
import { MobileContext } from '../context/mobileContext';
|
|
4
4
|
export default function useFocus(element) {
|
|
5
5
|
const isMobile = useContext(MobileContext);
|
|
@@ -25,7 +25,7 @@ export default function useFocus(element) {
|
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
return
|
|
28
|
+
return noop;
|
|
29
29
|
}, [element, isMobile, setFocus, unsetFocus]);
|
|
30
30
|
return {
|
|
31
31
|
hasFocus,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import debounce from 'lodash/debounce';
|
|
3
3
|
const DEFAULT_RECALCULATE_ON_RESIZE_DELAY = 1000;
|
|
4
4
|
const DEFAULT_OPTIONS = {
|
|
5
5
|
recalculateOnResizeDelay: DEFAULT_RECALCULATE_ON_RESIZE_DELAY,
|
|
@@ -12,7 +12,7 @@ const useHeightCalculator = (containerRef, options = DEFAULT_OPTIONS) => {
|
|
|
12
12
|
setContainerHeight(containerRef.current.offsetHeight);
|
|
13
13
|
}, [containerRef, containerHeight, setContainerHeight]);
|
|
14
14
|
useEffect(() => {
|
|
15
|
-
const handleResize =
|
|
15
|
+
const handleResize = debounce(calculateContainerHeight, recalculateOnResizeDelay);
|
|
16
16
|
handleResize();
|
|
17
17
|
window.addEventListener('resize', handleResize, { passive: true });
|
|
18
18
|
return () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import debounce from 'lodash/debounce';
|
|
3
3
|
import { BREAKPOINTS } from '../constants';
|
|
4
4
|
function calculate(windowWidth) {
|
|
5
5
|
const breakpointsSorted = Object.values(BREAKPOINTS).sort((b1, b2) => b1 - b2);
|
|
@@ -18,7 +18,7 @@ export default function useWindowBreakpoint() {
|
|
|
18
18
|
const [breakpoint, setBreakpoint] = useState(BREAKPOINTS.sm);
|
|
19
19
|
useEffect(() => {
|
|
20
20
|
setBreakpoint(calculate(window.innerWidth));
|
|
21
|
-
const detect =
|
|
21
|
+
const detect = debounce(() => {
|
|
22
22
|
setBreakpoint(calculate(window.innerWidth));
|
|
23
23
|
}, 100);
|
|
24
24
|
detect();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import debounce from 'lodash/debounce';
|
|
3
3
|
import OutsideClick from '../../../components/OutsideClick/OutsideClick';
|
|
4
4
|
import { Col, Grid, Row } from '../../../grid';
|
|
5
5
|
import { block } from '../../../utils';
|
|
@@ -26,7 +26,7 @@ export const Navigation = ({ data, logo }) => {
|
|
|
26
26
|
setShowBorder(window.scrollY > 0);
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
|
-
const scrollHandler =
|
|
29
|
+
const scrollHandler = debounce(showBorderOnScroll, 20);
|
|
30
30
|
window.addEventListener('scroll', scrollHandler, { passive: true });
|
|
31
31
|
return () => window.removeEventListener('scroll', scrollHandler);
|
|
32
32
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import React, { useContext, useMemo } from 'react';
|
|
3
|
-
import
|
|
3
|
+
import omit from 'lodash/omit';
|
|
4
4
|
import { BlockIdContext } from '../../../context/blockIdContext';
|
|
5
5
|
import { InnerContext } from '../../../context/innerContext';
|
|
6
6
|
import { NavigationItemType } from '../../../models';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import omit from 'lodash/omit';
|
|
2
2
|
import { ImageObjectProps } from '../../components/Image/schema';
|
|
3
3
|
import { BaseProps, CardBase, withTheme } from '../../schema/validators/common';
|
|
4
4
|
import { AnalyticsEventSchema } from '../../schema/validators/event';
|
|
5
5
|
import { ContentBase } from '../Content/schema';
|
|
6
|
-
const BackgroundCardContentProps =
|
|
6
|
+
const BackgroundCardContentProps = omit(ContentBase, ['size']);
|
|
7
7
|
export const BackgroundCard = {
|
|
8
8
|
'background-card': {
|
|
9
9
|
additionalProperties: false,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import omit from 'lodash/omit';
|
|
2
2
|
import { ImageProps } from '../../components/Image/schema';
|
|
3
3
|
import { BaseProps, CardBase } from '../../schema/validators/common';
|
|
4
4
|
import { ContentBase } from '../Content/schema';
|
|
5
|
-
const BasicCardContentProps =
|
|
5
|
+
const BasicCardContentProps = omit(ContentBase, ['size', 'theme']);
|
|
6
6
|
export const BasicCard = {
|
|
7
7
|
'basic-card': {
|
|
8
8
|
additionalProperties: false,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { Fragment, useCallback, useEffect, useState } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import chunk from 'lodash/chunk';
|
|
3
3
|
import { CardBase } from '../../../components';
|
|
4
4
|
import { BREAKPOINTS } from '../../../constants';
|
|
5
5
|
import { Col, Grid, GridColumnSize, Row } from '../../../grid';
|
|
@@ -48,11 +48,11 @@ const CombinedPriceDetailed = (props) => {
|
|
|
48
48
|
React.createElement("div", null, descriptionComponents),
|
|
49
49
|
React.createElement("div", { className: b('description', { delimiter: useMixedView }) }, detailsComponents)));
|
|
50
50
|
};
|
|
51
|
-
const chunkedItems =
|
|
51
|
+
const chunkedItems = chunk(items, groupItemsSize);
|
|
52
52
|
return (React.createElement(CardBase, { className: b(), border: border, analyticsEvents: analyticsEvents },
|
|
53
53
|
React.createElement(CardBase.Content, null,
|
|
54
|
-
React.createElement(Grid, null, chunkedItems.map((
|
|
55
|
-
return (React.createElement(Row, { key: id, className: b('row') }, getPrice(
|
|
54
|
+
React.createElement(Grid, null, chunkedItems.map((item, id) => {
|
|
55
|
+
return (React.createElement(Row, { key: id, className: b('row') }, getPrice(item)));
|
|
56
56
|
})))));
|
|
57
57
|
};
|
|
58
58
|
export default CombinedPriceDetailed;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-disable no-param-reassign */
|
|
2
|
+
/* eslint-disable no-not-accumulator-reassign/no-not-accumulator-reassign */
|
|
1
3
|
import { __rest } from "tslib";
|
|
2
4
|
import { BlockType, SubBlockType, } from '../models';
|
|
3
5
|
import { createItemsParser, typografTransformer, yfmTransformer, } from './common';
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
2
|
+
import shuffle from 'lodash/shuffle';
|
|
2
3
|
import { config } from './config';
|
|
3
4
|
import { filterContent } from './filter';
|
|
4
5
|
function transformBlocks(blocks, lang, customConfig = {}, options = {}) {
|
|
5
6
|
const fullConfig = Object.assign(Object.assign({}, config), customConfig);
|
|
6
7
|
const { plugins = [] } = options;
|
|
7
|
-
const clonedBlocks =
|
|
8
|
+
const clonedBlocks = cloneDeep(blocks);
|
|
8
9
|
return clonedBlocks.map((block) => transformBlock(lang, fullConfig, block, plugins));
|
|
9
10
|
}
|
|
10
11
|
function transformBlock(lang, blocksConfig, block, plugins) {
|
|
11
12
|
const blockConfig = blocksConfig[block.type];
|
|
12
13
|
if (block) {
|
|
13
14
|
if ('randomOrder' in block && block.randomOrder && 'children' in block && block.children) {
|
|
14
|
-
block.children =
|
|
15
|
+
block.children = shuffle(block.children);
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
18
|
if (blockConfig) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Options, Output } from '@doc-tools/transform';
|
|
2
2
|
import sanitize from 'sanitize-html';
|
|
3
3
|
import { Lang } from '../utils/configure';
|
|
4
|
-
import AddRuleOptions = typograf.AddRuleOptions;
|
|
5
4
|
export declare enum TransformType {
|
|
6
5
|
Text = "text",
|
|
7
6
|
Html = "html"
|
|
@@ -15,7 +14,6 @@ export declare const typografConfig: {
|
|
|
15
14
|
disabled: string[];
|
|
16
15
|
};
|
|
17
16
|
export declare const sanitizeStripOptions: sanitize.IOptions;
|
|
18
|
-
export declare function addTypografRules(options: AddRuleOptions[]): void;
|
|
19
17
|
export declare function typograf(text: string, lang?: Lang): string;
|
|
20
18
|
export declare function sanitizeHtml(html: string, options?: sanitize.IOptions): string;
|
|
21
19
|
export declare function typografToHTML(text: string, lang: Lang, allowedTags?: string[]): string;
|
|
@@ -34,11 +34,31 @@ export const sanitizeStripOptions = {
|
|
|
34
34
|
allowedTags: [],
|
|
35
35
|
allowedAttributes: {},
|
|
36
36
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
Typograf.addRule({
|
|
38
|
+
name: 'common/html/sup',
|
|
39
|
+
queue: 'end',
|
|
40
|
+
/* TODO mange with it: in typograf types AddRuleOptions.handler takes only one param: text.
|
|
41
|
+
But in cloud-www was used this notation with 3 params */
|
|
42
|
+
//@ts-ignore
|
|
43
|
+
handler: function (text, settings, context) {
|
|
44
|
+
const { prefs: { htmlEntity: { type = '' } = {} } = {} } = context;
|
|
45
|
+
let symbols;
|
|
46
|
+
switch (type) {
|
|
47
|
+
case 'digit':
|
|
48
|
+
symbols = '®|©|™';
|
|
49
|
+
break;
|
|
50
|
+
case 'name':
|
|
51
|
+
symbols = '®|©|™';
|
|
52
|
+
break;
|
|
53
|
+
default:
|
|
54
|
+
symbols = '®|©|™';
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
const symbolsRegex = new RegExp(`(?<!<sup>\\s*)(${symbols})|(${symbols})(?!\\s*<\\/sup>)`, 'gi');
|
|
58
|
+
return text.replace(symbolsRegex, '<sup>$1</sup>');
|
|
59
|
+
},
|
|
60
|
+
htmlAttrs: false,
|
|
61
|
+
});
|
|
42
62
|
function enableRules(tp) {
|
|
43
63
|
const { disabled, enabled } = typografConfig;
|
|
44
64
|
enabled.forEach((rule) => tp.enableRule(rule));
|
package/package.json
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/* eslint-disable no-param-reassign */
|
|
3
|
+
/* eslint-disable no-not-accumulator-reassign/no-not-accumulator-reassign */
|
|
2
4
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
5
|
var t = {};
|
|
4
6
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -4,20 +4,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.contentTransformer = void 0;
|
|
7
|
-
const
|
|
7
|
+
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
8
|
+
const shuffle_1 = __importDefault(require("lodash/shuffle"));
|
|
8
9
|
const config_1 = require("./config");
|
|
9
10
|
const filter_1 = require("./filter");
|
|
10
11
|
function transformBlocks(blocks, lang, customConfig = {}, options = {}) {
|
|
11
12
|
const fullConfig = Object.assign(Object.assign({}, config_1.config), customConfig);
|
|
12
13
|
const { plugins = [] } = options;
|
|
13
|
-
const clonedBlocks =
|
|
14
|
+
const clonedBlocks = (0, cloneDeep_1.default)(blocks);
|
|
14
15
|
return clonedBlocks.map((block) => transformBlock(lang, fullConfig, block, plugins));
|
|
15
16
|
}
|
|
16
17
|
function transformBlock(lang, blocksConfig, block, plugins) {
|
|
17
18
|
const blockConfig = blocksConfig[block.type];
|
|
18
19
|
if (block) {
|
|
19
20
|
if ('randomOrder' in block && block.randomOrder && 'children' in block && block.children) {
|
|
20
|
-
block.children =
|
|
21
|
+
block.children = (0, shuffle_1.default)(block.children);
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
if (blockConfig) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Options, Output } from '@doc-tools/transform';
|
|
2
2
|
import sanitize from 'sanitize-html';
|
|
3
3
|
import { Lang } from '../utils/configure';
|
|
4
|
-
import AddRuleOptions = typograf.AddRuleOptions;
|
|
5
4
|
export declare enum TransformType {
|
|
6
5
|
Text = "text",
|
|
7
6
|
Html = "html"
|
|
@@ -15,7 +14,6 @@ export declare const typografConfig: {
|
|
|
15
14
|
disabled: string[];
|
|
16
15
|
};
|
|
17
16
|
export declare const sanitizeStripOptions: sanitize.IOptions;
|
|
18
|
-
export declare function addTypografRules(options: AddRuleOptions[]): void;
|
|
19
17
|
export declare function typograf(text: string, lang?: Lang): string;
|
|
20
18
|
export declare function sanitizeHtml(html: string, options?: sanitize.IOptions): string;
|
|
21
19
|
export declare function typografToHTML(text: string, lang: Lang, allowedTags?: string[]): string;
|
|
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.typografEntity = exports.fullTransform = exports.transformMarkdown = exports.typografToText = exports.typografToHTML = exports.sanitizeHtml = exports.typograf = exports.
|
|
17
|
+
exports.typografEntity = exports.fullTransform = exports.transformMarkdown = exports.typografToText = exports.typografToHTML = exports.sanitizeHtml = exports.typograf = exports.sanitizeStripOptions = exports.typografConfig = exports.DEFAULT_ALLOWED_TAGS = exports.TransformType = void 0;
|
|
18
18
|
const transform_1 = __importDefault(require("@doc-tools/transform"));
|
|
19
19
|
const sanitize_html_1 = __importDefault(require("sanitize-html"));
|
|
20
20
|
const typograf_1 = __importDefault(require("typograf"));
|
|
@@ -50,12 +50,31 @@ exports.sanitizeStripOptions = {
|
|
|
50
50
|
allowedTags: [],
|
|
51
51
|
allowedAttributes: {},
|
|
52
52
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
typograf_1.default.addRule({
|
|
54
|
+
name: 'common/html/sup',
|
|
55
|
+
queue: 'end',
|
|
56
|
+
/* TODO mange with it: in typograf types AddRuleOptions.handler takes only one param: text.
|
|
57
|
+
But in cloud-www was used this notation with 3 params */
|
|
58
|
+
//@ts-ignore
|
|
59
|
+
handler: function (text, settings, context) {
|
|
60
|
+
const { prefs: { htmlEntity: { type = '' } = {} } = {} } = context;
|
|
61
|
+
let symbols;
|
|
62
|
+
switch (type) {
|
|
63
|
+
case 'digit':
|
|
64
|
+
symbols = '®|©|™';
|
|
65
|
+
break;
|
|
66
|
+
case 'name':
|
|
67
|
+
symbols = '®|©|™';
|
|
68
|
+
break;
|
|
69
|
+
default:
|
|
70
|
+
symbols = '®|©|™';
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
const symbolsRegex = new RegExp(`(?<!<sup>\\s*)(${symbols})|(${symbols})(?!\\s*<\\/sup>)`, 'gi');
|
|
74
|
+
return text.replace(symbolsRegex, '<sup>$1</sup>');
|
|
75
|
+
},
|
|
76
|
+
htmlAttrs: false,
|
|
77
|
+
});
|
|
59
78
|
function enableRules(tp) {
|
|
60
79
|
const { disabled, enabled } = exports.typografConfig;
|
|
61
80
|
enabled.forEach((rule) => tp.enableRule(rule));
|
package/server/utils/blocks.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.getQaAttrubutes = exports.getShareLink = exports.getHeaderBlock = exports.getOrderedBlocks = exports.getCustomTypes = exports.getCustomItems = exports.getBlockKey = exports.hasBlockTag = exports.getHeaderTag = void 0;
|
|
4
|
-
const
|
|
7
|
+
const camelCase_1 = __importDefault(require("lodash/camelCase"));
|
|
8
|
+
const flatten_1 = __importDefault(require("lodash/flatten"));
|
|
5
9
|
const models_1 = require("../models");
|
|
6
10
|
const BLOCK_ELEMENTS = [
|
|
7
11
|
'div',
|
|
@@ -125,9 +129,9 @@ exports.getShareLink = getShareLink;
|
|
|
125
129
|
const getQaAttrubutes = (qa, ...customKeys) => {
|
|
126
130
|
const attributes = {};
|
|
127
131
|
if (qa) {
|
|
128
|
-
const keys = QA_ATTRIBUTES_KEYS.concat((0,
|
|
132
|
+
const keys = QA_ATTRIBUTES_KEYS.concat((0, flatten_1.default)(customKeys));
|
|
129
133
|
keys.forEach((key) => {
|
|
130
|
-
attributes[(0,
|
|
134
|
+
attributes[(0, camelCase_1.default)(key)] = `${qa}-${key}`;
|
|
131
135
|
});
|
|
132
136
|
attributes.default = qa;
|
|
133
137
|
}
|