@gravity-ui/page-constructor 5.16.0 → 5.17.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/build/cjs/blocks/SliderNew/Arrow/Arrow.css +62 -0
- package/build/cjs/blocks/SliderNew/Arrow/Arrow.d.ts +9 -0
- package/build/cjs/blocks/SliderNew/Arrow/Arrow.js +13 -0
- package/build/cjs/blocks/SliderNew/Slider.css +819 -0
- package/build/cjs/blocks/SliderNew/Slider.d.ts +13 -0
- package/build/cjs/blocks/SliderNew/Slider.js +44 -0
- package/build/cjs/blocks/SliderNew/i18n/en.json +4 -0
- package/build/cjs/blocks/SliderNew/i18n/index.d.ts +1 -0
- package/build/cjs/blocks/SliderNew/i18n/index.js +9 -0
- package/build/cjs/blocks/SliderNew/i18n/ru.json +4 -0
- package/build/cjs/blocks/SliderNew/models.d.ts +8 -0
- package/build/cjs/blocks/SliderNew/models.js +10 -0
- package/build/cjs/blocks/SliderNew/schema.d.ts +253 -0
- package/build/cjs/blocks/SliderNew/schema.js +80 -0
- package/build/cjs/blocks/SliderNew/useSlider.d.ts +20 -0
- package/build/cjs/blocks/SliderNew/useSlider.js +65 -0
- package/build/cjs/blocks/SliderNew/utils.d.ts +14 -0
- package/build/cjs/blocks/SliderNew/utils.js +31 -0
- package/build/cjs/blocks/unstable.d.ts +1 -0
- package/build/cjs/blocks/unstable.js +8 -0
- package/build/cjs/components/CardBase/CardBase.css +3 -0
- package/build/cjs/constructor-items.d.ts +1 -0
- package/build/cjs/constructor-items.js +3 -0
- package/build/cjs/editor/data/templates/slider-new-block.json +46 -0
- package/build/cjs/models/constructor-items/blocks.d.ts +20 -2
- package/build/cjs/models/constructor-items/blocks.js +2 -0
- package/build/cjs/navigation/components/Navigation/Navigation.js +1 -1
- package/build/cjs/schema/constants.d.ts +2 -1
- package/build/cjs/schema/constants.js +1 -1
- package/build/cjs/schema/validators/blocks.d.ts +1 -0
- package/build/cjs/schema/validators/blocks.js +1 -0
- package/build/cjs/sub-blocks/Quote/Quote.css +3 -0
- package/build/esm/blocks/SliderNew/Arrow/Arrow.css +62 -0
- package/build/esm/blocks/SliderNew/Arrow/Arrow.d.ts +10 -0
- package/build/esm/blocks/SliderNew/Arrow/Arrow.js +11 -0
- package/build/esm/blocks/SliderNew/Slider.css +819 -0
- package/build/esm/blocks/SliderNew/Slider.d.ts +14 -0
- package/build/esm/blocks/SliderNew/Slider.js +40 -0
- package/build/esm/blocks/SliderNew/i18n/en.json +4 -0
- package/build/esm/blocks/SliderNew/i18n/index.d.ts +1 -0
- package/build/esm/blocks/SliderNew/i18n/index.js +5 -0
- package/build/esm/blocks/SliderNew/i18n/ru.json +4 -0
- package/build/esm/blocks/SliderNew/models.d.ts +8 -0
- package/build/esm/blocks/SliderNew/models.js +7 -0
- package/build/esm/blocks/SliderNew/schema.d.ts +253 -0
- package/build/esm/blocks/SliderNew/schema.js +77 -0
- package/build/esm/blocks/SliderNew/useSlider.d.ts +20 -0
- package/build/esm/blocks/SliderNew/useSlider.js +60 -0
- package/build/esm/blocks/SliderNew/utils.d.ts +14 -0
- package/build/esm/blocks/SliderNew/utils.js +26 -0
- package/build/esm/blocks/unstable.d.ts +1 -0
- package/build/esm/blocks/unstable.js +1 -0
- package/build/esm/components/CardBase/CardBase.css +3 -0
- package/build/esm/constructor-items.d.ts +1 -0
- package/build/esm/constructor-items.js +3 -0
- package/build/esm/editor/data/templates/slider-new-block.json +46 -0
- package/build/esm/models/constructor-items/blocks.d.ts +20 -2
- package/build/esm/models/constructor-items/blocks.js +2 -0
- package/build/esm/navigation/components/Navigation/Navigation.js +1 -1
- package/build/esm/schema/constants.d.ts +2 -1
- package/build/esm/schema/constants.js +2 -2
- package/build/esm/schema/validators/blocks.d.ts +1 -0
- package/build/esm/schema/validators/blocks.js +1 -0
- package/build/esm/sub-blocks/Quote/Quote.css +3 -0
- package/package.json +2 -1
- package/server/models/constructor-items/blocks.d.ts +20 -2
- package/server/models/constructor-items/blocks.js +2 -0
- package/styles/mixins.scss +5 -0
- package/widget/index.js +1 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { Swiper } from 'swiper/react';
|
|
3
|
+
import { ClassNameProps, Refable, SliderProps as SliderParams } from '../../models';
|
|
4
|
+
import './Slider.css';
|
|
5
|
+
import 'swiper/swiper-bundle.css';
|
|
6
|
+
export interface SliderNewProps extends Omit<SliderParams, 'children'>, Partial<Pick<Swiper, 'onSlideChange' | 'onSlideChangeTransitionStart' | 'onSlideChangeTransitionEnd' | 'onActiveIndexChange' | 'onBreakpoint'>>, Refable<HTMLDivElement>, ClassNameProps {
|
|
7
|
+
type?: string;
|
|
8
|
+
anchorId?: string;
|
|
9
|
+
dotsClassName?: string;
|
|
10
|
+
blockClassName?: string;
|
|
11
|
+
arrowSize?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare const SliderNewBlock: ({ animated, title, description, type, anchorId, arrows, adaptive, autoplay: autoplayMs, dots, dotsClassName, disclaimer, children, blockClassName, arrowSize, slidesToShow, onSlideChange, onSlideChangeTransitionStart, onSlideChangeTransitionEnd, onActiveIndexChange, onBreakpoint, }: PropsWithChildren<SliderNewProps>) => JSX.Element;
|
|
14
|
+
export default SliderNewBlock;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React, { Fragment } from 'react';
|
|
2
|
+
import SwiperCore, { A11y, Autoplay, Pagination } from 'swiper';
|
|
3
|
+
import { Swiper, SwiperSlide } from 'swiper/react';
|
|
4
|
+
import Anchor from '../../components/Anchor/Anchor';
|
|
5
|
+
import AnimateBlock from '../../components/AnimateBlock/AnimateBlock';
|
|
6
|
+
import Title from '../../components/Title/Title';
|
|
7
|
+
import { block } from '../../utils';
|
|
8
|
+
import Arrow from './Arrow/Arrow';
|
|
9
|
+
import { useSlider } from './useSlider';
|
|
10
|
+
import './Slider.css';
|
|
11
|
+
import 'swiper/swiper-bundle.css';
|
|
12
|
+
const b = block('SliderNewBlock');
|
|
13
|
+
SwiperCore.use([Autoplay, A11y, Pagination]);
|
|
14
|
+
export const SliderNewBlock = ({ animated, title, description, type, anchorId, arrows = true, adaptive, autoplay: autoplayMs, dots = true, dotsClassName, disclaimer, children, blockClassName, arrowSize, slidesToShow, onSlideChange, onSlideChangeTransitionStart, onSlideChangeTransitionEnd, onActiveIndexChange, onBreakpoint, }) => {
|
|
15
|
+
const { childrenCount, breakpoints, autoplay, onSwiper, onPrev, onNext, isLocked, setIsLocked } = useSlider({
|
|
16
|
+
slidesToShow,
|
|
17
|
+
children,
|
|
18
|
+
type,
|
|
19
|
+
autoplayMs,
|
|
20
|
+
});
|
|
21
|
+
return (React.createElement("div", { className: b({
|
|
22
|
+
'one-slide': childrenCount === 1,
|
|
23
|
+
'only-arrows': !(title === null || title === void 0 ? void 0 : title.text) && !description && arrows,
|
|
24
|
+
'without-dots': !dots || isLocked,
|
|
25
|
+
type,
|
|
26
|
+
}, blockClassName) },
|
|
27
|
+
anchorId && React.createElement(Anchor, { id: anchorId }),
|
|
28
|
+
React.createElement(Title, { title: title, subtitle: description, className: b('header', { 'no-description': !description }) }),
|
|
29
|
+
React.createElement(AnimateBlock, { className: b('animate-slides'), animate: animated },
|
|
30
|
+
React.createElement(Swiper, { className: b('slider'), onSwiper: onSwiper, pagination: dots && {
|
|
31
|
+
clickable: true,
|
|
32
|
+
bulletClass: b('dot', dotsClassName),
|
|
33
|
+
bulletActiveClass: b('dot_active'),
|
|
34
|
+
}, speed: 1000, autoplay: autoplay, autoHeight: adaptive, initialSlide: 0, noSwiping: false, breakpoints: breakpoints, onSlideChange: onSlideChange, onSlideChangeTransitionStart: onSlideChangeTransitionStart, onSlideChangeTransitionEnd: onSlideChangeTransitionEnd, onActiveIndexChange: onActiveIndexChange, onBreakpoint: onBreakpoint, onLock: () => setIsLocked(true), onUnlock: () => setIsLocked(false), watchSlidesVisibility: true, watchOverflow: true }, React.Children.map(children, (elem, index) => (React.createElement(SwiperSlide, { className: b('slide'), key: index }, elem)))),
|
|
35
|
+
arrows && !isLocked && (React.createElement(Fragment, null,
|
|
36
|
+
React.createElement(Arrow, { className: b('arrow', { prev: true }), type: "left", onClick: onPrev, size: arrowSize }),
|
|
37
|
+
React.createElement(Arrow, { className: b('arrow', { next: true }), type: "right", onClick: onNext, size: arrowSize }))),
|
|
38
|
+
React.createElement("div", { className: b('footer') }, disclaimer ? (React.createElement("div", { className: b('disclaimer', { size: (disclaimer === null || disclaimer === void 0 ? void 0 : disclaimer.size) || 'm' }) }, disclaimer === null || disclaimer === void 0 ? void 0 : disclaimer.text)) : null))));
|
|
39
|
+
};
|
|
40
|
+
export default SliderNewBlock;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const i18n: (key: "arrow-right" | "arrow-left", params?: import("@gravity-ui/i18n").Params | undefined) => string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export var SliderBreakpointNames;
|
|
2
|
+
(function (SliderBreakpointNames) {
|
|
3
|
+
SliderBreakpointNames["Xs"] = "xs";
|
|
4
|
+
SliderBreakpointNames["Sm"] = "sm";
|
|
5
|
+
SliderBreakpointNames["Md"] = "md";
|
|
6
|
+
SliderBreakpointNames["Lg"] = "lg";
|
|
7
|
+
})(SliderBreakpointNames || (SliderBreakpointNames = {}));
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
export declare const SliderNewProps: {
|
|
2
|
+
dots: {
|
|
3
|
+
type: string;
|
|
4
|
+
};
|
|
5
|
+
arrows: {
|
|
6
|
+
type: string;
|
|
7
|
+
};
|
|
8
|
+
randomOrder: {
|
|
9
|
+
type: string;
|
|
10
|
+
};
|
|
11
|
+
autoplay: {
|
|
12
|
+
type: string;
|
|
13
|
+
};
|
|
14
|
+
type: {
|
|
15
|
+
type: string;
|
|
16
|
+
};
|
|
17
|
+
adaptive: {
|
|
18
|
+
type: string;
|
|
19
|
+
};
|
|
20
|
+
arrowSize: {
|
|
21
|
+
type: string;
|
|
22
|
+
};
|
|
23
|
+
animated: {
|
|
24
|
+
animated: {
|
|
25
|
+
type: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
slidesToShow: {
|
|
29
|
+
oneOf: ({
|
|
30
|
+
type: string;
|
|
31
|
+
additionalProperties: boolean;
|
|
32
|
+
properties: {};
|
|
33
|
+
optionName: string;
|
|
34
|
+
} | {
|
|
35
|
+
type: string;
|
|
36
|
+
optionName: string;
|
|
37
|
+
additionalProperties?: undefined;
|
|
38
|
+
properties?: undefined;
|
|
39
|
+
})[];
|
|
40
|
+
};
|
|
41
|
+
disclaimer: {
|
|
42
|
+
additionalProperties: boolean;
|
|
43
|
+
required: string[];
|
|
44
|
+
properties: {
|
|
45
|
+
text: {
|
|
46
|
+
type: string;
|
|
47
|
+
contentType: string;
|
|
48
|
+
};
|
|
49
|
+
size: {
|
|
50
|
+
type: string;
|
|
51
|
+
enum: string[];
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
loadable: {
|
|
56
|
+
additionalProperties: boolean;
|
|
57
|
+
required: string[];
|
|
58
|
+
properties: {
|
|
59
|
+
source: {
|
|
60
|
+
type: string;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* @deprecated
|
|
64
|
+
*/
|
|
65
|
+
minCount: {
|
|
66
|
+
type: string;
|
|
67
|
+
};
|
|
68
|
+
params: {
|
|
69
|
+
type: string;
|
|
70
|
+
patternProperties: {
|
|
71
|
+
'.*': {
|
|
72
|
+
type: string[];
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
disabled: boolean;
|
|
78
|
+
};
|
|
79
|
+
children: {
|
|
80
|
+
type: string;
|
|
81
|
+
items: {
|
|
82
|
+
$ref: string;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
export declare const SliderNewBlock: {
|
|
87
|
+
'slider-new-block': {
|
|
88
|
+
additionalProperties: boolean;
|
|
89
|
+
required: never[];
|
|
90
|
+
properties: {
|
|
91
|
+
title: {
|
|
92
|
+
oneOf: ({
|
|
93
|
+
type: string;
|
|
94
|
+
optionName: string;
|
|
95
|
+
} | {
|
|
96
|
+
optionName: string;
|
|
97
|
+
type: string;
|
|
98
|
+
additionalProperties: boolean;
|
|
99
|
+
required: string[];
|
|
100
|
+
properties: {
|
|
101
|
+
text: {
|
|
102
|
+
type: string;
|
|
103
|
+
contentType: string;
|
|
104
|
+
};
|
|
105
|
+
textSize: {
|
|
106
|
+
type: string;
|
|
107
|
+
enum: string[];
|
|
108
|
+
};
|
|
109
|
+
url: {
|
|
110
|
+
type: string;
|
|
111
|
+
};
|
|
112
|
+
urlTitle: {
|
|
113
|
+
type: string;
|
|
114
|
+
};
|
|
115
|
+
resetMargin: {
|
|
116
|
+
type: string;
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
})[];
|
|
120
|
+
};
|
|
121
|
+
description: {
|
|
122
|
+
type: string;
|
|
123
|
+
contentType: string;
|
|
124
|
+
inputType: string;
|
|
125
|
+
};
|
|
126
|
+
dots: {
|
|
127
|
+
type: string;
|
|
128
|
+
};
|
|
129
|
+
arrows: {
|
|
130
|
+
type: string;
|
|
131
|
+
};
|
|
132
|
+
randomOrder: {
|
|
133
|
+
type: string;
|
|
134
|
+
};
|
|
135
|
+
autoplay: {
|
|
136
|
+
type: string;
|
|
137
|
+
};
|
|
138
|
+
type: {
|
|
139
|
+
type: string;
|
|
140
|
+
};
|
|
141
|
+
adaptive: {
|
|
142
|
+
type: string;
|
|
143
|
+
};
|
|
144
|
+
arrowSize: {
|
|
145
|
+
type: string;
|
|
146
|
+
};
|
|
147
|
+
animated: {
|
|
148
|
+
animated: {
|
|
149
|
+
type: string;
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
slidesToShow: {
|
|
153
|
+
oneOf: ({
|
|
154
|
+
type: string;
|
|
155
|
+
additionalProperties: boolean;
|
|
156
|
+
properties: {};
|
|
157
|
+
optionName: string;
|
|
158
|
+
} | {
|
|
159
|
+
type: string;
|
|
160
|
+
optionName: string;
|
|
161
|
+
additionalProperties?: undefined;
|
|
162
|
+
properties?: undefined;
|
|
163
|
+
})[];
|
|
164
|
+
};
|
|
165
|
+
disclaimer: {
|
|
166
|
+
additionalProperties: boolean;
|
|
167
|
+
required: string[];
|
|
168
|
+
properties: {
|
|
169
|
+
text: {
|
|
170
|
+
type: string;
|
|
171
|
+
contentType: string;
|
|
172
|
+
};
|
|
173
|
+
size: {
|
|
174
|
+
type: string;
|
|
175
|
+
enum: string[];
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
loadable: {
|
|
180
|
+
additionalProperties: boolean;
|
|
181
|
+
required: string[];
|
|
182
|
+
properties: {
|
|
183
|
+
source: {
|
|
184
|
+
type: string;
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* @deprecated
|
|
188
|
+
*/
|
|
189
|
+
minCount: {
|
|
190
|
+
type: string;
|
|
191
|
+
};
|
|
192
|
+
params: {
|
|
193
|
+
type: string;
|
|
194
|
+
patternProperties: {
|
|
195
|
+
'.*': {
|
|
196
|
+
type: string[];
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
disabled: boolean;
|
|
202
|
+
};
|
|
203
|
+
children: {
|
|
204
|
+
type: string;
|
|
205
|
+
items: {
|
|
206
|
+
$ref: string;
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
anchor: {
|
|
210
|
+
type: string;
|
|
211
|
+
additionalProperties: boolean;
|
|
212
|
+
required: string[];
|
|
213
|
+
properties: {
|
|
214
|
+
text: {
|
|
215
|
+
type: string;
|
|
216
|
+
contentType: string;
|
|
217
|
+
};
|
|
218
|
+
url: {
|
|
219
|
+
type: string;
|
|
220
|
+
};
|
|
221
|
+
urlTitle: {
|
|
222
|
+
type: string;
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
};
|
|
226
|
+
visible: {
|
|
227
|
+
type: string;
|
|
228
|
+
enum: string[];
|
|
229
|
+
};
|
|
230
|
+
resetPaddings: {
|
|
231
|
+
type: string;
|
|
232
|
+
};
|
|
233
|
+
context: {
|
|
234
|
+
type: string;
|
|
235
|
+
};
|
|
236
|
+
indent: {
|
|
237
|
+
type: string;
|
|
238
|
+
additionalProperties: boolean;
|
|
239
|
+
properties: {
|
|
240
|
+
top: {
|
|
241
|
+
enum: string[];
|
|
242
|
+
};
|
|
243
|
+
bottom: {
|
|
244
|
+
enum: string[];
|
|
245
|
+
};
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
when: {
|
|
249
|
+
type: string;
|
|
250
|
+
};
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { AnimatableProps, BlockBaseProps, BlockHeaderProps, ChildrenCardsProps, sliderSizesObject, textSize, } from '../../schema/validators/common';
|
|
2
|
+
const LoadableProps = {
|
|
3
|
+
additionalProperties: false,
|
|
4
|
+
required: ['source'],
|
|
5
|
+
properties: {
|
|
6
|
+
source: {
|
|
7
|
+
type: 'string',
|
|
8
|
+
// add loadable sources here if you use it in your project
|
|
9
|
+
// enum: ['my-loadable-source-1', 'my-loadable-source-1'],
|
|
10
|
+
},
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated
|
|
13
|
+
*/
|
|
14
|
+
minCount: {
|
|
15
|
+
type: 'number',
|
|
16
|
+
},
|
|
17
|
+
params: {
|
|
18
|
+
type: 'object',
|
|
19
|
+
patternProperties: {
|
|
20
|
+
'.*': {
|
|
21
|
+
type: ['string', 'number', 'boolean'],
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
// remove it in your custom validator schema if you use loadable
|
|
27
|
+
disabled: true,
|
|
28
|
+
};
|
|
29
|
+
const DisclaimerProps = {
|
|
30
|
+
additionalProperties: false,
|
|
31
|
+
required: ['text'],
|
|
32
|
+
properties: {
|
|
33
|
+
text: {
|
|
34
|
+
type: 'string',
|
|
35
|
+
contentType: 'text',
|
|
36
|
+
},
|
|
37
|
+
size: {
|
|
38
|
+
type: 'string',
|
|
39
|
+
enum: textSize,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
export const SliderNewProps = {
|
|
44
|
+
dots: {
|
|
45
|
+
type: 'boolean',
|
|
46
|
+
},
|
|
47
|
+
arrows: {
|
|
48
|
+
type: 'boolean',
|
|
49
|
+
},
|
|
50
|
+
randomOrder: {
|
|
51
|
+
type: 'boolean',
|
|
52
|
+
},
|
|
53
|
+
autoplay: {
|
|
54
|
+
type: 'number',
|
|
55
|
+
},
|
|
56
|
+
type: {
|
|
57
|
+
type: 'string',
|
|
58
|
+
},
|
|
59
|
+
adaptive: {
|
|
60
|
+
type: 'boolean',
|
|
61
|
+
},
|
|
62
|
+
arrowSize: {
|
|
63
|
+
type: 'number',
|
|
64
|
+
},
|
|
65
|
+
animated: AnimatableProps,
|
|
66
|
+
slidesToShow: sliderSizesObject,
|
|
67
|
+
disclaimer: DisclaimerProps,
|
|
68
|
+
loadable: LoadableProps,
|
|
69
|
+
children: ChildrenCardsProps,
|
|
70
|
+
};
|
|
71
|
+
export const SliderNewBlock = {
|
|
72
|
+
'slider-new-block': {
|
|
73
|
+
additionalProperties: false,
|
|
74
|
+
required: [],
|
|
75
|
+
properties: Object.assign(Object.assign(Object.assign(Object.assign({}, BlockBaseProps), AnimatableProps), SliderNewProps), BlockHeaderProps),
|
|
76
|
+
},
|
|
77
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
|
2
|
+
import type { Swiper } from 'swiper';
|
|
3
|
+
import { SlidesToShow } from '../../models';
|
|
4
|
+
export declare const useSlider: ({ children, autoplayMs, type, slidesToShow, }: React.PropsWithChildren<{
|
|
5
|
+
autoplayMs?: number | undefined;
|
|
6
|
+
type?: string | undefined;
|
|
7
|
+
slidesToShow?: SlidesToShow | undefined;
|
|
8
|
+
}>) => {
|
|
9
|
+
slider: Swiper | undefined;
|
|
10
|
+
onSwiper: React.Dispatch<React.SetStateAction<Swiper | undefined>>;
|
|
11
|
+
onNext: () => void;
|
|
12
|
+
onPrev: () => void;
|
|
13
|
+
breakpoints: Record<number, import("swiper").SwiperOptions>;
|
|
14
|
+
childrenCount: number;
|
|
15
|
+
isLocked: boolean;
|
|
16
|
+
setIsLocked: React.Dispatch<React.SetStateAction<boolean>>;
|
|
17
|
+
autoplay: false | {
|
|
18
|
+
delay: number | undefined;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import { SliderType } from '../../models';
|
|
3
|
+
import { getSliderResponsiveParams } from './utils';
|
|
4
|
+
export const useSlider = ({ children, autoplayMs, type, slidesToShow, }) => {
|
|
5
|
+
const [slider, setSlider] = useState();
|
|
6
|
+
const [isLocked, setIsLocked] = useState(false);
|
|
7
|
+
const childrenCount = React.Children.count(children);
|
|
8
|
+
const autoplayEnabled = useMemo(() => Boolean(autoplayMs), [autoplayMs]);
|
|
9
|
+
const breakpoints = useMemo(() => {
|
|
10
|
+
return getSliderResponsiveParams({
|
|
11
|
+
contentLength: childrenCount,
|
|
12
|
+
slidesToShow,
|
|
13
|
+
mobileFullscreen: Boolean(type && Object.values(SliderType).includes(type)),
|
|
14
|
+
});
|
|
15
|
+
}, [slidesToShow, type, childrenCount]);
|
|
16
|
+
const handleNext = () => {
|
|
17
|
+
if (!slider) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (slider.isEnd) {
|
|
21
|
+
slider.slideTo(0);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
slider.slideNext();
|
|
25
|
+
};
|
|
26
|
+
const handlePrev = () => {
|
|
27
|
+
if (!slider) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (slider.isBeginning) {
|
|
31
|
+
slider.slideTo(childrenCount - 1);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
slider.slidePrev();
|
|
35
|
+
};
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (!slider) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (autoplayEnabled) {
|
|
41
|
+
slider.autoplay.start();
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
slider.autoplay.stop();
|
|
45
|
+
}
|
|
46
|
+
}, [slider, autoplayEnabled]);
|
|
47
|
+
return {
|
|
48
|
+
slider,
|
|
49
|
+
onSwiper: setSlider,
|
|
50
|
+
onNext: handleNext,
|
|
51
|
+
onPrev: handlePrev,
|
|
52
|
+
breakpoints,
|
|
53
|
+
childrenCount,
|
|
54
|
+
isLocked,
|
|
55
|
+
setIsLocked,
|
|
56
|
+
autoplay: autoplayEnabled && {
|
|
57
|
+
delay: autoplayMs,
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { SwiperOptions } from 'swiper/types/swiper-options';
|
|
2
|
+
import { SlidesToShow } from './models';
|
|
3
|
+
export declare const DEFAULT_SLIDE_BREAKPOINTS: {
|
|
4
|
+
lg: number;
|
|
5
|
+
md: number;
|
|
6
|
+
sm: number;
|
|
7
|
+
xs: number;
|
|
8
|
+
};
|
|
9
|
+
export interface GetSlidesToShowParams {
|
|
10
|
+
contentLength: number;
|
|
11
|
+
slidesToShow?: SlidesToShow;
|
|
12
|
+
mobileFullscreen?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function getSliderResponsiveParams({ contentLength, slidesToShow, mobileFullscreen, }: GetSlidesToShowParams): Record<number, SwiperOptions>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import pickBy from 'lodash/pickBy';
|
|
2
|
+
import { BREAKPOINTS } from '../../constants';
|
|
3
|
+
import { SliderBreakpointNames } from './models';
|
|
4
|
+
export const DEFAULT_SLIDE_BREAKPOINTS = {
|
|
5
|
+
[SliderBreakpointNames.Lg]: 3,
|
|
6
|
+
[SliderBreakpointNames.Md]: 2,
|
|
7
|
+
[SliderBreakpointNames.Sm]: 2,
|
|
8
|
+
[SliderBreakpointNames.Xs]: 1.15,
|
|
9
|
+
};
|
|
10
|
+
export function getSliderResponsiveParams({ contentLength, slidesToShow, mobileFullscreen, }) {
|
|
11
|
+
let result;
|
|
12
|
+
if (typeof slidesToShow === 'number') {
|
|
13
|
+
result = Object.keys(DEFAULT_SLIDE_BREAKPOINTS).reduce((acc, breakpointName) => (Object.assign(Object.assign({}, acc), { [breakpointName]: slidesToShow })), {});
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
result = slidesToShow || DEFAULT_SLIDE_BREAKPOINTS;
|
|
17
|
+
}
|
|
18
|
+
const showCount = Object.assign(Object.assign(Object.assign({}, DEFAULT_SLIDE_BREAKPOINTS), pickBy(result, (value) => !isNaN(value))), { xs: !mobileFullscreen && contentLength > 1 ? DEFAULT_SLIDE_BREAKPOINTS.xs : 1 });
|
|
19
|
+
return Object.entries(showCount).reduce((res, [breakpointName, value]) => {
|
|
20
|
+
// eslint-disable-next-line no-param-reassign
|
|
21
|
+
res[BREAKPOINTS[breakpointName] + 1] = {
|
|
22
|
+
slidesPerView: value,
|
|
23
|
+
};
|
|
24
|
+
return res;
|
|
25
|
+
}, {});
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as SliderNewBlock } from './SliderNew/Slider';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as SliderNewBlock } from './SliderNew/Slider';
|
|
@@ -26,6 +26,9 @@ unpredictable css rules order in build */
|
|
|
26
26
|
.slick-slide:not(.slick-active) .pc-card-base-block {
|
|
27
27
|
box-shadow: none;
|
|
28
28
|
}
|
|
29
|
+
.swiper-slide:not(.swiper-slide-visible) .pc-card-base-block {
|
|
30
|
+
box-shadow: none;
|
|
31
|
+
}
|
|
29
32
|
}
|
|
30
33
|
.pc-card-base-block__header {
|
|
31
34
|
position: relative;
|
|
@@ -18,6 +18,7 @@ export declare const blockMap: {
|
|
|
18
18
|
"map-block": ({ map, border, disableShadow, ...props }: import("./models").MapBlockProps) => JSX.Element;
|
|
19
19
|
"filter-block": import("react").FC<import("./models").FilterBlockProps>;
|
|
20
20
|
"form-block": import("react").FC<import("./models").FormBlockProps>;
|
|
21
|
+
"slider-new-block": ({ animated, title, description, type, anchorId, arrows, adaptive, autoplay: autoplayMs, dots, dotsClassName, disclaimer, children, blockClassName, arrowSize, slidesToShow, onSlideChange, onSlideChangeTransitionStart, onSlideChangeTransitionEnd, onActiveIndexChange, onBreakpoint, }: import("react").PropsWithChildren<import("./blocks/SliderNew/Slider").SliderNewProps>) => JSX.Element;
|
|
21
22
|
};
|
|
22
23
|
export declare const subBlockMap: {
|
|
23
24
|
divider: ({ size, border }: import("./models").DividerProps) => JSX.Element;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BannerBlock, CardLayoutBlock, CompaniesBlock, ContentLayoutBlock, ExtendedFeaturesBlock, FilterBlock, FormBlock, HeaderBlock, HeaderSliderBlock, IconsBlock, InfoBlock, MapBlock, MediaBlock, PromoFeaturesBlock, QuestionsBlock, ShareBlock, SliderBlock, TableBlock, TabsBlock, } from './blocks';
|
|
2
|
+
import { SliderNewBlock } from './blocks/unstable';
|
|
2
3
|
import { BlockType, NavigationItemType, SubBlockType } from './models';
|
|
3
4
|
import { GithubButton, NavigationButton, NavigationDropdown, NavigationLink, } from './navigation/components/NavigationItem';
|
|
4
5
|
import SocialIcon from './navigation/components/SocialIcon/SocialIcon';
|
|
@@ -23,6 +24,8 @@ export const blockMap = {
|
|
|
23
24
|
[BlockType.MapBlock]: MapBlock,
|
|
24
25
|
[BlockType.FilterBlock]: FilterBlock,
|
|
25
26
|
[BlockType.FormBlock]: FormBlock,
|
|
27
|
+
// unstable
|
|
28
|
+
[BlockType.SliderNewBlock]: SliderNewBlock,
|
|
26
29
|
};
|
|
27
30
|
export const subBlockMap = {
|
|
28
31
|
[SubBlockType.Divider]: Divider,
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"template": {
|
|
3
|
+
"type": "slider-new-block",
|
|
4
|
+
"title": {
|
|
5
|
+
"text": "Slider new",
|
|
6
|
+
"url": "https://example.com"
|
|
7
|
+
},
|
|
8
|
+
"children": [
|
|
9
|
+
{
|
|
10
|
+
"type": "basic-card",
|
|
11
|
+
"url": "https://example.com",
|
|
12
|
+
"title": "Lorem ipsum dolor sit amet",
|
|
13
|
+
"text": "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
|
|
14
|
+
"icon": "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNiAyN0MyMi4wNzUxIDI3IDI3IDIyLjA3NTEgMjcgMTZDMjcgOS45MjQ4NyAyMi4wNzUxIDUgMTYgNUM5LjkyNDg3IDUgNSA5LjkyNDg3IDUgMTZDNSAyMi4wNzUxIDkuOTI0ODcgMjcgMTYgMjdaTTE2IDMwQzIzLjczMiAzMCAzMCAyMy43MzIgMzAgMTZDMzAgOC4yNjgwMSAyMy43MzIgMiAxNiAyQzguMjY4MDEgMiAyIDguMjY4MDEgMiAxNkMyIDIzLjczMiA4LjI2ODAxIDMwIDE2IDMwWiIgZmlsbD0iIzI2MjYyNiIvPgo8L3N2Zz4K"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"type": "basic-card",
|
|
18
|
+
"url": "https://example.com",
|
|
19
|
+
"title": "Lorem ipsum dolor sit amet",
|
|
20
|
+
"text": "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
|
|
21
|
+
"icon": "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNiAyN0MyMi4wNzUxIDI3IDI3IDIyLjA3NTEgMjcgMTZDMjcgOS45MjQ4NyAyMi4wNzUxIDUgMTYgNUM5LjkyNDg3IDUgNSA5LjkyNDg3IDUgMTZDNSAyMi4wNzUxIDkuOTI0ODcgMjcgMTYgMjdaTTE2IDMwQzIzLjczMiAzMCAzMCAyMy43MzIgMzAgMTZDMzAgOC4yNjgwMSAyMy43MzIgMiAxNiAyQzguMjY4MDEgMiAyIDguMjY4MDEgMiAxNkMyIDIzLjczMiA4LjI2ODAxIDMwIDE2IDMwWiIgZmlsbD0iIzI2MjYyNiIvPgo8L3N2Zz4K"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"type": "basic-card",
|
|
25
|
+
"url": "https://example.com",
|
|
26
|
+
"title": "Lorem ipsum dolor sit amet",
|
|
27
|
+
"text": "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
|
|
28
|
+
"icon": "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNiAyN0MyMi4wNzUxIDI3IDI3IDIyLjA3NTEgMjcgMTZDMjcgOS45MjQ4NyAyMi4wNzUxIDUgMTYgNUM5LjkyNDg3IDUgNSA5LjkyNDg3IDUgMTZDNSAyMi4wNzUxIDkuOTI0ODcgMjcgMTYgMjdaTTE2IDMwQzIzLjczMiAzMCAzMCAyMy43MzIgMzAgMTZDMzAgOC4yNjgwMSAyMy43MzIgMiAxNiAyQzguMjY4MDEgMiAyIDguMjY4MDEgMiAxNkMyIDIzLjczMiA4LjI2ODAxIDMwIDE2IDMwWiIgZmlsbD0iIzI2MjYyNiIvPgo8L3N2Zz4K"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"type": "basic-card",
|
|
32
|
+
"url": "https://example.com",
|
|
33
|
+
"title": "Lorem ipsum dolor sit amet",
|
|
34
|
+
"text": "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
|
|
35
|
+
"icon": "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNiAyN0MyMi4wNzUxIDI3IDI3IDIyLjA3NTEgMjcgMTZDMjcgOS45MjQ4NyAyMi4wNzUxIDUgMTYgNUM5LjkyNDg3IDUgNSA5LjkyNDg3IDUgMTZDNSAyMi4wNzUxIDkuOTI0ODcgMjcgMTYgMjdaTTE2IDMwQzIzLjczMiAzMCAzMCAyMy43MzIgMzAgMTZDMzAgOC4yNjgwMSAyMy43MzIgMiAxNiAyQzguMjY4MDEgMiAyIDguMjY4MDEgMiAxNkMyIDIzLjczMiA4LjI2ODAxIDMwIDE2IDMwWiIgZmlsbD0iIzI2MjYyNiIvPgo8L3N2Zz4K"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"type": "basic-card",
|
|
39
|
+
"url": "https://example.com",
|
|
40
|
+
"title": "Lorem ipsum dolor sit amet",
|
|
41
|
+
"text": "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
|
|
42
|
+
"icon": "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNiAyN0MyMi4wNzUxIDI3IDI3IDIyLjA3NTEgMjcgMTZDMjcgOS45MjQ4NyAyMi4wNzUxIDUgMTYgNUM5LjkyNDg3IDUgNSA5LjkyNDg3IDUgMTZDNSAyMi4wNzUxIDkuOTI0ODcgMjcgMTYgMjdaTTE2IDMwQzIzLjczMiAzMCAzMCAyMy43MzIgMzAgMTZDMzAgOC4yNjgwMSAyMy43MzIgMiAxNiAyQzguMjY4MDEgMiAyIDguMjY4MDEgMiAxNkMyIDIzLjczMiA4LjI2ODAxIDMwIDE2IDMwWiIgZmlsbD0iIzI2MjYyNiIvPgo8L3N2Zz4K"
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
}
|