@shopgate/pwa-ui-shared 7.30.3 → 7.31.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (326) hide show
  1. package/ActionButton/index.js +66 -67
  2. package/AddToCartButton/index.js +217 -185
  3. package/Availability/index.js +24 -6
  4. package/Button/index.js +105 -82
  5. package/Button/spec.js +3 -4
  6. package/Card/index.js +26 -7
  7. package/CardList/components/Item/index.js +15 -3
  8. package/CartTotalLine/components/Amount/index.js +13 -4
  9. package/CartTotalLine/components/Hint/index.js +13 -4
  10. package/CartTotalLine/components/Label/index.js +23 -10
  11. package/CartTotalLine/index.js +41 -7
  12. package/Checkbox/index.js +41 -17
  13. package/Chip/index.js +82 -7
  14. package/ContextMenu/components/Item/index.js +38 -20
  15. package/ContextMenu/components/Position/index.js +38 -56
  16. package/ContextMenu/index.js +64 -28
  17. package/Dialog/components/BasicDialog/index.js +1 -0
  18. package/Dialog/components/HtmlContentDialog/spec.js +39 -0
  19. package/Dialog/components/PipelineErrorDialog/index.js +108 -157
  20. package/Dialog/components/PipelineErrorDialog/spec.js +12 -18
  21. package/Dialog/components/TextMessageDialog/index.js +1 -1
  22. package/Dialog/components/VariantSelectModal/index.js +1 -1
  23. package/Dialog/index.js +1 -1
  24. package/DiscountBadge/index.js +48 -15
  25. package/FavoritesButton/index.js +95 -100
  26. package/FavoritesButton/spec.js +5 -2
  27. package/Form/Builder/classes/ActionListener/index.js +1 -0
  28. package/Form/Checkbox/index.js +64 -56
  29. package/Form/InfoField/index.js +18 -6
  30. package/Form/Password/index.js +39 -52
  31. package/Form/RadioGroup/components/Item/index.js +72 -56
  32. package/Form/RadioGroup/index.js +79 -90
  33. package/Form/Select/index.js +108 -130
  34. package/Form/SelectContextChoices/index.js +30 -8
  35. package/Form/TextField/index.js +106 -82
  36. package/Form/TextField/spec.js +4 -3
  37. package/FormElement/components/ErrorText/index.js +32 -14
  38. package/FormElement/components/Label/index.js +56 -6
  39. package/FormElement/components/Placeholder/index.js +44 -11
  40. package/FormElement/components/Underline/index.js +63 -12
  41. package/FormElement/index.js +62 -85
  42. package/Glow/index.js +73 -83
  43. package/IndicatorCircle/index.js +73 -17
  44. package/IndicatorCircle/spec.js +2 -5
  45. package/LoadingIndicator/index.js +34 -12
  46. package/Manufacturer/index.js +21 -10
  47. package/MessageBar/index.js +12 -38
  48. package/NoResults/components/Icon/index.js +30 -14
  49. package/NoResults/index.js +35 -7
  50. package/Placeholder/index.js +34 -23
  51. package/PlaceholderLabel/index.js +17 -3
  52. package/Price/index.js +34 -21
  53. package/PriceInfo/index.js +23 -9
  54. package/PriceStriked/index.js +67 -77
  55. package/ProgressBar/index.js +112 -77
  56. package/RadioButton/index.js +29 -11
  57. package/RatingStars/index.js +122 -137
  58. package/Ripple/components/RippleAnimation/index.js +13 -3
  59. package/Ripple/index.js +158 -212
  60. package/RippleButton/index.js +63 -60
  61. package/RippleButton/spec.js +15 -9
  62. package/ScannerOverlay/components/CameraOverlay/index.js +54 -10
  63. package/ScannerOverlay/components/ScannerBar/components/FlashlightButton/index.js +53 -27
  64. package/ScannerOverlay/components/ScannerBar/index.js +50 -26
  65. package/Sheet/components/Header/components/SearchBar/index.js +54 -10
  66. package/Sheet/components/Header/index.js +96 -76
  67. package/Sheet/index.js +295 -157
  68. package/Sheet/spec.js +8 -6
  69. package/TaxDisclaimer/index.js +17 -4
  70. package/TaxDisclaimer/spec.js +16 -5
  71. package/TextField/components/ErrorText/index.js +35 -14
  72. package/TextField/components/FormElement/index.js +29 -4
  73. package/TextField/components/Hint/index.js +39 -10
  74. package/TextField/components/Label/index.js +43 -6
  75. package/TextField/components/Underline/index.js +64 -13
  76. package/TextField/index.js +157 -171
  77. package/TextField/spec.js +5 -3
  78. package/icons/AccountBoxIcon.d.ts +7 -0
  79. package/icons/AccountBoxIcon.d.ts.map +1 -0
  80. package/icons/AccountBoxIcon.js +1 -4
  81. package/icons/AddMoreIcon.d.ts +7 -0
  82. package/icons/AddMoreIcon.d.ts.map +1 -0
  83. package/icons/AddMoreIcon.js +0 -3
  84. package/icons/ArrowDropIcon.d.ts +7 -0
  85. package/icons/ArrowDropIcon.d.ts.map +1 -0
  86. package/icons/ArrowDropIcon.js +0 -3
  87. package/icons/ArrowIcon.d.ts +10 -0
  88. package/icons/ArrowIcon.d.ts.map +1 -0
  89. package/icons/ArrowIcon.js +2 -11
  90. package/icons/BarcodeScannerIcon.d.ts +7 -0
  91. package/icons/BarcodeScannerIcon.d.ts.map +1 -0
  92. package/icons/BarcodeScannerIcon.js +0 -3
  93. package/icons/BoxIcon.d.ts +7 -0
  94. package/icons/BoxIcon.d.ts.map +1 -0
  95. package/icons/BoxIcon.js +0 -3
  96. package/icons/BrowseIcon.d.ts +7 -0
  97. package/icons/BrowseIcon.d.ts.map +1 -0
  98. package/icons/BrowseIcon.js +1 -3
  99. package/icons/BurgerIcon.d.ts +7 -0
  100. package/icons/BurgerIcon.d.ts.map +1 -0
  101. package/icons/BurgerIcon.js +0 -3
  102. package/icons/CalendarIcon.d.ts +7 -0
  103. package/icons/CalendarIcon.d.ts.map +1 -0
  104. package/icons/CalendarIcon.js +0 -2
  105. package/icons/CartCouponIcon.d.ts +7 -0
  106. package/icons/CartCouponIcon.d.ts.map +1 -0
  107. package/icons/CartCouponIcon.js +0 -2
  108. package/icons/CartIcon.d.ts +7 -0
  109. package/icons/CartIcon.d.ts.map +1 -0
  110. package/icons/CartIcon.js +0 -2
  111. package/icons/CartPlusIcon.d.ts +7 -0
  112. package/icons/CartPlusIcon.d.ts.map +1 -0
  113. package/icons/CartPlusIcon.js +0 -2
  114. package/icons/CheckIcon.d.ts +7 -0
  115. package/icons/CheckIcon.d.ts.map +1 -0
  116. package/icons/CheckIcon.js +0 -2
  117. package/icons/CheckedIcon.d.ts +7 -0
  118. package/icons/CheckedIcon.d.ts.map +1 -0
  119. package/icons/CheckedIcon.js +0 -3
  120. package/icons/ChevronIcon.d.ts +7 -0
  121. package/icons/ChevronIcon.d.ts.map +1 -0
  122. package/icons/ChevronIcon.js +0 -2
  123. package/icons/CreditCardIcon.d.ts +7 -0
  124. package/icons/CreditCardIcon.d.ts.map +1 -0
  125. package/icons/CreditCardIcon.js +0 -2
  126. package/icons/CrossIcon.d.ts +7 -0
  127. package/icons/CrossIcon.d.ts.map +1 -0
  128. package/icons/CrossIcon.js +0 -2
  129. package/icons/DescriptionIcon.d.ts +7 -0
  130. package/icons/DescriptionIcon.d.ts.map +1 -0
  131. package/icons/DescriptionIcon.js +0 -2
  132. package/icons/FilterIcon.d.ts +7 -0
  133. package/icons/FilterIcon.d.ts.map +1 -0
  134. package/icons/FilterIcon.js +0 -2
  135. package/icons/FlashDisabledIcon.d.ts +7 -0
  136. package/icons/FlashDisabledIcon.d.ts.map +1 -0
  137. package/icons/FlashDisabledIcon.js +0 -2
  138. package/icons/FlashEnabledIcon.d.ts +7 -0
  139. package/icons/FlashEnabledIcon.d.ts.map +1 -0
  140. package/icons/FlashEnabledIcon.js +0 -2
  141. package/icons/GridIcon.d.ts +7 -0
  142. package/icons/GridIcon.d.ts.map +1 -0
  143. package/icons/GridIcon.js +1 -3
  144. package/icons/HeartIcon.d.ts +7 -0
  145. package/icons/HeartIcon.d.ts.map +1 -0
  146. package/icons/HeartIcon.js +0 -2
  147. package/icons/HeartOutlineIcon.d.ts +7 -0
  148. package/icons/HeartOutlineIcon.d.ts.map +1 -0
  149. package/icons/HeartOutlineIcon.js +1 -3
  150. package/icons/HeartPlusIcon.d.ts +7 -0
  151. package/icons/HeartPlusIcon.d.ts.map +1 -0
  152. package/icons/HeartPlusIcon.js +1 -3
  153. package/icons/HeartPlusOutlineIcon.d.ts +7 -0
  154. package/icons/HeartPlusOutlineIcon.d.ts.map +1 -0
  155. package/icons/HeartPlusOutlineIcon.js +1 -3
  156. package/icons/HomeIcon.d.ts +7 -0
  157. package/icons/HomeIcon.d.ts.map +1 -0
  158. package/icons/HomeIcon.js +0 -2
  159. package/icons/InfoIcon.d.ts +7 -0
  160. package/icons/InfoIcon.d.ts.map +1 -0
  161. package/icons/InfoIcon.js +0 -2
  162. package/icons/InfoOutlineIcon.d.ts +7 -0
  163. package/icons/InfoOutlineIcon.d.ts.map +1 -0
  164. package/icons/InfoOutlineIcon.js +0 -2
  165. package/icons/ListIcon.d.ts +7 -0
  166. package/icons/ListIcon.d.ts.map +1 -0
  167. package/icons/ListIcon.js +0 -2
  168. package/icons/LocalShippingIcon.d.ts +7 -0
  169. package/icons/LocalShippingIcon.d.ts.map +1 -0
  170. package/icons/LocalShippingIcon.js +0 -2
  171. package/icons/LocationIcon.d.ts +7 -0
  172. package/icons/LocationIcon.d.ts.map +1 -0
  173. package/icons/LocationIcon.js +1 -4
  174. package/icons/LocatorIcon.d.ts +7 -0
  175. package/icons/LocatorIcon.d.ts.map +1 -0
  176. package/icons/LocatorIcon.js +1 -3
  177. package/icons/LockIcon.d.ts +9 -0
  178. package/icons/LockIcon.d.ts.map +1 -0
  179. package/icons/LockIcon.js +1 -2
  180. package/icons/LogoutIcon.d.ts +7 -0
  181. package/icons/LogoutIcon.d.ts.map +1 -0
  182. package/icons/LogoutIcon.js +0 -2
  183. package/icons/MagnifierIcon.d.ts +7 -0
  184. package/icons/MagnifierIcon.d.ts.map +1 -0
  185. package/icons/MagnifierIcon.js +0 -2
  186. package/icons/MapMarkerIcon.d.ts +7 -0
  187. package/icons/MapMarkerIcon.d.ts.map +1 -0
  188. package/icons/MapMarkerIcon.js +1 -3
  189. package/icons/MoreIcon.d.ts +7 -0
  190. package/icons/MoreIcon.d.ts.map +1 -0
  191. package/icons/MoreIcon.js +1 -3
  192. package/icons/MoreVertIcon.d.ts +7 -0
  193. package/icons/MoreVertIcon.d.ts.map +1 -0
  194. package/icons/MoreVertIcon.js +1 -3
  195. package/icons/NotificationIcon.d.ts +7 -0
  196. package/icons/NotificationIcon.d.ts.map +1 -0
  197. package/icons/NotificationIcon.js +1 -3
  198. package/icons/PersonIcon.d.ts +9 -0
  199. package/icons/PersonIcon.d.ts.map +1 -0
  200. package/icons/PersonIcon.js +0 -3
  201. package/icons/PhoneIcon.d.ts +7 -0
  202. package/icons/PhoneIcon.d.ts.map +1 -0
  203. package/icons/PhoneIcon.js +1 -4
  204. package/icons/PlaceholderIcon.d.ts +7 -0
  205. package/icons/PlaceholderIcon.d.ts.map +1 -0
  206. package/icons/PlaceholderIcon.js +0 -2
  207. package/icons/RadioCheckedIcon.d.ts +10 -0
  208. package/icons/RadioCheckedIcon.d.ts.map +1 -0
  209. package/icons/RadioCheckedIcon.js +0 -2
  210. package/icons/RadioUncheckedIcon.d.ts +10 -0
  211. package/icons/RadioUncheckedIcon.d.ts.map +1 -0
  212. package/icons/RadioUncheckedIcon.js +0 -2
  213. package/icons/SecurityIcon.d.ts +7 -0
  214. package/icons/SecurityIcon.d.ts.map +1 -0
  215. package/icons/SecurityIcon.js +0 -2
  216. package/icons/ShippingMethodIcon.d.ts +7 -0
  217. package/icons/ShippingMethodIcon.d.ts.map +1 -0
  218. package/icons/ShippingMethodIcon.js +0 -2
  219. package/icons/ShoppingCartIcon.d.ts +7 -0
  220. package/icons/ShoppingCartIcon.d.ts.map +1 -0
  221. package/icons/ShoppingCartIcon.js +0 -2
  222. package/icons/SortIcon.d.ts +7 -0
  223. package/icons/SortIcon.d.ts.map +1 -0
  224. package/icons/SortIcon.js +0 -2
  225. package/icons/StarHalfIcon.d.ts +7 -0
  226. package/icons/StarHalfIcon.d.ts.map +1 -0
  227. package/icons/StarHalfIcon.js +0 -9
  228. package/icons/StarIcon.d.ts +7 -0
  229. package/icons/StarIcon.d.ts.map +1 -0
  230. package/icons/StarIcon.js +0 -9
  231. package/icons/StarOutlineIcon.d.ts +7 -0
  232. package/icons/StarOutlineIcon.d.ts.map +1 -0
  233. package/icons/StarOutlineIcon.js +0 -2
  234. package/icons/StopIcon.d.ts +7 -0
  235. package/icons/StopIcon.d.ts.map +1 -0
  236. package/icons/StopIcon.js +0 -2
  237. package/icons/TickIcon.d.ts +7 -0
  238. package/icons/TickIcon.d.ts.map +1 -0
  239. package/icons/TickIcon.js +0 -2
  240. package/icons/TimeIcon.d.ts +7 -0
  241. package/icons/TimeIcon.d.ts.map +1 -0
  242. package/icons/TimeIcon.js +0 -2
  243. package/icons/TrashIcon.d.ts +7 -0
  244. package/icons/TrashIcon.d.ts.map +1 -0
  245. package/icons/TrashIcon.js +0 -3
  246. package/icons/TrashOutlineIcon.d.ts +8 -0
  247. package/icons/TrashOutlineIcon.d.ts.map +1 -0
  248. package/icons/TrashOutlineIcon.js +0 -2
  249. package/icons/UncheckedIcon.d.ts +7 -0
  250. package/icons/UncheckedIcon.d.ts.map +1 -0
  251. package/icons/UncheckedIcon.js +0 -2
  252. package/icons/ViewListIcon.d.ts +7 -0
  253. package/icons/ViewListIcon.d.ts.map +1 -0
  254. package/icons/ViewListIcon.js +0 -2
  255. package/icons/VisibilityIcon.d.ts +8 -0
  256. package/icons/VisibilityIcon.d.ts.map +1 -0
  257. package/icons/VisibilityIcon.js +2 -4
  258. package/icons/VisibilityOffIcon.d.ts +8 -0
  259. package/icons/VisibilityOffIcon.d.ts.map +1 -0
  260. package/icons/VisibilityOffIcon.js +2 -4
  261. package/icons/WarningIcon.d.ts +7 -0
  262. package/icons/WarningIcon.d.ts.map +1 -0
  263. package/icons/WarningIcon.js +1 -3
  264. package/package.json +5 -5
  265. package/tsconfig.build.json +16 -0
  266. package/tsconfig.json +3 -0
  267. package/ActionButton/style.js +0 -22
  268. package/AddToCartButton/style.js +0 -148
  269. package/Availability/style.js +0 -19
  270. package/Button/style.js +0 -155
  271. package/Card/style.js +0 -11
  272. package/CardList/components/Item/style.js +0 -7
  273. package/CartTotalLine/components/Amount/style.js +0 -8
  274. package/CartTotalLine/components/Hint/style.js +0 -12
  275. package/CartTotalLine/components/Label/style.js +0 -17
  276. package/CartTotalLine/style.js +0 -31
  277. package/Checkbox/style.js +0 -18
  278. package/Chip/style.js +0 -78
  279. package/ContextMenu/components/Item/style.js +0 -34
  280. package/ContextMenu/components/Position/style.js +0 -11
  281. package/ContextMenu/style.js +0 -45
  282. package/DiscountBadge/style.js +0 -36
  283. package/FavoritesButton/style.js +0 -26
  284. package/Form/Checkbox/style.js +0 -25
  285. package/Form/InfoField/style.js +0 -11
  286. package/Form/Password/style.js +0 -11
  287. package/Form/RadioGroup/components/Item/style.js +0 -32
  288. package/Form/RadioGroup/style.js +0 -20
  289. package/Form/Select/style.js +0 -27
  290. package/Form/SelectContextChoices/style.js +0 -23
  291. package/Form/TextField/style.js +0 -70
  292. package/FormElement/components/ErrorText/style.js +0 -13
  293. package/FormElement/components/Label/style.js +0 -89
  294. package/FormElement/components/Placeholder/style.js +0 -56
  295. package/FormElement/components/Underline/style.js +0 -60
  296. package/FormElement/style.js +0 -14
  297. package/Glow/style.js +0 -18
  298. package/IndicatorCircle/style.js +0 -65
  299. package/LoadingIndicator/style.js +0 -20
  300. package/Manufacturer/style.js +0 -5
  301. package/MessageBar/spec.js +0 -80
  302. package/MessageBar/style.js +0 -38
  303. package/NoResults/components/Icon/style.js +0 -17
  304. package/NoResults/style.js +0 -31
  305. package/Placeholder/style.js +0 -11
  306. package/PlaceholderLabel/style.js +0 -12
  307. package/Price/style.js +0 -22
  308. package/PriceInfo/style.js +0 -5
  309. package/PriceStriked/style.js +0 -36
  310. package/ProgressBar/style.js +0 -85
  311. package/RadioButton/style.js +0 -21
  312. package/RatingStars/style.js +0 -53
  313. package/Ripple/style.js +0 -18
  314. package/ScannerOverlay/components/CameraOverlay/style.js +0 -40
  315. package/ScannerOverlay/components/ScannerBar/components/FlashlightButton/style.js +0 -28
  316. package/ScannerOverlay/components/ScannerBar/style.js +0 -20
  317. package/Sheet/components/Header/components/SearchBar/style.js +0 -47
  318. package/Sheet/components/Header/style.js +0 -50
  319. package/Sheet/style.js +0 -143
  320. package/TaxDisclaimer/style.js +0 -9
  321. package/TextField/components/ErrorText/style.js +0 -27
  322. package/TextField/components/FormElement/style.js +0 -34
  323. package/TextField/components/Hint/style.js +0 -46
  324. package/TextField/components/Label/style.js +0 -80
  325. package/TextField/components/Underline/style.js +0 -60
  326. package/TextField/style.js +0 -35
