@shopgate/pwa-ui-shared 7.30.4-beta.1 → 7.31.0-alpha.2

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 (326) hide show
  1. package/ActionButton/index.js +66 -67
  2. package/AddToCartButton/index.js +217 -185
  3. package/AddToCartButton/style.js +8 -0
  4. package/Availability/index.js +24 -6
  5. package/Button/index.js +105 -82
  6. package/Button/spec.js +3 -4
  7. package/Card/index.js +26 -7
  8. package/CardList/components/Item/index.js +15 -3
  9. package/CartTotalLine/components/Amount/index.js +13 -4
  10. package/CartTotalLine/components/Hint/index.js +13 -4
  11. package/CartTotalLine/components/Label/index.js +23 -10
  12. package/CartTotalLine/index.js +41 -7
  13. package/Checkbox/index.js +41 -17
  14. package/Chip/index.js +82 -7
  15. package/ContextMenu/components/Item/index.js +38 -20
  16. package/ContextMenu/components/Position/index.js +38 -56
  17. package/ContextMenu/index.js +64 -28
  18. package/Dialog/components/BasicDialog/index.js +1 -0
  19. package/Dialog/components/HtmlContentDialog/spec.js +39 -0
  20. package/Dialog/components/PipelineErrorDialog/index.js +108 -157
  21. package/Dialog/components/PipelineErrorDialog/spec.js +12 -18
  22. package/Dialog/components/TextMessageDialog/index.js +1 -1
  23. package/Dialog/components/VariantSelectModal/index.js +1 -1
  24. package/Dialog/index.js +1 -1
  25. package/DiscountBadge/index.js +48 -15
  26. package/FavoritesButton/index.js +95 -100
  27. package/FavoritesButton/spec.js +5 -2
  28. package/Form/Builder/classes/ActionListener/index.js +1 -0
  29. package/Form/Checkbox/index.js +64 -56
  30. package/Form/InfoField/index.js +18 -6
  31. package/Form/Password/index.js +39 -52
  32. package/Form/RadioGroup/components/Item/index.js +72 -56
  33. package/Form/RadioGroup/index.js +79 -90
  34. package/Form/Select/index.js +108 -130
  35. package/Form/SelectContextChoices/index.js +30 -8
  36. package/Form/TextField/index.js +106 -82
  37. package/Form/TextField/spec.js +4 -3
  38. package/FormElement/components/ErrorText/index.js +32 -14
  39. package/FormElement/components/Label/index.js +56 -6
  40. package/FormElement/components/Placeholder/index.js +44 -11
  41. package/FormElement/components/Underline/index.js +63 -12
  42. package/FormElement/index.js +62 -85
  43. package/Glow/index.js +73 -83
  44. package/IndicatorCircle/index.js +73 -17
  45. package/IndicatorCircle/spec.js +2 -5
  46. package/LoadingIndicator/index.js +34 -12
  47. package/Manufacturer/index.js +21 -10
  48. package/MessageBar/index.js +12 -38
  49. package/NoResults/components/Icon/index.js +30 -14
  50. package/NoResults/index.js +35 -7
  51. package/Placeholder/index.js +34 -23
  52. package/PlaceholderLabel/index.js +17 -3
  53. package/Price/index.js +34 -21
  54. package/PriceInfo/index.js +23 -9
  55. package/PriceStriked/index.js +67 -77
  56. package/ProgressBar/index.js +112 -77
  57. package/RadioButton/index.js +29 -11
  58. package/RatingStars/index.js +122 -137
  59. package/Ripple/components/RippleAnimation/index.js +13 -3
  60. package/Ripple/index.js +158 -212
  61. package/RippleButton/index.js +63 -60
  62. package/RippleButton/spec.js +15 -9
  63. package/ScannerOverlay/components/CameraOverlay/index.js +54 -10
  64. package/ScannerOverlay/components/ScannerBar/components/FlashlightButton/index.js +53 -27
  65. package/ScannerOverlay/components/ScannerBar/index.js +50 -26
  66. package/Sheet/components/Header/components/SearchBar/index.js +54 -10
  67. package/Sheet/components/Header/index.js +96 -76
  68. package/Sheet/index.js +295 -157
  69. package/Sheet/spec.js +8 -6
  70. package/TaxDisclaimer/index.js +17 -4
  71. package/TaxDisclaimer/spec.js +16 -5
  72. package/TextField/components/ErrorText/index.js +35 -14
  73. package/TextField/components/FormElement/index.js +29 -4
  74. package/TextField/components/Hint/index.js +39 -10
  75. package/TextField/components/Label/index.js +43 -6
  76. package/TextField/components/Underline/index.js +64 -13
  77. package/TextField/index.js +157 -171
  78. package/TextField/spec.js +5 -3
  79. package/icons/AccountBoxIcon.d.ts +7 -0
  80. package/icons/AccountBoxIcon.d.ts.map +1 -0
  81. package/icons/AccountBoxIcon.js +1 -4
  82. package/icons/AddMoreIcon.d.ts +7 -0
  83. package/icons/AddMoreIcon.d.ts.map +1 -0
  84. package/icons/AddMoreIcon.js +0 -3
  85. package/icons/ArrowDropIcon.d.ts +7 -0
  86. package/icons/ArrowDropIcon.d.ts.map +1 -0
  87. package/icons/ArrowDropIcon.js +0 -3
  88. package/icons/ArrowIcon.d.ts +10 -0
  89. package/icons/ArrowIcon.d.ts.map +1 -0
  90. package/icons/ArrowIcon.js +2 -11
  91. package/icons/BarcodeScannerIcon.d.ts +7 -0
  92. package/icons/BarcodeScannerIcon.d.ts.map +1 -0
  93. package/icons/BarcodeScannerIcon.js +0 -3
  94. package/icons/BoxIcon.d.ts +7 -0
  95. package/icons/BoxIcon.d.ts.map +1 -0
  96. package/icons/BoxIcon.js +0 -3
  97. package/icons/BrowseIcon.d.ts +7 -0
  98. package/icons/BrowseIcon.d.ts.map +1 -0
  99. package/icons/BrowseIcon.js +1 -3
  100. package/icons/BurgerIcon.d.ts +7 -0
  101. package/icons/BurgerIcon.d.ts.map +1 -0
  102. package/icons/BurgerIcon.js +0 -3
  103. package/icons/CalendarIcon.d.ts +7 -0
  104. package/icons/CalendarIcon.d.ts.map +1 -0
  105. package/icons/CalendarIcon.js +0 -2
  106. package/icons/CartCouponIcon.d.ts +7 -0
  107. package/icons/CartCouponIcon.d.ts.map +1 -0
  108. package/icons/CartCouponIcon.js +0 -2
  109. package/icons/CartIcon.d.ts +7 -0
  110. package/icons/CartIcon.d.ts.map +1 -0
  111. package/icons/CartIcon.js +0 -2
  112. package/icons/CartPlusIcon.d.ts +7 -0
  113. package/icons/CartPlusIcon.d.ts.map +1 -0
  114. package/icons/CartPlusIcon.js +0 -2
  115. package/icons/CheckIcon.d.ts +7 -0
  116. package/icons/CheckIcon.d.ts.map +1 -0
  117. package/icons/CheckIcon.js +0 -2
  118. package/icons/CheckedIcon.d.ts +7 -0
  119. package/icons/CheckedIcon.d.ts.map +1 -0
  120. package/icons/CheckedIcon.js +0 -3
  121. package/icons/ChevronIcon.d.ts +7 -0
  122. package/icons/ChevronIcon.d.ts.map +1 -0
  123. package/icons/ChevronIcon.js +0 -2
  124. package/icons/CreditCardIcon.d.ts +7 -0
  125. package/icons/CreditCardIcon.d.ts.map +1 -0
  126. package/icons/CreditCardIcon.js +0 -2
  127. package/icons/CrossIcon.d.ts +7 -0
  128. package/icons/CrossIcon.d.ts.map +1 -0
  129. package/icons/CrossIcon.js +0 -2
  130. package/icons/DescriptionIcon.d.ts +7 -0
  131. package/icons/DescriptionIcon.d.ts.map +1 -0
  132. package/icons/DescriptionIcon.js +0 -2
  133. package/icons/FilterIcon.d.ts +7 -0
  134. package/icons/FilterIcon.d.ts.map +1 -0
  135. package/icons/FilterIcon.js +0 -2
  136. package/icons/FlashDisabledIcon.d.ts +7 -0
  137. package/icons/FlashDisabledIcon.d.ts.map +1 -0
  138. package/icons/FlashDisabledIcon.js +0 -2
  139. package/icons/FlashEnabledIcon.d.ts +7 -0
  140. package/icons/FlashEnabledIcon.d.ts.map +1 -0
  141. package/icons/FlashEnabledIcon.js +0 -2
  142. package/icons/GridIcon.d.ts +7 -0
  143. package/icons/GridIcon.d.ts.map +1 -0
  144. package/icons/GridIcon.js +1 -3
  145. package/icons/HeartIcon.d.ts +7 -0
  146. package/icons/HeartIcon.d.ts.map +1 -0
  147. package/icons/HeartIcon.js +0 -2
  148. package/icons/HeartOutlineIcon.d.ts +7 -0
  149. package/icons/HeartOutlineIcon.d.ts.map +1 -0
  150. package/icons/HeartOutlineIcon.js +1 -3
  151. package/icons/HeartPlusIcon.d.ts +7 -0
  152. package/icons/HeartPlusIcon.d.ts.map +1 -0
  153. package/icons/HeartPlusIcon.js +1 -3
  154. package/icons/HeartPlusOutlineIcon.d.ts +7 -0
  155. package/icons/HeartPlusOutlineIcon.d.ts.map +1 -0
  156. package/icons/HeartPlusOutlineIcon.js +1 -3
  157. package/icons/HomeIcon.d.ts +7 -0
  158. package/icons/HomeIcon.d.ts.map +1 -0
  159. package/icons/HomeIcon.js +0 -2
  160. package/icons/InfoIcon.d.ts +7 -0
  161. package/icons/InfoIcon.d.ts.map +1 -0
  162. package/icons/InfoIcon.js +0 -2
  163. package/icons/InfoOutlineIcon.d.ts +7 -0
  164. package/icons/InfoOutlineIcon.d.ts.map +1 -0
  165. package/icons/InfoOutlineIcon.js +0 -2
  166. package/icons/ListIcon.d.ts +7 -0
  167. package/icons/ListIcon.d.ts.map +1 -0
  168. package/icons/ListIcon.js +0 -2
  169. package/icons/LocalShippingIcon.d.ts +7 -0
  170. package/icons/LocalShippingIcon.d.ts.map +1 -0
  171. package/icons/LocalShippingIcon.js +0 -2
  172. package/icons/LocationIcon.d.ts +7 -0
  173. package/icons/LocationIcon.d.ts.map +1 -0
  174. package/icons/LocationIcon.js +1 -4
  175. package/icons/LocatorIcon.d.ts +7 -0
  176. package/icons/LocatorIcon.d.ts.map +1 -0
  177. package/icons/LocatorIcon.js +1 -3
  178. package/icons/LockIcon.d.ts +9 -0
  179. package/icons/LockIcon.d.ts.map +1 -0
  180. package/icons/LockIcon.js +1 -2
  181. package/icons/LogoutIcon.d.ts +7 -0
  182. package/icons/LogoutIcon.d.ts.map +1 -0
  183. package/icons/LogoutIcon.js +0 -2
  184. package/icons/MagnifierIcon.d.ts +7 -0
  185. package/icons/MagnifierIcon.d.ts.map +1 -0
  186. package/icons/MagnifierIcon.js +0 -2
  187. package/icons/MapMarkerIcon.d.ts +7 -0
  188. package/icons/MapMarkerIcon.d.ts.map +1 -0
  189. package/icons/MapMarkerIcon.js +1 -3
  190. package/icons/MoreIcon.d.ts +7 -0
  191. package/icons/MoreIcon.d.ts.map +1 -0
  192. package/icons/MoreIcon.js +1 -3
  193. package/icons/MoreVertIcon.d.ts +7 -0
  194. package/icons/MoreVertIcon.d.ts.map +1 -0
  195. package/icons/MoreVertIcon.js +1 -3
  196. package/icons/NotificationIcon.d.ts +7 -0
  197. package/icons/NotificationIcon.d.ts.map +1 -0
  198. package/icons/NotificationIcon.js +1 -3
  199. package/icons/PersonIcon.d.ts +9 -0
  200. package/icons/PersonIcon.d.ts.map +1 -0
  201. package/icons/PersonIcon.js +0 -3
  202. package/icons/PhoneIcon.d.ts +7 -0
  203. package/icons/PhoneIcon.d.ts.map +1 -0
  204. package/icons/PhoneIcon.js +1 -4
  205. package/icons/PlaceholderIcon.d.ts +7 -0
  206. package/icons/PlaceholderIcon.d.ts.map +1 -0
  207. package/icons/PlaceholderIcon.js +0 -2
  208. package/icons/RadioCheckedIcon.d.ts +10 -0
  209. package/icons/RadioCheckedIcon.d.ts.map +1 -0
  210. package/icons/RadioCheckedIcon.js +0 -2
  211. package/icons/RadioUncheckedIcon.d.ts +10 -0
  212. package/icons/RadioUncheckedIcon.d.ts.map +1 -0
  213. package/icons/RadioUncheckedIcon.js +0 -2
  214. package/icons/SecurityIcon.d.ts +7 -0
  215. package/icons/SecurityIcon.d.ts.map +1 -0
  216. package/icons/SecurityIcon.js +0 -2
  217. package/icons/ShippingMethodIcon.d.ts +7 -0
  218. package/icons/ShippingMethodIcon.d.ts.map +1 -0
  219. package/icons/ShippingMethodIcon.js +0 -2
  220. package/icons/ShoppingCartIcon.d.ts +7 -0
  221. package/icons/ShoppingCartIcon.d.ts.map +1 -0
  222. package/icons/ShoppingCartIcon.js +0 -2
  223. package/icons/SortIcon.d.ts +7 -0
  224. package/icons/SortIcon.d.ts.map +1 -0
  225. package/icons/SortIcon.js +0 -2
  226. package/icons/StarHalfIcon.d.ts +7 -0
  227. package/icons/StarHalfIcon.d.ts.map +1 -0
  228. package/icons/StarHalfIcon.js +0 -9
  229. package/icons/StarIcon.d.ts +7 -0
  230. package/icons/StarIcon.d.ts.map +1 -0
  231. package/icons/StarIcon.js +0 -9
  232. package/icons/StarOutlineIcon.d.ts +7 -0
  233. package/icons/StarOutlineIcon.d.ts.map +1 -0
  234. package/icons/StarOutlineIcon.js +0 -2
  235. package/icons/StopIcon.d.ts +7 -0
  236. package/icons/StopIcon.d.ts.map +1 -0
  237. package/icons/StopIcon.js +0 -2
  238. package/icons/TickIcon.d.ts +7 -0
  239. package/icons/TickIcon.d.ts.map +1 -0
  240. package/icons/TickIcon.js +0 -2
  241. package/icons/TimeIcon.d.ts +7 -0
  242. package/icons/TimeIcon.d.ts.map +1 -0
  243. package/icons/TimeIcon.js +0 -2
  244. package/icons/TrashIcon.d.ts +7 -0
  245. package/icons/TrashIcon.d.ts.map +1 -0
  246. package/icons/TrashIcon.js +0 -3
  247. package/icons/TrashOutlineIcon.d.ts +8 -0
  248. package/icons/TrashOutlineIcon.d.ts.map +1 -0
  249. package/icons/TrashOutlineIcon.js +0 -2
  250. package/icons/UncheckedIcon.d.ts +7 -0
  251. package/icons/UncheckedIcon.d.ts.map +1 -0
  252. package/icons/UncheckedIcon.js +0 -2
  253. package/icons/ViewListIcon.d.ts +7 -0
  254. package/icons/ViewListIcon.d.ts.map +1 -0
  255. package/icons/ViewListIcon.js +0 -2
  256. package/icons/VisibilityIcon.d.ts +8 -0
  257. package/icons/VisibilityIcon.d.ts.map +1 -0
  258. package/icons/VisibilityIcon.js +2 -4
  259. package/icons/VisibilityOffIcon.d.ts +8 -0
  260. package/icons/VisibilityOffIcon.d.ts.map +1 -0
  261. package/icons/VisibilityOffIcon.js +2 -4
  262. package/icons/WarningIcon.d.ts +7 -0
  263. package/icons/WarningIcon.d.ts.map +1 -0
  264. package/icons/WarningIcon.js +1 -3
  265. package/package.json +5 -5
  266. package/tsconfig.build.json +16 -0
  267. package/tsconfig.json +3 -0
  268. package/ActionButton/style.js +0 -22
  269. package/Availability/style.js +0 -19
  270. package/Button/style.js +0 -155
  271. package/Card/style.js +0 -11
  272. package/CardList/components/Item/style.js +0 -7
  273. package/CartTotalLine/components/Amount/style.js +0 -8
  274. package/CartTotalLine/components/Hint/style.js +0 -12
  275. package/CartTotalLine/components/Label/style.js +0 -17
  276. package/CartTotalLine/style.js +0 -31
  277. package/Checkbox/style.js +0 -18
  278. package/Chip/style.js +0 -78
  279. package/ContextMenu/components/Item/style.js +0 -34
  280. package/ContextMenu/components/Position/style.js +0 -11
  281. package/ContextMenu/style.js +0 -45
  282. package/DiscountBadge/style.js +0 -36
  283. package/FavoritesButton/style.js +0 -26
  284. package/Form/Checkbox/style.js +0 -25
  285. package/Form/InfoField/style.js +0 -11
  286. package/Form/Password/style.js +0 -11
  287. package/Form/RadioGroup/components/Item/style.js +0 -32
  288. package/Form/RadioGroup/style.js +0 -20
  289. package/Form/Select/style.js +0 -27
  290. package/Form/SelectContextChoices/style.js +0 -23
  291. package/Form/TextField/style.js +0 -70
  292. package/FormElement/components/ErrorText/style.js +0 -13
  293. package/FormElement/components/Label/style.js +0 -89
  294. package/FormElement/components/Placeholder/style.js +0 -56
  295. package/FormElement/components/Underline/style.js +0 -60
  296. package/FormElement/style.js +0 -14
  297. package/Glow/style.js +0 -18
  298. package/IndicatorCircle/style.js +0 -65
  299. package/LoadingIndicator/style.js +0 -20
  300. package/Manufacturer/style.js +0 -5
  301. package/MessageBar/spec.js +0 -80
  302. package/MessageBar/style.js +0 -38
  303. package/NoResults/components/Icon/style.js +0 -17
  304. package/NoResults/style.js +0 -31
  305. package/Placeholder/style.js +0 -11
  306. package/PlaceholderLabel/style.js +0 -12
  307. package/Price/style.js +0 -22
  308. package/PriceInfo/style.js +0 -5
  309. package/PriceStriked/style.js +0 -36
  310. package/ProgressBar/style.js +0 -85
  311. package/RadioButton/style.js +0 -21
  312. package/RatingStars/style.js +0 -53
  313. package/Ripple/style.js +0 -18
  314. package/ScannerOverlay/components/CameraOverlay/style.js +0 -40
  315. package/ScannerOverlay/components/ScannerBar/components/FlashlightButton/style.js +0 -28
  316. package/ScannerOverlay/components/ScannerBar/style.js +0 -20
  317. package/Sheet/components/Header/components/SearchBar/style.js +0 -47
  318. package/Sheet/components/Header/style.js +0 -50
  319. package/Sheet/style.js +0 -143
  320. package/TaxDisclaimer/style.js +0 -9
  321. package/TextField/components/ErrorText/style.js +0 -27
  322. package/TextField/components/FormElement/style.js +0 -34
  323. package/TextField/components/Hint/style.js +0 -46
  324. package/TextField/components/Label/style.js +0 -80
  325. package/TextField/components/Underline/style.js +0 -60
  326. package/TextField/style.js +0 -35
