@gem-sdk/components 2.0.0-dev.447 → 2.0.0-dev.448
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/dist/cjs/sticky/components/Sticky.js +8 -5
- package/dist/cjs/sticky/components/Sticky.liquid.js +6 -5
- package/dist/cjs/sticky/components/common/styles.js +55 -6
- package/dist/cjs/sticky/components/hooks/useSticky.js +2 -8
- package/dist/cjs/sticky/setting/configs/settingsV2.js +1 -1
- package/dist/esm/sticky/components/Sticky.js +9 -6
- package/dist/esm/sticky/components/Sticky.liquid.js +8 -7
- package/dist/esm/sticky/components/common/styles.js +53 -8
- package/dist/esm/sticky/components/hooks/useSticky.js +2 -8
- package/dist/esm/sticky/setting/configs/settingsV2.js +1 -1
- package/package.json +1 -1
|
@@ -11,16 +11,18 @@ require('react');
|
|
|
11
11
|
var _const = require('../../common/const.js');
|
|
12
12
|
var useSticky = require('./hooks/useSticky.js');
|
|
13
13
|
var system = require('@gem-sdk/system');
|
|
14
|
+
var styles = require('./common/styles.js');
|
|
14
15
|
|
|
15
16
|
const Sticky = ({ children, builderAttrs, setting, style, builderProps })=>{
|
|
17
|
+
const mode = core.useEditorMode();
|
|
16
18
|
const { background, preloadBgImage } = setting ?? {};
|
|
17
|
-
const { w,
|
|
19
|
+
const { w, positionStyle, displayStyle, getCSSAlign } = useSticky.default(setting);
|
|
18
20
|
const computedContainerStyles = system.createStyle({
|
|
19
21
|
margin: '0 auto',
|
|
20
|
-
...style,
|
|
21
22
|
...w,
|
|
22
|
-
...core.getStyleBackgroundByDevice(background),
|
|
23
23
|
...displayStyle,
|
|
24
|
+
...styles.getStylePadding(style),
|
|
25
|
+
...mode !== 'edit' && setting?.isScrollToTop ? styles.displayConditionStyle(setting?.display, setting?.position) : {},
|
|
24
26
|
...positionStyle,
|
|
25
27
|
...getCSSAlign,
|
|
26
28
|
zIndex: _const.ELEMENT_Z_INDEX.STICKY
|
|
@@ -53,8 +55,9 @@ const Sticky = ({ children, builderAttrs, setting, style, builderProps })=>{
|
|
|
53
55
|
children: /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
54
56
|
...builderAttrs,
|
|
55
57
|
"data-id": builderProps?.uid,
|
|
56
|
-
|
|
57
|
-
...
|
|
58
|
+
style: {
|
|
59
|
+
...styles.filterStyles(style),
|
|
60
|
+
...core.getStyleBackgroundByDevice(background)
|
|
58
61
|
},
|
|
59
62
|
children: core.isEmptyChildren(children) ? /*#__PURE__*/ jsxRuntime.jsx(ChildrenDroppable.default, {}) : children
|
|
60
63
|
})
|
|
@@ -8,12 +8,10 @@ var system = require('@gem-sdk/system');
|
|
|
8
8
|
var styles = require('./common/styles.js');
|
|
9
9
|
|
|
10
10
|
const Sticky = ({ children, builderAttrs, setting, style, builderProps, advanced })=>{
|
|
11
|
-
const { width,
|
|
11
|
+
const { width, position, display, preloadBgImage, background, isScrollToTop } = setting ?? {};
|
|
12
12
|
const advancedDisplay = advanced?.d;
|
|
13
|
-
const w = core.makeWidth(width, fullWidth);
|
|
14
13
|
const computedContainerStyles = system.createStyle(styles.getContainerStyles({
|
|
15
|
-
|
|
16
|
-
background,
|
|
14
|
+
width,
|
|
17
15
|
position,
|
|
18
16
|
style,
|
|
19
17
|
display
|
|
@@ -40,7 +38,10 @@ const Sticky = ({ children, builderAttrs, setting, style, builderProps, advanced
|
|
|
40
38
|
>
|
|
41
39
|
<div ${{
|
|
42
40
|
...builderAttrs
|
|
43
|
-
}}
|
|
41
|
+
}} style="${{
|
|
42
|
+
...styles.filterStyles(style),
|
|
43
|
+
...core.getStyleBackgroundByDevice(background)
|
|
44
|
+
}}">
|
|
44
45
|
${children}
|
|
45
46
|
</div>
|
|
46
47
|
</gp-sticky>
|
|
@@ -30,7 +30,7 @@ const getDisplayStyle = (device, display, position)=>{
|
|
|
30
30
|
const getCSSPosition = (position)=>{
|
|
31
31
|
return position == 'top' ? 'sticky' : 'fixed';
|
|
32
32
|
};
|
|
33
|
-
const
|
|
33
|
+
const displayConditionStyle = (display, position)=>{
|
|
34
34
|
return {
|
|
35
35
|
...getDisplayStyle('', display?.desktop, position?.desktop),
|
|
36
36
|
...getDisplayStyle('-tablet', display?.tablet ?? display?.desktop, position?.tablet ?? position?.desktop),
|
|
@@ -38,16 +38,65 @@ const displayStyle = (display, position)=>{
|
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
40
|
const getContainerStyles = (args)=>{
|
|
41
|
-
const { style,
|
|
41
|
+
const { style, width, position, display } = args;
|
|
42
42
|
return {
|
|
43
43
|
margin: '0 auto',
|
|
44
|
-
...style,
|
|
45
|
-
...core.makeStyleResponsive('w',
|
|
46
|
-
...
|
|
47
|
-
...displayStyle(display, position),
|
|
44
|
+
...getStylePadding(style),
|
|
45
|
+
...core.makeStyleResponsive('w', width),
|
|
46
|
+
...displayConditionStyle(display, position),
|
|
48
47
|
...getCSSAlign(position),
|
|
49
48
|
'z-index': _const.ELEMENT_Z_INDEX.STICKY
|
|
50
49
|
};
|
|
51
50
|
};
|
|
51
|
+
const getStylePadding = (style)=>{
|
|
52
|
+
const keepList = [
|
|
53
|
+
'--pt',
|
|
54
|
+
'--pb',
|
|
55
|
+
'--pr',
|
|
56
|
+
'--pl',
|
|
57
|
+
'--pt-mobile',
|
|
58
|
+
'--pb-mobile',
|
|
59
|
+
'--pr-mobile',
|
|
60
|
+
'--pl-mobile',
|
|
61
|
+
'--pt-tablet',
|
|
62
|
+
'--pb-tablet',
|
|
63
|
+
'--pr-tablet',
|
|
64
|
+
'--pl-tablet'
|
|
65
|
+
];
|
|
66
|
+
const keepStyles = {};
|
|
67
|
+
keepList.forEach((element)=>{
|
|
68
|
+
if (style?.[element]) {
|
|
69
|
+
keepStyles[element] = style[element];
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
return keepStyles;
|
|
73
|
+
};
|
|
74
|
+
const filterStyles = (style)=>{
|
|
75
|
+
const cloneStyle = {
|
|
76
|
+
...style
|
|
77
|
+
};
|
|
78
|
+
const delList = [
|
|
79
|
+
'--pt',
|
|
80
|
+
'--pb',
|
|
81
|
+
'--pr',
|
|
82
|
+
'--pl',
|
|
83
|
+
'--pt-mobile',
|
|
84
|
+
'--pb-mobile',
|
|
85
|
+
'--pr-mobile',
|
|
86
|
+
'--pl-mobile',
|
|
87
|
+
'--pt-tablet',
|
|
88
|
+
'--pb-tablet',
|
|
89
|
+
'--pr-tablet',
|
|
90
|
+
'--pl-tablet'
|
|
91
|
+
];
|
|
92
|
+
delList.forEach((element)=>{
|
|
93
|
+
delete cloneStyle?.[element];
|
|
94
|
+
});
|
|
95
|
+
return cloneStyle;
|
|
96
|
+
};
|
|
52
97
|
|
|
98
|
+
exports.displayConditionStyle = displayConditionStyle;
|
|
99
|
+
exports.filterStyles = filterStyles;
|
|
53
100
|
exports.getContainerStyles = getContainerStyles;
|
|
101
|
+
exports.getDisplayStyle = getDisplayStyle;
|
|
102
|
+
exports.getStylePadding = getStylePadding;
|
|
@@ -3,17 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var core = require('@gem-sdk/core');
|
|
6
|
-
var helpers = require('../../../grid/row/commons/helpers.js');
|
|
7
6
|
var React = require('react');
|
|
8
7
|
|
|
9
8
|
const useSticky = (setting)=>{
|
|
10
|
-
const { width,
|
|
11
|
-
const
|
|
12
|
-
desktop: false,
|
|
13
|
-
tablet: false,
|
|
14
|
-
mobile: false
|
|
15
|
-
});
|
|
16
|
-
const w = core.makeStyleResponsive('w', styleObject.content);
|
|
9
|
+
const { width, position } = setting ?? {};
|
|
10
|
+
const w = core.makeStyleResponsive('w', width);
|
|
17
11
|
const sidebarMode = core.usePageStore((s)=>s.sidebarMode === 'interaction');
|
|
18
12
|
const currentDevice = core.useCurrentDevice();
|
|
19
13
|
const getCSSPosition = (position)=>{
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
|
-
import {
|
|
3
|
+
import { useEditorMode, cls, getStyleBackgroundByDevice, isEmptyChildren } from '@gem-sdk/core';
|
|
4
4
|
import Head from 'next/head';
|
|
5
5
|
import ChildrenDroppable from '../../grid/components/ChildrenDroppable.js';
|
|
6
6
|
import 'react';
|
|
7
7
|
import { ELEMENT_Z_INDEX } from '../../common/const.js';
|
|
8
8
|
import useSticky from './hooks/useSticky.js';
|
|
9
9
|
import { createStyle } from '@gem-sdk/system';
|
|
10
|
+
import { getStylePadding, displayConditionStyle, filterStyles } from './common/styles.js';
|
|
10
11
|
|
|
11
12
|
const Sticky = ({ children, builderAttrs, setting, style, builderProps })=>{
|
|
13
|
+
const mode = useEditorMode();
|
|
12
14
|
const { background, preloadBgImage } = setting ?? {};
|
|
13
|
-
const { w,
|
|
15
|
+
const { w, positionStyle, displayStyle, getCSSAlign } = useSticky(setting);
|
|
14
16
|
const computedContainerStyles = createStyle({
|
|
15
17
|
margin: '0 auto',
|
|
16
|
-
...style,
|
|
17
18
|
...w,
|
|
18
|
-
...getStyleBackgroundByDevice(background),
|
|
19
19
|
...displayStyle,
|
|
20
|
+
...getStylePadding(style),
|
|
21
|
+
...mode !== 'edit' && setting?.isScrollToTop ? displayConditionStyle(setting?.display, setting?.position) : {},
|
|
20
22
|
...positionStyle,
|
|
21
23
|
...getCSSAlign,
|
|
22
24
|
zIndex: ELEMENT_Z_INDEX.STICKY
|
|
@@ -49,8 +51,9 @@ const Sticky = ({ children, builderAttrs, setting, style, builderProps })=>{
|
|
|
49
51
|
children: /*#__PURE__*/ jsx("div", {
|
|
50
52
|
...builderAttrs,
|
|
51
53
|
"data-id": builderProps?.uid,
|
|
52
|
-
|
|
53
|
-
...
|
|
54
|
+
style: {
|
|
55
|
+
...filterStyles(style),
|
|
56
|
+
...getStyleBackgroundByDevice(background)
|
|
54
57
|
},
|
|
55
58
|
children: isEmptyChildren(children) ? /*#__PURE__*/ jsx(ChildrenDroppable, {}) : children
|
|
56
59
|
})
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { template, RenderIf, getStyleBackgroundByDevice, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
|
|
2
2
|
import { getSettingPreloadData } from '../../helpers.js';
|
|
3
3
|
import { createStyle, createStateOrContext } from '@gem-sdk/system';
|
|
4
|
-
import { getContainerStyles } from './common/styles.js';
|
|
4
|
+
import { getContainerStyles, filterStyles } from './common/styles.js';
|
|
5
5
|
|
|
6
6
|
const Sticky = ({ children, builderAttrs, setting, style, builderProps, advanced })=>{
|
|
7
|
-
const { width,
|
|
7
|
+
const { width, position, display, preloadBgImage, background, isScrollToTop } = setting ?? {};
|
|
8
8
|
const advancedDisplay = advanced?.d;
|
|
9
|
-
const w = makeWidth(width, fullWidth);
|
|
10
9
|
const computedContainerStyles = createStyle(getContainerStyles({
|
|
11
|
-
|
|
12
|
-
background,
|
|
10
|
+
width,
|
|
13
11
|
position,
|
|
14
12
|
style,
|
|
15
13
|
display
|
|
@@ -36,7 +34,10 @@ const Sticky = ({ children, builderAttrs, setting, style, builderProps, advanced
|
|
|
36
34
|
>
|
|
37
35
|
<div ${{
|
|
38
36
|
...builderAttrs
|
|
39
|
-
}}
|
|
37
|
+
}} style="${{
|
|
38
|
+
...filterStyles(style),
|
|
39
|
+
...getStyleBackgroundByDevice(background)
|
|
40
|
+
}}">
|
|
40
41
|
${children}
|
|
41
42
|
</div>
|
|
42
43
|
</gp-sticky>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { makeStyleResponsive
|
|
1
|
+
import { makeStyleResponsive } from '@gem-sdk/core';
|
|
2
2
|
import 'react/jsx-runtime';
|
|
3
3
|
import 'react';
|
|
4
4
|
import { ELEMENT_Z_INDEX } from '../../../common/const.js';
|
|
@@ -28,7 +28,7 @@ const getDisplayStyle = (device, display, position)=>{
|
|
|
28
28
|
const getCSSPosition = (position)=>{
|
|
29
29
|
return position == 'top' ? 'sticky' : 'fixed';
|
|
30
30
|
};
|
|
31
|
-
const
|
|
31
|
+
const displayConditionStyle = (display, position)=>{
|
|
32
32
|
return {
|
|
33
33
|
...getDisplayStyle('', display?.desktop, position?.desktop),
|
|
34
34
|
...getDisplayStyle('-tablet', display?.tablet ?? display?.desktop, position?.tablet ?? position?.desktop),
|
|
@@ -36,16 +36,61 @@ const displayStyle = (display, position)=>{
|
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
38
|
const getContainerStyles = (args)=>{
|
|
39
|
-
const { style,
|
|
39
|
+
const { style, width, position, display } = args;
|
|
40
40
|
return {
|
|
41
41
|
margin: '0 auto',
|
|
42
|
-
...style,
|
|
43
|
-
...makeStyleResponsive('w',
|
|
44
|
-
...
|
|
45
|
-
...displayStyle(display, position),
|
|
42
|
+
...getStylePadding(style),
|
|
43
|
+
...makeStyleResponsive('w', width),
|
|
44
|
+
...displayConditionStyle(display, position),
|
|
46
45
|
...getCSSAlign(position),
|
|
47
46
|
'z-index': ELEMENT_Z_INDEX.STICKY
|
|
48
47
|
};
|
|
49
48
|
};
|
|
49
|
+
const getStylePadding = (style)=>{
|
|
50
|
+
const keepList = [
|
|
51
|
+
'--pt',
|
|
52
|
+
'--pb',
|
|
53
|
+
'--pr',
|
|
54
|
+
'--pl',
|
|
55
|
+
'--pt-mobile',
|
|
56
|
+
'--pb-mobile',
|
|
57
|
+
'--pr-mobile',
|
|
58
|
+
'--pl-mobile',
|
|
59
|
+
'--pt-tablet',
|
|
60
|
+
'--pb-tablet',
|
|
61
|
+
'--pr-tablet',
|
|
62
|
+
'--pl-tablet'
|
|
63
|
+
];
|
|
64
|
+
const keepStyles = {};
|
|
65
|
+
keepList.forEach((element)=>{
|
|
66
|
+
if (style?.[element]) {
|
|
67
|
+
keepStyles[element] = style[element];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
return keepStyles;
|
|
71
|
+
};
|
|
72
|
+
const filterStyles = (style)=>{
|
|
73
|
+
const cloneStyle = {
|
|
74
|
+
...style
|
|
75
|
+
};
|
|
76
|
+
const delList = [
|
|
77
|
+
'--pt',
|
|
78
|
+
'--pb',
|
|
79
|
+
'--pr',
|
|
80
|
+
'--pl',
|
|
81
|
+
'--pt-mobile',
|
|
82
|
+
'--pb-mobile',
|
|
83
|
+
'--pr-mobile',
|
|
84
|
+
'--pl-mobile',
|
|
85
|
+
'--pt-tablet',
|
|
86
|
+
'--pb-tablet',
|
|
87
|
+
'--pr-tablet',
|
|
88
|
+
'--pl-tablet'
|
|
89
|
+
];
|
|
90
|
+
delList.forEach((element)=>{
|
|
91
|
+
delete cloneStyle?.[element];
|
|
92
|
+
});
|
|
93
|
+
return cloneStyle;
|
|
94
|
+
};
|
|
50
95
|
|
|
51
|
-
export { getContainerStyles };
|
|
96
|
+
export { displayConditionStyle, filterStyles, getContainerStyles, getDisplayStyle, getStylePadding };
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import { makeStyleResponsive, usePageStore, useCurrentDevice } from '@gem-sdk/core';
|
|
2
|
-
import { createStyleObject } from '../../../grid/row/commons/helpers.js';
|
|
3
2
|
import { useMemo } from 'react';
|
|
4
3
|
|
|
5
4
|
const useSticky = (setting)=>{
|
|
6
|
-
const { width,
|
|
7
|
-
const
|
|
8
|
-
desktop: false,
|
|
9
|
-
tablet: false,
|
|
10
|
-
mobile: false
|
|
11
|
-
});
|
|
12
|
-
const w = makeStyleResponsive('w', styleObject.content);
|
|
5
|
+
const { width, position } = setting ?? {};
|
|
6
|
+
const w = makeStyleResponsive('w', width);
|
|
13
7
|
const sidebarMode = usePageStore((s)=>s.sidebarMode === 'interaction');
|
|
14
8
|
const currentDevice = useCurrentDevice();
|
|
15
9
|
const getCSSPosition = (position)=>{
|