@shopgate/pwa-ui-shared 7.30.0-alpha.7 → 7.30.0-alpha.9

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 (266) hide show
  1. package/AccordionContainer/index.js +39 -5
  2. package/AccordionContainer/spec.js +25 -2
  3. package/ActionButton/index.js +63 -7
  4. package/ActionButton/spec.js +63 -2
  5. package/ActionButton/style.js +22 -1
  6. package/AddToCartButton/index.js +184 -27
  7. package/AddToCartButton/mock.js +18 -4
  8. package/AddToCartButton/spec.js +65 -2
  9. package/AddToCartButton/style.js +127 -11
  10. package/Availability/index.js +34 -2
  11. package/Availability/spec.js +41 -1
  12. package/Availability/style.js +19 -1
  13. package/Button/index.js +76 -5
  14. package/Button/spec.js +33 -1
  15. package/Button/style.js +130 -21
  16. package/ButtonLink/connector.js +11 -2
  17. package/ButtonLink/index.js +44 -6
  18. package/ButtonLink/spec.js +23 -1
  19. package/Card/index.js +19 -2
  20. package/Card/style.js +11 -1
  21. package/CardList/components/Item/index.js +26 -2
  22. package/CardList/components/Item/style.js +7 -1
  23. package/CardList/index.js +34 -3
  24. package/CartTotalLine/components/Amount/index.js +28 -2
  25. package/CartTotalLine/components/Amount/style.js +8 -1
  26. package/CartTotalLine/components/Hint/index.js +23 -2
  27. package/CartTotalLine/components/Hint/style.js +12 -1
  28. package/CartTotalLine/components/Label/index.js +36 -2
  29. package/CartTotalLine/components/Label/style.js +17 -1
  30. package/CartTotalLine/components/Spacer/index.js +16 -2
  31. package/CartTotalLine/index.js +39 -2
  32. package/CartTotalLine/style.js +31 -1
  33. package/Checkbox/index.js +31 -2
  34. package/Checkbox/style.js +18 -1
  35. package/Chip/index.js +61 -2
  36. package/Chip/spec.js +24 -1
  37. package/Chip/style.js +71 -3
  38. package/ContextMenu/ContextMenu.hooks.js +6 -2
  39. package/ContextMenu/ContextMenuProvider.context.js +9 -3
  40. package/ContextMenu/ContextMenuProvider.js +21 -2
  41. package/ContextMenu/components/Item/index.js +67 -5
  42. package/ContextMenu/components/Item/style.js +32 -3
  43. package/ContextMenu/components/Position/index.js +61 -10
  44. package/ContextMenu/components/Position/style.js +11 -1
  45. package/ContextMenu/index.js +124 -3
  46. package/ContextMenu/spec.js +101 -2
  47. package/ContextMenu/style.js +45 -1
  48. package/Dialog/components/BasicDialog/index.js +5 -1
  49. package/Dialog/components/HtmlContentDialog/index.js +22 -2
  50. package/Dialog/components/HtmlContentDialog/spec.js +59 -1
  51. package/Dialog/components/PipelineErrorDialog/index.js +114 -25
  52. package/Dialog/components/PipelineErrorDialog/spec.js +92 -12
  53. package/Dialog/components/TextMessageDialog/index.js +28 -2
  54. package/Dialog/components/TextMessageDialog/spec.js +59 -1
  55. package/Dialog/components/VariantSelectModal/connector.js +11 -2
  56. package/Dialog/components/VariantSelectModal/index.js +65 -6
  57. package/Dialog/components/VariantSelectModal/spec.js +51 -2
  58. package/Dialog/constants.js +6 -1
  59. package/Dialog/index.js +114 -7
  60. package/Dialog/spec.js +81 -3
  61. package/DiscountBadge/index.js +30 -2
  62. package/DiscountBadge/spec.js +19 -1
  63. package/DiscountBadge/style.js +34 -2
  64. package/FavoritesButton/connector.js +18 -3
  65. package/FavoritesButton/index.js +118 -15
  66. package/FavoritesButton/mock.js +50 -4
  67. package/FavoritesButton/spec.js +120 -2
  68. package/FavoritesButton/style.js +26 -1
  69. package/Form/Builder/builders/buildCountryList.js +40 -6
  70. package/Form/Builder/builders/buildFormDefaults.js +35 -6
  71. package/Form/Builder/builders/buildFormElements.js +68 -10
  72. package/Form/Builder/builders/buildProvinceList.js +19 -2
  73. package/Form/Builder/builders/buildValidationErrorList.js +7 -2
  74. package/Form/Builder/classes/ActionListener/constants.js +22 -2
  75. package/Form/Builder/classes/ActionListener/index.js +441 -93
  76. package/Form/Builder/classes/ActionListener/spec.js +321 -19
  77. package/Form/Builder/components/CheckboxElement.js +35 -3
  78. package/Form/Builder/components/CountryElement.js +40 -3
  79. package/Form/Builder/components/ProvinceElement.js +40 -3
  80. package/Form/Builder/components/RadioElement.js +41 -3
  81. package/Form/Builder/components/SelectElement.js +39 -3
  82. package/Form/Builder/components/TextElement.js +49 -4
  83. package/Form/Builder/elementTypes.js +11 -1
  84. package/Form/Builder/index.js +298 -52
  85. package/Form/Builder/iso-3166-2.js +4943 -1
  86. package/Form/Builder/spec.js +308 -16
  87. package/Form/Checkbox/index.js +66 -4
  88. package/Form/Checkbox/style.js +25 -2
  89. package/Form/InfoField/index.js +50 -2
  90. package/Form/InfoField/spec.js +9 -1
  91. package/Form/InfoField/style.js +11 -1
  92. package/Form/Password/index.js +51 -6
  93. package/Form/Password/spec.js +34 -1
  94. package/Form/Password/style.js +11 -1
  95. package/Form/RadioGroup/components/Item/index.js +59 -3
  96. package/Form/RadioGroup/components/Item/style.js +32 -2
  97. package/Form/RadioGroup/index.js +101 -9
  98. package/Form/RadioGroup/spec.js +83 -3
  99. package/Form/RadioGroup/style.js +18 -2
  100. package/Form/Select/index.js +158 -10
  101. package/Form/Select/spec.js +36 -5
  102. package/Form/Select/style.js +27 -1
  103. package/Form/SelectContextChoices/index.js +77 -3
  104. package/Form/SelectContextChoices/spec.js +33 -4
  105. package/Form/SelectContextChoices/style.js +23 -1
  106. package/Form/TextField/index.js +92 -8
  107. package/Form/TextField/spec.js +110 -1
  108. package/Form/TextField/style.js +66 -8
  109. package/Form/index.js +54 -13
  110. package/FormElement/components/ErrorText/index.js +31 -2
  111. package/FormElement/components/ErrorText/style.js +13 -1
  112. package/FormElement/components/Label/index.js +35 -2
  113. package/FormElement/components/Label/style.js +76 -8
  114. package/FormElement/components/Placeholder/index.js +26 -2
  115. package/FormElement/components/Placeholder/style.js +48 -6
  116. package/FormElement/components/Underline/index.js +18 -2
  117. package/FormElement/components/Underline/style.js +51 -4
  118. package/FormElement/index.js +91 -6
  119. package/FormElement/spec.js +67 -2
  120. package/FormElement/style.js +13 -2
  121. package/Glow/index.js +90 -7
  122. package/Glow/spec.js +9 -1
  123. package/Glow/style.js +18 -1
  124. package/IndicatorCircle/index.js +33 -3
  125. package/IndicatorCircle/spec.js +28 -1
  126. package/IndicatorCircle/style.js +57 -3
  127. package/LoadingIndicator/index.js +29 -2
  128. package/LoadingIndicator/style.js +20 -1
  129. package/Manufacturer/index.js +20 -2
  130. package/Manufacturer/style.js +5 -1
  131. package/MessageBar/index.js +36 -2
  132. package/MessageBar/spec.js +79 -1
  133. package/MessageBar/style.js +38 -1
  134. package/NoResults/components/Icon/index.js +130 -2
  135. package/NoResults/components/Icon/style.js +17 -1
  136. package/NoResults/index.js +46 -2
  137. package/NoResults/style.js +31 -1
  138. package/Placeholder/index.js +25 -3
  139. package/Placeholder/style.js +11 -1
  140. package/PlaceholderLabel/index.js +27 -2
  141. package/PlaceholderLabel/spec.js +19 -1
  142. package/PlaceholderLabel/style.js +12 -1
  143. package/PlaceholderParagraph/index.js +36 -2
  144. package/PlaceholderParagraph/spec.js +19 -1
  145. package/Price/index.js +88 -7
  146. package/Price/style.js +22 -1
  147. package/PriceInfo/index.js +20 -2
  148. package/PriceInfo/style.js +5 -1
  149. package/PriceStriked/index.js +83 -12
  150. package/PriceStriked/style.js +33 -3
  151. package/ProductProperties/index.js +32 -2
  152. package/ProgressBar/index.js +101 -13
  153. package/ProgressBar/spec.js +13 -1
  154. package/ProgressBar/style.js +83 -2
  155. package/RadioButton/index.js +18 -2
  156. package/RadioButton/spec.js +21 -1
  157. package/RadioButton/style.js +21 -1
  158. package/RatingNumber/index.js +29 -2
  159. package/RatingStars/constants.js +2 -1
  160. package/RatingStars/index.js +130 -12
  161. package/RatingStars/spec.js +90 -3
  162. package/RatingStars/style.js +51 -2
  163. package/Ripple/components/RippleAnimation/index.js +88 -6
  164. package/Ripple/index.js +218 -40
  165. package/Ripple/style.js +18 -1
  166. package/RippleButton/index.js +52 -5
  167. package/RippleButton/spec.js +45 -1
  168. package/ScannerOverlay/components/CameraOverlay/index.js +13 -2
  169. package/ScannerOverlay/components/CameraOverlay/style.js +40 -1
  170. package/ScannerOverlay/components/ScannerBar/components/FlashlightButton/index.js +34 -2
  171. package/ScannerOverlay/components/ScannerBar/components/FlashlightButton/style.js +28 -1
  172. package/ScannerOverlay/components/ScannerBar/components/ScannerInstructions/index.js +11 -2
  173. package/ScannerOverlay/components/ScannerBar/index.js +31 -2
  174. package/ScannerOverlay/components/ScannerBar/style.js +20 -1
  175. package/ScannerOverlay/index.js +47 -7
  176. package/Sheet/components/Header/components/SearchBar/index.js +46 -2
  177. package/Sheet/components/Header/components/SearchBar/spec.js +21 -3
  178. package/Sheet/components/Header/components/SearchBar/style.js +47 -1
  179. package/Sheet/components/Header/index.js +75 -7
  180. package/Sheet/components/Header/spec.js +14 -1
  181. package/Sheet/components/Header/style.js +50 -1
  182. package/Sheet/index.js +170 -17
  183. package/Sheet/spec.js +85 -5
  184. package/Sheet/style.js +143 -2
  185. package/TaxDisclaimer/index.js +34 -4
  186. package/TaxDisclaimer/spec.js +31 -3
  187. package/TaxDisclaimer/style.js +9 -1
  188. package/TextField/components/ErrorText/index.js +33 -2
  189. package/TextField/components/ErrorText/style.js +25 -3
  190. package/TextField/components/FormElement/index.js +19 -2
  191. package/TextField/components/FormElement/style.js +32 -4
  192. package/TextField/components/Hint/index.js +21 -2
  193. package/TextField/components/Hint/style.js +40 -5
  194. package/TextField/components/Label/index.js +32 -3
  195. package/TextField/components/Label/style.js +68 -8
  196. package/TextField/components/Underline/index.js +19 -2
  197. package/TextField/components/Underline/style.js +51 -4
  198. package/TextField/index.js +189 -27
  199. package/TextField/spec.js +128 -3
  200. package/TextField/style.js +34 -4
  201. package/ToggleIcon/index.js +58 -8
  202. package/ToggleIcon/spec.js +35 -1
  203. package/icons/AccountBoxIcon.js +11 -2
  204. package/icons/AddMoreIcon.js +11 -2
  205. package/icons/ArrowDropIcon.js +11 -2
  206. package/icons/ArrowIcon.js +21 -2
  207. package/icons/BarcodeScannerIcon.js +11 -2
  208. package/icons/BoxIcon.js +11 -2
  209. package/icons/BrowseIcon.js +11 -2
  210. package/icons/BurgerIcon.js +11 -2
  211. package/icons/CalendarIcon.js +15 -3
  212. package/icons/CartCouponIcon.js +72 -2
  213. package/icons/CartIcon.js +11 -2
  214. package/icons/CartPlusIcon.js +11 -2
  215. package/icons/CheckIcon.js +11 -2
  216. package/icons/CheckedIcon.js +11 -2
  217. package/icons/ChevronIcon.js +11 -2
  218. package/icons/CreditCardIcon.js +11 -2
  219. package/icons/CrossIcon.js +11 -2
  220. package/icons/DescriptionIcon.js +11 -2
  221. package/icons/FilterIcon.js +11 -2
  222. package/icons/FlashDisabledIcon.js +11 -2
  223. package/icons/FlashEnabledIcon.js +11 -2
  224. package/icons/GridIcon.js +11 -2
  225. package/icons/HeartIcon.js +11 -2
  226. package/icons/HeartOutlineIcon.js +11 -2
  227. package/icons/HeartPlusIcon.js +12 -2
  228. package/icons/HeartPlusOutlineIcon.js +12 -2
  229. package/icons/HomeIcon.js +11 -2
  230. package/icons/InfoIcon.js +11 -2
  231. package/icons/InfoOutlineIcon.js +11 -2
  232. package/icons/ListIcon.js +11 -2
  233. package/icons/LocalShippingIcon.js +11 -2
  234. package/icons/LocationIcon.js +13 -3
  235. package/icons/LocatorIcon.js +11 -2
  236. package/icons/LockIcon.js +11 -2
  237. package/icons/LogoutIcon.js +11 -2
  238. package/icons/MagnifierIcon.js +11 -2
  239. package/icons/MapMarkerIcon.js +24 -3
  240. package/icons/MoreIcon.js +11 -2
  241. package/icons/MoreVertIcon.js +11 -2
  242. package/icons/NotificationIcon.js +14 -3
  243. package/icons/PersonIcon.js +12 -2
  244. package/icons/PhoneIcon.js +13 -3
  245. package/icons/PlaceholderIcon.js +11 -2
  246. package/icons/RadioCheckedIcon.js +11 -2
  247. package/icons/RadioUncheckedIcon.js +11 -2
  248. package/icons/SecurityIcon.js +11 -2
  249. package/icons/ShippingMethodIcon.js +18 -3
  250. package/icons/ShoppingCartIcon.js +11 -2
  251. package/icons/SortIcon.js +11 -2
  252. package/icons/StarHalfIcon.js +18 -2
  253. package/icons/StarIcon.js +18 -2
  254. package/icons/StarOutlineIcon.js +11 -2
  255. package/icons/StopIcon.js +11 -2
  256. package/icons/TickIcon.js +11 -2
  257. package/icons/TimeIcon.js +14 -3
  258. package/icons/TrashIcon.js +11 -2
  259. package/icons/TrashOutlineIcon.js +12 -2
  260. package/icons/UncheckedIcon.js +11 -2
  261. package/icons/ViewListIcon.js +11 -2
  262. package/icons/VisibilityIcon.js +11 -2
  263. package/icons/VisibilityOffIcon.js +11 -2
  264. package/icons/WarningIcon.js +11 -2
  265. package/index.js +13 -1
  266. package/package.json +5 -5