@@ -1,66 +1,82 @@
1
- import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
1
  import _camelCase from "lodash/camelCase";
3
- import React, { PureComponent } from 'react';
2
+ import React from 'react';
4
3
  import PropTypes from 'prop-types';
5
- import classNames from 'classnames';
6
4
  import { I18n, CheckedIcon, UncheckedIcon } from '@shopgate/engage/components';
7
- import style from "./style";
5
+ import { makeStyles } from '@shopgate/engage/styles';
6
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
+ const useStyles = makeStyles()(theme => ({
8
+ container: {
9
+ display: 'flex',
10
+ marginLeft: -1
11
+ },
12
+ icon: {
13
+ width: 24,
14
+ height: 24,
15
+ flexShrink: 0
16
+ },
17
+ disabled: {
18
+ opacity: 0.25,
19
+ pointerEvents: 'none'
20
+ },
21
+ label: {
22
+ flex: 1,
23
+ fontSize: '1rem',
24
+ lineHeight: 1.5,
25
+ marginLeft: theme.spacing(1),
26
+ marginBottom: theme.spacing(1)
27
+ },
28
+ active: {
29
+ color: 'var(--color-primary)'
30
+ }
31
+ }));
8
32
 
9
33
  /**
10
34
  * RadioItem component.
35
+ * @param {Object} props Props.
36
+ * @returns {JSX.Element}
11
37
  */
