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

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 +59 -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 +51 -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 +300 -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 +41 -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,6 +1,34 @@
1
- import{css}from'glamor';/**
1
+ import { css } from 'glamor';
2
+
3
+ /**
2
4
  * The styles for the input field.
3
- */var input=css({position:'relative',padding:0,width:'100%',marginTop:24,outline:0,fontSize:16,lineHeight:'19px'}).toString();/**
5
+ */
6
+ const input = css({
7
+ position: 'relative',
8
+ padding: 0,
9
+ width: '100%',
10
+ marginTop: 24,
11
+ outline: 0,
12
+ fontSize: 16,
13
+ lineHeight: '19px'
14
+ }).toString();
15
+
16
+ /**
4
17
  * The styles for the multiLine.
5
- */var multiLine=css({position:'relative',marginTop:24,marginBottom:3,padding:0,width:'100%',outline:0,height:19,minHeight:19,lineHeight:'19px',verticalAlign:'top'// Important to avoid bottom whitespace.
6
- }).toString();export default{input:input,multiLine:multiLine};
18
+ */
19
+ const multiLine = css({
20
+ position: 'relative',
21
+ marginTop: 24,
22
+ marginBottom: 3,
23
+ padding: 0,
24
+ width: '100%',
25
+ outline: 0,
26
+ height: 19,
27
+ minHeight: 19,
28
+ lineHeight: '19px',
29
+ verticalAlign: 'top' // Important to avoid bottom whitespace.
30
+ }).toString();
31
+ export default {
32
+ input,
33
+ multiLine
34
+ };
@@ -1,6 +1,25 @@
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 hint component.
3
9
  * @param {string} hintText The hint text.
4
10
  * @param {boolean} visible Sets the hint visibility.
5
11
  * @return {JSX}
6
- */var Hint=function Hint(_ref){var hintText=_ref.hintText,visible=_ref.visible;return React.createElement("div",{className:classNames(styles.hintStyles(visible),'hint')},React.createElement(I18n.Text,{string:hintText}));};Hint.defaultProps={hintText:'',visible:false};export default Hint;
12
+ */
13
+ const Hint = ({
14
+ hintText,
15
+ visible
16
+ }) => /*#__PURE__*/React.createElement("div", {
17
+ className: classNames(styles.hintStyles(visible), 'hint')
18
+ }, /*#__PURE__*/React.createElement(I18n.Text, {
19
+ string: hintText
20
+ }));
21
+ Hint.defaultProps = {
22
+ hintText: '',
23
+ visible: false
24
+ };
25
+ export default Hint;
@@ -1,11 +1,46 @@
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 hint text.
5
- */var hint=css(_extends({position:'absolute',pointerEvents:'none',bottom:12,color:themeConfig.colors.shade4,willChange:'transform',transition:"opacity ".concat(easing)},ellipsisLine)).toString();/**
18
+ */
19
+ const hint = css({
20
+ position: 'absolute',
21
+ pointerEvents: 'none',
22
+ bottom: 12,
23
+ color: themeConfig.colors.shade4,
24
+ willChange: 'transform',
25
+ transition: `opacity ${easing}`,
26
+ ...ellipsisLine
27
+ }).toString();
28
+
29
+ /**
6
30
  * The styles for the invisible hint text.
7
- */var hintInactive=css({opacity:0}).toString();/**
31
+ */
32
+ const hintInactive = css({
33
+ opacity: 0
34
+ }).toString();
35
+
36
+ /**
8
37
  * Gets the style classes for the underline element.
9
38
  * @param {boolean} visible Whether the hint is visible.
10
39
  * @return {string} The style classes.
11
- */var hintStyles=function hintStyles(){var visible=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;return classNames(hint,_defineProperty({},hintInactive,!visible));};export default{hintStyles:hintStyles};
40
+ */
41
+ const hintStyles = (visible = false) => classNames(hint, {
42
+ [hintInactive]: !visible
43
+ });
44
+ export default {
45
+ hintStyles
46
+ };
@@ -1,6 +1,35 @@
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
  * Renders the label element.
3
9
  * @param {Object} props The component props.