@@ -1,21 +1,89 @@
1
- function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{css}from'glamor';import classNames from'classnames';import{themeConfig}from'@shopgate/pwa-common/helpers/config';/**
1
+ import { css } from 'glamor';
2
+ import classNames from 'classnames';
3
+ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
4
+
5
+ /**
2
6
  * The style object for a one line text element with an ellipsis on overflow.
3
- */var ellipsisLine={overflow:'hidden',width:'100%',whiteSpace:'nowrap',textOverflow:'ellipsis'};var easing='450ms cubic-bezier(0.23, 1, 0.32, 1)';/**
7
+ */
8
+ const ellipsisLine = {
9
+ overflow: 'hidden',
10
+ width: '100%',
11
+ whiteSpace: 'nowrap',
12
+ textOverflow: 'ellipsis'
13
+ };
14
+ const easing = '450ms cubic-bezier(0.23, 1, 0.32, 1)';
15
+
16
+ /**
4
17
  * The styles for the error label.
5
- */var labelError=css({color:"var(--color-state-alert, ".concat(themeConfig.colors.error,")")}).toString();/**
18
+ */
19
+ const labelError = css({
20
+ color: `var(--color-state-alert, ${themeConfig.colors.error})`
21
+ }).toString();
22
+
23
+ /**
6
24
  * Regular label is hidden, because placeholder is visible
7
- */var labelRegular=css({opacity:0}).toString();/**
25
+ */
26
+ const labelRegular = css({
27
+ opacity: 0
28
+ }).toString();
29
+
30
+ /**
8
31
  * The styles for the focused label.
9
- */var labelFocus=css({color:themeConfig.colors.focus}).toString();/**
32
+ */
33
+ const labelFocus = css({
34
+ color: themeConfig.colors.focus
35
+ }).toString();
36
+
37
+ /**
10
38
  * The styles for the floating label.
11
- */var labelFloating=css({transform:'translate3d(0, -22px, 0) scale3d(0.75, 0.75, 0.75)',opacity:1}).toString();/**
39
+ */
40
+ const labelFloating = css({
41
+ transform: 'translate3d(0, -22px, 0) scale3d(0.75, 0.75, 0.75)',
42
+ opacity: 1
43
+ }).toString();
44
+
45
+ /**
12
46
  * The basic styles for the label.
13
47
  * @type {string}
14
- */var label=css(_extends({position:'absolute',left:0,top:24,lineHeight:'19px',pointerEvents:'none',userSelect:'none',color:themeConfig.colors.shade12,transformOrigin:'left top 0px',willChange:'transform, color',overflow:'visible',transition:"transform ".concat(easing,", color ").concat(easing)},ellipsisLine)).toString();var labelStatic=css({opacity:1,lineHeight:'19px',pointerEvents:'none',userSelect:'none',color:themeConfig.colors.shade12}).toString();/**
48
+ */
49
+ const label = css({
50
+ position: 'absolute',
51
+ left: 0,
52
+ top: 24,
53
+ lineHeight: '19px',
54
+ pointerEvents: 'none',
55
+ userSelect: 'none',
56
+ color: themeConfig.colors.shade12,
57
+ transformOrigin: 'left top 0px',
58
+ willChange: 'transform, color',
59
+ overflow: 'visible',
60
+ transition: `transform ${easing}, color ${easing}`,
61
+ ...ellipsisLine
62
+ }).toString();
63
+ const labelStatic = css({
64
+ opacity: 1,
65
+ lineHeight: '19px',
66
+ pointerEvents: 'none',
67
+ userSelect: 'none',
68
+ color: themeConfig.colors.shade12
69
+ }).toString();
70
+
71
+ /**
15
72
  * Gets the style classes for the label.
16
73
  * @param {boolean} focused Whether the input field is focused.
17
74
  * @param {boolean} floating Whether the label is floating.
18
75
  * @param {boolean} error Whether the input field shows an error message.
19
76
  * @param {boolean} isStatic Whether the label is static.
20
77
  * @return {string} The style classes.
21
- */var labelStyles=function labelStyles(){var focused=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;var floating=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var error=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var isStatic=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;return classNames(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({},label,!isStatic),labelStatic,isStatic),labelFloating,floating),labelRegular,!focused),labelFocus,!error&&focused),labelError,error&&focused));};export default{labelStyles:labelStyles};
78
+ */
79
+ const labelStyles = (focused = false, floating = false, error = false, isStatic = false) => classNames({
80
+ [label]: !isStatic,
81
+ [labelStatic]: isStatic,
82
+ [labelFloating]: floating,
83
+ [labelRegular]: !focused,
84
+ [labelFocus]: !error && focused,
85
+ [labelError]: error && focused
86
+ });
87
+ export default {
88
+ labelStyles
89
+ };
@@ -1,8 +1,32 @@
1
- import React from'react';import PropTypes from'prop-types';import classNames from'classnames';import I18n from'@shopgate/pwa-common/components/I18n';import styles from"./style";/**
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import classNames from 'classnames';
4
+ import I18n from '@shopgate/pwa-common/components/I18n';
5
+ import styles from "./style";
6
+
7
+ /**
2
8
  * The form element placeholder component.
3
9
  * @param {string} placeholder The placeholder text.
4
10
  * @param {boolean} visible Sets the placeholder visibility.
5
11
  * @param {boolean} props['aria-hidden'] Accessibility attribute to mark the placeholder as hidden
6
12
  * @param {boolean} hasLeftElement Whether a left element is present
7
13
  * @return {JSX.Element}
8
- */var Placeholder=function Placeholder(_ref){var placeholder=_ref.placeholder,visible=_ref.visible,ariaHidden=_ref['aria-hidden'],hasLeftElement=_ref.hasLeftElement;return React.createElement("div",{className:classNames(styles.placeholderStyles(visible,hasLeftElement),'placeholder'),"aria-hidden":ariaHidden},React.createElement(I18n.Text,{string:placeholder}));};Placeholder.defaultProps={'aria-hidden':null,hasLeftElement:false,placeholder:'',visible:false};export default Placeholder;
14
+ */
15
+ const Placeholder = ({
16
+ placeholder,
17
+ visible,
18
+ 'aria-hidden': ariaHidden,
19
+ hasLeftElement
20
+ }) => /*#__PURE__*/React.createElement("div", {
21
+ className: classNames(styles.placeholderStyles(visible, hasLeftElement), 'placeholder'),
22
+ "aria-hidden": ariaHidden
23
+ }, /*#__PURE__*/React.createElement(I18n.Text, {
24
+ string: placeholder
25
+ }));
26
+ Placeholder.defaultProps = {
27
+ 'aria-hidden': null,
28
+ hasLeftElement: false,
29
+ placeholder: '',
30
+ visible: false
31
+ };
32
+ export default Placeholder;
@@ -1,14 +1,56 @@
1
- function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{css}from'glamor';import classNames from'classnames';import{themeConfig}from'@shopgate/pwa-common/helpers/config';/**
1
+ import { css } from 'glamor';
2
+ import classNames from 'classnames';
3
+ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
4
+
5
+ /**
2
6
  * The style object for a one line text element with an ellipsis on overflow.
3
- */var ellipsisLine={overflow:'hidden',width:'100%',whiteSpace:'nowrap',textOverflow:'ellipsis'};var easing='450ms cubic-bezier(0.23, 1, 0.32, 1)';/**
7
+ */
8
+ const ellipsisLine = {
9
+ overflow: 'hidden',
10
+ width: '100%',
11
+ whiteSpace: 'nowrap',
12
+ textOverflow: 'ellipsis'
13
+ };
14
+ const easing = '450ms cubic-bezier(0.23, 1, 0.32, 1)';
15
+
16
+ /**
4
17
  * The styles for the placeholder text.
5
- */var placeholder=css(_extends({position:'absolute',pointerEvents:'none',top:24,color:"var(--color-text-medium-emphasis, ".concat(themeConfig.colors.shade6,")"),willChange:'transform',transition:"opacity ".concat(easing)},ellipsisLine)).toString();/**
18
+ */
19
+ const placeholder = css({
20
+ position: 'absolute',
21
+ pointerEvents: 'none',
22
+ top: 24,
23
+ color: `var(--color-text-medium-emphasis, ${themeConfig.colors.shade6})`,
24
+ willChange: 'transform',
25
+ transition: `opacity ${easing}`,
26
+ ...ellipsisLine
27
+ }).toString();
28
+
29
+ /**
6
30
  * The styles for the invisible hint text.
7
- */var placeholderInactive=css({opacity:0}).toString();/**
31
+ */
32
+ const placeholderInactive = css({
33
+ opacity: 0
34
+ }).toString();
35
+
36
+ /**
8
37
  * Additional left spacing when a left element is present
9
- */var leftOffset=css({left:'var(--form-element-left-offset, 26px)',width:'calc(100% - var(--form-element-left-offset, 26px))'}).toString();/**
38
+ */
39
+ const leftOffset = css({
40
+ left: 'var(--form-element-left-offset, 26px)',
41
+ width: 'calc(100% - var(--form-element-left-offset, 26px))'
42
+ }).toString();
43
+
44
+ /**
10
45
  * Gets the style classes for the underline element.
11
46
  * @param {boolean} visible Whether the hint is visible.
12
47
  * @param {boolean} hasLeftElement - Whether a left element is present.
13
48
  * @return {string} The style classes.
14
- */var placeholderStyles=function placeholderStyles(){var visible=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;var hasLeftElement=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;return classNames(placeholder,_defineProperty(_defineProperty({},placeholderInactive,!visible),leftOffset,hasLeftElement));};export default{placeholderStyles:placeholderStyles};
49
+ */
50
+ const placeholderStyles = (visible = false, hasLeftElement = false) => classNames(placeholder, {
51
+ [placeholderInactive]: !visible,
52
+ [leftOffset]: hasLeftElement
53
+ });
54
+ export default {
55
+ placeholderStyles
56
+ };
@@ -1,5 +1,21 @@
1
- import React from'react';import PropTypes from'prop-types';import classNames from'classnames';import styles from"./style";/**
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import classNames from 'classnames';
4
+ import styles from "./style";
5
+
6
+ /**
2
7
  * Renders the label element.
3
8
  * @param {Object} props The component props.
4
9
  * @return {JSX}
5
- */var Underline=function Underline(props){return React.createElement("div",{className:classNames(styles.underlineWrapper,'underline')},React.createElement("div",{className:styles.underline,style:styles.underlineStyle(props.isFocused,props.hasErrorMessage)}));};Underline.defaultProps={isFocused:false,hasErrorMessage:false};export default Underline;
10
+ */
11
+ const Underline = props => /*#__PURE__*/React.createElement("div", {
12
+ className: classNames(styles.underlineWrapper, 'underline')
13
+ }, /*#__PURE__*/React.createElement("div", {
14
+ className: styles.underline,
15
+ style: styles.underlineStyle(props.isFocused, props.hasErrorMessage)
16
+ }));
17
+ Underline.defaultProps = {
18
+ isFocused: false,
19
+ hasErrorMessage: false
20
+ };
21
+ export default Underline;
@@ -1,13 +1,60 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{css}from'glamor';import color from'color';import{getCSSCustomProp}from'@shopgate/engage/styles';import{themeConfig}from'@shopgate/pwa-common/helpers/config';var colors=themeConfig.colors;var easing='450ms cubic-bezier(0.23, 1, 0.32, 1)';/**
1
+ import { css } from 'glamor';
2
+ import color from 'color';
3
+ import { getCSSCustomProp } from '@shopgate/engage/styles';
4
+ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
5
+ const {
6
+ colors
7
+ } = themeConfig;
8
+ const easing = '450ms cubic-bezier(0.23, 1, 0.32, 1)';
9
+
10
+ /**
2
11
  * The styles for the underline wrapper element.
3
- */var underlineWrapper=css({position:'relative',width:'100%',borderBottom:"1px solid ".concat(colors.shade12),marginTop:2,marginBottom:7}).toString();/**
12
+ */
13
+ const underlineWrapper = css({
14
+ position: 'relative',
15
+ width: '100%',
16
+ borderBottom: `1px solid ${colors.shade12}`,
17
+ marginTop: 2,
18
+ marginBottom: 7
19
+ }).toString();
20
+
21
+ /**
4
22
  * The styles for the underline element.
5
23
  * @param {boolean} focused Whether the input field is focused.
6
24
  * @param {boolean} error Whether the input field shows an error message.
7
25
  * @return {string} The style class.
8
- */var underline=css({position:'relative',width:'100%',top:1,borderBottomWidth:2,borderBottomStyle:'solid',willChange:'transform',transition:"transform ".concat(easing)}).toString();/**
26
+ */
27
+ const underline = css({
28
+ position: 'relative',
29
+ width: '100%',
30
+ top: 1,
31
+ borderBottomWidth: 2,
32
+ borderBottomStyle: 'solid',
33
+ willChange: 'transform',
34
+ transition: `transform ${easing}`
35
+ }).toString();
36
+
37
+ /**
9
38
  * Returns the underline style.
10
39
  * @param {boolean} focused Is focused set or not.
11
40
  * @param {boolean} hasError Has error set or not.
12
41
  * @return {Object} style
13
- */var underlineStyle=function underlineStyle(focused,hasError){var primaryColor=getCSSCustomProp('--color-primary')||colors.primary;var focusColor='--color-primary';if(color(primaryColor).luminosity()>=0.8){focusColor='--color-secondary';}return _extends({borderBottomColor:hasError?"var(--color-state-alert, ".concat(colors.error,")"):"var(".concat(focusColor,", ").concat(colors.focus,")")},!focused&&!hasError&&{transform:'scale3d(0,1,1)'});};export default{underline:underline,underlineWrapper:underlineWrapper,underlineStyle:underlineStyle};
42
+ */
43
+ const underlineStyle = (focused, hasError) => {
44
+ const primaryColor = getCSSCustomProp('--color-primary') || colors.primary;
45
+ let focusColor = '--color-primary';
46
+ if (color(primaryColor).luminosity() >= 0.8) {
47
+ focusColor = '--color-secondary';
48
+ }
49
+ return {
50
+ borderBottomColor: hasError ? `var(--color-state-alert, ${colors.error})` : `var(${focusColor}, ${colors.focus})`,
51
+ ...(!focused && !hasError && {
52
+ transform: 'scale3d(0,1,1)'
53
+ })
54
+ };
55
+ };
56
+ export default {
57
+ underline,
58
+ underlineWrapper,
59
+ underlineStyle
60
+ };
@@ -1,11 +1,96 @@
1
- function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{Component}from'react';import PropTypes from'prop-types';import classNames from'classnames';import Label from"./components/Label";import Underline from"./components/Underline";import ErrorText from"./components/ErrorText";import Placeholder from"./components/Placeholder";import style from"./style";/**
1
+ import React, { Component } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import classNames from 'classnames';
4
+ import Label from "./components/Label";
5
+ import Underline from "./components/Underline";
6
+ import ErrorText from "./components/ErrorText";
7
+ import Placeholder from "./components/Placeholder";
8
+ import style from "./style";
9
+
10
+ /**
2
11
  * A component that provides a styled form element in material design.
3
- */var FormElement=/*#__PURE__*/function(_Component){function FormElement(){_classCallCheck(this,FormElement);return _callSuper(this,FormElement,arguments);}_inherits(FormElement,_Component);return _createClass(FormElement,[{key:"isLabelFloating",get:/**
12
+ */
13
+ class FormElement extends Component {
14
+ /**
4
15
  * @returns {boolean} Whether the label is currently floating.
5
- */function get(){return!this.props.labelStatic&&(this.props.isFocused||this.props.hasValue);}/**
16
+ */
17
+ get isLabelFloating() {
18
+ return !this.props.labelStatic && (this.props.isFocused || this.props.hasValue);
19
+ }
20
+
21
+ /**
6
22
  * @returns {boolean} Whether the hint text is currently visible.
7
- */},{key:"isPlaceholderVisible",get:function get(){return!this.props.isFocused&&!this.props.hasValue;}/**
23
+ */
24
+ get isPlaceholderVisible() {
25
+ return !this.props.isFocused && !this.props.hasValue;
26
+ }
27
+
28
+ /**
8
29
  * @returns {boolean} Whether the hint text is currently visible.
9
- */},{key:"hasErrorMessage",get:function get(){return!!this.props.errorText;}/**
30
+ */
31
+ get hasErrorMessage() {
32
+ return !!this.props.errorText;
33
+ }
34
+
35
+ /**
10
36
  * @return {JSX.Element}
11
- */},{key:"render",value:function render(){var _this$props=this.props,isFocused=_this$props.isFocused,errorText=_this$props.errorText,translateErrorText=_this$props.translateErrorText,placeholder=_this$props.placeholder,hasLeftElement=_this$props.hasLeftElement,hasPlaceholder=_this$props.hasPlaceholder,htmlFor=_this$props.htmlFor,label=_this$props.label,className=_this$props.className,disabled=_this$props.disabled,labelStatic=_this$props.labelStatic,showErrorText=_this$props.showErrorText;return React.createElement("div",{className:classNames(style.formElement,className,'formElement','ui-shared__form-element',{disabled:disabled})},hasPlaceholder&&(placeholder||label)&&React.createElement(Placeholder,{visible:this.isPlaceholderVisible,placeholder:placeholder||label,hasLeftElement:hasLeftElement,"aria-hidden":true}),label&&React.createElement(Label,{htmlFor:htmlFor,label:label,labelStatic:labelStatic,isFocused:isFocused,isFloating:this.isLabelFloating,hasErrorMessage:this.hasErrorMessage}),this.props.children,this.props.hasUnderline&&React.createElement(Underline,{isFocused:isFocused,hasErrorMessage:this.hasErrorMessage}),errorText&&showErrorText&&React.createElement(ErrorText,{errorText:errorText,translate:translateErrorText,elementName:htmlFor}));}}]);}(Component);_defineProperty(FormElement,"defaultProps",{children:null,className:'',errorText:'',placeholder:'',htmlFor:'',label:'',labelStatic:false,isFocused:false,hasLeftElement:false,hasValue:false,hasPlaceholder:true,hasUnderline:true,translateErrorText:true,disabled:false,showErrorText:true});export default FormElement;
37
+ */
38
+ render() {
39
+ const {
40
+ isFocused,
41
+ errorText,
42
+ translateErrorText,
43
+ placeholder,
44
+ hasLeftElement,
45
+ hasPlaceholder,
46
+ htmlFor,
47
+ label,
48
+ className,
49
+ disabled,
50
+ labelStatic,
51
+ showErrorText
52
+ } = this.props;
53
+ return /*#__PURE__*/React.createElement("div", {
54
+ className: classNames(style.formElement, className, 'formElement', 'ui-shared__form-element', {
55
+ disabled
56
+ })
57
+ }, hasPlaceholder && (placeholder || label) && /*#__PURE__*/React.createElement(Placeholder, {
58
+ visible: this.isPlaceholderVisible,
59
+ placeholder: placeholder || label,
60
+ hasLeftElement: hasLeftElement,
61
+ "aria-hidden": true
62
+ }), label && /*#__PURE__*/React.createElement(Label, {
63
+ htmlFor: htmlFor,
64
+ label: label,
65
+ labelStatic: labelStatic,
66
+ isFocused: isFocused,
67
+ isFloating: this.isLabelFloating,
68
+ hasErrorMessage: this.hasErrorMessage
69
+ }), this.props.children, this.props.hasUnderline && /*#__PURE__*/React.createElement(Underline, {
70
+ isFocused: isFocused,
71
+ hasErrorMessage: this.hasErrorMessage
72
+ }), errorText && showErrorText && /*#__PURE__*/React.createElement(ErrorText, {
73
+ errorText: errorText,
74
+ translate: translateErrorText,
75
+ elementName: htmlFor
76
+ }));
77
+ }
78
+ }
79
+ FormElement.defaultProps = {
80
+ children: null,
81
+ className: '',
82
+ errorText: '',
83
+ placeholder: '',
84
+ htmlFor: '',
85
+ label: '',
86
+ labelStatic: false,
87
+ isFocused: false,
88
+ hasLeftElement: false,
89
+ hasValue: false,
90
+ hasPlaceholder: true,
91
+ hasUnderline: true,
92
+ translateErrorText: true,
93
+ disabled: false,
94
+ showErrorText: true
95
+ };
96
+ export default FormElement;
@@ -1,2 +1,67 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import React from'react';import{mount}from'enzyme';import FormElement from"./index";var inputProps={htmlFor:'test-input'};describe('<FormElement />',function(){// Simple tests for snapshots
2
- var tests={'should render a form element with no children':{props:{}},'should render a form element with 1 child':{props:{children:[React.createElement("input",{key:"test-key"})]}},'should render a focused form element':{props:{isFocused:true}},'should show the label':{props:{label:'The label'},find:'Label',equal:'The label'},'should show the error message':{props:{errorText:'The error text'},find:'ErrorText',equal:'The error text'},'should show the placeholder text':{props:{placeholder:'The placeholder'},find:'Placeholder',equal:'The placeholder'}};Object.keys(tests).forEach(function(test){it(test,function(){var testFixtures=tests[test];var wrapper=mount(React.createElement(FormElement,_extends({},inputProps,{},testFixtures.props)));expect(wrapper).toMatchSnapshot();if(testFixtures.find){expect(wrapper.find(testFixtures.find).find('Translate').props().string).toEqual(testFixtures.equal);}});});it('Should hide placeholder with hasValue',function(){var wrapper=mount(React.createElement(FormElement,_extends({label:"testlabel"},inputProps,{hasValue:true})));expect(wrapper).toMatchSnapshot();expect(wrapper.find('Placeholder').props().visible).toEqual(false);});});
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React from 'react';
3
+ import { mount } from 'enzyme';
4
+ import FormElement from "./index";
5
+ const inputProps = {
6
+ htmlFor: 'test-input'
7
+ };
8
+ describe('<FormElement />', () => {
9
+ // Simple tests for snapshots
10
+ const tests = {
11
+ 'should render a form element with no children': {
12
+ props: {}
13
+ },
14
+ 'should render a form element with 1 child': {
15
+ props: {
16
+ children: [/*#__PURE__*/React.createElement("input", {
17
+ key: "test-key"
18
+ })]
19
+ }
20
+ },
21
+ 'should render a focused form element': {
22
+ props: {
23
+ isFocused: true
24
+ }
25
+ },
26
+ 'should show the label': {
27
+ props: {
28
+ label: 'The label'
29
+ },
30
+ find: 'Label',
31
+ equal: 'The label'
32
+ },
33
+ 'should show the error message': {
34
+ props: {
35
+ errorText: 'The error text'
36
+ },
37
+ find: 'ErrorText',
38
+ equal: 'The error text'
39
+ },
40
+ 'should show the placeholder text': {
41
+ props: {
42
+ placeholder: 'The placeholder'
43
+ },
44
+ find: 'Placeholder',
45
+ equal: 'The placeholder'
46
+ }
47
+ };
48
+ Object.keys(tests).forEach(test => {
49
+ it(test, () => {
50
+ const testFixtures = tests[test];
51
+ const wrapper = mount(/*#__PURE__*/React.createElement(FormElement, _extends({}, inputProps, testFixtures.props)));
52
+ expect(wrapper).toMatchSnapshot();
53
+ if (testFixtures.find) {
54
+ expect(wrapper.find(testFixtures.find).find('Translate').props().string).toEqual(testFixtures.equal);
55
+ }
56
+ });
57
+ });
58
+ it('Should hide placeholder with hasValue', () => {
59
+ const wrapper = mount(/*#__PURE__*/React.createElement(FormElement, _extends({
60
+ label: "testlabel"
61
+ }, inputProps, {
62
+ hasValue: true
63
+ })));
64
+ expect(wrapper).toMatchSnapshot();
65
+ expect(wrapper.find('Placeholder').props().visible).toEqual(false);
66
+ });
67
+ });
@@ -1,3 +1,14 @@
1
- import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';/**
1
+ import { css } from 'glamor';
2
+ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
3
+
4
+ /**
2
5
  * The styles for the container element.
3
- */var formElement=css({position:'relative',paddingBottom:themeConfig.variables.gap.big,width:'100%'}).toString();export default{formElement:formElement};
6
+ */
7
+ const formElement = css({
8
+ position: 'relative',
9
+ paddingBottom: themeConfig.variables.gap.big,
10
+ width: '100%'
11
+ }).toString();
12
+ export default {
13
+ formElement
14
+ };
package/Glow/index.js CHANGED
@@ -1,13 +1,96 @@
1
- var _excluded=["children","styles","forwardedRef","className","color"];function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{Component}from'react';import PropTypes from'prop-types';import classNames from'classnames';import{withForwardedRef}from'@shopgate/engage/core';import{themeConfig}from'@shopgate/pwa-common/helpers/config';import styles from"./style";/**
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React, { Component } from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import classNames from 'classnames';
5
+ import { withForwardedRef } from '@shopgate/engage/core';
6
+ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
7
+ import styles from "./style";
8
+
9
+ /**
2
10
  * Renders a glowing component that is visible when the user interacts with the element.
3
- */var Glow=/*#__PURE__*/function(_Component){/**
11
+ */
12
+ class Glow extends Component {
13
+ /**
4
14
  * The component constructor.
5
15
  * @param {Object} props The component props.
6
- */function Glow(props){var _this2;_classCallCheck(this,Glow);_this2=_callSuper(this,Glow,[props]);_defineProperty(_this2,"handleTouchTap",function(){if(_this2.props.disabled){return;}_this2.setState({hover:true});_this2.timeout=setTimeout(function(){_this2.setState({hover:false});},250);});_this2.timeout=null;_this2.state={hover:false};return _this2;}/**
16
+ */
17
+ constructor(props) {
18
+ super(props);
19
+ this.handleTouchTap = () => {
20
+ if (this.props.disabled) {
21
+ return;
22
+ }
23
+ this.setState({
24
+ hover: true
25
+ });
26
+ this.timeout = setTimeout(() => {
27
+ this.setState({
28
+ hover: false
29
+ });
30
+ }, 250);
31
+ };
32
+ this.timeout = null;
33
+ this.state = {
34
+ hover: false
35
+ };
36
+ }
37
+
38
+ /**
7
39
  * Clears any previously set timeout.
8
- */_inherits(Glow,_Component);return _createClass(Glow,[{key:"componentWillUnmount",value:function componentWillUnmount(){clearTimeout(this.timeout);}},{key:"render",value:/**
40
+ */
41
+ componentWillUnmount() {
42
+ clearTimeout(this.timeout);
43
+ }
44
+ /**
9
45
  * Renders the component.
10
46
  * @returns {JSX.Element}
11
- */function render(){var _this$props=this.props,children=_this$props.children,propStyles=_this$props.styles,forwardedRef=_this$props.forwardedRef,className=_this$props.className,color=_this$props.color,rest=_objectWithoutProperties(_this$props,_excluded);var innerInlineStyles;if(this.state.hover){innerInlineStyles=_extends({},propStyles.glow,{},propStyles.hover,{background:color});}else{innerInlineStyles=_extends({},propStyles.glow);}/* eslint-disable jsx-a11y/no-static-element-interactions,
12
- jsx-a11y/click-events-have-key-events */return React.createElement("div",_extends({},rest,{className:classNames(styles.container,className,'ui-shared__glow'),onClick:this.handleTouchTap,style:propStyles.container,ref:forwardedRef}),React.createElement("div",{className:styles.glow,style:innerInlineStyles}),children);/* eslint-enable jsx-a11y/no-static-element-interactions,
13
- jsx-a11y/click-events-have-key-events */}}]);}(Component);_defineProperty(Glow,"defaultProps",{color:themeConfig.colors.shade8,className:null,forwardedRef:null,disabled:false,styles:{container:null,glow:null,hover:null}});export default withForwardedRef(Glow);
47
+ */
48
+ render() {
49
+ const {
50
+ children,
51
+ styles: propStyles,
52
+ forwardedRef,
53
+ className,
54
+ color,
55
+ ...rest
56
+ } = this.props;
57
+ let innerInlineStyles;
58
+ if (this.state.hover) {
59
+ innerInlineStyles = {
60
+ ...propStyles.glow,
61
+ ...propStyles.hover,
62
+ background: color
63
+ };
64
+ } else {
65
+ innerInlineStyles = {
66
+ ...propStyles.glow
67
+ };
68
+ }
69
+
70
+ /* eslint-disable jsx-a11y/no-static-element-interactions,
71
+ jsx-a11y/click-events-have-key-events */
72
+ return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
73
+ className: classNames(styles.container, className, 'ui-shared__glow'),
74
+ onClick: this.handleTouchTap,
75
+ style: propStyles.container,
76
+ ref: forwardedRef
77
+ }), /*#__PURE__*/React.createElement("div", {
78
+ className: styles.glow,
79
+ style: innerInlineStyles
80
+ }), children);
81
+ /* eslint-enable jsx-a11y/no-static-element-interactions,
82
+ jsx-a11y/click-events-have-key-events */
83
+ }
84
+ }
85
+ Glow.defaultProps = {
86
+ color: themeConfig.colors.shade8,
87
+ className: null,
88
+ forwardedRef: null,
89
+ disabled: false,
90
+ styles: {
91
+ container: null,
92
+ glow: null,
93
+ hover: null
94
+ }
95
+ };
96
+ export default withForwardedRef(Glow);
package/Glow/spec.js CHANGED
@@ -1 +1,9 @@
1
- import React from'react';import{mount}from'enzyme';import Glow from"./index";describe('<Glow />',function(){it('should render with a smile',function(){var wrapper=mount(React.createElement(Glow,null,React.createElement("p",null,"Glowing!")));expect(wrapper).toMatchSnapshot();});});
1
+ import React from 'react';
2
+ import { mount } from 'enzyme';
3
+ import Glow from "./index";
4
+ describe('<Glow />', () => {
5
+ it('should render with a smile', () => {
6
+ const wrapper = mount(/*#__PURE__*/React.createElement(Glow, null, /*#__PURE__*/React.createElement("p", null, "Glowing!")));
7
+ expect(wrapper).toMatchSnapshot();
8
+ });
9
+ });
package/Glow/style.js CHANGED
@@ -1 +1,18 @@
1
- import{css}from'glamor';var container=css({position:'relative'}).toString();var glow=css({position:'absolute',left:0,top:0,width:'100%',height:'100%',background:'transparent',transition:'background 100ms cubic-bezier(0.25, 0.1, 0.25, 1)',zIndex:0}).toString();export default{container:container,glow:glow};
1
+ import { css } from 'glamor';
2
+ const container = css({
3
+ position: 'relative'
4
+ }).toString();
5
+ const glow = css({
6
+ position: 'absolute',
7
+ left: 0,
8
+ top: 0,
9
+ width: '100%',
10
+ height: '100%',
11
+ background: 'transparent',
12
+ transition: 'background 100ms cubic-bezier(0.25, 0.1, 0.25, 1)',
13
+ zIndex: 0
14
+ }).toString();
15
+ export default {
16
+ container,
17
+ glow
18
+ };