@shopgate/pwa-ui-shared 7.30.0-alpha.6 → 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,5 +1,79 @@
1
- function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import React,{useState,useCallback,Fragment}from'react';import PropTypes from'prop-types';import pick from'lodash/pick';import{i18n}from'@shopgate/engage/core';import Chevron from"../../icons/ChevronIcon";import InfoField from"../InfoField";import ContextMenu from"../../ContextMenu";import styles from"./style";/**
1
+ import React, { useState, useCallback, Fragment } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import pick from 'lodash/pick';
4
+ import { i18n } from '@shopgate/engage/core';
5
+ import Chevron from "../../icons/ChevronIcon";
6
+ import InfoField from "../InfoField";
7
+ import ContextMenu from "../../ContextMenu";
8
+ import styles from "./style";
9
+
10
+ /**
2
11
  * @param {Object} props .
3
12
  * @returns {JSX}
4
- */var SelectContextChoices=function SelectContextChoices(_ref){var options=_ref.options,onChange=_ref.onChange,value=_ref.value,placeholder=_ref.placeholder,className=_ref.className,label=_ref.label,errorText=_ref.errorText,showErrorText=_ref.showErrorText;var _useState=useState(false),_useState2=_slicedToArray(_useState,2),opened=_useState2[0],setOpened=_useState2[1];var onMenuChange=useCallback(function(_ref2){var active=_ref2.active;setOpened(active);},[]);var onItemClick=useCallback(function(key){if(key===''){onChange([]);}else if(value.includes(key)){// Eliminate value
5
- onChange(value.filter(function(v){return v!==key;}));}else{onChange([].concat(value,[key]));}},[onChange,value]);var hasValue=!!value&&!!value.length;var values=hasValue?Object.values(pick(options,value)):[];return React.createElement(Fragment,null,React.createElement(InfoField,{className:className,label:label,errorText:errorText,showErrorText:showErrorText,hasValue:true,rightElement:React.createElement(Chevron,{className:styles.chevron})},React.createElement("div",{role:"button",onClick:function onClick(){return setOpened(true);},"aria-hidden":true,tabIndex:"0",className:styles.toggle},!hasValue&&(placeholder||i18n.text('common.please_choose')),hasValue&&values.join(', ')),React.createElement(ContextMenu,{isOpened:opened,onStateChange:onMenuChange,showToggle:false,scroll:true},Object.keys(options).map(function(key){return React.createElement(ContextMenu.Item,{key:key,autoClose:false,onClick:function onClick(){return onItemClick(key);},className:hasValue&&value.includes(key)?styles.itemSelected:''},options[key]);}))));};SelectContextChoices.defaultProps={className:'',errorText:'',placeholder:'',label:'',onChange:function onChange(){},options:{},value:[],showErrorText:true};export default SelectContextChoices;
13
+ */
14
+ const SelectContextChoices = ({
15
+ options,
16
+ onChange,
17
+ value,
18
+ placeholder,
19
+ className,
20
+ label,
21
+ errorText,
22
+ showErrorText
23
+ }) => {
24
+ const [opened, setOpened] = useState(false);
25
+ const onMenuChange = useCallback(({
26
+ active
27
+ }) => {
28
+ setOpened(active);
29
+ }, []);
30
+ const onItemClick = useCallback(key => {
31
+ if (key === '') {
32
+ onChange([]);
33
+ } else if (value.includes(key)) {
34
+ // Eliminate value
35
+ onChange(value.filter(v => v !== key));
36
+ } else {
37
+ onChange([...value, key]);
38
+ }
39
+ }, [onChange, value]);
40
+ const hasValue = !!value && !!value.length;
41
+ const values = hasValue ? Object.values(pick(options, value)) : [];
42
+ return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(InfoField, {
43
+ className: className,
44
+ label: label,
45
+ errorText: errorText,
46
+ showErrorText: showErrorText,
47
+ hasValue: true,
48
+ rightElement: /*#__PURE__*/React.createElement(Chevron, {
49
+ className: styles.chevron
50
+ })
51
+ }, /*#__PURE__*/React.createElement("div", {
52
+ role: "button",
53
+ onClick: () => setOpened(true),
54
+ "aria-hidden": true,
55
+ tabIndex: "0",
56
+ className: styles.toggle
57
+ }, !hasValue && (placeholder || i18n.text('common.please_choose')), hasValue && values.join(', ')), /*#__PURE__*/React.createElement(ContextMenu, {
58
+ isOpened: opened,
59
+ onStateChange: onMenuChange,
60
+ showToggle: false,
61
+ scroll: true
62
+ }, Object.keys(options).map(key => /*#__PURE__*/React.createElement(ContextMenu.Item, {
63
+ key: key,
64
+ autoClose: false,
65
+ onClick: () => onItemClick(key),
66
+ className: hasValue && value.includes(key) ? styles.itemSelected : ''
67
+ }, options[key])))));
68
+ };
69
+ SelectContextChoices.defaultProps = {
70
+ className: '',
71
+ errorText: '',
72
+ placeholder: '',
73
+ label: '',
74
+ onChange: () => {},
75
+ options: {},
76
+ value: [],
77
+ showErrorText: true
78
+ };
79
+ export default SelectContextChoices;
@@ -1,4 +1,33 @@
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{shallow}from'enzyme';import SelectContextChoices from"./index";jest.mock('@shopgate/engage/a11y/components');jest.mock('@shopgate/engage/components');describe('<SelectContextChoices />',function(){// Simple tests for snapshots
2
- var tests={'should render select with no options':{},// eslint-disable-next-line extra-rules/no-single-line-objects
3
- 'should render select with 2 options':{options:{DE:'Germany',US:'United states'}},// eslint-disable-next-line extra-rules/no-single-line-objects
4
- 'should render select with 1 selected option':{options:{DE:'Germany',US:'United states'},value:['DE']}};Object.keys(tests).forEach(function(test){it(test,function(){var testFixtures=tests[test];var wrapper=shallow(React.createElement(SelectContextChoices,_extends({},testFixtures)));expect(wrapper).toMatchSnapshot();});});});
1
+ import React from 'react';
2
+ import { shallow } from 'enzyme';
3
+ import SelectContextChoices from "./index";
4
+ jest.mock('@shopgate/engage/a11y/components');
5
+ jest.mock('@shopgate/engage/components');
6
+ describe('<SelectContextChoices />', () => {
7
+ // Simple tests for snapshots
8
+ const tests = {
9
+ 'should render select with no options': {},
10
+ // eslint-disable-next-line extra-rules/no-single-line-objects
11
+ 'should render select with 2 options': {
12
+ options: {
13
+ DE: 'Germany',
14
+ US: 'United states'
15
+ }
16
+ },
17
+ // eslint-disable-next-line extra-rules/no-single-line-objects
18
+ 'should render select with 1 selected option': {
19
+ options: {
20
+ DE: 'Germany',
21
+ US: 'United states'
22
+ },
23
+ value: ['DE']
24
+ }
25
+ };
26
+ Object.keys(tests).forEach(test => {
27
+ it(test, () => {
28
+ const testFixtures = tests[test];
29
+ const wrapper = shallow(/*#__PURE__*/React.createElement(SelectContextChoices, testFixtures));
30
+ expect(wrapper).toMatchSnapshot();
31
+ });
32
+ });
33
+ });
@@ -1 +1,23 @@
1
- import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';var chevron=css({position:'absolute',top:'50%',right:0,transform:'translateY(-50%) rotateZ(-90deg)',fontSize:'1.3em !important',marginTop:-3}).toString();var toggle=css({fontSize:'1rem',paddingRight:'2rem'});var itemSelected=css({backgroundColor:themeConfig.colors.shade8,fontWeight:500}).toString();export default{chevron:chevron,toggle:toggle,itemSelected:itemSelected};
1
+ import { css } from 'glamor';
2
+ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
3
+ const chevron = css({
4
+ position: 'absolute',
5
+ top: '50%',
6
+ right: 0,
7
+ transform: 'translateY(-50%) rotateZ(-90deg)',
8
+ fontSize: '1.3em !important',
9
+ marginTop: -3
10
+ }).toString();
11
+ const toggle = css({
12
+ fontSize: '1rem',
13
+ paddingRight: '2rem'
14
+ });
15
+ const itemSelected = css({
16
+ backgroundColor: themeConfig.colors.shade8,
17
+ fontWeight: 500
18
+ }).toString();
19
+ export default {
20
+ chevron,
21
+ toggle,
22
+ itemSelected
23
+ };
@@ -1,14 +1,98 @@
1
- var _excluded=["className","placeholder","label","errorText","leftElement","rightElement","hasUnderline"];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 Input from'@shopgate/pwa-common/components/Input';import Grid from'@shopgate/pwa-common/components/Grid';import FormElement from'@shopgate/pwa-ui-shared/FormElement';import style from"./style";/**
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React, { Component } from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import Input from '@shopgate/pwa-common/components/Input';
5
+ import Grid from '@shopgate/pwa-common/components/Grid';
6
+ import FormElement from '@shopgate/pwa-ui-shared/FormElement';
7
+ import style from "./style";
8
+
9
+ /**
2
10
  * No operational
3
- */var noop=function noop(){};/**
11
+ */
12
+ const noop = () => {};
13
+
14
+ /**
4
15
  * TextField component
5
- */var TextField=/*#__PURE__*/function(_Component){/**
16
+ */
17
+ class TextField extends Component {
18
+ /**
6
19
  * Creates a new text field component.
7
20
  * @param {Object} props The component properties.
8
- */function TextField(props){var _this2;_classCallCheck(this,TextField);_this2=_callSuper(this,TextField,[props]);/**
9
- * Internal focus event handler.
10
- * @param {boolean} isFocused Whether the input component is focused.
11
- */_defineProperty(_this2,"handleFocusChange",function(isFocused){_this2.setState({isFocused:isFocused});_this2.props.onFocusChange(isFocused);});_this2.state={isFocused:false};return _this2;}_inherits(TextField,_Component);return _createClass(TextField,[{key:"render",value:/**
21
+ */
22
+ constructor(props) {
23
+ super(props);
24
+ /**
25
+ * Internal focus event handler.
26
+ * @param {boolean} isFocused Whether the input component is focused.
27
+ */
28
+ this.handleFocusChange = isFocused => {
29
+ this.setState({
30
+ isFocused
31
+ });
32
+ this.props.onFocusChange(isFocused);
33
+ };
34
+ this.state = {
35
+ isFocused: false
36
+ };
37
+ }
38
+ /**
12
39
  * Renders the text field.
13
40
  * @return {JSX.Element}
14
- */function render(){var _this$props=this.props,className=_this$props.className,placeholder=_this$props.placeholder,label=_this$props.label,errorText=_this$props.errorText,leftElement=_this$props.leftElement,rightElement=_this$props.rightElement,hasUnderline=_this$props.hasUnderline,props=_objectWithoutProperties(_this$props,_excluded);return React.createElement(FormElement,{className:"".concat(className," ui-shared__form__text-field"),htmlFor:props.name,placeholder:placeholder,label:label,errorText:errorText,hasLeftElement:!!leftElement,hasUnderline:hasUnderline,hasValue:!!props.value,isFocused:this.state.isFocused},React.createElement(Grid,null,leftElement&&React.createElement(Grid.Item,{grow:0,className:style.element},leftElement),React.createElement(Grid.Item,{grow:1,className:style.container},React.createElement(Input,_extends({},props,{onFocusChange:this.handleFocusChange,className:"\n ".concat(style[props.multiLine?'multiLine':'input']," \n ").concat(leftElement?style.leftOffset:'',"\n "),validateOnBlur:true}))),rightElement&&React.createElement(Grid.Item,{grow:0,className:style.element},rightElement)));}}]);}(Component);_defineProperty(TextField,"defaultProps",{attributes:null,className:'',errorText:'',hasUnderline:true,label:'',leftElement:null,onChange:noop,onFocusChange:noop,placeholder:'',multiLine:false,rightElement:null,value:'',type:'text',maxLength:''});export default TextField;
41
+ */
42
+ render() {
43
+ const {
44
+ className,
45
+ placeholder,
46
+ label,
47
+ errorText,
48
+ leftElement,
49
+ rightElement,
50
+ hasUnderline,
51
+ ...props
52
+ } = this.props;
53
+ return /*#__PURE__*/React.createElement(FormElement, {
54
+ className: `${className} ui-shared__form__text-field`,
55
+ htmlFor: props.name,
56
+ placeholder: placeholder,
57
+ label: label,
58
+ errorText: errorText,
59
+ hasLeftElement: !!leftElement,
60
+ hasUnderline: hasUnderline,
61
+ hasValue: !!props.value,
62
+ isFocused: this.state.isFocused
63
+ }, /*#__PURE__*/React.createElement(Grid, null, leftElement && /*#__PURE__*/React.createElement(Grid.Item, {
64
+ grow: 0,
65
+ className: style.element
66
+ }, leftElement), /*#__PURE__*/React.createElement(Grid.Item, {
67
+ grow: 1,
68
+ className: style.container
69
+ }, /*#__PURE__*/React.createElement(Input, _extends({}, props, {
70
+ onFocusChange: this.handleFocusChange,
71
+ className: `
72
+ ${style[props.multiLine ? 'multiLine' : 'input']}
73
+ ${leftElement ? style.leftOffset : ''}
74
+ `,
75
+ validateOnBlur: true
76
+ }))), rightElement && /*#__PURE__*/React.createElement(Grid.Item, {
77
+ grow: 0,
78
+ className: style.element
79
+ }, rightElement)));
80
+ }
81
+ }
82
+ TextField.defaultProps = {
83
+ attributes: null,
84
+ className: '',
85
+ errorText: '',
86
+ hasUnderline: true,
87
+ label: '',
88
+ leftElement: null,
89
+ onChange: noop,
90
+ onFocusChange: noop,
91
+ placeholder: '',
92
+ multiLine: false,
93
+ rightElement: null,
94
+ value: '',
95
+ type: 'text',
96
+ maxLength: ''
97
+ };
98
+ export default TextField;
@@ -1 +1,110 @@
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 TextField from"./index";var inputProps={name:'test-input'};describe('<TextField>',function(){it('should render a simple text field',function(){var wrapper=mount(React.createElement(TextField,inputProps));expect(wrapper).toMatchSnapshot();expect(wrapper.find('input').length).toBe(1);});it('should render the text field as password',function(){var wrapper=mount(React.createElement(TextField,_extends({},inputProps,{password:true})));expect(wrapper).toMatchSnapshot();expect(wrapper.find('input[type="password"]').length).toBe(1);});it('should render the text field with a default value',function(){var wrapper=mount(React.createElement(TextField,_extends({},inputProps,{value:"FooBar"})));expect(wrapper).toMatchSnapshot();expect(wrapper.find('input[value="FooBar"]').length).toBe(1);});it('should trigger the onChange callback',function(){var onChangeMock=jest.fn();var wrapper=mount(React.createElement(TextField,_extends({},inputProps,{onChange:onChangeMock})));wrapper.find('input').simulate('change',{target:{value:'a'}});expect(onChangeMock).toHaveBeenCalledTimes(2);expect(wrapper.find('input').props().value).toEqual('a');});it('should receive the correct value while typing',function(){var wrapper=mount(React.createElement(TextField,inputProps));var input=wrapper.find('input');input.simulate('change',{target:{value:'foobar'}});expect(wrapper).toMatchSnapshot();expect(input.instance().value).toBe('foobar');});it('should sanitize the input',function(){var wrapper=mount(React.createElement(TextField,_extends({},inputProps,{onSanitize:function onSanitize(value){return value.toUpperCase();}})));var input=wrapper.find('input');input.simulate('change',{target:{value:'foobar'}});expect(wrapper).toMatchSnapshot();expect(input.instance().value).toBe('FOOBAR');});it('should trigger the validation callback',function(){var onValidateMock=jest.fn();var wrapper=mount(React.createElement(TextField,_extends({},inputProps,{onValidate:onValidateMock})));expect(wrapper).toMatchSnapshot();expect(onValidateMock).toHaveBeenCalled();});it('should focus the input',function(){var onFocusMock=jest.fn();var wrapper=mount(React.createElement(TextField,_extends({},inputProps,{onFocusChange:onFocusMock})));var input=wrapper.find('SimpleInput');expect(wrapper).toMatchSnapshot();expect(input.instance().isFocused).toBe(false);input.simulate('focus');expect(input.instance().isFocused).toBe(true);input.simulate('blur');expect(input.instance().isFocused).toBe(false);});it('should show the error message',function(){var errorText='This is an error here';var wrapper=mount(React.createElement(TextField,_extends({},inputProps,{errorText:errorText})));expect(wrapper).toMatchSnapshot();expect(wrapper.find('ErrorText').find('Translate').at(0).props().string).toEqual(errorText);});it('should show the label',function(){var label='This is the label';var wrapper=mount(React.createElement(TextField,_extends({},inputProps,{label:label})));expect(wrapper).toMatchSnapshot();expect(wrapper.find('Label').find('Translate').props().string).toEqual(label);});it('should show the placeholder text',function(){var placeholder='This is the placeholder text';var wrapper=mount(React.createElement(TextField,_extends({},inputProps,{placeholder:placeholder})));expect(wrapper).toMatchSnapshot();expect(wrapper.find('Placeholder').find('Translate').at(0).props().string).toEqual(placeholder);});});
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React from 'react';
3
+ import { mount } from 'enzyme';
4
+ import TextField from "./index";
5
+ const inputProps = {
6
+ name: 'test-input'
7
+ };
8
+ describe('<TextField>', () => {
9
+ it('should render a simple text field', () => {
10
+ const wrapper = mount(/*#__PURE__*/React.createElement(TextField, inputProps));
11
+ expect(wrapper).toMatchSnapshot();
12
+ expect(wrapper.find('input').length).toBe(1);
13
+ });
14
+ it('should render the text field as password', () => {
15
+ const wrapper = mount(/*#__PURE__*/React.createElement(TextField, _extends({}, inputProps, {
16
+ password: true
17
+ })));
18
+ expect(wrapper).toMatchSnapshot();
19
+ expect(wrapper.find('input[type="password"]').length).toBe(1);
20
+ });
21
+ it('should render the text field with a default value', () => {
22
+ const wrapper = mount(/*#__PURE__*/React.createElement(TextField, _extends({}, inputProps, {
23
+ value: "FooBar"
24
+ })));
25
+ expect(wrapper).toMatchSnapshot();
26
+ expect(wrapper.find('input[value="FooBar"]').length).toBe(1);
27
+ });
28
+ it('should trigger the onChange callback', () => {
29
+ const onChangeMock = jest.fn();
30
+ const wrapper = mount(/*#__PURE__*/React.createElement(TextField, _extends({}, inputProps, {
31
+ onChange: onChangeMock
32
+ })));
33
+ wrapper.find('input').simulate('change', {
34
+ target: {
35
+ value: 'a'
36
+ }
37
+ });
38
+ expect(onChangeMock).toHaveBeenCalledTimes(2);
39
+ expect(wrapper.find('input').props().value).toEqual('a');
40
+ });
41
+ it('should receive the correct value while typing', () => {
42
+ const wrapper = mount(/*#__PURE__*/React.createElement(TextField, inputProps));
43
+ const input = wrapper.find('input');
44
+ input.simulate('change', {
45
+ target: {
46
+ value: 'foobar'
47
+ }
48
+ });
49
+ expect(wrapper).toMatchSnapshot();
50
+ expect(input.instance().value).toBe('foobar');
51
+ });
52
+ it('should sanitize the input', () => {
53
+ const wrapper = mount(/*#__PURE__*/React.createElement(TextField, _extends({}, inputProps, {
54
+ onSanitize: value => value.toUpperCase()
55
+ })));
56
+ const input = wrapper.find('input');
57
+ input.simulate('change', {
58
+ target: {
59
+ value: 'foobar'
60
+ }
61
+ });
62
+ expect(wrapper).toMatchSnapshot();
63
+ expect(input.instance().value).toBe('FOOBAR');
64
+ });
65
+ it('should trigger the validation callback', () => {
66
+ const onValidateMock = jest.fn();
67
+ const wrapper = mount(/*#__PURE__*/React.createElement(TextField, _extends({}, inputProps, {
68
+ onValidate: onValidateMock
69
+ })));
70
+ expect(wrapper).toMatchSnapshot();
71
+ expect(onValidateMock).toHaveBeenCalled();
72
+ });
73
+ it('should focus the input', () => {
74
+ const onFocusMock = jest.fn();
75
+ const wrapper = mount(/*#__PURE__*/React.createElement(TextField, _extends({}, inputProps, {
76
+ onFocusChange: onFocusMock
77
+ })));
78
+ const input = wrapper.find('SimpleInput');
79
+ expect(wrapper).toMatchSnapshot();
80
+ expect(input.instance().isFocused).toBe(false);
81
+ input.simulate('focus');
82
+ expect(input.instance().isFocused).toBe(true);
83
+ input.simulate('blur');
84
+ expect(input.instance().isFocused).toBe(false);
85
+ });
86
+ it('should show the error message', () => {
87
+ const errorText = 'This is an error here';
88
+ const wrapper = mount(/*#__PURE__*/React.createElement(TextField, _extends({}, inputProps, {
89
+ errorText: errorText
90
+ })));
91
+ expect(wrapper).toMatchSnapshot();
92
+ expect(wrapper.find('ErrorText').find('Translate').at(0).props().string).toEqual(errorText);
93
+ });
94
+ it('should show the label', () => {
95
+ const label = 'This is the label';
96
+ const wrapper = mount(/*#__PURE__*/React.createElement(TextField, _extends({}, inputProps, {
97
+ label: label
98
+ })));
99
+ expect(wrapper).toMatchSnapshot();
100
+ expect(wrapper.find('Label').find('Translate').props().string).toEqual(label);
101
+ });
102
+ it('should show the placeholder text', () => {
103
+ const placeholder = 'This is the placeholder text';
104
+ const wrapper = mount(/*#__PURE__*/React.createElement(TextField, _extends({}, inputProps, {
105
+ placeholder: placeholder
106
+ })));
107
+ expect(wrapper).toMatchSnapshot();
108
+ expect(wrapper.find('Placeholder').find('Translate').at(0).props().string).toEqual(placeholder);
109
+ });
110
+ });
@@ -1,12 +1,70 @@
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;}import{css}from'glamor';// Selects a date input that is not focused.
2
- var bluredDateSelector='input[type="date"]:in-range:not(:focus)';/**
1
+ import { css } from 'glamor';
2
+
3
+ // Selects a date input that is not focused.
4
+ const bluredDateSelector = 'input[type="date"]:in-range:not(:focus)';
5
+
6
+ /**
3
7
  * The styles for the container element.
4
- */var container=css(_defineProperty({// Fixes layout issue with webkit. Height is 0 in some webkit browsers.
5
- '& input[type="date"]':{minHeight:'1.3rem',appearance:'none',paddingLeft:0,marginLeft:0}},"& ".concat(bluredDateSelector,"::-webkit-datetime-edit-year-field, ")+"".concat(bluredDateSelector,"::-webkit-datetime-edit-month-field, ")+"".concat(bluredDateSelector,"::-webkit-datetime-edit-day-field, ")+"".concat(bluredDateSelector,"::-webkit-datetime-edit-text"),{padding:0,color:'transparent'})).toString();/**
8
+ */
9
+ const container = css({
10
+ // Fixes layout issue with webkit. Height is 0 in some webkit browsers.
11
+ '& input[type="date"]': {
12
+ minHeight: '1.3rem',
13
+ appearance: 'none',
14
+ paddingLeft: 0,
15
+ marginLeft: 0
16
+ },
17
+ // Removes placeholder texts on chrome when input is not focused.
18
+ [`& ${bluredDateSelector}::-webkit-datetime-edit-year-field, ` + `${bluredDateSelector}::-webkit-datetime-edit-month-field, ` + `${bluredDateSelector}::-webkit-datetime-edit-day-field, ` + `${bluredDateSelector}::-webkit-datetime-edit-text`]: {
19
+ padding: 0,
20
+ color: 'transparent'
21
+ }
22
+ }).toString();
23
+
24
+ /**
6
25
  * The styles for the input field.
7
- */var input=css({position:'relative',padding:0,width:'100%',marginTop:24,outline:0,fontSize:16,lineHeight:'19px'}).toString();/**
26
+ */
27
+ const input = css({
28
+ position: 'relative',
29
+ padding: 0,
30
+ width: '100%',
31
+ marginTop: 24,
32
+ outline: 0,
33
+ fontSize: 16,
34
+ lineHeight: '19px'
35
+ }).toString();
36
+
37
+ /**
8
38
  * The styles for the multiLine.
9
- */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.
10
- }).toString();var element=css({marginTop:16,display:'flex',alignItems:'flex-end'}).toString();/**
39
+ */
40
+ const multiLine = css({
41
+ position: 'relative',
42
+ marginTop: 24,
43
+ marginBottom: 3,
44
+ padding: 0,
45
+ width: '100%',
46
+ outline: 0,
47
+ height: 19,
48
+ minHeight: 19,
49
+ lineHeight: '19px',
50
+ verticalAlign: 'top' // Important to avoid bottom whitespace.
51
+ }).toString();
52
+ const element = css({
53
+ marginTop: 16,
54
+ display: 'flex',
55
+ alignItems: 'flex-end'
56
+ }).toString();
57
+
58
+ /**
11
59
  * Additional left spacing when a left element is present
12
- */var leftOffset=css({marginLeft:2}).toString();export default{container:container,input:input,multiLine:multiLine,element:element,leftOffset:leftOffset};
60
+ */
61
+ const leftOffset = css({
62
+ marginLeft: 2
63
+ }).toString();
64
+ export default {
65
+ container,
66
+ input,
67
+ multiLine,
68
+ element,
69
+ leftOffset
70
+ };
package/Form/index.js CHANGED
@@ -1,17 +1,58 @@
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,{PureComponent}from'react';import PropTypes from'prop-types';/**
1
+ import React, { PureComponent } from 'react';
2
+ import PropTypes from 'prop-types';
3
+
4
+ /**
2
5
  * Form component that handles keyboard submit, next buttons, ...
3
6
  * @deprecated Use `@shopgate/engage/components/Form` instead.
4
- */var Form=/*#__PURE__*/function(_PureComponent){function Form(props){var _this2;_classCallCheck(this,Form);_this2=_callSuper(this,Form,[props]);/**
5
- * Handles the form submit.
6
- * @param {Object} event The event that caused the submit.
7
- */_defineProperty(_this2,"handleSubmit",function(event){event.preventDefault();var inputFocused=[].concat(_this2.formElement.current.querySelectorAll('input')).some(function(input){return document.activeElement===input;});if(inputFocused){document.activeElement.blur();}_this2.props.onSubmit();});/**
8
- * Handles form submits by key.
9
- * @param {Object} event The event that caused the keypress.
10
- */_defineProperty(_this2,"handleKeyPress",function(event){// Enter key and on iOS also the "Done" button.
11
- if(event.which===13){_this2.handleSubmit(event);}});_this2.formElement=React.createRef();return _this2;}_inherits(Form,_PureComponent);return _createClass(Form,[{key:"render",value:/**
12
- * Renders the component.
13
- * @returns {JSX}
14
- */function render(){/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */return React.createElement("form",{action:"#",onSubmit:this.handleSubmit,onKeyPress:this.handleKeyPress,ref:this.formElement,className:"ui-shared__form"},this.props.children);/* eslint-enable jsx-a11y/no-noninteractive-element-interactions */}}]);}(PureComponent);_defineProperty(Form,"defaultProps",{onSubmit:function onSubmit(){}/**
7
+ */
8
+ class Form extends PureComponent {
9
+ /**
15
10
  * Initializes the form component.
16
11
  * @param {Object} props The components props.
17
- */});export default Form;
12
+ */
13
+ constructor(props) {
14
+ super(props);
15
+ /**
16
+ * Handles the form submit.
17
+ * @param {Object} event The event that caused the submit.
18
+ */
19
+ this.handleSubmit = event => {
20
+ event.preventDefault();
21
+ const inputFocused = [...this.formElement.current.querySelectorAll('input')].some(input => document.activeElement === input);
22
+ if (inputFocused) {
23
+ document.activeElement.blur();
24
+ }
25
+ this.props.onSubmit();
26
+ };
27
+ /**
28
+ * Handles form submits by key.
29
+ * @param {Object} event The event that caused the keypress.
30
+ */
31
+ this.handleKeyPress = event => {
32
+ // Enter key and on iOS also the "Done" button.
33
+ if (event.which === 13) {
34
+ this.handleSubmit(event);
35
+ }
36
+ };
37
+ this.formElement = /*#__PURE__*/React.createRef();
38
+ }
39
+ /**
40
+ * Renders the component.
41
+ * @returns {JSX}
42
+ */
43
+ render() {
44
+ /* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
45
+ return /*#__PURE__*/React.createElement("form", {
46
+ action: "#",
47
+ onSubmit: this.handleSubmit,
48
+ onKeyPress: this.handleKeyPress,
49
+ ref: this.formElement,
50
+ className: "ui-shared__form"
51
+ }, this.props.children);
52
+ /* eslint-enable jsx-a11y/no-noninteractive-element-interactions */
53
+ }
54
+ }
55
+ Form.defaultProps = {
56
+ onSubmit: () => {}
57
+ };
58
+ export default Form;
@@ -1,5 +1,34 @@
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
  * Error message component.