package/Chip/index.js CHANGED
@@ -2,16 +2,84 @@ import React, { useRef, useCallback, useEffect } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import Button from '@shopgate/pwa-common/components/Button';
4
4
  import ResponsiveContainer from '@shopgate/engage/components/ResponsiveContainer';
5
+ import { hasNewServices } from '@shopgate/engage/core/helpers';
6
+ import { makeStyles, responsiveMediaQuery } from '@shopgate/engage/styles';
5
7
  import CrossIcon from "../icons/CrossIcon";
6
- import styles from "./style";
8
+
9
+ /**
10
+ * @param {boolean} hasRemoveButton Whether this chip has a remove button.
11
+ * @param {Object} theme Theme with spacing().
12
+ * @returns {Object} Shared layout fields for the chip root.
13
+ */
14
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
15
+ const chipBase = (hasRemoveButton, theme) => ({
16
+ display: 'flex',
17
+ alignItems: 'center',
18
+ borderRadius: 26,
19
+ outline: 0,
20
+ height: 26,
21
+ paddingRight: theme.spacing(1),
22
+ paddingLeft: hasRemoveButton ? theme.spacing(0.5) : theme.spacing(1),
23
+ marginRight: 5,
24
+ marginTop: 4,
25
+ marginBottom: 4,
26
+ minWidth: 0
27
+ });
28
+ const useStyles = makeStyles()((theme, {
29
+ removable,
30
+ invert
31
+ }) => ({
32
+ chip: {
33
+ ...chipBase(removable, theme),
34
+ ...(hasNewServices() ? {
35
+ backgroundColor: invert ? 'var(--color-primary)' : 'var(--color-primary-contrast)',
36
+ color: invert ? 'var(--color-primary-contrast)' : 'var(--color-primary)'
37
+ } : {
38
+ backgroundColor: invert ? 'var(--color-secondary)' : 'var(--color-secondary-contrast)',
39
+ color: invert ? 'var(--color-secondary-contrast)' : 'var(--color-secondary)',
40
+ '--color-text-high-emphasis': invert ? 'var(--color-secondary-contrast)' : 'var(--color-secondary)'
41
+ })
42
+ },
43
+ removeButton: {
44
+ flexShrink: 0,
45
+ padding: 0,
46
+ [responsiveMediaQuery('>xs', {
47
+ webOnly: true
48
+ })]: {
49
+ padding: '0 5px',
50
+ fontSize: '1.125rem'
51
+ }
52
+ },
53
+ name: {
54
+ paddingLeft: theme.spacing(0.5),
55
+ paddingRight: theme.spacing(0.5),
56
+ paddingTop: 3,
57
+ paddingBottom: 3,
58
+ fontSize: 12,
59
+ fontWeight: 500,
60
+ textOverflow: 'ellipsis',
61
+ maxWidth: '100%',
62
+ whiteSpace: 'nowrap',
63
+ overflow: 'hidden',
64
+ display: 'block',
65
+ lineHeight: '1',
66
+ color: 'inherit',
67
+ [responsiveMediaQuery('>xs', {
68
+ webOnly: true
69
+ })]: {
70
+ fontSize: '0.875rem',
71
+ lineHeight: '1.25rem',
72
+ padding: '6px 8px 6px 0'
73
+ }
74
+ }
75
+ }));
7
76
 
