@gem-sdk/core 1.5.17 → 1.5.22

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.
Files changed (206) hide show
  1. package/dist/cjs/components/AddOn.js +7 -7
  2. package/dist/cjs/components/ComponentWrapper.js +14 -8
  3. package/dist/cjs/components/ComponentWrapperPreview.js +55 -46
  4. package/dist/cjs/components/Empty.js +1 -1
  5. package/dist/cjs/components/Render.js +50 -13
  6. package/dist/cjs/components/Render.liquid.js +81 -57
  7. package/dist/cjs/components/RenderBlock.js +41 -8
  8. package/dist/cjs/components/RenderPreview.js +51 -13
  9. package/dist/cjs/components/RenderSection.js +11 -7
  10. package/dist/cjs/components/constant.js +24 -24
  11. package/dist/cjs/contexts/AddonContext.js +25 -14
  12. package/dist/cjs/contexts/BuilderComponent.js +23 -19
  13. package/dist/cjs/contexts/BuilderContext.js +25 -19
  14. package/dist/cjs/contexts/BuilderPreviewContext.js +349 -341
  15. package/dist/cjs/contexts/CartLineContext.js +19 -14
  16. package/dist/cjs/contexts/CollectionContext.js +21 -13
  17. package/dist/cjs/contexts/ProductContext.js +136 -115
  18. package/dist/cjs/contexts/ProductListContext.js +21 -13
  19. package/dist/cjs/contexts/SectionContext.js +41 -37
  20. package/dist/cjs/contexts/ShopContext.js +49 -31
  21. package/dist/cjs/graphql/fragments/analytic.generated.js +1 -1
  22. package/dist/cjs/graphql/fragments/collection-detail.generated.js +1 -1
  23. package/dist/cjs/graphql/fragments/collection-product.generated.js +1 -1
  24. package/dist/cjs/graphql/fragments/custom-code.generated.js +1 -1
  25. package/dist/cjs/graphql/fragments/data-seo.generated.js +1 -1
  26. package/dist/cjs/graphql/fragments/media.generated.js +1 -1
  27. package/dist/cjs/graphql/fragments/product-little.generated.js +1 -1
  28. package/dist/cjs/graphql/fragments/product-option-value.generated.js +1 -1
  29. package/dist/cjs/graphql/fragments/product-option.generated.js +1 -1
  30. package/dist/cjs/graphql/fragments/product.generated.js +1 -1
  31. package/dist/cjs/graphql/fragments/published-custom-section.generated.js +1 -1
  32. package/dist/cjs/graphql/fragments/published-page-section.generated.js +1 -1
  33. package/dist/cjs/graphql/fragments/published-theme-page.generated.js +1 -1
  34. package/dist/cjs/graphql/fragments/published-theme-style.generated.js +1 -1
  35. package/dist/cjs/graphql/fragments/selected-option.generated.js +1 -1
  36. package/dist/cjs/graphql/fragments/variant.generated.js +1 -1
  37. package/dist/cjs/graphql/mutations/page-view-up.generated.js +1 -1
  38. package/dist/cjs/graphql/queries/products.generated.js +1 -1
  39. package/dist/cjs/graphql/queries/store-property.generated.js +1 -1
  40. package/dist/cjs/helpers/GlobalEvent.js +12 -10
  41. package/dist/cjs/helpers/background.js +96 -96
  42. package/dist/cjs/helpers/borders.js +123 -127
  43. package/dist/cjs/helpers/clone-deep.js +1 -1
  44. package/dist/cjs/helpers/cls.js +11 -15
  45. package/dist/cjs/helpers/colors.js +121 -156
  46. package/dist/cjs/helpers/compose-advance-style.js +115 -121
  47. package/dist/cjs/helpers/constant.js +16 -11
  48. package/dist/cjs/helpers/css-variable.js +2 -2
  49. package/dist/cjs/helpers/email.js +3 -3
  50. package/dist/cjs/helpers/flatten-connection.js +4 -5
  51. package/dist/cjs/helpers/get-resonsive-value.js +24 -25
  52. package/dist/cjs/helpers/get-shortname.js +87 -87
  53. package/dist/cjs/helpers/is-browser.js +2 -2
  54. package/dist/cjs/helpers/is-defined.js +2 -2
  55. package/dist/cjs/helpers/is-empty-children.js +2 -2
  56. package/dist/cjs/helpers/layout.js +9 -10
  57. package/dist/cjs/helpers/load-script.js +26 -27
  58. package/dist/cjs/helpers/make-style.js +77 -86
  59. package/dist/cjs/helpers/normalize-builder-data.js +18 -12
  60. package/dist/cjs/helpers/prefetch-queries.js +72 -52
  61. package/dist/cjs/helpers/product.js +25 -29
  62. package/dist/cjs/helpers/queries/get-collection.js +179 -167
  63. package/dist/cjs/helpers/queries/get-product-by-slug.js +103 -94
  64. package/dist/cjs/helpers/queries/get-product.js +121 -106
  65. package/dist/cjs/helpers/queries/get-products.js +137 -125
  66. package/dist/cjs/helpers/radius.js +78 -81
  67. package/dist/cjs/helpers/render.js +56 -56
  68. package/dist/cjs/helpers/shadow.js +38 -38
  69. package/dist/cjs/helpers/size.js +12 -13
  70. package/dist/cjs/helpers/spacing.js +35 -37
  71. package/dist/cjs/helpers/tracking/fpixel.js +21 -22
  72. package/dist/cjs/helpers/tracking/gtag.js +84 -90
  73. package/dist/cjs/helpers/tracking/tiktokpixel.js +12 -12
  74. package/dist/cjs/helpers/typography.js +2 -2
  75. package/dist/cjs/hooks/cart/use-add-to-cart.js +10 -10
  76. package/dist/cjs/hooks/cart/use-cart-data.js +18 -16
  77. package/dist/cjs/hooks/cart/use-cart-discount-codes-update.js +10 -10
  78. package/dist/cjs/hooks/cart/use-cart-note-update.js +10 -10
  79. package/dist/cjs/hooks/cart/use-create-cart.js +12 -12
  80. package/dist/cjs/hooks/cart/use-remove-cart-item.js +10 -10
  81. package/dist/cjs/hooks/cart/use-update-cart-item.js +10 -10
  82. package/dist/cjs/hooks/shop/use-collection-query.js +12 -6
  83. package/dist/cjs/hooks/shop/use-product-query.js +12 -6
  84. package/dist/cjs/hooks/shop/use-products-query.js +14 -6
  85. package/dist/cjs/hooks/shop.js +86 -67
  86. package/dist/cjs/hooks/use-current-device.js +14 -16
  87. package/dist/cjs/hooks/use-lazy-video.js +7 -7
  88. package/dist/cjs/hooks/useCartId.js +35 -27
  89. package/dist/cjs/hooks/useCartLine.js +2 -2
  90. package/dist/cjs/hooks/useCartUI.js +37 -31
  91. package/dist/cjs/hooks/useCollection.js +2 -2
  92. package/dist/cjs/hooks/useFetchHandle.js +6 -6
  93. package/dist/cjs/hooks/useFormatMoney.js +11 -7
  94. package/dist/cjs/hooks/useIsomorphicLayoutEffect.js +1 -1
  95. package/dist/cjs/hooks/useLoadScript.js +22 -20
  96. package/dist/cjs/hooks/useMoney.js +59 -42
  97. package/dist/cjs/hooks/usePrevious.js +12 -10
  98. package/dist/cjs/hooks/useProduct.js +92 -69
  99. package/dist/cjs/hooks/useProductList.js +11 -11
  100. package/dist/cjs/hooks/useSuspenseFetch.js +20 -17
  101. package/dist/cjs/hooks/useSwatchesOptions.js +32 -30
  102. package/dist/cjs/types/global-style.js +9 -2
  103. package/dist/esm/components/AddOn.js +7 -7
  104. package/dist/esm/components/ComponentWrapper.js +14 -8
  105. package/dist/esm/components/ComponentWrapperPreview.js +55 -46
  106. package/dist/esm/components/Empty.js +1 -1
  107. package/dist/esm/components/Render.js +50 -13
  108. package/dist/esm/components/Render.liquid.js +81 -57
  109. package/dist/esm/components/RenderBlock.js +41 -8
  110. package/dist/esm/components/RenderPreview.js +51 -13
  111. package/dist/esm/components/RenderSection.js +11 -7
  112. package/dist/esm/components/constant.js +24 -24
  113. package/dist/esm/contexts/AddonContext.js +26 -15
  114. package/dist/esm/contexts/BuilderComponent.js +24 -20
  115. package/dist/esm/contexts/BuilderContext.js +26 -20
  116. package/dist/esm/contexts/BuilderPreviewContext.js +350 -342
  117. package/dist/esm/contexts/CartLineContext.js +20 -15
  118. package/dist/esm/contexts/CollectionContext.js +22 -14
  119. package/dist/esm/contexts/ProductContext.js +137 -116
  120. package/dist/esm/contexts/ProductListContext.js +22 -14
  121. package/dist/esm/contexts/SectionContext.js +42 -38
  122. package/dist/esm/contexts/ShopContext.js +50 -32
  123. package/dist/esm/graphql/fragments/analytic.generated.js +1 -1
  124. package/dist/esm/graphql/fragments/collection-detail.generated.js +1 -1
  125. package/dist/esm/graphql/fragments/collection-product.generated.js +1 -1
  126. package/dist/esm/graphql/fragments/custom-code.generated.js +1 -1
  127. package/dist/esm/graphql/fragments/data-seo.generated.js +1 -1
  128. package/dist/esm/graphql/fragments/media.generated.js +1 -1
  129. package/dist/esm/graphql/fragments/product-little.generated.js +1 -1
  130. package/dist/esm/graphql/fragments/product-option-value.generated.js +1 -1
  131. package/dist/esm/graphql/fragments/product-option.generated.js +1 -1
  132. package/dist/esm/graphql/fragments/product.generated.js +1 -1
  133. package/dist/esm/graphql/fragments/published-custom-section.generated.js +1 -1
  134. package/dist/esm/graphql/fragments/published-page-section.generated.js +1 -1
  135. package/dist/esm/graphql/fragments/published-theme-page.generated.js +1 -1
  136. package/dist/esm/graphql/fragments/published-theme-style.generated.js +1 -1
  137. package/dist/esm/graphql/fragments/selected-option.generated.js +1 -1
  138. package/dist/esm/graphql/fragments/variant.generated.js +1 -1
  139. package/dist/esm/graphql/mutations/page-view-up.generated.js +1 -1
  140. package/dist/esm/graphql/queries/products.generated.js +1 -1
  141. package/dist/esm/graphql/queries/store-property.generated.js +1 -1
  142. package/dist/esm/helpers/GlobalEvent.js +12 -10
  143. package/dist/esm/helpers/background.js +96 -96
  144. package/dist/esm/helpers/borders.js +123 -127
  145. package/dist/esm/helpers/clone-deep.js +1 -1
  146. package/dist/esm/helpers/cls.js +11 -15
  147. package/dist/esm/helpers/colors.js +121 -156
  148. package/dist/esm/helpers/compose-advance-style.js +115 -121
  149. package/dist/esm/helpers/constant.js +16 -11
  150. package/dist/esm/helpers/css-variable.js +2 -2
  151. package/dist/esm/helpers/email.js +3 -3
  152. package/dist/esm/helpers/flatten-connection.js +4 -5
  153. package/dist/esm/helpers/get-resonsive-value.js +24 -25
  154. package/dist/esm/helpers/get-shortname.js +87 -87
  155. package/dist/esm/helpers/is-browser.js +2 -2
  156. package/dist/esm/helpers/is-defined.js +2 -2
  157. package/dist/esm/helpers/is-empty-children.js +2 -2
  158. package/dist/esm/helpers/layout.js +9 -10
  159. package/dist/esm/helpers/load-script.js +26 -27
  160. package/dist/esm/helpers/make-style.js +77 -86
  161. package/dist/esm/helpers/normalize-builder-data.js +18 -12
  162. package/dist/esm/helpers/prefetch-queries.js +72 -52
  163. package/dist/esm/helpers/product.js +25 -29
  164. package/dist/esm/helpers/queries/get-collection.js +179 -167
  165. package/dist/esm/helpers/queries/get-product-by-slug.js +103 -94
  166. package/dist/esm/helpers/queries/get-product.js +121 -106
  167. package/dist/esm/helpers/queries/get-products.js +137 -125
  168. package/dist/esm/helpers/radius.js +78 -81
  169. package/dist/esm/helpers/render.js +56 -56
  170. package/dist/esm/helpers/shadow.js +38 -38
  171. package/dist/esm/helpers/size.js +12 -13
  172. package/dist/esm/helpers/spacing.js +35 -37
  173. package/dist/esm/helpers/tracking/fpixel.js +21 -22
  174. package/dist/esm/helpers/tracking/gtag.js +84 -90
  175. package/dist/esm/helpers/tracking/tiktokpixel.js +12 -12
  176. package/dist/esm/helpers/typography.js +2 -2
  177. package/dist/esm/hooks/cart/use-add-to-cart.js +10 -10
  178. package/dist/esm/hooks/cart/use-cart-data.js +18 -16
  179. package/dist/esm/hooks/cart/use-cart-discount-codes-update.js +10 -10
  180. package/dist/esm/hooks/cart/use-cart-note-update.js +10 -10
  181. package/dist/esm/hooks/cart/use-create-cart.js +12 -12
  182. package/dist/esm/hooks/cart/use-remove-cart-item.js +10 -10
  183. package/dist/esm/hooks/cart/use-update-cart-item.js +10 -10
  184. package/dist/esm/hooks/shop/use-collection-query.js +12 -6
  185. package/dist/esm/hooks/shop/use-product-query.js +12 -6
  186. package/dist/esm/hooks/shop/use-products-query.js +14 -6
  187. package/dist/esm/hooks/shop.js +86 -67
  188. package/dist/esm/hooks/use-current-device.js +14 -16
  189. package/dist/esm/hooks/use-lazy-video.js +7 -7
  190. package/dist/esm/hooks/useCartId.js +35 -27
  191. package/dist/esm/hooks/useCartLine.js +2 -2
  192. package/dist/esm/hooks/useCartUI.js +37 -31
  193. package/dist/esm/hooks/useCollection.js +2 -2
  194. package/dist/esm/hooks/useFetchHandle.js +6 -6
  195. package/dist/esm/hooks/useFormatMoney.js +11 -7
  196. package/dist/esm/hooks/useIsomorphicLayoutEffect.js +1 -1
  197. package/dist/esm/hooks/useLoadScript.js +22 -20
  198. package/dist/esm/hooks/useMoney.js +59 -42
  199. package/dist/esm/hooks/usePrevious.js +12 -10
  200. package/dist/esm/hooks/useProduct.js +92 -69
  201. package/dist/esm/hooks/useProductList.js +11 -11
  202. package/dist/esm/hooks/useSuspenseFetch.js +20 -17
  203. package/dist/esm/hooks/useSwatchesOptions.js +32 -30
  204. package/dist/esm/types/global-style.js +9 -2
  205. package/dist/types/index.d.ts +24 -2
  206. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- const PublishedCustomSectionSelect = `
1
+ /* eslint-disable */ const PublishedCustomSectionSelect = `
2
2
  fragment PublishedCustomSectionSelect on PublishedCustomSection {
3
3
  cid
4
4
  component
@@ -1,4 +1,4 @@
1
- const PublishedPageSectionSelect = `
1
+ /* eslint-disable */ const PublishedPageSectionSelect = `
2
2
  fragment PublishedPageSectionSelect on PublishedPageSection {
3
3
  cid
4
4
  component
@@ -1,4 +1,4 @@
1
- const PublishedThemePageSelect = `
1
+ /* eslint-disable */ const PublishedThemePageSelect = `
2
2
  fragment PublishedThemePageSelect on PublishedThemePage {
3
3
  id
4
4
  name
@@ -1,4 +1,4 @@
1
- const PublishedThemeStyleSelect = `
1
+ /* eslint-disable */ const PublishedThemeStyleSelect = `
2
2
  fragment PublishedThemeStyleSelect on PublishedThemeStyle {
3
3
  id
4
4
  data
@@ -1,4 +1,4 @@
1
- const SelectedOptionSelect = `
1
+ /* eslint-disable */ const SelectedOptionSelect = `
2
2
  fragment SelectedOptionSelect on SelectedOption {
3
3
  name
4
4
  value
@@ -1,4 +1,4 @@
1
- const VariantSelect = `
1
+ /* eslint-disable */ const VariantSelect = `
2
2
  fragment VariantSelect on ProductVariant {
3
3
  id
4
4
  title
@@ -1,4 +1,4 @@
1
- const PageViewUpDocument = `
1
+ /* eslint-disable */ const PageViewUpDocument = `
2
2
  mutation pageViewUp($pageHandle: String!, $userAgent: String!) {
3
3
  pageViewUp(pageHandle: $pageHandle, userAgent: $userAgent)
4
4
  }
@@ -13,7 +13,7 @@ const ProductsEdgeDetail = `
13
13
  ...ProductSelect
14
14
  }
15
15
  }
16
- `;
16
+ `;
17
17
  const ProductsDocument = `
18
18
  query products($first: Int, $where: ProductWhereInput, $firstMedia: Int, $orderBy: ProductOrder, $after: Cursor, $firstVariant: Int, $afterVariant: Cursor, $afterMedia: Cursor, $orderByMedia: MediaOrder) {
19
19
  products(first: $first, where: $where, orderBy: $orderBy, after: $after) {
@@ -1,4 +1,4 @@
1
- const StorePropertyDocument = `
1
+ /* eslint-disable */ const StorePropertyDocument = `
2
2
  query storeProperty {
3
3
  storeProperty {
4
4
  favicon
@@ -1,13 +1,15 @@
1
- const globalEvent = {
2
- subscribe(callback) {
3
- document.addEventListener('onDispatch', (e) => callback(e.detail));
4
- },
5
- dispatch(data) {
6
- document.dispatchEvent(new CustomEvent('onDispatch', { detail: data }));
7
- },
8
- remove(callback) {
9
- document.removeEventListener('onDispatch', callback);
10
- },
1
+ const globalEvent = {
2
+ subscribe (callback) {
3
+ document.addEventListener('onDispatch', (e)=>callback(e.detail));
4
+ },
5
+ dispatch (data) {
6
+ document.dispatchEvent(new CustomEvent('onDispatch', {
7
+ detail: data
8
+ }));
9
+ },
10
+ remove (callback) {
11
+ document.removeEventListener('onDispatch', callback);
12
+ }
11
13
  };
12
14
 
13
15
  export { globalEvent as default };
@@ -1,102 +1,102 @@
1
1
  import { isColor } from './colors.js';
2
2
  import { makeStyleResponsive } from './make-style.js';
3
3
 
4
- const getStyleBackgroundByDevice = (background) => {
5
- if (!background) {
6
- return {};
7
- }
8
- return {
9
- ...getStyleBgColor(background),
10
- ...getStyleBgImage(background),
11
- ...getStyleBgPosition(background),
12
- ...getStyleBgSize(background),
13
- ...getStyleBgRepeat(background),
14
- ...getStyleBgAttachment(background),
15
- };
16
- };
17
- const getStyleBgColor = (background) => {
18
- const bgColor = {
19
- desktop: getBgColorByDevice(background, 'desktop'),
20
- tablet: getBgColorByDevice(background, 'tablet'),
21
- mobile: getBgColorByDevice(background, 'mobile'),
22
- };
23
- return makeStyleResponsive('bgc', bgColor);
24
- };
25
- const getBgColorByDevice = (background, device) => {
26
- return getColor(background?.[device]?.color);
27
- };
28
- const getColor = (color) => {
29
- if (!color) {
30
- return;
31
- }
32
- if (isColor(color?.toString())) {
33
- return color;
34
- }
35
- return `var(--g-c-${color})`;
36
- };
37
- const getStyleBgImage = (background) => {
38
- const bgImage = {
39
- // desktop:
40
- // background.desktop?.type === 'color' ? 'none' : getBgImageByDevice(background, 'desktop'),
41
- // tablet: background.tablet?.type === 'color' ? 'none' : getBgImageByDevice(background, 'tablet'),
42
- // mobile: background.mobile?.type === 'color' ? 'none' : getBgImageByDevice(background, 'mobile'),
43
- desktop: getBgImageByDevice(background, 'desktop'),
44
- tablet: getBgImageByDevice(background, 'tablet'),
45
- mobile: getBgImageByDevice(background, 'mobile'),
46
- };
47
- return makeStyleResponsive('bgi', bgImage);
48
- };
49
- const getBgImageByDevice = (background, device) => {
50
- const imageByDevice = background?.[device]?.image?.src;
51
- if (typeof imageByDevice === 'string') {
52
- return `url(${imageByDevice})`;
53
- }
54
- return;
55
- };
56
- const getStyleBgPosition = (background) => {
57
- const bgPosition = {
58
- desktop: getBgPositionByDevice(background, 'desktop'),
59
- tablet: getBgPositionByDevice(background, 'tablet'),
60
- mobile: getBgPositionByDevice(background, 'mobile'),
61
- };
62
- return makeStyleResponsive('bgp', bgPosition);
63
- };
64
- const getBgPositionByDevice = (background, device) => {
65
- const positionByDevice = background?.[device]?.position;
66
- return positionByDevice && `${positionByDevice.x}% ${positionByDevice.y}%`;
67
- };
68
- const getStyleBgSize = (background) => {
69
- const bgSize = {
70
- desktop: getBgSizeByDevice(background, 'desktop'),
71
- tablet: getBgSizeByDevice(background, 'tablet'),
72
- mobile: getBgSizeByDevice(background, 'mobile'),
73
- };
74
- return makeStyleResponsive('bgs', bgSize);
75
- };
76
- const getBgSizeByDevice = (background, device) => {
77
- return background?.[device]?.size;
78
- };
79
- const getStyleBgRepeat = (background) => {
80
- const bgRepeat = {
81
- desktop: getBgRepeatByDevice(background, 'desktop'),
82
- tablet: getBgRepeatByDevice(background, 'tablet'),
83
- mobile: getBgRepeatByDevice(background, 'mobile'),
84
- };
85
- return makeStyleResponsive('bgr', bgRepeat);
86
- };
87
- const getBgRepeatByDevice = (background, device) => {
88
- return background?.[device]?.repeat;
89
- };
90
- const getStyleBgAttachment = (background) => {
91
- const bgAttachment = {
92
- desktop: getBgAttachmentByDevice(background, 'desktop'),
93
- tablet: getBgAttachmentByDevice(background, 'tablet'),
94
- mobile: getBgAttachmentByDevice(background, 'mobile'),
95
- };
96
- return makeStyleResponsive('bga', bgAttachment);
97
- };
98
- const getBgAttachmentByDevice = (background, device) => {
99
- return background?.[device]?.attachment;
4
+ const getStyleBackgroundByDevice = (background)=>{
5
+ if (!background) {
6
+ return {};
7
+ }
8
+ return {
9
+ ...getStyleBgColor(background),
10
+ ...getStyleBgImage(background),
11
+ ...getStyleBgPosition(background),
12
+ ...getStyleBgSize(background),
13
+ ...getStyleBgRepeat(background),
14
+ ...getStyleBgAttachment(background)
15
+ };
16
+ };
17
+ const getStyleBgColor = (background)=>{
18
+ const bgColor = {
19
+ desktop: getBgColorByDevice(background, 'desktop'),
20
+ tablet: getBgColorByDevice(background, 'tablet'),
21
+ mobile: getBgColorByDevice(background, 'mobile')
22
+ };
23
+ return makeStyleResponsive('bgc', bgColor);
24
+ };
25
+ const getBgColorByDevice = (background, device)=>{
26
+ return getColor(background?.[device]?.color);
27
+ };
28
+ const getColor = (color)=>{
29
+ if (!color) {
30
+ return;
31
+ }
32
+ if (isColor(color?.toString())) {
33
+ return color;
34
+ }
35
+ return `var(--g-c-${color})`;
36
+ };
37
+ const getStyleBgImage = (background)=>{
38
+ const bgImage = {
39
+ // desktop:
40
+ // background.desktop?.type === 'color' ? 'none' : getBgImageByDevice(background, 'desktop'),
41
+ // tablet: background.tablet?.type === 'color' ? 'none' : getBgImageByDevice(background, 'tablet'),
42
+ // mobile: background.mobile?.type === 'color' ? 'none' : getBgImageByDevice(background, 'mobile'),
43
+ desktop: getBgImageByDevice(background, 'desktop'),
44
+ tablet: getBgImageByDevice(background, 'tablet'),
45
+ mobile: getBgImageByDevice(background, 'mobile')
46
+ };
47
+ return makeStyleResponsive('bgi', bgImage);
48
+ };
49
+ const getBgImageByDevice = (background, device)=>{
50
+ const imageByDevice = background?.[device]?.image?.src;
51
+ if (typeof imageByDevice === 'string') {
52
+ return `url(${imageByDevice})`;
53
+ }
54
+ return;
55
+ };
56
+ const getStyleBgPosition = (background)=>{
57
+ const bgPosition = {
58
+ desktop: getBgPositionByDevice(background, 'desktop'),
59
+ tablet: getBgPositionByDevice(background, 'tablet'),
60
+ mobile: getBgPositionByDevice(background, 'mobile')
61
+ };
62
+ return makeStyleResponsive('bgp', bgPosition);
63
+ };
64
+ const getBgPositionByDevice = (background, device)=>{
65
+ const positionByDevice = background?.[device]?.position;
66
+ return positionByDevice && `${positionByDevice.x}% ${positionByDevice.y}%`;
67
+ };
68
+ const getStyleBgSize = (background)=>{
69
+ const bgSize = {
70
+ desktop: getBgSizeByDevice(background, 'desktop'),
71
+ tablet: getBgSizeByDevice(background, 'tablet'),
72
+ mobile: getBgSizeByDevice(background, 'mobile')
73
+ };
74
+ return makeStyleResponsive('bgs', bgSize);
75
+ };
76
+ const getBgSizeByDevice = (background, device)=>{
77
+ return background?.[device]?.size;
78
+ };
79
+ const getStyleBgRepeat = (background)=>{
80
+ const bgRepeat = {
81
+ desktop: getBgRepeatByDevice(background, 'desktop'),
82
+ tablet: getBgRepeatByDevice(background, 'tablet'),
83
+ mobile: getBgRepeatByDevice(background, 'mobile')
84
+ };
85
+ return makeStyleResponsive('bgr', bgRepeat);
86
+ };
87
+ const getBgRepeatByDevice = (background, device)=>{
88
+ return background?.[device]?.repeat;
89
+ };
90
+ const getStyleBgAttachment = (background)=>{
91
+ const bgAttachment = {
92
+ desktop: getBgAttachmentByDevice(background, 'desktop'),
93
+ tablet: getBgAttachmentByDevice(background, 'tablet'),
94
+ mobile: getBgAttachmentByDevice(background, 'mobile')
95
+ };
96
+ return makeStyleResponsive('bga', bgAttachment);
97
+ };
98
+ const getBgAttachmentByDevice = (background, device)=>{
99
+ return background?.[device]?.attachment;
100
100
  };
101
101
 
102
102
  export { getStyleBackgroundByDevice };
@@ -1,133 +1,129 @@
1
1
  import { getGlobalColorStateResponsiveStyle, getGlobalColorStateStyle, getGlobalColorStateResponsiveClass, getGlobalColorStateClass } from './colors.js';
2
2
  import { makeStyleResponsiveState, makeStyleState } from './make-style.js';
3
3
 
4
- const handleConvertBorderStyle = (value) => {
5
- if (!value)
6
- return undefined;
7
- if ('desktop' in value || 'tablet' in value || 'mobile' in value) {
8
- const data = value;
9
- const newVal = {
10
- desktop: {
11
- normal: data.desktop?.normal?.border,
12
- hover: data.desktop?.hover?.border,
13
- focus: data.desktop?.focus?.border,
14
- },
15
- tablet: {
16
- normal: data.tablet?.normal?.border,
17
- hover: data.tablet?.hover?.border,
18
- focus: data.tablet?.focus?.border,
19
- },
20
- mobile: {
21
- normal: data.mobile?.normal?.border,
22
- hover: data.mobile?.hover?.border,
23
- focus: data.mobile?.focus?.border,
24
- },
25
- };
26
- return makeStyleResponsiveState('bs', newVal);
27
- }
28
- const data = value;
29
- const newVal = {
30
- normal: data?.normal?.border,
31
- hover: data?.hover?.border,
32
- focus: data?.focus?.border,
33
- };
34
- return makeStyleState('bs', newVal);
35
- };
36
- const handleConvertBorderWidth = (value) => {
37
- if (!value)
38
- return undefined;
39
- if ('desktop' in value || 'tablet' in value || 'mobile' in value) {
40
- const data = value;
41
- const newVal = {
42
- desktop: {
43
- normal: data.desktop?.normal?.width,
44
- hover: data.desktop?.hover?.width,
45
- focus: data.desktop?.focus?.width,
46
- },
47
- tablet: {
48
- normal: data.tablet?.normal?.width,
49
- hover: data.tablet?.hover?.width,
50
- focus: data.tablet?.focus?.width,
51
- },
52
- mobile: {
53
- normal: data.mobile?.normal?.width,
54
- hover: data.mobile?.hover?.width,
55
- focus: data.mobile?.focus?.width,
56
- },
57
- };
58
- return makeStyleResponsiveState('bw', newVal);
59
- }
60
- const data = value;
61
- const newVal = {
62
- normal: data?.normal?.width,
63
- hover: data?.hover?.width,
64
- focus: data?.focus?.width,
65
- };
66
- return makeStyleState('bw', newVal);
67
- };
68
- const handleConvertBorderColor = (value) => {
69
- if (!value)
70
- return undefined;
71
- if ('desktop' in value || 'tablet' in value || 'mobile' in value) {
72
- const data = value;
73
- const newVal = {
74
- desktop: {
75
- normal: data.desktop?.normal?.color,
76
- hover: data.desktop?.hover?.color,
77
- focus: data.desktop?.focus?.color,
78
- },
79
- tablet: {
80
- normal: data.tablet?.normal?.color,
81
- hover: data.tablet?.hover?.color,
82
- focus: data.tablet?.focus?.color,
83
- },
84
- mobile: {
85
- normal: data.mobile?.normal?.color,
86
- hover: data.mobile?.hover?.color,
87
- focus: data.mobile?.focus?.color,
88
- },
89
- };
90
- return getGlobalColorStateResponsiveStyle('bc', newVal);
91
- }
92
- const data = value;
93
- const newVal = {
94
- normal: data?.normal?.color,
95
- hover: data?.hover?.color,
96
- focus: data?.focus?.color,
97
- };
98
- return getGlobalColorStateStyle('bc', newVal);
99
- };
100
- const handleConvertClassColor = (value) => {
101
- if (!value)
102
- return undefined;
103
- if ('desktop' in value || 'tablet' in value || 'mobile' in value) {
104
- const data = value;
105
- const newVal = {
106
- desktop: {
107
- normal: data.desktop?.normal?.color,
108
- hover: data.desktop?.hover?.color,
109
- focus: data.desktop?.focus?.color,
110
- },
111
- tablet: {
112
- normal: data.tablet?.normal?.color,
113
- hover: data.tablet?.hover?.color,
114
- focus: data.tablet?.focus?.color,
115
- },
116
- mobile: {
117
- normal: data.mobile?.normal?.color,
118
- hover: data.mobile?.hover?.color,
119
- focus: data.mobile?.focus?.color,
120
- },
121
- };
122
- return getGlobalColorStateResponsiveClass('border', newVal);
123
- }
124
- const data = value;
125
- const newVal = {
126
- normal: data?.normal?.color,
127
- hover: data?.hover?.color,
128
- focus: data?.focus?.color,
129
- };
130
- return getGlobalColorStateClass('border', newVal);
4
+ const handleConvertBorderStyle = (value)=>{
5
+ if (!value) return undefined;
6
+ if ('desktop' in value || 'tablet' in value || 'mobile' in value) {
7
+ const data = value;
8
+ const newVal = {
9
+ desktop: {
10
+ normal: data.desktop?.normal?.border,
11
+ hover: data.desktop?.hover?.border,
12
+ focus: data.desktop?.focus?.border
13
+ },
14
+ tablet: {
15
+ normal: data.tablet?.normal?.border,
16
+ hover: data.tablet?.hover?.border,
17
+ focus: data.tablet?.focus?.border
18
+ },
19
+ mobile: {
20
+ normal: data.mobile?.normal?.border,
21
+ hover: data.mobile?.hover?.border,
22
+ focus: data.mobile?.focus?.border
23
+ }
24
+ };
25
+ return makeStyleResponsiveState('bs', newVal);
26
+ }
27
+ const data = value;
28
+ const newVal = {
29
+ normal: data?.normal?.border,
30
+ hover: data?.hover?.border,
31
+ focus: data?.focus?.border
32
+ };
33
+ return makeStyleState('bs', newVal);
34
+ };
35
+ const handleConvertBorderWidth = (value)=>{
36
+ if (!value) return undefined;
37
+ if ('desktop' in value || 'tablet' in value || 'mobile' in value) {
38
+ const data = value;
39
+ const newVal = {
40
+ desktop: {
41
+ normal: data.desktop?.normal?.width,
42
+ hover: data.desktop?.hover?.width,
43
+ focus: data.desktop?.focus?.width
44
+ },
45
+ tablet: {
46
+ normal: data.tablet?.normal?.width,
47
+ hover: data.tablet?.hover?.width,
48
+ focus: data.tablet?.focus?.width
49
+ },
50
+ mobile: {
51
+ normal: data.mobile?.normal?.width,
52
+ hover: data.mobile?.hover?.width,
53
+ focus: data.mobile?.focus?.width
54
+ }
55
+ };
56
+ return makeStyleResponsiveState('bw', newVal);
57
+ }
58
+ const data = value;
59
+ const newVal = {
60
+ normal: data?.normal?.width,
61
+ hover: data?.hover?.width,
62
+ focus: data?.focus?.width
63
+ };
64
+ return makeStyleState('bw', newVal);
65
+ };
66
+ const handleConvertBorderColor = (value)=>{
67
+ if (!value) return undefined;
68
+ if ('desktop' in value || 'tablet' in value || 'mobile' in value) {
69
+ const data = value;
70
+ const newVal = {
71
+ desktop: {
72
+ normal: data.desktop?.normal?.color,
73
+ hover: data.desktop?.hover?.color,
74
+ focus: data.desktop?.focus?.color
75
+ },
76
+ tablet: {
77
+ normal: data.tablet?.normal?.color,
78
+ hover: data.tablet?.hover?.color,
79
+ focus: data.tablet?.focus?.color
80
+ },
81
+ mobile: {
82
+ normal: data.mobile?.normal?.color,
83
+ hover: data.mobile?.hover?.color,
84
+ focus: data.mobile?.focus?.color
85
+ }
86
+ };
87
+ return getGlobalColorStateResponsiveStyle('bc', newVal);
88
+ }
89
+ const data = value;
90
+ const newVal = {
91
+ normal: data?.normal?.color,
92
+ hover: data?.hover?.color,
93
+ focus: data?.focus?.color
94
+ };
95
+ return getGlobalColorStateStyle('bc', newVal);
96
+ };
97
+ const handleConvertClassColor = (value)=>{
98
+ if (!value) return undefined;
99
+ if ('desktop' in value || 'tablet' in value || 'mobile' in value) {
100
+ const data = value;
101
+ const newVal = {
102
+ desktop: {
103
+ normal: data.desktop?.normal?.color,
104
+ hover: data.desktop?.hover?.color,
105
+ focus: data.desktop?.focus?.color
106
+ },
107
+ tablet: {
108
+ normal: data.tablet?.normal?.color,
109
+ hover: data.tablet?.hover?.color,
110
+ focus: data.tablet?.focus?.color
111
+ },
112
+ mobile: {
113
+ normal: data.mobile?.normal?.color,
114
+ hover: data.mobile?.hover?.color,
115
+ focus: data.mobile?.focus?.color
116
+ }
117
+ };
118
+ return getGlobalColorStateResponsiveClass('border', newVal);
119
+ }
120
+ const data = value;
121
+ const newVal = {
122
+ normal: data?.normal?.color,
123
+ hover: data?.hover?.color,
124
+ focus: data?.focus?.color
125
+ };
126
+ return getGlobalColorStateClass('border', newVal);
131
127
  };
132
128
 
133
129
  export { handleConvertBorderColor, handleConvertBorderStyle, handleConvertBorderWidth, handleConvertClassColor };
@@ -1,3 +1,3 @@
1
- const cloneDeep = (data) => JSON.parse(JSON.stringify(data));
1
+ const cloneDeep = (data)=>JSON.parse(JSON.stringify(data));
2
2
 
3
3
  export { cloneDeep };
@@ -1,18 +1,14 @@
1
- function toVal(mix) {
2
- if (typeof mix === 'string') {
3
- return mix;
4
- }
5
- else if (typeof mix === 'object' && mix !== null) {
6
- return Object.keys(mix)
7
- .filter((key) => mix[key])
8
- .join(' ');
9
- }
10
- else {
11
- return false;
12
- }
13
- }
14
- function cls(...classes) {
15
- return classes.map(toVal).filter(Boolean).join(' ');
1
+ function toVal(mix) {
2
+ if (typeof mix === 'string') {
3
+ return mix;
4
+ } else if (typeof mix === 'object' && mix !== null) {
5
+ return Object.keys(mix).filter((key)=>mix[key]).join(' ');
6
+ } else {
7
+ return false;
8
+ }
9
+ }
10
+ function cls(...classes) {
11
+ return classes.map(toVal).filter(Boolean).join(' ');
16
12
  }
17
13
 
18
14
  export { cls };