3
9
  * @param {Object} props The component props.
4
10
  * @returns {JSX.Element}
5
- */var ErrorText=function ErrorText(_ref){var className=_ref.className,errorText=_ref.errorText,translate=_ref.translate,elementName=_ref.elementName,ariaHidden=_ref.ariaHidden;return React.createElement("div",{id:"ariaError-".concat(elementName),className:classNames(className,styles,'errorText'),"aria-live":"assertive","aria-atomic":"true","aria-hidden":ariaHidden},translate&&React.createElement(I18n.Text,{string:errorText}),!translate&&errorText);};ErrorText.defaultProps={className:null,errorText:null,elementName:null,translate:true,ariaHidden:false};export default ErrorText;
11
+ */
12
+ const ErrorText = ({
13
+ className,
14
+ errorText,
15
+ translate,
16
+ elementName,
17
+ ariaHidden
18
+ }) => /*#__PURE__*/React.createElement("div", {
19
+ id: `ariaError-${elementName}`,
20
+ className: classNames(className, styles, 'errorText'),
21
+ "aria-live": "assertive",
22
+ "aria-atomic": "true",
23
+ "aria-hidden": ariaHidden
24
+ }, translate && /*#__PURE__*/React.createElement(I18n.Text, {
25
+ string: errorText
26
+ }), !translate && errorText);
27
+ ErrorText.defaultProps = {
28
+ className: null,
29
+ errorText: null,
30
+ elementName: null,
31
+ translate: true,
32
+ ariaHidden: false
33
+ };
34
+ export default ErrorText;
@@ -1 +1,13 @@
1
- import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';export default css({bottom:2,color:"var(--color-state-alert, ".concat(themeConfig.colors.error,")"),fontSize:12,lineHeight:'14px',overflow:'hidden',position:'absolute',textOverflow:'ellipsis',whiteSpace:'nowrap',width:'100%'}).toString();
1
+ import { css } from 'glamor';
2
+ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
3
+ export default css({
4
+ bottom: 2,
5
+ color: `var(--color-state-alert, ${themeConfig.colors.error})`,
6
+ fontSize: 12,
7
+ lineHeight: '14px',
8
+ overflow: 'hidden',
9
+ position: 'absolute',
10
+ textOverflow: 'ellipsis',
11
+ whiteSpace: 'nowrap',
12
+ width: '100%'
13
+ }).toString();
@@ -1,5 +1,38 @@
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(_ref){var hasErrorMessage=_ref.hasErrorMessage,htmlFor=_ref.htmlFor,isFloating=_ref.isFloating,isFocused=_ref.isFocused,label=_ref.label,labelStatic=_ref.labelStatic;var labelStyles=styles.labelStyles(isFocused,isFloating,hasErrorMessage,labelStatic);return(/* eslint-disable-next-line jsx-a11y/label-has-associated-control */React.createElement("label",{htmlFor:htmlFor,className:classNames(labelStyles,'label',{floating:isFloating})},React.createElement(I18n.Text,{string:label})));};Label.defaultProps={htmlFor:'',isFocused:false,isFloating:false,hasErrorMessage:false,label:'',labelStatic:false};export default Label;
11
+ */
12
+ const Label = ({
13
+ hasErrorMessage,
14
+ htmlFor,
15
+ isFloating,
16
+ isFocused,
17
+ label,
18
+ labelStatic
19
+ }) => {
20
+ const labelStyles = styles.labelStyles(isFocused, isFloating, hasErrorMessage, labelStatic);
21
+ return /*#__PURE__*/ /* eslint-disable-next-line jsx-a11y/label-has-associated-control */React.createElement("label", {
22
+ htmlFor: htmlFor,
23
+ className: classNames(labelStyles, 'label', {
24
+ floating: isFloating
25
+ })
26
+ }, /*#__PURE__*/React.createElement(I18n.Text, {
27
+ string: label
28
+ }));
29
+ };
30
+ Label.defaultProps = {
31
+ htmlFor: '',
32
+ isFocused: false,
33
+ isFloating: false,
34
+ hasErrorMessage: false,
35
+ label: '',
36
+ labelStatic: false
37
+ };
38
+ export default Label;