4
10
  * @return {JSX}
5
- */var Label=function Label(props){var labelStyles=styles.labelStyles(props.isFocused,props.isFloating,props.hasErrorMessage);return(// eslint-disable-next-line jsx-a11y/label-has-associated-control
6
- React.createElement("label",{htmlFor:props.name,"aria-hidden":true,className:classNames(labelStyles,'label',{floating:props.isFloating})},React.createElement(I18n.Text,{string:props.label})));};Label.defaultProps={name:'',label:'',isFocused:false,isFloating:false,hasErrorMessage:false};export default Label;
11
+ */
12
+ const Label = props => {
13
+ const labelStyles = styles.labelStyles(props.isFocused, props.isFloating, props.hasErrorMessage);
14
+ return (
15
+ /*#__PURE__*/
16
+ // eslint-disable-next-line jsx-a11y/label-has-associated-control
17
+ React.createElement("label", {
18
+ htmlFor: props.name,
19
+ "aria-hidden": true,
20
+ className: classNames(labelStyles, 'label', {
21
+ floating: props.isFloating
22
+ })
23
+ }, /*#__PURE__*/React.createElement(I18n.Text, {
24
+ string: props.label
25
+ }))
26
+ );
27
+ };
28
+ Label.defaultProps = {
29
+ name: '',
30
+ label: '',
31
+ isFocused: false,
32
+ isFloating: false,
33
+ hasErrorMessage: false
34
+ };
35
+ export default Label;
@@ -1,20 +1,80 @@
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 colors=themeConfig.colors;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 {
15
+ colors
16
+ } = themeConfig;
17
+ const easing = '450ms cubic-bezier(0.23, 1, 0.32, 1)';
18
+
19
+ /**
4
20
  * The styles for the error label.
5
- */var labelError=css({color:"var(--color-state-alert, ".concat(colors.error,")")}).toString();/**
21
+ */
22
+ const labelError = css({
23
+ color: `var(--color-state-alert, ${colors.error})`
24
+ }).toString();
25
+
26
+ /**
6
27
  * The styles for the regular label.
7
- */var labelRegular=css({color:colors.shade4}).toString();/**
28
+ */
29
+ const labelRegular = css({
30
+ color: colors.shade4
31
+ }).toString();
32
+
33
+ /**
8
34
  * The styles for the focused label.
9
- */var labelFocus=css({color:colors.focus}).toString();/**
35
+ */
36
+ const labelFocus = css({
37
+ color: colors.focus
38
+ }).toString();
39
+
40
+ /**
10
41
  * The styles for the floating label.
11
- */var labelFloating=css({transform:'translate3d(0, -22px, 0) scale3d(0.75, 0.75, 0.75)'}).toString();/**
42
+ */
43
+ const labelFloating = css({
44
+ transform: 'translate3d(0, -22px, 0) scale3d(0.75, 0.75, 0.75)'
45
+ }).toString();
46
+
47
+ /**
12
48
  * The basic styles for the label.
13
49
  * @type {string}
14
- */var label=css(_extends({position:'absolute',left:0,top:24,lineHeight:'19px',pointerEvents:'none',userSelect:'none',color:"var(--color-text-medium-emphasis, ".concat(colors.shade6,")"),transformOrigin:'left top 0px',willChange:'transform, color',transition:"transform ".concat(easing,", color ").concat(easing)},ellipsisLine)).toString();/**
50
+ */
51
+ const label = css({
52
+ position: 'absolute',
53
+ left: 0,
54
+ top: 24,
55
+ lineHeight: '19px',
56
+ pointerEvents: 'none',
57
+ userSelect: 'none',
58
+ color: `var(--color-text-medium-emphasis, ${colors.shade6})`,
59
+ transformOrigin: 'left top 0px',
60
+ willChange: 'transform, color',
61
+ transition: `transform ${easing}, color ${easing}`,
62
+ ...ellipsisLine
63
+ }).toString();
64
+
65
+ /**
15
66
  * Gets the style classes for the label.
16
67
  * @param {boolean} focused Whether the input field is focused.
17
68
  * @param {boolean} floating Whether the label is floating.
18
69
  * @param {boolean} error Whether the input field shows an error message.
19
70
  * @return {string} The style classes.
20
- */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;return classNames(label,_defineProperty(_defineProperty(_defineProperty(_defineProperty({},labelFloating,floating),labelRegular,!focused),labelFocus,!error&&focused),labelError,error&&focused));};export default{labelStyles:labelStyles};
71
+ */
72
+ const labelStyles = (focused = false, floating = false, error = false) => classNames(label, {
73
+ [labelFloating]: floating,
74
+ [labelRegular]: !focused,
75
+ [labelFocus]: !error && focused,
76
+ [labelError]: error && focused
77
+ });
78
+ export default {
79
+ labelStyles
80
+ };
@@ -1,5 +1,22 @@
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'),"aria-hidden":true},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
+ "aria-hidden": true
14
+ }, /*#__PURE__*/React.createElement("div", {
15
+ className: styles.underline,
16
+ style: styles.underlineStyle(props.isFocused, props.hasErrorMessage)
17
+ }));
18
+ Underline.defaultProps = {
19
+ isFocused: false,
20
+ hasErrorMessage: false
21
+ };
22
+ 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,36 +1,198 @@
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 Hint from"./components/Hint";import styles from"./style";import FormElement from"./components/FormElement/index";/**
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 Hint from "./components/Hint";
8
+ import styles from "./style";
9
+ import FormElement from "./components/FormElement/index";
10
+
11
+ /**
2
12
  * A component that provides a styled text field for user input in material design.
3
- */var TextField=/*#__PURE__*/function(_Component){/**
13
+ */
14
+ class TextField extends Component {
15
+ /**
4
16
  * Creates a new text field component.
5
17
  * @param {Object} props The component properties.
6
- */function TextField(props){var _this2;_classCallCheck(this,TextField);_this2=_callSuper(this,TextField,[props]);/**
7
- * Internal focus event handler.
8
- * @param {boolean} isFocused Whether the input component is focused.
9
- */_defineProperty(_this2,"handleFocusChange",function(isFocused){_this2.setState({isFocused:isFocused});_this2.props.onFocusChange(isFocused);});/**
10
- * Updates the state if the input value has been changed.
11
- * @param {string} value The entered text.
12
- * @param {Object} event The original event object.
13
- */_defineProperty(_this2,"handleChange",function(value,event){_this2.props.onChange(value,event);});/**
14
- * Updates the validation error text if required.
15
- * @param {string} value The entered text.
16
- * @param {boolean} isInitial Whether this is the initial value of the input field.
17
- * @return {boolean} Whether the validation was successful.
18
- */_defineProperty(_this2,"handleValidate",function(value,isInitial){var validationError=_this2.props.onValidate(value);if(validationError!==true&&validationError){/**
19
- * An error message was returned by the validation callback. Update the state.
20
- * Because the validation is performed when the component is constructed, we need to make
21
- * sure we're not calling setState() in this situation.
22
- */if(!isInitial){_this2.setState({validationError:validationError});}else{_this2.state.validationError=validationError;}}else if(_this2.state.validationError){// There was no error, clear the state variable.
23
- _this2.setState({validationError:null});}// Forward the boolean result to the input field.
24
- return validationError===true;});_this2.state={isFocused:false,validationError:null};return _this2;}/**
18
+ */
19
+ constructor(props) {
20
+ super(props);
21
+ /**
22
+ * Internal focus event handler.
23
+ * @param {boolean} isFocused Whether the input component is focused.
24
+ */
25
+ this.handleFocusChange = isFocused => {
26
+ this.setState({
27
+ isFocused
28
+ });
29
+ this.props.onFocusChange(isFocused);
30
+ };
31
+ /**
32
+ * Updates the state if the input value has been changed.
33
+ * @param {string} value The entered text.
34
+ * @param {Object} event The original event object.
35
+ */
36
+ this.handleChange = (value, event) => {
37
+ this.props.onChange(value, event);
38
+ };
39
+ /**
40
+ * Updates the validation error text if required.
41
+ * @param {string} value The entered text.
42
+ * @param {boolean} isInitial Whether this is the initial value of the input field.
43
+ * @return {boolean} Whether the validation was successful.
44
+ */
45
+ this.handleValidate = (value, isInitial) => {
46
+ const validationError = this.props.onValidate(value);
47
+ if (validationError !== true && validationError) {
48
+ /**
49
+ * An error message was returned by the validation callback. Update the state.
50
+ * Because the validation is performed when the component is constructed, we need to make
51
+ * sure we're not calling setState() in this situation.
52
+ */
53
+ if (!isInitial) {
54
+ this.setState({
55
+ validationError
56
+ });
57
+ } else {
58
+ this.state.validationError = validationError;
59
+ }
60
+ } else if (this.state.validationError) {
61
+ // There was no error, clear the state variable.
62
+ this.setState({
63
+ validationError: null
64
+ });
65
+ }
66
+
67
+ // Forward the boolean result to the input field.
68
+ return validationError === true;
69
+ };
70
+ this.state = {
71
+ isFocused: false,
72
+ validationError: null
73
+ };
74
+ }
75
+
76
+ /**
25
77
  * @returns {boolean} Whether the text field is currently focused.
26
- */_inherits(TextField,_Component);return _createClass(TextField,[{key:"isFocused",get:function get(){return this.state.isFocused;}/**
78
+ */
79
+ get isFocused() {
80
+ return this.state.isFocused;
81
+ }
82
+
83
+ /**
27
84
  * @returns {boolean} Whether the label is currently floating.
28
- */},{key:"isLabelFloating",get:function get(){// On Firefox empty date inputs always show a placeholder with date pattern
29
- if(navigator.userAgent.includes('Firefox')&&this.props.type==='date'){return true;}return this.isFocused||!!this.props.value;}/**
85
+ */
86
+ get isLabelFloating() {
87
+ // On Firefox empty date inputs always show a placeholder with date pattern
88
+ if (navigator.userAgent.includes('Firefox') && this.props.type === 'date') {
89
+ return true;
90
+ }
91
+ return this.isFocused || !!this.props.value;
92
+ }
93
+
94
+ /**
30
95
  * @returns {boolean} Whether the hint text is currently visible.
31
- */},{key:"isHintVisible",get:function get(){return this.isFocused&&!this.props.value;}/**
96
+ */
97
+ get isHintVisible() {
98
+ return this.isFocused && !this.props.value;
99
+ }
100
+
101
+ /**
32
102
  * @return {boolean} Whether the error message is set.
33
- */},{key:"hasErrorMessage",get:function get(){return!!(this.state.validationError||this.props.errorText);}},{key:"render",value:/**
103
+ */
104
+ get hasErrorMessage() {
105
+ return !!(this.state.validationError || this.props.errorText);
106
+ }
107
+ /**
34
108
  * Renders the text field.
35
109
  * @return {JSX.Element}
36
- */function render(){var styleType=this.props.multiLine?'multiLine':'input';var style=styles.container[styleType];var _this$props=this.props,multiLine=_this$props.multiLine,className=_this$props.className,disabled=_this$props.disabled,hintText=_this$props.hintText,name=_this$props.name,label=_this$props.label,setRef=_this$props.setRef,onSanitize=_this$props.onSanitize,password=_this$props.password,type=_this$props.type,value=_this$props.value,isControlled=_this$props.isControlled,inputComponent=_this$props.inputComponent,showErrorText=_this$props.showErrorText,errorText=_this$props.errorText,translateErrorText=_this$props.translateErrorText,required=_this$props.required;return React.createElement("div",{className:classNames(style,className,'textField','ui-shared__text-field',{disabled:disabled})},React.createElement(Hint,{visible:this.isHintVisible,hintText:hintText}),React.createElement(Label,{name:name,label:label,isFocused:this.isFocused,isFloating:this.isLabelFloating,hasErrorMessage:this.hasErrorMessage}),React.createElement(FormElement,{id:name,multiLine:multiLine,name:name,setRef:setRef,onFocusChange:this.handleFocusChange,onChange:this.handleChange,onSanitize:onSanitize,onValidate:this.handleValidate,password:password,type:type,value:value,isControlled:isControlled,inputComponent:inputComponent,disabled:disabled,required:required,attributes:{'aria-invalid':!!errorText,'aria-describedby':this.hasErrorMessage?"ariaError-".concat(name):null}}),React.createElement(Underline,{isFocused:this.isFocused,hasErrorMessage:this.hasErrorMessage}),showErrorText&&React.createElement(ErrorText,{validationError:this.state.validationError,errorText:errorText,translate:translateErrorText,elementName:name}));}}]);}(Component);_defineProperty(TextField,"defaultProps",{className:'',errorText:'',showErrorText:true,setRef:function setRef(){},hintText:'',isControlled:false,label:'',multiLine:false,onChange:function onChange(){},onFocusChange:function onFocusChange(){},onSanitize:function onSanitize(value){return value;},onValidate:function onValidate(){return true;},required:false,password:false,translateErrorText:true,type:'text',value:'',inputComponent:'input',disabled:false});export default TextField;
110
+ */
111
+ render() {
112
+ const styleType = this.props.multiLine ? 'multiLine' : 'input';
113
+ const style = styles.container[styleType];
114
+ const {
115
+ multiLine,
116
+ className,
117
+ disabled,
118
+ hintText,
119
+ name,
120
+ label,
121
+ setRef,
122
+ onSanitize,
123
+ password,
124
+ type,
125
+ value,
126
+ isControlled,
127
+ inputComponent,
128
+ showErrorText,
129
+ errorText,
130
+ translateErrorText,
131
+ required
132
+ } = this.props;
133
+ return /*#__PURE__*/React.createElement("div", {
134
+ className: classNames(style, className, 'textField', 'ui-shared__text-field', {
135
+ disabled
136
+ })
137
+ }, /*#__PURE__*/React.createElement(Hint, {
138
+ visible: this.isHintVisible,
139
+ hintText: hintText
140
+ }), /*#__PURE__*/React.createElement(Label, {
141
+ name: name,
142
+ label: label,
143
+ isFocused: this.isFocused,
144
+ isFloating: this.isLabelFloating,
145
+ hasErrorMessage: this.hasErrorMessage
146
+ }), /*#__PURE__*/React.createElement(FormElement, {
147
+ id: name,
148
+ multiLine: multiLine,
149
+ name: name,
150
+ setRef: setRef,
151
+ onFocusChange: this.handleFocusChange,
152
+ onChange: this.handleChange,
153
+ onSanitize: onSanitize,
154
+ onValidate: this.handleValidate,
155
+ password: password,
156
+ type: type,
157
+ value: value,
158
+ isControlled: isControlled,
159
+ inputComponent: inputComponent,
160
+ disabled: disabled,
161
+ required: required,
162
+ attributes: {
163
+ 'aria-invalid': !!errorText,
164
+ 'aria-describedby': this.hasErrorMessage ? `ariaError-${name}` : null
165
+ }
166
+ }), /*#__PURE__*/React.createElement(Underline, {
167
+ isFocused: this.isFocused,
168
+ hasErrorMessage: this.hasErrorMessage
169
+ }), showErrorText && /*#__PURE__*/React.createElement(ErrorText, {
170
+ validationError: this.state.validationError,
171
+ errorText: errorText,
172
+ translate: translateErrorText,
173
+ elementName: name
174
+ }));
175
+ }
176
+ }
177
+ TextField.defaultProps = {
178
+ className: '',
179
+ errorText: '',
180
+ showErrorText: true,
181
+ setRef: () => {},
182
+ hintText: '',
183
+ isControlled: false,
184
+ label: '',
185
+ multiLine: false,
186
+ onChange: () => {},
187
+ onFocusChange: () => {},
188
+ onSanitize: value => value,
189
+ onValidate: () => true,
190
+ required: false,
191
+ password: false,
192
+ translateErrorText: true,
193
+ type: 'text',
194
+ value: '',
195
+ inputComponent: 'input',
196
+ disabled: false
197
+ };
198
+ export default TextField;