12
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
- let RadioItem = /*#__PURE__*/function (_PureComponent) {
14
- function RadioItem() {
15
- return _PureComponent.apply(this, arguments) || this;
16
- }
17
- _inheritsLoose(RadioItem, _PureComponent);
18
- var _proto = RadioItem.prototype;
19
- /**
20
- * Renders the component.
21
- * @returns {JSX.Element}
22
- */
23
- _proto.render = function render() {
24
- const {
25
- label: ItemLabel,
26
- name,
27
- onChange,
28
- checked,
29
- className,
30
- attributes,
31
- id
32
- } = this.props;
33
- const {
34
- disabled
35
- } = attributes || {};
36
- return /*#__PURE__*/_jsxs("label", {
37
- className: classNames(style.container, className, {
38
- [style.disabled]: !!disabled
39
- }, _camelCase(name), 'radioItem'),
40
- htmlFor: id || name,
41
- children: [checked && /*#__PURE__*/_jsx(CheckedIcon, {
42
- className: classNames(style.active, style.icon, 'checkedIcon')
43
- }), !checked && /*#__PURE__*/_jsx(UncheckedIcon, {
44
- className: classNames(style.icon, 'uncheckedIcon')
45
- }), /*#__PURE__*/_jsx("input", {
46
- className: classNames('sr-only', 'input'),
47
- checked: checked,
48
- id: id || name,
49
- type: "radio",
50
- name: name,
51
- onChange: onChange,
52
- "aria-labelledby": `${id || name}-label`,
53
- ...attributes
54
- }), /*#__PURE__*/_jsx(I18n.Text, {
55
- string: ItemLabel,
56
- "aria-hidden": true,
57
- id: `${id || name}-label`,
58
- className: classNames(style.label, 'label')
59
- })]
60
- });
61
- };
62
- return RadioItem;
63
- }(PureComponent);
38
+ const RadioItem = ({
39
+ label: ItemLabel,
40
+ name,
41
+ onChange,
42
+ checked,
43
+ className,
44
+ attributes,
45
+ id
46
+ }) => {
47
+ const {
48
+ classes,
49
+ cx
50
+ } = useStyles();
51
+ const {
52
+ disabled
53
+ } = attributes || {};
54
+ return /*#__PURE__*/_jsxs("label", {
55
+ className: cx(classes.container, className, {
56
+ [classes.disabled]: !!disabled
57
+ }, _camelCase(name), 'radioItem'),
58
+ htmlFor: id || name,
59
+ children: [checked && /*#__PURE__*/_jsx(CheckedIcon, {
60
+ className: cx(classes.active, classes.icon, 'checkedIcon')
61
+ }), !checked && /*#__PURE__*/_jsx(UncheckedIcon, {
62
+ className: cx(classes.icon, 'uncheckedIcon')
63
+ }), /*#__PURE__*/_jsx("input", {
64
+ className: cx('sr-only', 'input'),
65
+ checked: checked,
66
+ id: id || name,
67
+ type: "radio",
68
+ name: name,
69
+ onChange: onChange,
70
+ "aria-labelledby": `${id || name}-label`,
71
+ ...attributes
72
+ }), /*#__PURE__*/_jsx(I18n.Text, {
73
+ string: ItemLabel,
74
+ "aria-hidden": true,
75
+ id: `${id || name}-label`,
76
+ className: cx(classes.label, 'label')
77
+ })]
78
+ });
79
+ };
64
80
  RadioItem.defaultProps = {
65
81
  attributes: null,
66
82
  id: null,
@@ -1,103 +1,92 @@
1
- import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
- import React, { Component, Children, cloneElement } from 'react';
1
+ import React, { Children, cloneElement, useCallback, useEffect, useState } from 'react';
3
2
  import PropTypes from 'prop-types';
4
- import classNames from 'classnames';
5
3
  import FormElement from '@shopgate/pwa-ui-shared/FormElement';
6
- import style from "./style";
4
+ import { makeStyles } from '@shopgate/engage/styles';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ const useStyles = makeStyles()((_t, {
7
+ direction
8
+ }) => ({
9
+ container: {
10
+ display: 'flex',
11
+ flexDirection: direction
12
+ }
13
+ }));
7
14
 
8
15
  /**
9
- * RadioGroup component.
16
+ * Radio group: clones children (radio items) with shared `name`, `checked`, and `onChange`.
17
+ * @param {Object} props Props.
18
+ * @returns {JSX.Element}
10
19
  */
11
- import { jsx as _jsx } from "react/jsx-runtime";
12
- let RadioGroup = /*#__PURE__*/function (_Component) {
13
- /**
14
- * Initializes the component.
15
- * @param {Object} props The components props.
16
- */
17
- function RadioGroup(props) {
18
- var _this;
19
- _this = _Component.call(this, props) || this;
20
- /**
21
- * @param {string} event click from radio element
22
- */
23
- _this.handleChange = ({
24
- target: {
25
- name
26
- }
27
- }) => {
28
- if (_this.props.disabled) {
29
- return;
30
- }
31
- if (!_this.props.isControlled) {
32
- _this.setState({
33
- value: name
34
- });
35
- }
36
- _this.props.onChange(name);
37
- };
38
- _this.state = {
39
- value: props.value
40
- };
41
- return _this;
42
- }
20
+ const RadioGroup = ({
21
+ name,
22
+ children,
23
+ className,
24
+ direction,
25
+ disabled,
26
+ errorText,
27
+ isControlled,
28
+ label,
29
+ onChange,
30
+ showErrorText,
31
+ translateErrorText,
32
+ value: valueProp
33
+ }) => {
34
+ const {
35
+ classes,
36
+ cx
37
+ } = useStyles({
38
+ direction
39
+ });
40
+ const [selectedValue, setSelectedValue] = useState(valueProp);
41
+ useEffect(() => {
42
+ if (isControlled) {
43
+ setSelectedValue(valueProp);
44
+ }
45
+ }, [isControlled, valueProp]);
43
46
 
44
47
  /**
45
- * @param {Object} nextProps props
48
+ * @param {{ target: { name: string } }} event Change event from a radio input.
46
49
  */
47
- _inheritsLoose(RadioGroup, _Component);
48
- var _proto = RadioGroup.prototype;
49
- _proto.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(nextProps) {
50
- if (this.props.isControlled && this.state.value !== nextProps.value) {
51
- this.setState({
52
- value: nextProps.value
53
- });
50
+ const handleItemChange = useCallback(({
51
+ target: {
52
+ name: itemName
54
53
  }
55
- };
56
- /**
57
- * Renders the component.
58
- * @returns {JSX}
59
- */
60
- _proto.render = function render() {
61
- const {
62
- children,
63
- className,
64
- label,
65
- errorText,
66
- direction,
67
- name,
68
- translateErrorText,
69
- disabled,
70
- showErrorText
71
- } = this.props;
72
- return /*#__PURE__*/_jsx(FormElement, {
73
- className: classNames(className, 'radioGroup', 'ui-shared__form__radio-group', {
74
- disabled
75
- }),
76
- label: label,
77
- labelStatic: true,
78
- errorText: errorText,
79
- translateErrorText: translateErrorText,
80
- showErrorText: showErrorText,
81
- htmlFor: "none",
82
- hasUnderline: false,
83
- hasValue: true,
84
- children: /*#__PURE__*/_jsx("div", {
85
- className: classNames(style.container(direction), 'radioGroup'),
86
- children: Children.map(children, child => {
87
- if (!child) {
88
- return null;
89
- }
90
- return /*#__PURE__*/cloneElement(child, {
91
- key: `${name}_${child.props.name}`,
92
- checked: this.state.value === child.props.name,
93
- onChange: this.handleChange
94
- });
95
- })
54
+ }) => {
55
+ if (disabled) {
56
+ return;
57
+ }
58
+ if (!isControlled) {
59
+ setSelectedValue(itemName);
60
+ }
61
+ onChange(itemName);
62
+ }, [disabled, isControlled, onChange]);
63
+ return /*#__PURE__*/_jsx(FormElement, {
64
+ className: cx(className, 'radioGroup', 'ui-shared__form__radio-group', {
65
+ disabled
66
+ }),
67
+ label: label,
68
+ labelStatic: true,
69
+ errorText: errorText,
70
+ translateErrorText: translateErrorText,
71
+ showErrorText: showErrorText,
72
+ htmlFor: "none",
73
+ hasUnderline: false,
74
+ hasValue: true,
75
+ children: /*#__PURE__*/_jsx("div", {
76
+ className: cx(classes.container, 'radioGroup'),
77
+ children: Children.map(children, child => {
78
+ if (!child) {
79
+ return null;
80
+ }
81
+ return /*#__PURE__*/cloneElement(child, {
82
+ key: `${name}_${child.props.name}`,
83
+ checked: selectedValue === child.props.name,
84
+ onChange: handleItemChange
85
+ });
96
86
  })
97
- });
98
- };
99
- return RadioGroup;
100
- }(Component);
87
+ })
88
+ });
89
+ };
101
90
  RadioGroup.defaultProps = {
102
91
  onChange: () => {},
103
92
  children: null,
@@ -1,139 +1,118 @@
1
- import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
- import React, { Component } from 'react';
1
+ import React, { useCallback, useEffect, useState } from 'react';
3
2
  import PropTypes from 'prop-types';
4
- import classNames from 'classnames';
3
+ import { makeStyles } from '@shopgate/engage/styles';
5
4
  import Chevron from "../../icons/ChevronIcon";
6
5
  import FormElement from "../../FormElement";
7
- import styles from "./style";
6
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
7
+ const useStyles = makeStyles()({
8
+ select: {
9
+ appearance: 'none',
10
+ position: 'relative',
11
+ overflow: 'hidden',
12
+ whiteSpace: 'nowrap',
13
+ textOverflow: 'ellipsis',
14
+ padding: '0 20px 0 0',
15
+ width: '100%',
16
+ margin: '24px 0 0 0',
17
+ outline: 0,
18
+ fontSize: 16,
19
+ lineHeight: '19px',
20
+ zIndex: 10
21
+ },
22
+ chevron: {
23
+ position: 'absolute',
24
+ top: '50%',
25
+ right: 0,
26
+ transform: 'translateY(-50%) rotateZ(-90deg)',
27
+ fontSize: '1.3em !important',
28
+ marginTop: -3
29
+ }
30
+ });
8
31
 
9
32
  /**
10
- * A component that provides a styled select for user input in material design.
33
+ * Styled select for material-style forms (native select + chevron).
34
+ * @param {Object} props Props.
35
+ * @returns {JSX.Element}
11
36
  */
12
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
- let Select = /*#__PURE__*/function (_Component) {
14
- /**
15
- * Creates a new text field component.
16
- * @param {Object} props The component properties.
17
- */
18
- function Select(props) {
19
- var _this;
20
- _this = _Component.call(this, props) || this;
21
- /**
22
- * @param {string} value The entered text.
23
- */
24
- _this.handleChange = ({
25
- target
26
- }) => {
27
- const {
28
- multiple
29
- } = _this.props;
30
- let {
31
- value
32
- } = target;
33
- if (multiple) {
34
- value = Array.from(target.selectedOptions, option => option.value);
35
- }
36
- if (!_this.props.isControlled) {
37
- _this.setState({
38
- value
39
- });
40
- }
41
- _this.props.onChange(value);
42
- };
43
- /**
44
- * @param {boolean} isFocused focused
45
- */
46
- _this.handleFocusChange = isFocused => {
47
- _this.setState({
48
- isFocused
49
- });
50
- };
51
- _this.state = {
52
- value: props.value,
53
- isFocused: false
54
- };
55
- return _this;
56
- }
57
-
58
- /**
59
- * Corrects the selected value to the first option when the initial value is not located within
60
- * the options.
61
- */
62
- _inheritsLoose(Select, _Component);
63
- var _proto = Select.prototype;
64
- _proto.componentDidMount = function componentDidMount() {
65
- const {
66
- multiple,
67
- options
68
- } = this.props;
69
- const {
70
- value
71
- } = this.state;
72
- if (!multiple && options?.[value] === undefined) {
73
- const fallback = Object.entries(options)?.[0]?.[0];
74
- if (fallback !== undefined) {
75
- this.handleChange({
76
- target: {
77
- value: fallback
78
- }
79
- });
80
- }
37
+ const Select = ({
38
+ name,
39
+ options,
40
+ translateErrorText,
41
+ disabled,
42
+ multiple,
43
+ size,
44
+ showErrorText,
45
+ className,
46
+ placeholder,
47
+ label,
48
+ errorText,
49
+ required,
50
+ isControlled,
51
+ onChange,
52
+ value: valueProp,
53
+ 'aria-invalid': ariaInvalid,
54
+ 'aria-describedby': ariaDescribedBy
55
+ }) => {
56
+ const {
57
+ classes,
58
+ cx
59
+ } = useStyles();
60
+ const [value, setValue] = useState(valueProp);
61
+ const [isFocused, setIsFocused] = useState(false);
62
+ useEffect(() => {
63
+ setValue(valueProp);
64
+ }, [valueProp]);
65
+ useEffect(() => {
66
+ if (multiple || options?.[valueProp] !== undefined) {
67
+ return;
81
68
  }
82
- }
83
-
84
- /**
85
- * Update state with new props.
86
- * @param {Object} nextProps The new props.
87
- */;
88
- _proto.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(nextProps) {
89
- this.setState({
90
- value: nextProps.value
91
- });
92
- };
93
- /**
94
- * @return {JSX.Element}
95
- */
96
- _proto.render = function render() {
97
- const {
98
- name,
99
- options,
100
- translateErrorText,
101
- disabled,
102
- multiple,
103
- size,
104
- showErrorText,
105
- className,
106
- placeholder,
107
- label,
108
- errorText,
109
- required,
110
- 'aria-invalid': ariaInvalid,
111
- 'aria-describedby': ariaDescribedBy
112
- } = this.props;
113
- const {
114
- value,
115
- isFocused
116
- } = this.state;
117
- return /*#__PURE__*/_jsxs(FormElement, {
118
- className: `${className} ui-shared__form__select`,
119
- placeholder: placeholder,
120
- htmlFor: name,
121
- label: label,
122
- errorText: errorText,
123
- translateErrorText: translateErrorText,
124
- isFocused: isFocused,
125
- hasValue: !!value || !!options[''],
126
- hasPlaceholder: !disabled || value !== '',
127
- disabled: disabled,
128
- showErrorText: showErrorText,
69
+ const fallback = Object.entries(options)?.[0]?.[0];
70
+ if (fallback === undefined) {
71
+ return;
72
+ }
73
+ if (!isControlled) {
74
+ setValue(fallback);
75
+ }
76
+ onChange(fallback);
77
+ // Intentionally mount-only (same as legacy componentDidMount).
78
+ // eslint-disable-next-line react-hooks/exhaustive-deps
79
+ }, []);
80
+ const handleChange = useCallback(({
81
+ target
82
+ }) => {
83
+ let next = target.value;
84
+ if (multiple) {
85
+ next = Array.from(target.selectedOptions, option => option.value);
86
+ }
87
+ if (!isControlled) {
88
+ setValue(next);
89
+ }
90
+ onChange(next);
91
+ }, [isControlled, multiple, onChange]);
92
+ const handleFocusChange = useCallback(focused => {
93
+ setIsFocused(focused);
94
+ }, []);
95
+ return /*#__PURE__*/_jsx(FormElement, {
96
+ className: cx(className, 'ui-shared__form__select'),
97
+ placeholder: placeholder,
98
+ htmlFor: name,
99
+ label: label,
100
+ errorText: errorText,
101
+ translateErrorText: translateErrorText,
102
+ isFocused: isFocused,
103
+ hasValue: !!value || !!options[''],
104
+ hasPlaceholder: !disabled || value !== '',
105
+ disabled: disabled,
106
+ showErrorText: showErrorText,
107
+ children: /*#__PURE__*/_jsxs(_Fragment, {
129
108
  children: [/*#__PURE__*/_jsx("select", {
130
109
  id: name,
131
110
  name: name,
132
- onChange: this.handleChange,
133
- onFocus: () => this.handleFocusChange(true),
134
- onBlur: () => this.handleFocusChange(false),
111
+ onChange: handleChange,
112
+ onFocus: () => handleFocusChange(true),
113
+ onBlur: () => handleFocusChange(false),
135
114
  value: value,
136
- className: classNames(styles.select, 'select'),
115
+ className: cx(classes.select, 'select'),
137
116
  disabled: disabled,
138
117
  required: required,
139
118
  "aria-invalid": ariaInvalid,
@@ -148,12 +127,11 @@ let Select = /*#__PURE__*/function (_Component) {
148
127
  children: options[key]
149
128
  }, `${name}_${key}`))
150
129
  }), /*#__PURE__*/_jsx(Chevron, {
151
- className: styles.chevron
130
+ className: classes.chevron
152
131
  })]
153
- });
154
- };
155
- return Select;
156
- }(Component);
132
+ })
133
+ });
134
+ };
157
135
  Select.defaultProps = {
158
136
  'aria-invalid': false,
159
137
  'aria-describedby': null,
@@ -1,17 +1,37 @@
1
+ import "core-js/modules/es.array.includes.js";
1
2
  import React, { useState, useCallback } from 'react';
2
3
  import PropTypes from 'prop-types';
3
4
  import pick from 'lodash/pick';
4
- import { i18n } from '@shopgate/engage/core';
5
+ import { i18n } from '@shopgate/engage/core/helpers';
6
+ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
7
+ import { makeStyles } from '@shopgate/engage/styles';
5
8
  import Chevron from "../../icons/ChevronIcon";
6
9
  import InfoField from "../InfoField";
7
10
  import ContextMenu from "../../ContextMenu";
8
- import styles from "./style";
11
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
+ const useStyles = makeStyles()({
13
+ chevron: {
14
+ position: 'absolute',
15
+ top: '50%',
16
+ right: 0,
17
+ transform: 'translateY(-50%) rotateZ(-90deg)',
18
+ fontSize: '1.3em !important',
19
+ marginTop: -3
20
+ },
21
+ toggle: {
22
+ fontSize: '1rem',
23
+ paddingRight: '2rem'
24
+ },
25
+ itemSelected: {
26
+ backgroundColor: themeConfig.colors.shade8,
27
+ fontWeight: 500
28
+ }
29
+ });
9
30
 
10
31
  /**
11
- * @param {Object} props .
32
+ * @param {Object} props Props.
12
33
  * @returns {JSX}
13
34
  */
14
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
15
35
  const SelectContextChoices = ({
16
36
  options,
17
37
  onChange,
@@ -22,6 +42,9 @@ const SelectContextChoices = ({
22
42
  errorText,
23
43
  showErrorText
24
44
  }) => {
45
+ const {
46
+ classes
47
+ } = useStyles();
25
48
  const [opened, setOpened] = useState(false);
26
49
  const onMenuChange = useCallback(({
27
50
  active
@@ -32,7 +55,6 @@ const SelectContextChoices = ({
32
55
  if (key === '') {
33
56
  onChange([]);
34
57
  } else if (value.includes(key)) {
35
- // Eliminate value
36
58
  onChange(value.filter(v => v !== key));
37
59
  } else {
38
60
  onChange([].concat(value, [key]));
@@ -47,14 +69,14 @@ const SelectContextChoices = ({
47
69
  showErrorText: showErrorText,
48
70
  hasValue: true,
49
71
  rightElement: /*#__PURE__*/_jsx(Chevron, {
50
- className: styles.chevron
72
+ className: classes.chevron
51
73
  }),
52
74
  children: [/*#__PURE__*/_jsxs("div", {
53
75
  role: "button",
54
76
  onClick: () => setOpened(true),
55
77
  "aria-hidden": true,
56
78
  tabIndex: "0",
57
- className: styles.toggle,
79
+ className: classes.toggle,
58
80
  children: [!hasValue && (placeholder || i18n.text('common.please_choose')), hasValue && values.join(', ')]
59
81
  }), /*#__PURE__*/_jsx(ContextMenu, {
60
82
  isOpened: opened,
@@ -64,7 +86,7 @@ const SelectContextChoices = ({
64
86
  children: Object.keys(options).map(key => /*#__PURE__*/_jsx(ContextMenu.Item, {
65
87
  autoClose: false,
66
88
  onClick: () => onItemClick(key),
67
- className: hasValue && value.includes(key) ? styles.itemSelected : '',
89
+ className: hasValue && value.includes(key) ? classes.itemSelected : '',
68
90
  children: options[key]
69
91
  }, key))
70
92
  })]