@gem-sdk/components 2.0.0-dev.471 → 2.0.0-dev.472

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.
@@ -12,19 +12,30 @@ var _const = require('../../common/const.js');
12
12
  var useSticky = require('./hooks/useSticky.js');
13
13
  var system = require('@gem-sdk/system');
14
14
  var styles = require('./common/styles.js');
15
+ var classes = require('./common/classes.js');
15
16
 
16
- const Sticky = ({ children, builderAttrs, setting, style, builderProps })=>{
17
- const { background, preloadBgImage } = setting ?? {};
18
- const { w, positionStyle, displayStyle, getCSSAlign } = useSticky.default(setting);
17
+ const Sticky = ({ children, builderAttrs, setting, style, builderProps, advanced })=>{
18
+ const { background, preloadBgImage, width, isScrollToTop } = setting ?? {};
19
+ const { w, positionStyle, displayStyle } = useSticky.default(setting);
19
20
  const computedContainerStyles = system.createStyle({
20
21
  margin: '0 auto',
21
22
  ...w,
22
23
  ...displayStyle,
23
24
  ...styles.getStylePadding(style),
24
25
  ...positionStyle,
25
- ...getCSSAlign,
26
26
  zIndex: _const.ELEMENT_Z_INDEX.STICKY
27
27
  });
28
+ const computedContentStyles = system.createStyle(styles.getContentStyles({
29
+ width,
30
+ style,
31
+ background
32
+ }));
33
+ const computedContainerClasses = system.createClass(classes.getContainerClasses({
34
+ uid: builderProps?.uid,
35
+ isScrollToTop,
36
+ cssClass: advanced?.cssClass,
37
+ isLiquid: false
38
+ }));
28
39
  return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
29
40
  children: [
30
41
  !!preloadBgImage && /*#__PURE__*/ jsxRuntime.jsxs(Head, {
@@ -47,15 +58,14 @@ const Sticky = ({ children, builderAttrs, setting, style, builderProps })=>{
47
58
  ]
48
59
  }),
49
60
  /*#__PURE__*/ jsxRuntime.jsx("div", {
50
- className: core.cls('sticky-wrapper', builderProps?.uid),
61
+ className: computedContainerClasses,
51
62
  id: builderProps?.uid,
52
63
  style: computedContainerStyles,
53
64
  children: /*#__PURE__*/ jsxRuntime.jsx("div", {
54
65
  ...builderAttrs,
55
66
  "data-id": builderProps?.uid,
56
67
  style: {
57
- ...styles.filterStyles(style),
58
- ...core.getStyleBackgroundByDevice(background)
68
+ ...computedContentStyles
59
69
  },
60
70
  children: core.isEmptyChildren(children) ? /*#__PURE__*/ jsxRuntime.jsx(ChildrenDroppable.default, {}) : children
61
71
  })
@@ -6,6 +6,7 @@ var core = require('@gem-sdk/core');
6
6
  var helpers = require('../../helpers.js');
7
7
  var system = require('@gem-sdk/system');
8
8
  var styles = require('./common/styles.js');
9
+ var classes = require('./common/classes.js');
9
10
 
10
11
  const Sticky = ({ children, builderAttrs, setting, style, builderProps, advanced })=>{
11
12
  const { width, position, display, preloadBgImage, background, isScrollToTop } = setting ?? {};
@@ -16,6 +17,17 @@ const Sticky = ({ children, builderAttrs, setting, style, builderProps, advanced
16
17
  style,
17
18
  display
18
19
  }));
20
+ const computedContentStyles = system.createStyle(styles.getContentStyles({
21
+ width,
22
+ style,
23
+ background
24
+ }));
25
+ const computedContainerClasses = system.createClass(classes.getContainerClasses({
26
+ uid: builderProps?.uid,
27
+ isScrollToTop,
28
+ cssClass: advanced?.cssClass,
29
+ isLiquid: true
30
+ }));
19
31
  const createDataState = system.createStateOrContext({
20
32
  uid: builderProps?.uid,
21
33
  setting: {
@@ -32,14 +44,13 @@ const Sticky = ({ children, builderAttrs, setting, style, builderProps, advanced
32
44
  gp-data='${JSON.stringify(createDataState)}'
33
45
  id="${builderProps?.uid}"
34
46
  data-id="${builderProps?.uid}"
35
- class="${builderProps?.uid} ${helpers.getSettingPreloadData('gps-lazy')} ${advanced?.cssClass} ${isScrollToTop ? '!gp-pointer-events-none [&_gp-button_a]:!gp-pointer-events-auto' : ''}"
47
+ class="${computedContainerClasses} ${helpers.getSettingPreloadData('gps-lazy')}"
36
48
  style="${computedContainerStyles}"
37
49
  >
38
50
  <div ${{
39
51
  ...builderAttrs
40
52
  }} style="${{
41
- ...styles.filterStyles(style),
42
- ...core.getStyleBackgroundByDevice(background)
53
+ ...computedContentStyles
43
54
  }}">
44
55
  ${children}
45
56
  </div>
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ var core = require('@gem-sdk/core');
4
+
5
+ const getContainerClasses = (args)=>{
6
+ const { uid, isScrollToTop, cssClass, isLiquid } = args;
7
+ const extraClass = isScrollToTop && isLiquid ? '!gp-pointer-events-none [&_gp-button_a]:!gp-pointer-events-auto' : '';
8
+ return core.composeClasses(`sticky-wrapper gp-w-full ${extraClass} ${uid} ${cssClass}`);
9
+ };
10
+
11
+ exports.getContainerClasses = getContainerClasses;
@@ -5,19 +5,6 @@ require('react/jsx-runtime');
5
5
  require('react');
6
6
  var _const = require('../../../common/const.js');
7
7
 
8
- const getCSSAlignByDevice = (position, device)=>{
9
- return {
10
- [`--left${device}`]: position == 'top' ? '0' : '50%',
11
- [`--t${device}`]: position == 'top' ? 'unset' : 'translateX(-50%)'
12
- };
13
- };
14
- const getCSSAlign = (position)=>{
15
- return {
16
- ...getCSSAlignByDevice(position?.desktop, ''),
17
- ...getCSSAlignByDevice(position?.tablet ?? position?.desktop, '-tablet'),
18
- ...getCSSAlignByDevice(position?.mobile ?? position?.desktop, '-mobile')
19
- };
20
- };
21
8
  const getDisplayStyle = (device, display, position)=>{
22
9
  const style = {
23
10
  [`--top${device}`]: 'auto',
@@ -38,16 +25,26 @@ const displayConditionStyle = (display, position)=>{
38
25
  };
39
26
  };
40
27
  const getContainerStyles = (args)=>{
41
- const { style, width, position, display } = args;
28
+ const { style, position, display } = args;
42
29
  return {
43
30
  margin: '0 auto',
44
31
  ...getStylePadding(style),
45
- ...core.makeStyleResponsive('w', width),
46
32
  ...displayConditionStyle(display, position),
47
- ...getCSSAlign(position),
48
33
  'z-index': _const.ELEMENT_Z_INDEX.STICKY
49
34
  };
50
35
  };
36
+ const getContentStyles = (args)=>{
37
+ const { style, width, background } = args;
38
+ return {
39
+ ...core.makeStyle({
40
+ m: '0 auto'
41
+ }),
42
+ ...core.makeStyleResponsive('w', width),
43
+ ...filterStyles(style),
44
+ ...core.getGradientBgrStyleByDevice(background),
45
+ ...core.getStyleBackgroundByDevice(background)
46
+ };
47
+ };
51
48
  const getStylePadding = (style)=>{
52
49
  const keepList = [
53
50
  '--pt',
@@ -98,5 +95,6 @@ const filterStyles = (style)=>{
98
95
  exports.displayConditionStyle = displayConditionStyle;
99
96
  exports.filterStyles = filterStyles;
100
97
  exports.getContainerStyles = getContainerStyles;
98
+ exports.getContentStyles = getContentStyles;
101
99
  exports.getDisplayStyle = getDisplayStyle;
102
100
  exports.getStylePadding = getStylePadding;
@@ -1,26 +1,37 @@
1
1
  'use client';
2
2
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
3
- import { cls, getStyleBackgroundByDevice, isEmptyChildren } from '@gem-sdk/core';
3
+ import { 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
- import { createStyle } from '@gem-sdk/system';
10
- import { getStylePadding, filterStyles } from './common/styles.js';
9
+ import { createStyle, createClass } from '@gem-sdk/system';
10
+ import { getStylePadding, getContentStyles } from './common/styles.js';
11
+ import { getContainerClasses } from './common/classes.js';
11
12
 
12
- const Sticky = ({ children, builderAttrs, setting, style, builderProps })=>{
13
- const { background, preloadBgImage } = setting ?? {};
14
- const { w, positionStyle, displayStyle, getCSSAlign } = useSticky(setting);
13
+ const Sticky = ({ children, builderAttrs, setting, style, builderProps, advanced })=>{
14
+ const { background, preloadBgImage, width, isScrollToTop } = setting ?? {};
15
+ const { w, positionStyle, displayStyle } = useSticky(setting);
15
16
  const computedContainerStyles = createStyle({
16
17
  margin: '0 auto',
17
18
  ...w,
18
19
  ...displayStyle,
19
20
  ...getStylePadding(style),
20
21
  ...positionStyle,
21
- ...getCSSAlign,
22
22
  zIndex: ELEMENT_Z_INDEX.STICKY
23
23
  });
24
+ const computedContentStyles = createStyle(getContentStyles({
25
+ width,
26
+ style,
27
+ background
28
+ }));
29
+ const computedContainerClasses = createClass(getContainerClasses({
30
+ uid: builderProps?.uid,
31
+ isScrollToTop,
32
+ cssClass: advanced?.cssClass,
33
+ isLiquid: false
34
+ }));
24
35
  return /*#__PURE__*/ jsxs(Fragment, {
25
36
  children: [
26
37
  !!preloadBgImage && /*#__PURE__*/ jsxs(Head, {
@@ -43,15 +54,14 @@ const Sticky = ({ children, builderAttrs, setting, style, builderProps })=>{
43
54
  ]
44
55
  }),
45
56
  /*#__PURE__*/ jsx("div", {
46
- className: cls('sticky-wrapper', builderProps?.uid),
57
+ className: computedContainerClasses,
47
58
  id: builderProps?.uid,
48
59
  style: computedContainerStyles,
49
60
  children: /*#__PURE__*/ jsx("div", {
50
61
  ...builderAttrs,
51
62
  "data-id": builderProps?.uid,
52
63
  style: {
53
- ...filterStyles(style),
54
- ...getStyleBackgroundByDevice(background)
64
+ ...computedContentStyles
55
65
  },
56
66
  children: isEmptyChildren(children) ? /*#__PURE__*/ jsx(ChildrenDroppable, {}) : children
57
67
  })
@@ -1,7 +1,8 @@
1
- import { template, RenderIf, getStyleBackgroundByDevice, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
1
+ import { template, RenderIf, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
2
2
  import { getSettingPreloadData } from '../../helpers.js';
3
- import { createStyle, createStateOrContext } from '@gem-sdk/system';
4
- import { getContainerStyles, filterStyles } from './common/styles.js';
3
+ import { createStyle, createClass, createStateOrContext } from '@gem-sdk/system';
4
+ import { getContainerStyles, getContentStyles } from './common/styles.js';
5
+ import { getContainerClasses } from './common/classes.js';
5
6
 
6
7
  const Sticky = ({ children, builderAttrs, setting, style, builderProps, advanced })=>{
7
8
  const { width, position, display, preloadBgImage, background, isScrollToTop } = setting ?? {};
@@ -12,6 +13,17 @@ const Sticky = ({ children, builderAttrs, setting, style, builderProps, advanced
12
13
  style,
13
14
  display
14
15
  }));
16
+ const computedContentStyles = createStyle(getContentStyles({
17
+ width,
18
+ style,
19
+ background
20
+ }));
21
+ const computedContainerClasses = createClass(getContainerClasses({
22
+ uid: builderProps?.uid,
23
+ isScrollToTop,
24
+ cssClass: advanced?.cssClass,
25
+ isLiquid: true
26
+ }));
15
27
  const createDataState = createStateOrContext({
16
28
  uid: builderProps?.uid,
17
29
  setting: {
@@ -28,14 +40,13 @@ const Sticky = ({ children, builderAttrs, setting, style, builderProps, advanced
28
40
  gp-data='${JSON.stringify(createDataState)}'
29
41
  id="${builderProps?.uid}"
30
42
  data-id="${builderProps?.uid}"
31
- class="${builderProps?.uid} ${getSettingPreloadData('gps-lazy')} ${advanced?.cssClass} ${isScrollToTop ? '!gp-pointer-events-none [&_gp-button_a]:!gp-pointer-events-auto' : ''}"
43
+ class="${computedContainerClasses} ${getSettingPreloadData('gps-lazy')}"
32
44
  style="${computedContainerStyles}"
33
45
  >
34
46
  <div ${{
35
47
  ...builderAttrs
36
48
  }} style="${{
37
- ...filterStyles(style),
38
- ...getStyleBackgroundByDevice(background)
49
+ ...computedContentStyles
39
50
  }}">
40
51
  ${children}
41
52
  </div>
@@ -0,0 +1,9 @@
1
+ import { composeClasses } from '@gem-sdk/core';
2
+
3
+ const getContainerClasses = (args)=>{
4
+ const { uid, isScrollToTop, cssClass, isLiquid } = args;
5
+ const extraClass = isScrollToTop && isLiquid ? '!gp-pointer-events-none [&_gp-button_a]:!gp-pointer-events-auto' : '';
6
+ return composeClasses(`sticky-wrapper gp-w-full ${extraClass} ${uid} ${cssClass}`);
7
+ };
8
+
9
+ export { getContainerClasses };
@@ -1,21 +1,8 @@
1
- import { makeStyleResponsive } from '@gem-sdk/core';
1
+ import { makeStyle, makeStyleResponsive, getGradientBgrStyleByDevice, getStyleBackgroundByDevice } from '@gem-sdk/core';
2
2
  import 'react/jsx-runtime';
3
3
  import 'react';
4
4
  import { ELEMENT_Z_INDEX } from '../../../common/const.js';
5
5
 
6
- const getCSSAlignByDevice = (position, device)=>{
7
- return {
8
- [`--left${device}`]: position == 'top' ? '0' : '50%',
9
- [`--t${device}`]: position == 'top' ? 'unset' : 'translateX(-50%)'
10
- };
11
- };
12
- const getCSSAlign = (position)=>{
13
- return {
14
- ...getCSSAlignByDevice(position?.desktop, ''),
15
- ...getCSSAlignByDevice(position?.tablet ?? position?.desktop, '-tablet'),
16
- ...getCSSAlignByDevice(position?.mobile ?? position?.desktop, '-mobile')
17
- };
18
- };
19
6
  const getDisplayStyle = (device, display, position)=>{
20
7
  const style = {
21
8
  [`--top${device}`]: 'auto',
@@ -36,16 +23,26 @@ const displayConditionStyle = (display, position)=>{
36
23
  };
37
24
  };
38
25
  const getContainerStyles = (args)=>{
39
- const { style, width, position, display } = args;
26
+ const { style, position, display } = args;
40
27
  return {
41
28
  margin: '0 auto',
42
29
  ...getStylePadding(style),
43
- ...makeStyleResponsive('w', width),
44
30
  ...displayConditionStyle(display, position),
45
- ...getCSSAlign(position),
46
31
  'z-index': ELEMENT_Z_INDEX.STICKY
47
32
  };
48
33
  };
34
+ const getContentStyles = (args)=>{
35
+ const { style, width, background } = args;
36
+ return {
37
+ ...makeStyle({
38
+ m: '0 auto'
39
+ }),
40
+ ...makeStyleResponsive('w', width),
41
+ ...filterStyles(style),
42
+ ...getGradientBgrStyleByDevice(background),
43
+ ...getStyleBackgroundByDevice(background)
44
+ };
45
+ };
49
46
  const getStylePadding = (style)=>{
50
47
  const keepList = [
51
48
  '--pt',
@@ -93,4 +90,4 @@ const filterStyles = (style)=>{
93
90
  return cloneStyle;
94
91
  };
95
92
 
96
- export { displayConditionStyle, filterStyles, getContainerStyles, getDisplayStyle, getStylePadding };
93
+ export { displayConditionStyle, filterStyles, getContainerStyles, getContentStyles, getDisplayStyle, getStylePadding };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/components",
3
- "version": "2.0.0-dev.471",
3
+ "version": "2.0.0-dev.472",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",