8
77
  /**
9
78
  * The chip component.
10
79
  * @param {Object} props The component props.
11
80
  * @returns {JSX}
12
81
  */
13
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
- function Chip(props) {
82
+ const Chip = props => {
15
83
  const {
16
84
  removable,
17
85
  children,
@@ -22,6 +90,13 @@ function Chip(props) {
22
90
  removeLabel,
23
91
  editLabel
24
92
  } = props;
93
+ const {
94
+ classes,
95
+ cx
96
+ } = useStyles({
97
+ removable,
98
+ invert
99
+ });
25
100
  const ref = useRef(null);
26
101
  const handleRemove = useCallback(() => {
27
102
  onRemove(id);
@@ -31,10 +106,10 @@ function Chip(props) {
31
106
  });
32
107
  return /*#__PURE__*/_jsxs("div", {
33
108
  ref: ref,
34
- className: `ui-shared__chip ${styles.chip(removable, invert)}`,
109
+ className: cx('ui-shared__chip', classes.chip),
35
110
  "data-test-id": id,
36
111
  children: [removable && /*#__PURE__*/_jsxs(Button, {
37
- className: styles.removeButton,
112
+ className: classes.removeButton,
38
113
  onClick: handleRemove,
39
114
  testId: "removeFilter",
40
115
  "aria-label": removeLabel,
@@ -52,13 +127,13 @@ function Chip(props) {
52
127
  })
53
128
  })]
54
129
  }), /*#__PURE__*/_jsx(Button, {
55
- className: styles.name,
130
+ className: classes.name,
56
131
  onClick: onClick,
57
132
  "aria-label": editLabel,
58
133
  children: children
59
134
  })]
60
135
  });
