@gravity-ui/page-constructor 2.0.0-beta.0 → 2.0.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/CHANGELOG.md +40 -0
- package/build/cjs/blocks/ExtendedFeatures/ExtendedFeatures.css +4 -4
- package/build/cjs/blocks/ExtendedFeatures/ExtendedFeatures.js +1 -1
- package/build/cjs/blocks/Map/schema.d.ts +0 -12
- package/build/cjs/components/HTML/HTML.d.ts +1 -1
- package/build/cjs/components/Map/GoogleMap.js +7 -5
- package/build/cjs/components/Map/Map.css +5 -0
- package/build/cjs/components/Map/YMap/YMap.d.ts +4 -2
- package/build/cjs/components/Map/YMap/YMap.js +18 -10
- package/build/cjs/components/Map/YMap/YandexMap.js +18 -9
- package/build/cjs/models/constructor-items/common.d.ts +0 -2
- package/build/cjs/navigation/components/Header/Header.css +23 -0
- package/build/cjs/navigation/components/Header/Header.js +12 -8
- package/build/cjs/navigation/components/MobileNavigation/MobileNavigation.css +5 -2
- package/build/cjs/navigation/components/MobileNavigation/MobileNavigation.d.ts +2 -2
- package/build/cjs/navigation/components/MobileNavigation/MobileNavigation.js +11 -11
- package/build/cjs/navigation/components/Navigation/Navigation.css +0 -11
- package/build/cjs/navigation/components/Navigation/Navigation.d.ts +4 -11
- package/build/cjs/navigation/components/Navigation/Navigation.js +5 -23
- package/build/cjs/navigation/components/NavigationDropdownItem/NavigationDropdownItem.d.ts +11 -0
- package/build/cjs/navigation/components/NavigationDropdownItem/NavigationDropdownItem.js +14 -0
- package/build/cjs/navigation/components/NavigationListItem/NavigationListItem.css +11 -0
- package/build/cjs/navigation/components/NavigationListItem/NavigationListItem.d.ts +16 -0
- package/build/cjs/navigation/components/NavigationListItem/NavigationListItem.js +28 -0
- package/build/cjs/navigation/constants.d.ts +6 -0
- package/build/cjs/navigation/constants.js +10 -0
- package/build/cjs/navigation/utils.d.ts +10 -0
- package/build/cjs/navigation/utils.js +11 -0
- package/build/cjs/schema/validators/common.d.ts +0 -6
- package/build/cjs/schema/validators/common.js +0 -4
- package/build/cjs/sub-blocks/HubspotForm/HubspotForm.css +1 -0
- package/build/esm/blocks/ExtendedFeatures/ExtendedFeatures.css +4 -4
- package/build/esm/blocks/ExtendedFeatures/ExtendedFeatures.js +1 -1
- package/build/esm/blocks/Map/schema.d.ts +0 -12
- package/build/esm/components/HTML/HTML.d.ts +1 -1
- package/build/esm/components/Map/GoogleMap.js +7 -5
- package/build/esm/components/Map/Map.css +5 -0
- package/build/esm/components/Map/YMap/YMap.d.ts +4 -2
- package/build/esm/components/Map/YMap/YMap.js +18 -10
- package/build/esm/components/Map/YMap/YandexMap.js +18 -9
- package/build/esm/models/constructor-items/common.d.ts +0 -2
- package/build/esm/navigation/components/Header/Header.css +23 -0
- package/build/esm/navigation/components/Header/Header.js +12 -8
- package/build/esm/navigation/components/MobileNavigation/MobileNavigation.css +5 -2
- package/build/esm/navigation/components/MobileNavigation/MobileNavigation.d.ts +2 -2
- package/build/esm/navigation/components/MobileNavigation/MobileNavigation.js +11 -11
- package/build/esm/navigation/components/Navigation/Navigation.css +0 -11
- package/build/esm/navigation/components/Navigation/Navigation.d.ts +4 -11
- package/build/esm/navigation/components/Navigation/Navigation.js +6 -25
- package/build/esm/navigation/components/NavigationDropdownItem/NavigationDropdownItem.d.ts +11 -0
- package/build/esm/navigation/components/NavigationDropdownItem/NavigationDropdownItem.js +12 -0
- package/build/esm/navigation/components/NavigationListItem/NavigationListItem.css +11 -0
- package/build/esm/navigation/components/NavigationListItem/NavigationListItem.d.ts +17 -0
- package/build/esm/navigation/components/NavigationListItem/NavigationListItem.js +24 -0
- package/build/esm/navigation/constants.d.ts +6 -0
- package/build/esm/navigation/constants.js +7 -0
- package/build/esm/navigation/utils.d.ts +10 -0
- package/build/esm/navigation/utils.js +7 -0
- package/build/esm/schema/validators/common.d.ts +0 -6
- package/build/esm/schema/validators/common.js +0 -4
- package/build/esm/sub-blocks/HubspotForm/HubspotForm.css +1 -0
- package/package.json +2 -5
- package/server/models/constructor-items/common.d.ts +0 -2
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { NavigationItemModel } from '../../../models/navigation';
|
|
3
3
|
import './Navigation.css';
|
|
4
4
|
export interface NavigationProps {
|
|
5
5
|
links: NavigationItemModel[];
|
|
6
|
-
|
|
7
|
-
onActiveItemChange: (index: number) => void;
|
|
6
|
+
activeItemId?: string;
|
|
8
7
|
className?: string;
|
|
9
8
|
highlightActiveItem?: boolean;
|
|
10
|
-
|
|
11
|
-
export interface NavigationDropdownProps {
|
|
12
|
-
data: NavigationDropdownItem;
|
|
13
|
-
onClick: MouseEventHandler;
|
|
14
|
-
isActive: boolean;
|
|
15
|
-
position: number;
|
|
16
|
-
hidePopup: () => void;
|
|
9
|
+
onActiveItemChange: (id?: string) => void;
|
|
17
10
|
}
|
|
18
11
|
declare const Navigation: React.FC<NavigationProps>;
|
|
19
12
|
export default Navigation;
|
|
@@ -1,32 +1,20 @@
|
|
|
1
|
-
import { __rest } from "tslib";
|
|
2
1
|
import _ from 'lodash';
|
|
3
|
-
import React, {
|
|
2
|
+
import React, { useState, useEffect, useCallback, useContext, useRef } from 'react';
|
|
4
3
|
import { block } from '../../../utils';
|
|
5
4
|
import OverflowScroller from '../../../components/OverflowScroller/OverflowScroller';
|
|
6
|
-
import { NavigationItemType, } from '../../../models/navigation';
|
|
7
|
-
import NavigationPopup from '../NavigationPopup/NavigationPopup';
|
|
8
|
-
import NavigationItem from '../NavigationItem/NavigationItem';
|
|
9
5
|
import { LocationContext } from '../../../context/locationContext';
|
|
6
|
+
import { ItemColumnName } from '../../constants';
|
|
7
|
+
import { NavigationListItem } from '../NavigationListItem/NavigationListItem';
|
|
10
8
|
import './Navigation.css';
|
|
11
9
|
const b = block('navigation');
|
|
12
|
-
const
|
|
13
|
-
const { text, items } = data, popupProps = __rest(data, ["text", "items"]);
|
|
14
|
-
return (React.createElement(Fragment, null,
|
|
15
|
-
React.createElement(NavigationItem, { className: b('link'), onClick: onClick, isOpened: isActive, data: { text, type: NavigationItemType.Dropdown } }),
|
|
16
|
-
isActive && (React.createElement(NavigationPopup, Object.assign({ left: position, onClose: hidePopup, items: items }, popupProps)))));
|
|
17
|
-
};
|
|
18
|
-
const Navigation = ({ className, onActiveItemChange, links, activeItemIndex, highlightActiveItem, }) => {
|
|
10
|
+
const Navigation = ({ className, onActiveItemChange, links, activeItemId, highlightActiveItem, }) => {
|
|
19
11
|
const { asPath, pathname } = useContext(LocationContext);
|
|
20
12
|
const itemRefs = useRef([]);
|
|
21
13
|
const [itemPositions, setItemPosition] = useState([]);
|
|
22
14
|
const [lastLeftScroll, setLastLeftScroll] = useState(0);
|
|
23
15
|
const hidePopup = useCallback(() => {
|
|
24
|
-
onActiveItemChange(
|
|
16
|
+
onActiveItemChange();
|
|
25
17
|
}, [onActiveItemChange]);
|
|
26
|
-
const getItemClickHandler = useCallback((index) => (e) => {
|
|
27
|
-
e.stopPropagation();
|
|
28
|
-
onActiveItemChange(index === activeItemIndex ? -1 : index);
|
|
29
|
-
}, [activeItemIndex, onActiveItemChange]);
|
|
30
18
|
const calculateItemPositions = useCallback(() => {
|
|
31
19
|
if (itemRefs.current.length) {
|
|
32
20
|
const currentItemPositions = itemRefs.current.map((itemRef) => (itemRef && itemRef.getBoundingClientRect().left) || 0);
|
|
@@ -56,13 +44,6 @@ const Navigation = ({ className, onActiveItemChange, links, activeItemIndex, hig
|
|
|
56
44
|
}, [hidePopup, asPath, pathname]);
|
|
57
45
|
return (React.createElement(OverflowScroller, { className: b(null, className), onScrollStart: hidePopup, onScrollEnd: calculateItemPositions },
|
|
58
46
|
React.createElement("nav", null,
|
|
59
|
-
React.createElement("ul", { className: b('links') }, links.map((link, index) => {
|
|
60
|
-
const isActive = index === activeItemIndex;
|
|
61
|
-
const onClick = getItemClickHandler(index);
|
|
62
|
-
return (React.createElement("li", { ref: (el) => itemRefs.current.push(el), key: index, className: b('links-item') },
|
|
63
|
-
link.type === NavigationItemType.Dropdown ? (React.createElement(NavigationDropdown, { data: link, onClick: onClick, isActive: isActive, position: itemPositions[index], hidePopup: hidePopup })) : (React.createElement(NavigationItem, { data: link, onClick: onClick })),
|
|
64
|
-
highlightActiveItem && isActive && (React.createElement("div", { className: b('slider-container') },
|
|
65
|
-
React.createElement("div", { className: b('slider') })))));
|
|
66
|
-
})))));
|
|
47
|
+
React.createElement("ul", { className: b('links') }, links.map((link, index) => (React.createElement(NavigationListItem, { key: index, className: b('links-item'), item: link, itemRefs: itemRefs, index: index, activeItemId: activeItemId, highlightActiveItem: highlightActiveItem, hidePopup: hidePopup, itemPositions: itemPositions, column: ItemColumnName.Left, onActiveItemChange: onActiveItemChange })))))));
|
|
67
48
|
};
|
|
68
49
|
export default Navigation;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React, { MouseEventHandler } from 'react';
|
|
2
|
+
import { NavigationDropdownItem } from '../../../models';
|
|
3
|
+
export interface NavigationDropdownProps {
|
|
4
|
+
data: NavigationDropdownItem;
|
|
5
|
+
onClick: MouseEventHandler;
|
|
6
|
+
isActive: boolean;
|
|
7
|
+
position: number;
|
|
8
|
+
hidePopup: () => void;
|
|
9
|
+
}
|
|
10
|
+
declare const NavigationDropdown: React.FC<NavigationDropdownProps>;
|
|
11
|
+
export default NavigationDropdown;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import React, { Fragment } from 'react';
|
|
3
|
+
import { NavigationItemType } from '../../../models';
|
|
4
|
+
import NavigationItem from '../NavigationItem/NavigationItem';
|
|
5
|
+
import NavigationPopup from '../NavigationPopup/NavigationPopup';
|
|
6
|
+
const NavigationDropdown = ({ data, isActive, position, hidePopup, onClick, }) => {
|
|
7
|
+
const { text, icon, items } = data, popupProps = __rest(data, ["text", "icon", "items"]);
|
|
8
|
+
return (React.createElement(Fragment, null,
|
|
9
|
+
React.createElement(NavigationItem, { onClick: onClick, isOpened: isActive, data: { text, type: NavigationItemType.Dropdown, icon } }),
|
|
10
|
+
isActive && (React.createElement(NavigationPopup, Object.assign({ left: position, onClose: hidePopup, items: items }, popupProps)))));
|
|
11
|
+
};
|
|
12
|
+
export default NavigationDropdown;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ClassNameProps, NavigationItemModel } from '../../../models';
|
|
3
|
+
import { ItemColumnName } from '../../constants';
|
|
4
|
+
import './NavigationListItem.css';
|
|
5
|
+
type NavigationListItemProps = {
|
|
6
|
+
item: NavigationItemModel;
|
|
7
|
+
index: number;
|
|
8
|
+
column: ItemColumnName;
|
|
9
|
+
activeItemId?: string;
|
|
10
|
+
itemPositions?: number[];
|
|
11
|
+
itemRefs?: React.MutableRefObject<(HTMLLIElement | null)[]>;
|
|
12
|
+
highlightActiveItem?: boolean;
|
|
13
|
+
hidePopup: () => void;
|
|
14
|
+
onActiveItemChange: (id?: string) => void;
|
|
15
|
+
} & ClassNameProps;
|
|
16
|
+
export declare const NavigationListItem: ({ item, itemRefs, className, index, activeItemId, highlightActiveItem, hidePopup, itemPositions, column, onActiveItemChange, }: NavigationListItemProps) => JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import { block } from '../../../utils';
|
|
3
|
+
import { NavigationItemType } from '../../../models';
|
|
4
|
+
import { getItemClickHandler } from '../../utils';
|
|
5
|
+
import NavigationDropdownItem from '../NavigationDropdownItem/NavigationDropdownItem';
|
|
6
|
+
import NavigationItem from '../NavigationItem/NavigationItem';
|
|
7
|
+
import './NavigationListItem.css';
|
|
8
|
+
const b = block('navigation');
|
|
9
|
+
export const NavigationListItem = ({ item, itemRefs, className, index, activeItemId, highlightActiveItem, hidePopup, itemPositions, column, onActiveItemChange, }) => {
|
|
10
|
+
var _a;
|
|
11
|
+
const ref = useRef(null);
|
|
12
|
+
const id = `${column}-${index}`;
|
|
13
|
+
const isActive = id === activeItemId;
|
|
14
|
+
const onClick = getItemClickHandler({
|
|
15
|
+
column,
|
|
16
|
+
index,
|
|
17
|
+
activeItemId,
|
|
18
|
+
onActiveItemChange,
|
|
19
|
+
});
|
|
20
|
+
return (React.createElement("li", { ref: itemRefs ? (el) => itemRefs.current.push(el) : ref, className: className },
|
|
21
|
+
item.type === NavigationItemType.Dropdown ? (React.createElement(NavigationDropdownItem, { data: item, onClick: onClick, isActive: isActive, position: (itemPositions === null || itemPositions === void 0 ? void 0 : itemPositions[index]) || ((_a = ref.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().left) || 0, hidePopup: hidePopup })) : (React.createElement(NavigationItem, { data: item, onClick: onClick })),
|
|
22
|
+
highlightActiveItem && isActive && (React.createElement("div", { className: b('slider-container') },
|
|
23
|
+
React.createElement("div", { className: b('slider') })))));
|
|
24
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MouseEventHandler } from 'react';
|
|
2
|
+
import { ItemColumnName } from './constants';
|
|
3
|
+
type GetItemClickHandlerArgs = {
|
|
4
|
+
column: ItemColumnName;
|
|
5
|
+
index: number;
|
|
6
|
+
activeItemId?: string;
|
|
7
|
+
onActiveItemChange: (id?: string) => void;
|
|
8
|
+
};
|
|
9
|
+
export declare const getItemClickHandler: ({ column, index, onActiveItemChange, }: GetItemClickHandlerArgs) => MouseEventHandler;
|
|
10
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravity-ui/page-constructor",
|
|
3
|
-
"version": "2.0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Gravity UI Page Constructor",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"bem-cn-lite": "^4.0.0",
|
|
51
51
|
"github-buttons": "2.23.0",
|
|
52
52
|
"lodash": "^4.17.21",
|
|
53
|
-
"react-player": "^2.
|
|
53
|
+
"react-player": "^2.12.0",
|
|
54
54
|
"react-slick": "^0.28.1",
|
|
55
55
|
"react-spring": "^9.3.0",
|
|
56
56
|
"react-transition-group": "^4.4.2",
|
|
@@ -137,8 +137,5 @@
|
|
|
137
137
|
"*.{json,yaml,yml,md}": [
|
|
138
138
|
"prettier --write"
|
|
139
139
|
]
|
|
140
|
-
},
|
|
141
|
-
"publishConfig": {
|
|
142
|
-
"tag": "beta"
|
|
143
140
|
}
|
|
144
141
|
}
|
|
@@ -189,7 +189,6 @@ export interface MediaProps extends Animatable, Partial<MediaComponentDataLensPr
|
|
|
189
189
|
export type Coordinate = number[];
|
|
190
190
|
export interface MapBaseProps {
|
|
191
191
|
zoom?: number;
|
|
192
|
-
center?: Coordinate;
|
|
193
192
|
}
|
|
194
193
|
export interface GMapProps extends MapBaseProps {
|
|
195
194
|
address: string;
|
|
@@ -197,7 +196,6 @@ export interface GMapProps extends MapBaseProps {
|
|
|
197
196
|
export interface YMapProps extends MapBaseProps {
|
|
198
197
|
markers: YMapMarker[];
|
|
199
198
|
id: string;
|
|
200
|
-
center: Coordinate;
|
|
201
199
|
}
|
|
202
200
|
export interface YMapMarker {
|
|
203
201
|
address?: string;
|