61
- }
136
+ };
62
137
  Chip.defaultProps = {
63
138
  invert: false,
64
139
  onClick: () => {},
@@ -1,17 +1,41 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import noop from 'lodash/noop';
4
- import classNames from 'classnames';
4
+ import Color from 'color';
5
+ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
6
+ import { getCSSCustomProp, makeStyles } from '@shopgate/engage/styles';
5
7
  import Glow from "../../../Glow";
6
- import { getItemClass } from "./style";
7
8
  import { useContextMenu } from "../../ContextMenu.hooks";
8
-
9
- /**
10
- * A delay in ms after that the closeMenu callback gets triggered.
11
- * @type {number}
12
- */
13
9
  import { jsx as _jsx } from "react/jsx-runtime";
14
10
  const CLOSE_DELAY = 250;
11
+ const useStyles = makeStyles()((theme, {
12
+ disabled
13
+ }) => {
14
+ let background = themeConfig.colors.shade8;
15
+ const customPropColor = getCSSCustomProp('--color-primary');
16
+ if (customPropColor) {
17
+ background = Color(customPropColor).alpha(0.04).toString();
18
+ }
19
+ return {
20
+ root: {
21
+ position: 'relative',
22
+ whiteSpace: 'nowrap',
23
+ marginBottom: 2,
24
+ padding: theme.spacing(1.75, 2.75),
25
+ lineHeight: 1,
26
+ zIndex: 1,
27
+ color: disabled ? theme.palette.text.secondary : 'inherits',
28
+ ...(!disabled ? {
29
+ cursor: 'pointer',
30
+ '&:hover': {
31
+ background
32
+ }
33
+ } : {
34
+ cursor: 'default'
35
+ })
36
+ }
37
+ };
38
+ });
15
39
 
16
40
  /**
17
41
  * The Context Menu Item component.
@@ -25,15 +49,15 @@ const Item = ({
25
49
  autoClose,
26
50
  className
27
51
  }) => {
52
+ const {
53
+ classes,
54
+ cx
55
+ } = useStyles({
56
+ disabled
57
+ });
28
58
  const {
29
59
  handleMenuToggle
30
60
  } = useContextMenu();
31
-
32
- /**
33
- * Handles the click event.
34
- * @param {Event} event The click event.
35
- * @returns {void}
36
- */
37
61
  const handleClick = useCallback(event => {
38
62
  event.persist();
39
63
  setTimeout(() => {
@@ -45,12 +69,6 @@ const Item = ({
45
69
  }, 0);
46
70
  }, autoClose ? CLOSE_DELAY : 0);
47
71
  }, [autoClose, handleMenuToggle, onClick]);
48
-
49
- /**
50
- * Handles the keypress event for screen readers.
51
- * @param {Event} event The click event.
52
- * @returns {void}
53
- */
54
72
  const handleKeyPress = useCallback(event => {
55
73
  if (event.key === 'Enter' || event.key === ' ') {
56
74
  event.preventDefault();
@@ -60,7 +78,7 @@ const Item = ({
60
78
  return /*#__PURE__*/_jsx(Glow, {
61
79
  disabled: disabled,
62
80
  children: /*#__PURE__*/_jsx("div", {
63
- className: classNames(getItemClass(disabled), className),
81
+ className: cx(classes.root, className),
64
82
  onClick: disabled ? noop : handleClick,
65
83
  "data-test-id": "contextMenuButton",
66
84
  "aria-disabled": disabled,
@@ -1,70 +1,52 @@
1
- import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
- import React, { Component } from 'react';
1
+ import React, { useRef, useLayoutEffect } from 'react';
3
2
  import PropTypes from 'prop-types';
4
3
  import clamp from 'lodash/clamp';
5
- import styles from "./style";
4
+ import { makeStyles, useTheme } from '@shopgate/engage/styles';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ const useStyles = makeStyles()(theme => ({
7
+ container: {
8
+ position: 'absolute',
9
+ margin: theme.spacing(1)
10
+ }
11
+ }));
6
12
 
7
13
  /**
8
14
  * The Context Menu Position component.
15
+ * @param {Object} props Props.
16
+ * @returns {JSX.Element}
9
17
  */
10
- import { jsx as _jsx } from "react/jsx-runtime";
11
- let Position = /*#__PURE__*/function (_Component) {
12
- /**
13
- * The Constructor.
14
- * @param {Object} props The component props.
15
- */
16
- function Position(props) {
17
- var _this;
18
- _this = _Component.call(this, props) || this;
19
- _this.elementRef = null;
20
- return _this;
21
- }
22
-
23
- /**
24
- * Calculate and apply the correct menu position after mounting.
25
- */
26
- _inheritsLoose(Position, _Component);
27
- var _proto = Position.prototype;
28
- _proto.componentDidMount = function componentDidMount() {
29
- const {
30
- offset
31
- } = this.props;
32
-
33
- // Get ref to the actual child DOM element and calculate bounding rect.
34
- const [child] = this.elementRef.childNodes;
18
+ const Position = ({
19
+ children,
20
+ offset
21
+ }) => {
22
+ const theme = useTheme();
23
+ const gap = theme.spacing(1);
24
+ const {
25
+ classes
26
+ } = useStyles();
27
+ const elementRef = useRef(null);
28
+ useLayoutEffect(() => {
29
+ if (!elementRef.current) {
30
+ return;
31
+ }
32
+ const [child] = elementRef.current.childNodes;
33
+ if (!child) {
34
+ return;
35
+ }
35
36
  const bounds = child.getBoundingClientRect();
36
-
37
- // Get window dimensions
38
37
  const width = window.innerWidth;
39
38
  const height = window.innerHeight;
40
-
41
- // Get the outer gap from styles
42
- const gap = styles.outerGap;
43
-
44
- // Calculate clamped menu position
45
39
  const left = clamp(offset.left, 0, width - bounds.width - gap * 2);
46
40
  const top = clamp(offset.top - gap, 0, height - bounds.height - gap * 2);
47
-
48
- // Assign position directly w/o re-rendering the component
49
- this.elementRef.style.left = `${left}px`;
50
- this.elementRef.style.top = `${top}px`;
51
- }
52
-
53
- /**
54
- * Renders the component.
55
- * @returns {JSX}
56
- */;
57
- _proto.render = function render() {
58
- return /*#__PURE__*/_jsx("div", {
59
- ref: ref => {
60
- this.elementRef = ref;
61
- },
62
- className: styles.container,
63
- children: this.props.children
64
- });
65
- };
66
- return Position;
67
- }(Component);
41
+ elementRef.current.style.left = `${left}px`;
42
+ elementRef.current.style.top = `${top}px`;
43
+ }, [offset, gap]);
44
+ return /*#__PURE__*/_jsx("div", {
45
+ ref: elementRef,
46
+ className: classes.container,
47
+ children: children
48
+ });
49
+ };
68
50
  Position.defaultProps = {
69
51
  children: null,
70
52
  offset: {
@@ -1,41 +1,82 @@
1
1
  import React, { useState, useEffect, useRef, useCallback } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { ConnectedReactPortal } from '@shopgate/engage/components';
4
- import classNames from 'classnames';
5
4
  import Backdrop from '@shopgate/pwa-common/components/Backdrop';
6
5
  import { FocusTrap } from '@shopgate/engage/a11y/components';
7
- import { i18n } from '@shopgate/engage/core';
6
+ import { i18n } from '@shopgate/engage/core/helpers';
7
+ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
8
+ import { makeStyles } from '@shopgate/engage/styles';
8
9
  import MoreVertIcon from "../icons/MoreVertIcon";
9
10
  import Position from "./components/Position";
10
11
  import Item from "./components/Item";
11
- import styles from "./style";
12
12
  import ContextMenuProvider from "./ContextMenuProvider";
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ const useStyles = makeStyles()(theme => ({
15
+ container: {
16
+ position: 'relative'
17
+ },
18
+ button: {
19
+ display: 'block',
20
+ fontSize: '1.5rem',
21
+ outline: 0,
22
+ padding: 0,
23
+ color: 'inherit'
24
+ },
25
+ disabled: {
26
+ cursor: 'not-allowed'
27
+ },
28
+ overlay: {
29
+ position: 'fixed',
30
+ top: 0,
31
+ right: 0,
32
+ bottom: 0,
33
+ left: 0,
34
+ zIndex: 10
35
+ },
36
+ menu: {
37
+ position: 'absolute',
38
+ top: 0,
39
+ left: 0,
40
+ padding: theme.spacing(1, 0),
41
+ minWidth: 130,
42
+ background: themeConfig.colors.light,
43
+ borderRadius: 2,
44
+ boxShadow: themeConfig.shadows.contextMenu
45
+ },
46
+ scrollable: {
47
+ maxHeight: '30vh',
48
+ overflowY: 'auto'
49
+ }
50
+ }));
13
51
 
14
52
  /**
15
53
  * The Context Menu component.
16
- * @param {Object} props The component props.
17
- * @param {Object} props.children The menu items.
18
- * @param {Object} props.classes The classes for the container and button.
19
- * @param {string} props.classes.container The class name for the container.
20
- * @param {string} props.classes.button The class name for the button.
21
- * @param {boolean} props.disabled Whether the menu is disabled.
22
- * @param {boolean} props.isOpened Whether the menu is opened.
23
- * @param {Function} props.onStateChange A callback that is called when the menu state changes.
24
- * @param {boolean} props.scroll Whether the menu should be scrollable.
25
- * @param {boolean} props.showToggle Whether the toggle button should be shown.
26
- * @returns {JSX}
27
- */
28
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
54
+ * @param {Object} props The component props.
55
+ * @param {Object} props.children The menu items.
56
+ * @param {Object} props.classes The classes for the container and button.
57
+ * @param {string} props.classes.container The class name for the container.
58
+ * @param {string} props.classes.button The class name for the button.
59
+ * @param {boolean} props.disabled Whether the menu is disabled.
60
+ * @param {boolean} props.isOpened Whether the menu is opened.
61
+ * @param {Function} props.onStateChange A callback that is called when the menu state changes.
62
+ * @param {boolean} props.scroll Whether the menu should be scrollable.
63
+ * @param {boolean} props.showToggle Whether the toggle button should be shown.
64
+ * @returns {JSX.Element}
65
+ */
29
66
  const ContextMenu = props => {
30
67
  const {
31
68
  children,
32
- classes,
69
+ classes: parentClasses,
33
70
  disabled,
34
71
  showToggle,
35
72
  scroll,
36
73
  isOpened,
37
74
  onStateChange
38
75
  } = props;
76
+ const {
77
+ classes,
78
+ cx
79
+ } = useStyles();
39
80
  const [active, setActive] = useState(isOpened);
40
81
  const elementRef = useRef(null);
41
82
  const menuRef = useRef(null);
@@ -49,11 +90,6 @@ const ContextMenu = props => {
49
90
  menuRef.current.focus();
50
91
  }
51
92
  }, [active]);
52
-
53
- /**
54
- * Handles the menu toggle.
55
- * @param {Object} e The event object.
56
- */
57
93
  const handleMenuToggle = useCallback(e => {
58
94
  if (e) {
59
95
  e.preventDefault();
@@ -79,10 +115,10 @@ const ContextMenu = props => {
79
115
  return /*#__PURE__*/_jsxs("div", {
80
116
  "data-test-id": "contextMenu",
81
117
  ref: elementRef,
82
- className: classNames(styles.container, classes.container, 'ui-shared__context-menu'),
118
+ className: cx(classes.container, parentClasses.container, 'ui-shared__context-menu'),
83
119
  children: [showToggle && /*#__PURE__*/_jsx("button", {
84
- className: classNames(styles.button, classes.button, {
85
- [styles.disabled]: disabled
120
+ className: cx(classes.button, parentClasses.button, {
121
+ [classes.disabled]: disabled
86
122
  }),
87
123
  onClick: handleMenuToggle,
88
124
  disabled: disabled,
@@ -99,7 +135,7 @@ const ContextMenu = props => {
99
135
  children: /*#__PURE__*/_jsx(FocusTrap, {
100
136
  active: active,
101
137
  children: /*#__PURE__*/_jsxs("div", {
102
- className: styles.overlay,
138
+ className: classes.overlay,
103
139
  children: [/*#__PURE__*/_jsx(Backdrop, {
104
140
  isVisible: true,
105
141
  level: 0,
@@ -110,8 +146,8 @@ const ContextMenu = props => {
110
146
  children: /*#__PURE__*/_jsx(ContextMenuProvider, {
111
147
  handleMenuToggle: handleMenuToggle,
112
148
  children: /*#__PURE__*/_jsxs("div", {
113
- className: classNames(styles.menu, {
114
- [styles.scrollable]: useScroll
149
+ className: cx(classes.menu, {
150
+ [classes.scrollable]: useScroll
115
151
  }),
116
152
  ref: menuRef,
117
153
  tabIndex: "-1",
@@ -1,3 +1,4 @@
1
+ import "core-js/modules/es.array.includes.js";
1
2
  // TODO: Move to ThemeContext
2
3
  import BaseDialogGMD from '@shopgate/pwa-ui-material/BaseDialog';
3
4
  import BaseDialogIOS from '@shopgate/pwa-ui-ios/BaseDialog';
@@ -5,6 +5,45 @@ import { jsx as _jsx } from "react/jsx-runtime";
5
5
  const message = '<p><i>This is a html message.</i></p>';
6
6
  const title = 'This is the title.';
7
7
  jest.mock('@shopgate/engage/a11y/components');
8
+ jest.mock('@shopgate/engage/components', () => {
9
+ const mockReact = jest.requireActual('react');
10
+ function Text({
11
+ string
12
+ }) {
13
+ return mockReact.createElement('span', null, string);
14
+ }
15
+ Text.propTypes = {
16
+ params: () => null
17
+ };
18
+ Text.defaultProps = {
19
+ params: {}
20
+ };
21
+ const I18n = {
22
+ Text
23
+ };
24
+ function Ellipsis({
25
+ children
26
+ }) {
27
+ return mockReact.createElement('span', null, children);
28
+ }
29
+ function Button({
30
+ children,
31
+ onClick,
32
+ disabled,
33
+ className
34
+ }) {
35
+ return mockReact.createElement('button', {
36
+ onClick,
37
+ disabled,
38
+ className
39
+ }, children);
40
+ }
41
+ return {
42
+ I18n,
43
+ Ellipsis,
44
+ Button
45
+ };
46
+ });
8
47
  describe('<HtmlContentDialog />', () => {
9
48
  it('should render with minimal props', () => {
10
49
  const wrapper = shallow(/*#__PURE__*/_jsx(HtmlContentDialog, {