@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.
- package/ActionButton/index.js +66 -67
- package/AddToCartButton/index.js +217 -185
- package/Availability/index.js +24 -6
- package/Button/index.js +105 -82
- package/Button/spec.js +3 -4
- package/Card/index.js +26 -7
- package/CardList/components/Item/index.js +15 -3
- package/CartTotalLine/components/Amount/index.js +13 -4
- package/CartTotalLine/components/Hint/index.js +13 -4
- package/CartTotalLine/components/Label/index.js +23 -10
- package/CartTotalLine/index.js +41 -7
- package/Checkbox/index.js +41 -17
- package/Chip/index.js +82 -7
- package/ContextMenu/components/Item/index.js +38 -20
- package/ContextMenu/components/Position/index.js +38 -56
- package/ContextMenu/index.js +64 -28
- package/Dialog/components/BasicDialog/index.js +1 -0
- package/Dialog/components/HtmlContentDialog/spec.js +39 -0
- package/Dialog/components/PipelineErrorDialog/index.js +108 -157
- package/Dialog/components/PipelineErrorDialog/spec.js +12 -18
- package/Dialog/components/TextMessageDialog/index.js +1 -1
- package/Dialog/components/VariantSelectModal/index.js +1 -1
- package/Dialog/index.js +1 -1
- package/DiscountBadge/index.js +48 -15
- package/FavoritesButton/index.js +95 -100
- package/FavoritesButton/spec.js +5 -2
- package/Form/Builder/classes/ActionListener/index.js +1 -0
- package/Form/Checkbox/index.js +64 -56
- package/Form/InfoField/index.js +18 -6
- package/Form/Password/index.js +39 -52
- package/Form/RadioGroup/components/Item/index.js +72 -56
- package/Form/RadioGroup/index.js +79 -90
- package/Form/Select/index.js +108 -130
- package/Form/SelectContextChoices/index.js +30 -8
- package/Form/TextField/index.js +106 -82
- package/Form/TextField/spec.js +4 -3
- package/FormElement/components/ErrorText/index.js +32 -14
- package/FormElement/components/Label/index.js +56 -6
- package/FormElement/components/Placeholder/index.js +44 -11
- package/FormElement/components/Underline/index.js +63 -12
- package/FormElement/index.js +62 -85
- package/Glow/index.js +73 -83
- package/IndicatorCircle/index.js +73 -17
- package/IndicatorCircle/spec.js +2 -5
- package/LoadingIndicator/index.js +34 -12
- package/Manufacturer/index.js +21 -10
- package/MessageBar/index.js +12 -38
- package/NoResults/components/Icon/index.js +30 -14
- package/NoResults/index.js +35 -7
- package/Placeholder/index.js +34 -23
- package/PlaceholderLabel/index.js +17 -3
- package/Price/index.js +34 -21
- package/PriceInfo/index.js +23 -9
- package/PriceStriked/index.js +67 -77
- package/ProgressBar/index.js +112 -77
- package/RadioButton/index.js +29 -11
- package/RatingStars/index.js +122 -137
- package/Ripple/components/RippleAnimation/index.js +13 -3
- package/Ripple/index.js +158 -212
- package/RippleButton/index.js +63 -60
- package/RippleButton/spec.js +15 -9
- package/ScannerOverlay/components/CameraOverlay/index.js +54 -10
- package/ScannerOverlay/components/ScannerBar/components/FlashlightButton/index.js +53 -27
- package/ScannerOverlay/components/ScannerBar/index.js +50 -26
- package/Sheet/components/Header/components/SearchBar/index.js +54 -10
- package/Sheet/components/Header/index.js +96 -76
- package/Sheet/index.js +295 -157
- package/Sheet/spec.js +8 -6
- package/TaxDisclaimer/index.js +17 -4
- package/TaxDisclaimer/spec.js +16 -5
- package/TextField/components/ErrorText/index.js +35 -14
- package/TextField/components/FormElement/index.js +29 -4
- package/TextField/components/Hint/index.js +39 -10
- package/TextField/components/Label/index.js +43 -6
- package/TextField/components/Underline/index.js +64 -13
- package/TextField/index.js +157 -171
- package/TextField/spec.js +5 -3
- package/icons/AccountBoxIcon.d.ts +7 -0
- package/icons/AccountBoxIcon.d.ts.map +1 -0
- package/icons/AccountBoxIcon.js +1 -4
- package/icons/AddMoreIcon.d.ts +7 -0
- package/icons/AddMoreIcon.d.ts.map +1 -0
- package/icons/AddMoreIcon.js +0 -3
- package/icons/ArrowDropIcon.d.ts +7 -0
- package/icons/ArrowDropIcon.d.ts.map +1 -0
- package/icons/ArrowDropIcon.js +0 -3
- package/icons/ArrowIcon.d.ts +10 -0
- package/icons/ArrowIcon.d.ts.map +1 -0
- package/icons/ArrowIcon.js +2 -11
- package/icons/BarcodeScannerIcon.d.ts +7 -0
- package/icons/BarcodeScannerIcon.d.ts.map +1 -0
- package/icons/BarcodeScannerIcon.js +0 -3
- package/icons/BoxIcon.d.ts +7 -0
- package/icons/BoxIcon.d.ts.map +1 -0
- package/icons/BoxIcon.js +0 -3
- package/icons/BrowseIcon.d.ts +7 -0
- package/icons/BrowseIcon.d.ts.map +1 -0
- package/icons/BrowseIcon.js +1 -3
- package/icons/BurgerIcon.d.ts +7 -0
- package/icons/BurgerIcon.d.ts.map +1 -0
- package/icons/BurgerIcon.js +0 -3
- package/icons/CalendarIcon.d.ts +7 -0
- package/icons/CalendarIcon.d.ts.map +1 -0
- package/icons/CalendarIcon.js +0 -2
- package/icons/CartCouponIcon.d.ts +7 -0
- package/icons/CartCouponIcon.d.ts.map +1 -0
- package/icons/CartCouponIcon.js +0 -2
- package/icons/CartIcon.d.ts +7 -0
- package/icons/CartIcon.d.ts.map +1 -0
- package/icons/CartIcon.js +0 -2
- package/icons/CartPlusIcon.d.ts +7 -0
- package/icons/CartPlusIcon.d.ts.map +1 -0
- package/icons/CartPlusIcon.js +0 -2
- package/icons/CheckIcon.d.ts +7 -0
- package/icons/CheckIcon.d.ts.map +1 -0
- package/icons/CheckIcon.js +0 -2
- package/icons/CheckedIcon.d.ts +7 -0
- package/icons/CheckedIcon.d.ts.map +1 -0
- package/icons/CheckedIcon.js +0 -3
- package/icons/ChevronIcon.d.ts +7 -0
- package/icons/ChevronIcon.d.ts.map +1 -0
- package/icons/ChevronIcon.js +0 -2
- package/icons/CreditCardIcon.d.ts +7 -0
- package/icons/CreditCardIcon.d.ts.map +1 -0
- package/icons/CreditCardIcon.js +0 -2
- package/icons/CrossIcon.d.ts +7 -0
- package/icons/CrossIcon.d.ts.map +1 -0
- package/icons/CrossIcon.js +0 -2
- package/icons/DescriptionIcon.d.ts +7 -0
- package/icons/DescriptionIcon.d.ts.map +1 -0
- package/icons/DescriptionIcon.js +0 -2
- package/icons/FilterIcon.d.ts +7 -0
- package/icons/FilterIcon.d.ts.map +1 -0
- package/icons/FilterIcon.js +0 -2
- package/icons/FlashDisabledIcon.d.ts +7 -0
- package/icons/FlashDisabledIcon.d.ts.map +1 -0
- package/icons/FlashDisabledIcon.js +0 -2
- package/icons/FlashEnabledIcon.d.ts +7 -0
- package/icons/FlashEnabledIcon.d.ts.map +1 -0
- package/icons/FlashEnabledIcon.js +0 -2
- package/icons/GridIcon.d.ts +7 -0
- package/icons/GridIcon.d.ts.map +1 -0
- package/icons/GridIcon.js +1 -3
- package/icons/HeartIcon.d.ts +7 -0
- package/icons/HeartIcon.d.ts.map +1 -0
- package/icons/HeartIcon.js +0 -2
- package/icons/HeartOutlineIcon.d.ts +7 -0
- package/icons/HeartOutlineIcon.d.ts.map +1 -0
- package/icons/HeartOutlineIcon.js +1 -3
- package/icons/HeartPlusIcon.d.ts +7 -0
- package/icons/HeartPlusIcon.d.ts.map +1 -0
- package/icons/HeartPlusIcon.js +1 -3
- package/icons/HeartPlusOutlineIcon.d.ts +7 -0
- package/icons/HeartPlusOutlineIcon.d.ts.map +1 -0
- package/icons/HeartPlusOutlineIcon.js +1 -3
- package/icons/HomeIcon.d.ts +7 -0
- package/icons/HomeIcon.d.ts.map +1 -0
- package/icons/HomeIcon.js +0 -2
- package/icons/InfoIcon.d.ts +7 -0
- package/icons/InfoIcon.d.ts.map +1 -0
- package/icons/InfoIcon.js +0 -2
- package/icons/InfoOutlineIcon.d.ts +7 -0
- package/icons/InfoOutlineIcon.d.ts.map +1 -0
- package/icons/InfoOutlineIcon.js +0 -2
- package/icons/ListIcon.d.ts +7 -0
- package/icons/ListIcon.d.ts.map +1 -0
- package/icons/ListIcon.js +0 -2
- package/icons/LocalShippingIcon.d.ts +7 -0
- package/icons/LocalShippingIcon.d.ts.map +1 -0
- package/icons/LocalShippingIcon.js +0 -2
- package/icons/LocationIcon.d.ts +7 -0
- package/icons/LocationIcon.d.ts.map +1 -0
- package/icons/LocationIcon.js +1 -4
- package/icons/LocatorIcon.d.ts +7 -0
- package/icons/LocatorIcon.d.ts.map +1 -0
- package/icons/LocatorIcon.js +1 -3
- package/icons/LockIcon.d.ts +9 -0
- package/icons/LockIcon.d.ts.map +1 -0
- package/icons/LockIcon.js +1 -2
- package/icons/LogoutIcon.d.ts +7 -0
- package/icons/LogoutIcon.d.ts.map +1 -0
- package/icons/LogoutIcon.js +0 -2
- package/icons/MagnifierIcon.d.ts +7 -0
- package/icons/MagnifierIcon.d.ts.map +1 -0
- package/icons/MagnifierIcon.js +0 -2
- package/icons/MapMarkerIcon.d.ts +7 -0
- package/icons/MapMarkerIcon.d.ts.map +1 -0
- package/icons/MapMarkerIcon.js +1 -3
- package/icons/MoreIcon.d.ts +7 -0
- package/icons/MoreIcon.d.ts.map +1 -0
- package/icons/MoreIcon.js +1 -3
- package/icons/MoreVertIcon.d.ts +7 -0
- package/icons/MoreVertIcon.d.ts.map +1 -0
- package/icons/MoreVertIcon.js +1 -3
- package/icons/NotificationIcon.d.ts +7 -0
- package/icons/NotificationIcon.d.ts.map +1 -0
- package/icons/NotificationIcon.js +1 -3
- package/icons/PersonIcon.d.ts +9 -0
- package/icons/PersonIcon.d.ts.map +1 -0
- package/icons/PersonIcon.js +0 -3
- package/icons/PhoneIcon.d.ts +7 -0
- package/icons/PhoneIcon.d.ts.map +1 -0
- package/icons/PhoneIcon.js +1 -4
- package/icons/PlaceholderIcon.d.ts +7 -0
- package/icons/PlaceholderIcon.d.ts.map +1 -0
- package/icons/PlaceholderIcon.js +0 -2
- package/icons/RadioCheckedIcon.d.ts +10 -0
- package/icons/RadioCheckedIcon.d.ts.map +1 -0
- package/icons/RadioCheckedIcon.js +0 -2
- package/icons/RadioUncheckedIcon.d.ts +10 -0
- package/icons/RadioUncheckedIcon.d.ts.map +1 -0
- package/icons/RadioUncheckedIcon.js +0 -2
- package/icons/SecurityIcon.d.ts +7 -0
- package/icons/SecurityIcon.d.ts.map +1 -0
- package/icons/SecurityIcon.js +0 -2
- package/icons/ShippingMethodIcon.d.ts +7 -0
- package/icons/ShippingMethodIcon.d.ts.map +1 -0
- package/icons/ShippingMethodIcon.js +0 -2
- package/icons/ShoppingCartIcon.d.ts +7 -0
- package/icons/ShoppingCartIcon.d.ts.map +1 -0
- package/icons/ShoppingCartIcon.js +0 -2
- package/icons/SortIcon.d.ts +7 -0
- package/icons/SortIcon.d.ts.map +1 -0
- package/icons/SortIcon.js +0 -2
- package/icons/StarHalfIcon.d.ts +7 -0
- package/icons/StarHalfIcon.d.ts.map +1 -0
- package/icons/StarHalfIcon.js +0 -9
- package/icons/StarIcon.d.ts +7 -0
- package/icons/StarIcon.d.ts.map +1 -0
- package/icons/StarIcon.js +0 -9
- package/icons/StarOutlineIcon.d.ts +7 -0
- package/icons/StarOutlineIcon.d.ts.map +1 -0
- package/icons/StarOutlineIcon.js +0 -2
- package/icons/StopIcon.d.ts +7 -0
- package/icons/StopIcon.d.ts.map +1 -0
- package/icons/StopIcon.js +0 -2
- package/icons/TickIcon.d.ts +7 -0
- package/icons/TickIcon.d.ts.map +1 -0
- package/icons/TickIcon.js +0 -2
- package/icons/TimeIcon.d.ts +7 -0
- package/icons/TimeIcon.d.ts.map +1 -0
- package/icons/TimeIcon.js +0 -2
- package/icons/TrashIcon.d.ts +7 -0
- package/icons/TrashIcon.d.ts.map +1 -0
- package/icons/TrashIcon.js +0 -3
- package/icons/TrashOutlineIcon.d.ts +8 -0
- package/icons/TrashOutlineIcon.d.ts.map +1 -0
- package/icons/TrashOutlineIcon.js +0 -2
- package/icons/UncheckedIcon.d.ts +7 -0
- package/icons/UncheckedIcon.d.ts.map +1 -0
- package/icons/UncheckedIcon.js +0 -2
- package/icons/ViewListIcon.d.ts +7 -0
- package/icons/ViewListIcon.d.ts.map +1 -0
- package/icons/ViewListIcon.js +0 -2
- package/icons/VisibilityIcon.d.ts +8 -0
- package/icons/VisibilityIcon.d.ts.map +1 -0
- package/icons/VisibilityIcon.js +2 -4
- package/icons/VisibilityOffIcon.d.ts +8 -0
- package/icons/VisibilityOffIcon.d.ts.map +1 -0
- package/icons/VisibilityOffIcon.js +2 -4
- package/icons/WarningIcon.d.ts +7 -0
- package/icons/WarningIcon.d.ts.map +1 -0
- package/icons/WarningIcon.js +1 -3
- package/package.json +5 -5
- package/tsconfig.build.json +16 -0
- package/tsconfig.json +3 -0
- package/ActionButton/style.js +0 -22
- package/AddToCartButton/style.js +0 -148
- package/Availability/style.js +0 -19
- package/Button/style.js +0 -155
- package/Card/style.js +0 -11
- package/CardList/components/Item/style.js +0 -7
- package/CartTotalLine/components/Amount/style.js +0 -8
- package/CartTotalLine/components/Hint/style.js +0 -12
- package/CartTotalLine/components/Label/style.js +0 -17
- package/CartTotalLine/style.js +0 -31
- package/Checkbox/style.js +0 -18
- package/Chip/style.js +0 -78
- package/ContextMenu/components/Item/style.js +0 -34
- package/ContextMenu/components/Position/style.js +0 -11
- package/ContextMenu/style.js +0 -45
- package/DiscountBadge/style.js +0 -36
- package/FavoritesButton/style.js +0 -26
- package/Form/Checkbox/style.js +0 -25
- package/Form/InfoField/style.js +0 -11
- package/Form/Password/style.js +0 -11
- package/Form/RadioGroup/components/Item/style.js +0 -32
- package/Form/RadioGroup/style.js +0 -20
- package/Form/Select/style.js +0 -27
- package/Form/SelectContextChoices/style.js +0 -23
- package/Form/TextField/style.js +0 -70
- package/FormElement/components/ErrorText/style.js +0 -13
- package/FormElement/components/Label/style.js +0 -89
- package/FormElement/components/Placeholder/style.js +0 -56
- package/FormElement/components/Underline/style.js +0 -60
- package/FormElement/style.js +0 -14
- package/Glow/style.js +0 -18
- package/IndicatorCircle/style.js +0 -65
- package/LoadingIndicator/style.js +0 -20
- package/Manufacturer/style.js +0 -5
- package/MessageBar/spec.js +0 -80
- package/MessageBar/style.js +0 -38
- package/NoResults/components/Icon/style.js +0 -17
- package/NoResults/style.js +0 -31
- package/Placeholder/style.js +0 -11
- package/PlaceholderLabel/style.js +0 -12
- package/Price/style.js +0 -22
- package/PriceInfo/style.js +0 -5
- package/PriceStriked/style.js +0 -36
- package/ProgressBar/style.js +0 -85
- package/RadioButton/style.js +0 -21
- package/RatingStars/style.js +0 -53
- package/Ripple/style.js +0 -18
- package/ScannerOverlay/components/CameraOverlay/style.js +0 -40
- package/ScannerOverlay/components/ScannerBar/components/FlashlightButton/style.js +0 -28
- package/ScannerOverlay/components/ScannerBar/style.js +0 -20
- package/Sheet/components/Header/components/SearchBar/style.js +0 -47
- package/Sheet/components/Header/style.js +0 -50
- package/Sheet/style.js +0 -143
- package/TaxDisclaimer/style.js +0 -9
- package/TextField/components/ErrorText/style.js +0 -27
- package/TextField/components/FormElement/style.js +0 -34
- package/TextField/components/Hint/style.js +0 -46
- package/TextField/components/Label/style.js +0 -80
- package/TextField/components/Underline/style.js +0 -60
- package/TextField/style.js +0 -35
package/Form/TextField/index.js
CHANGED
|
@@ -1,97 +1,121 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React, { Component } from 'react';
|
|
1
|
+
import React, { useState, useCallback } from 'react';
|
|
3
2
|
import PropTypes from 'prop-types';
|
|
4
3
|
import Input from '@shopgate/pwa-common/components/Input';
|
|
5
4
|
import Grid from '@shopgate/pwa-common/components/Grid';
|
|
6
5
|
import FormElement from '@shopgate/pwa-ui-shared/FormElement';
|
|
7
|
-
import
|
|
6
|
+
import { makeStyles } from '@shopgate/engage/styles';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
|
-
*
|
|
9
|
+
* Default handler when an optional callback is omitted.
|
|
10
|
+
* @returns {void}
|
|
11
11
|
*/
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
const noop = () => {};
|
|
14
|
+
const bluredDateSelector = 'input[type="date"]:in-range:not(:focus)';
|
|
15
|
+
const webkitDateFields = ['::-webkit-datetime-edit-year-field', '::-webkit-datetime-edit-month-field', '::-webkit-datetime-edit-day-field', '::-webkit-datetime-edit-text'].map(suffix => `${bluredDateSelector}${suffix}`).join(', ');
|
|
16
|
+
const useStyles = makeStyles()({
|
|
17
|
+
container: {
|
|
18
|
+
'& input[type="date"]': {
|
|
19
|
+
minHeight: '1.3rem',
|
|
20
|
+
appearance: 'none',
|
|
21
|
+
paddingLeft: 0,
|
|
22
|
+
marginLeft: 0
|
|
23
|
+
},
|
|
24
|
+
[`& ${webkitDateFields}`]: {
|
|
25
|
+
padding: 0,
|
|
26
|
+
color: 'transparent'
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
input: {
|
|
30
|
+
position: 'relative',
|
|
31
|
+
padding: 0,
|
|
32
|
+
width: '100%',
|
|
33
|
+
marginTop: 24,
|
|
34
|
+
outline: 0,
|
|
35
|
+
fontSize: 16,
|
|
36
|
+
lineHeight: '19px'
|
|
37
|
+
},
|
|
38
|
+
multiLine: {
|
|
39
|
+
position: 'relative',
|
|
40
|
+
marginTop: 24,
|
|
41
|
+
marginBottom: 3,
|
|
42
|
+
padding: 0,
|
|
43
|
+
width: '100%',
|
|
44
|
+
outline: 0,
|
|
45
|
+
height: 19,
|
|
46
|
+
minHeight: 19,
|
|
47
|
+
lineHeight: '19px',
|
|
48
|
+
verticalAlign: 'top'
|
|
49
|
+
},
|
|
50
|
+
element: {
|
|
51
|
+
marginTop: 16,
|
|
52
|
+
display: 'flex',
|
|
53
|
+
alignItems: 'flex-end'
|
|
54
|
+
},
|
|
55
|
+
leftOffset: {
|
|
56
|
+
marginLeft: 2
|
|
57
|
+
}
|
|
58
|
+
});
|
|
14
59
|
|
|
15
60
|
/**
|
|
16
|
-
* TextField component
|
|
61
|
+
* TextField component (form wrapper with leading/trailing elements).
|
|
62
|
+
* @param {Object} allProps Props.
|
|
63
|
+
* @returns {JSX.Element}
|
|
17
64
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
children: leftElement
|
|
73
|
-
}), /*#__PURE__*/_jsx(Grid.Item, {
|
|
74
|
-
grow: 1,
|
|
75
|
-
className: style.container,
|
|
76
|
-
children: /*#__PURE__*/_jsx(Input, {
|
|
77
|
-
...props,
|
|
78
|
-
onFocusChange: this.handleFocusChange,
|
|
79
|
-
className: `
|
|
80
|
-
${style[props.multiLine ? 'multiLine' : 'input']}
|
|
81
|
-
${leftElement ? style.leftOffset : ''}
|
|
82
|
-
`,
|
|
83
|
-
validateOnBlur: true
|
|
84
|
-
})
|
|
85
|
-
}), rightElement && /*#__PURE__*/_jsx(Grid.Item, {
|
|
86
|
-
grow: 0,
|
|
87
|
-
className: style.element,
|
|
88
|
-
children: rightElement
|
|
89
|
-
})]
|
|
90
|
-
})
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
return TextField;
|
|
94
|
-
}(Component);
|
|
65
|
+
const TextField = allProps => {
|
|
66
|
+
const {
|
|
67
|
+
className,
|
|
68
|
+
placeholder,
|
|
69
|
+
label,
|
|
70
|
+
errorText,
|
|
71
|
+
leftElement,
|
|
72
|
+
rightElement,
|
|
73
|
+
hasUnderline,
|
|
74
|
+
onFocusChange,
|
|
75
|
+
...props
|
|
76
|
+
} = allProps;
|
|
77
|
+
const {
|
|
78
|
+
classes,
|
|
79
|
+
cx
|
|
80
|
+
} = useStyles();
|
|
81
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
82
|
+
const handleFocusChange = useCallback(focused => {
|
|
83
|
+
setIsFocused(focused);
|
|
84
|
+
onFocusChange(focused);
|
|
85
|
+
}, [onFocusChange]);
|
|
86
|
+
const inputTypeClass = props.multiLine ? classes.multiLine : classes.input;
|
|
87
|
+
return /*#__PURE__*/_jsx(FormElement, {
|
|
88
|
+
className: cx(className, 'ui-shared__form__text-field'),
|
|
89
|
+
htmlFor: props.name,
|
|
90
|
+
placeholder: placeholder,
|
|
91
|
+
label: label,
|
|
92
|
+
errorText: errorText,
|
|
93
|
+
hasLeftElement: !!leftElement,
|
|
94
|
+
hasUnderline: hasUnderline,
|
|
95
|
+
hasValue: !!props.value,
|
|
96
|
+
isFocused: isFocused,
|
|
97
|
+
children: /*#__PURE__*/_jsxs(Grid, {
|
|
98
|
+
children: [leftElement && /*#__PURE__*/_jsx(Grid.Item, {
|
|
99
|
+
grow: 0,
|
|
100
|
+
className: classes.element,
|
|
101
|
+
children: leftElement
|
|
102
|
+
}), /*#__PURE__*/_jsx(Grid.Item, {
|
|
103
|
+
grow: 1,
|
|
104
|
+
className: classes.container,
|
|
105
|
+
children: /*#__PURE__*/_jsx(Input, {
|
|
106
|
+
...props,
|
|
107
|
+
onFocusChange: handleFocusChange,
|
|
108
|
+
className: cx(inputTypeClass, leftElement && classes.leftOffset),
|
|
109
|
+
validateOnBlur: true
|
|
110
|
+
})
|
|
111
|
+
}), rightElement && /*#__PURE__*/_jsx(Grid.Item, {
|
|
112
|
+
grow: 0,
|
|
113
|
+
className: classes.element,
|
|
114
|
+
children: rightElement
|
|
115
|
+
})]
|
|
116
|
+
})
|
|
117
|
+
});
|
|
118
|
+
};
|
|
95
119
|
TextField.defaultProps = {
|
|
96
120
|
attributes: null,
|
|
97
121
|
className: '',
|
package/Form/TextField/spec.js
CHANGED
|
@@ -5,6 +5,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
5
5
|
const inputProps = {
|
|
6
6
|
name: 'test-input'
|
|
7
7
|
};
|
|
8
|
+
jest.mock('@shopgate/engage/components');
|
|
8
9
|
describe('<TextField>', () => {
|
|
9
10
|
it('should render a simple text field', () => {
|
|
10
11
|
const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
|
|
@@ -100,7 +101,7 @@ describe('<TextField>', () => {
|
|
|
100
101
|
errorText: errorText
|
|
101
102
|
}));
|
|
102
103
|
expect(wrapper).toMatchSnapshot();
|
|
103
|
-
expect(wrapper.find('ErrorText').find('
|
|
104
|
+
expect(wrapper.find('ErrorText').find('Text').at(0).props().string).toEqual(errorText);
|
|
104
105
|
});
|
|
105
106
|
it('should show the label', () => {
|
|
106
107
|
const label = 'This is the label';
|
|
@@ -109,7 +110,7 @@ describe('<TextField>', () => {
|
|
|
109
110
|
label: label
|
|
110
111
|
}));
|
|
111
112
|
expect(wrapper).toMatchSnapshot();
|
|
112
|
-
expect(wrapper.find('Label').find('
|
|
113
|
+
expect(wrapper.find('Label').find('Text').props().string).toEqual(label);
|
|
113
114
|
});
|
|
114
115
|
it('should show the placeholder text', () => {
|
|
115
116
|
const placeholder = 'This is the placeholder text';
|
|
@@ -118,6 +119,6 @@ describe('<TextField>', () => {
|
|
|
118
119
|
placeholder: placeholder
|
|
119
120
|
}));
|
|
120
121
|
expect(wrapper).toMatchSnapshot();
|
|
121
|
-
expect(wrapper.find('Placeholder').find('
|
|
122
|
+
expect(wrapper.find('Placeholder').find('Text').at(0).props().string).toEqual(placeholder);
|
|
122
123
|
});
|
|
123
124
|
});
|
|
@@ -1,31 +1,49 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
3
|
+
import { I18n } from '@shopgate/engage/components';
|
|
4
|
+
import { makeStyles } from '@shopgate/engage/styles';
|
|
5
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
const useStyles = makeStyles()(theme => ({
|
|
7
|
+
root: {
|
|
8
|
+
bottom: 2,
|
|
9
|
+
color: theme.palette.error.main,
|
|
10
|
+
fontSize: 12,
|
|
11
|
+
lineHeight: '14px',
|
|
12
|
+
overflow: 'hidden',
|
|
13
|
+
position: 'absolute',
|
|
14
|
+
textOverflow: 'ellipsis',
|
|
15
|
+
whiteSpace: 'nowrap',
|
|
16
|
+
width: '100%'
|
|
17
|
+
}
|
|
18
|
+
}));
|
|
6
19
|
|
|
7
20
|
/**
|
|
8
21
|
* Error message component.
|
|
9
22
|
* @param {Object} props The component props.
|
|
10
23
|
* @returns {JSX.Element}
|
|
11
24
|
*/
|
|
12
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
25
|
const ErrorText = ({
|
|
14
26
|
className,
|
|
15
27
|
errorText,
|
|
16
28
|
translate,
|
|
17
29
|
elementName,
|
|
18
30
|
ariaHidden
|
|
19
|
-
}) =>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
}) => {
|
|
32
|
+
const {
|
|
33
|
+
classes,
|
|
34
|
+
cx
|
|
35
|
+
} = useStyles();
|
|
36
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
37
|
+
id: `ariaError-${elementName}`,
|
|
38
|
+
className: cx(classes.root, 'errorText', className),
|
|
39
|
+
"aria-live": "assertive",
|
|
40
|
+
"aria-atomic": "true",
|
|
41
|
+
"aria-hidden": ariaHidden,
|
|
42
|
+
children: [translate && /*#__PURE__*/_jsx(I18n.Text, {
|
|
43
|
+
string: errorText
|
|
44
|
+
}), !translate && errorText]
|
|
45
|
+
});
|
|
46
|
+
};
|
|
29
47
|
ErrorText.defaultProps = {
|
|
30
48
|
className: null,
|
|
31
49
|
errorText: null,
|
|
@@ -1,15 +1,54 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
3
|
+
import { I18n } from '@shopgate/engage/components';
|
|
4
|
+
import { makeStyles } from '@shopgate/engage/styles';
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
const easing = '450ms cubic-bezier(0.23, 1, 0.32, 1)';
|
|
7
|
+
const ellipsisLine = {
|
|
8
|
+
overflow: 'hidden',
|
|
9
|
+
width: '100%',
|
|
10
|
+
whiteSpace: 'nowrap',
|
|
11
|
+
textOverflow: 'ellipsis'
|
|
12
|
+
};
|
|
13
|
+
const useStyles = makeStyles()(theme => ({
|
|
14
|
+
label: {
|
|
15
|
+
position: 'absolute',
|
|
16
|
+
left: 0,
|
|
17
|
+
top: 24,
|
|
18
|
+
lineHeight: '19px',
|
|
19
|
+
pointerEvents: 'none',
|
|
20
|
+
userSelect: 'none',
|
|
21
|
+
color: 'var(--color-text-medium-emphasis)',
|
|
22
|
+
transformOrigin: 'left top 0px',
|
|
23
|
+
willChange: 'transform, color',
|
|
24
|
+
overflow: 'visible',
|
|
25
|
+
transition: `transform ${easing}, color ${easing}`,
|
|
26
|
+
...ellipsisLine
|
|
27
|
+
},
|
|
28
|
+
labelStatic: {
|
|
29
|
+
opacity: 1,
|
|
30
|
+
lineHeight: '19px',
|
|
31
|
+
pointerEvents: 'none',
|
|
32
|
+
userSelect: 'none',
|
|
33
|
+
color: 'var(--color-text-medium-emphasis)'
|
|
34
|
+
},
|
|
35
|
+
labelFloating: {
|
|
36
|
+
transform: 'translate3d(0, -22px, 0) scale3d(0.75, 0.75, 0.75)',
|
|
37
|
+
opacity: 1
|
|
38
|
+
},
|
|
39
|
+
labelRegular: {
|
|
40
|
+
opacity: 0
|
|
41
|
+
},
|
|
42
|
+
labelError: {
|
|
43
|
+
color: theme.palette.error.main
|
|
44
|
+
}
|
|
45
|
+
}));
|
|
6
46
|
|
|
7
47
|
/**
|
|
8
48
|
* Renders the label element.
|
|
9
49
|
* @param {Object} props The component props.
|
|
10
50
|
* @return {JSX}
|
|
11
51
|
*/
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
52
|
const Label = ({
|
|
14
53
|
hasErrorMessage,
|
|
15
54
|
htmlFor,
|
|
@@ -18,10 +57,21 @@ const Label = ({
|
|
|
18
57
|
label,
|
|
19
58
|
labelStatic
|
|
20
59
|
}) => {
|
|
21
|
-
const
|
|
60
|
+
const {
|
|
61
|
+
classes,
|
|
62
|
+
cx
|
|
63
|
+
} = useStyles();
|
|
22
64
|
return /*#__PURE__*/ /* eslint-disable-next-line jsx-a11y/label-has-associated-control */_jsx("label", {
|
|
23
65
|
htmlFor: htmlFor,
|
|
24
|
-
className:
|
|
66
|
+
className: cx({
|
|
67
|
+
[classes.label]: !labelStatic,
|
|
68
|
+
[classes.labelStatic]: labelStatic,
|
|
69
|
+
[classes.labelFloating]: isFloating,
|
|
70
|
+
// Hide label only when placeholder is shown (empty + blurred). When floating or
|
|
71
|
+
// static, never apply opacity: 0 — JSS rule order differs from glamor injection order.
|
|
72
|
+
[classes.labelRegular]: !labelStatic && !isFloating && !isFocused,
|
|
73
|
+
[classes.labelError]: hasErrorMessage && isFocused
|
|
74
|
+
}, 'label', {
|
|
25
75
|
floating: isFloating
|
|
26
76
|
}),
|
|
27
77
|
children: /*#__PURE__*/_jsx(I18n.Text, {
|
|
@@ -1,8 +1,33 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
3
|
+
import { I18n } from '@shopgate/engage/components';
|
|
4
|
+
import { makeStyles } from '@shopgate/engage/styles';
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
const easing = '450ms cubic-bezier(0.23, 1, 0.32, 1)';
|
|
7
|
+
const ellipsisLine = {
|
|
8
|
+
overflow: 'hidden',
|
|
9
|
+
width: '100%',
|
|
10
|
+
whiteSpace: 'nowrap',
|
|
11
|
+
textOverflow: 'ellipsis'
|
|
12
|
+
};
|
|
13
|
+
const useStyles = makeStyles()({
|
|
14
|
+
placeholder: {
|
|
15
|
+
position: 'absolute',
|
|
16
|
+
pointerEvents: 'none',
|
|
17
|
+
top: 24,
|
|
18
|
+
color: 'var(--color-text-medium-emphasis)',
|
|
19
|
+
willChange: 'transform',
|
|
20
|
+
transition: `opacity ${easing}`,
|
|
21
|
+
...ellipsisLine
|
|
22
|
+
},
|
|
23
|
+
placeholderInactive: {
|
|
24
|
+
opacity: 0
|
|
25
|
+
},
|
|
26
|
+
leftOffset: {
|
|
27
|
+
left: 'var(--form-element-left-offset, 26px)',
|
|
28
|
+
width: 'calc(100% - var(--form-element-left-offset, 26px))'
|
|
29
|
+
}
|
|
30
|
+
});
|
|
6
31
|
|
|
7
32
|
/**
|
|
8
33
|
* The form element placeholder component.
|
|
@@ -12,19 +37,27 @@ import styles from "./style";
|
|
|
12
37
|
* @param {boolean} hasLeftElement Whether a left element is present
|
|
13
38
|
* @return {JSX.Element}
|
|
14
39
|
*/
|
|
15
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
40
|
const Placeholder = ({
|
|
17
41
|
placeholder,
|
|
18
42
|
visible,
|
|
19
43
|
'aria-hidden': ariaHidden,
|
|
20
44
|
hasLeftElement
|
|
21
|
-
}) =>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
45
|
+
}) => {
|
|
46
|
+
const {
|
|
47
|
+
classes,
|
|
48
|
+
cx
|
|
49
|
+
} = useStyles();
|
|
50
|
+
return /*#__PURE__*/_jsx("div", {
|
|
51
|
+
className: cx(classes.placeholder, {
|
|
52
|
+
[classes.placeholderInactive]: !visible,
|
|
53
|
+
[classes.leftOffset]: hasLeftElement
|
|
54
|
+
}, 'placeholder'),
|
|
55
|
+
"aria-hidden": ariaHidden,
|
|
56
|
+
children: /*#__PURE__*/_jsx(I18n.Text, {
|
|
57
|
+
string: placeholder
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
};
|
|
28
61
|
Placeholder.defaultProps = {
|
|
29
62
|
'aria-hidden': null,
|
|
30
63
|
hasLeftElement: false,
|
|
@@ -1,21 +1,72 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import color from 'color';
|
|
4
|
+
import { getCSSCustomProp, makeStyles, useTheme } from '@shopgate/engage/styles';
|
|
5
|
+
import { themeConfig } from '@shopgate/pwa-common/helpers/config';
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
const {
|
|
8
|
+
colors
|
|
9
|
+
} = themeConfig;
|
|
10
|
+
const easing = '450ms cubic-bezier(0.23, 1, 0.32, 1)';
|
|
11
|
+
const useStyles = makeStyles()({
|
|
12
|
+
underlineWrapper: {
|
|
13
|
+
position: 'relative',
|
|
14
|
+
width: '100%',
|
|
15
|
+
borderBottom: `1px solid ${colors.shade12}`,
|
|
16
|
+
marginTop: 2,
|
|
17
|
+
marginBottom: 7
|
|
18
|
+
},
|
|
19
|
+
underline: {
|
|
20
|
+
position: 'relative',
|
|
21
|
+
width: '100%',
|
|
22
|
+
top: 1,
|
|
23
|
+
borderBottomWidth: 2,
|
|
24
|
+
borderBottomStyle: 'solid',
|
|
25
|
+
willChange: 'transform',
|
|
26
|
+
transition: `transform ${easing}`
|
|
27
|
+
}
|
|
28
|
+
});
|
|
5
29
|
|
|
6
30
|
/**
|
|
7
|
-
*
|
|
8
|
-
* @param {
|
|
31
|
+
* Returns the underline inline style (border color + scale).
|
|
32
|
+
* @param {boolean} focused Is focused set or not.
|
|
33
|
+
* @param {boolean} hasError Has error set or not.
|
|
34
|
+
* @param {string} errorColor Theme error main color.
|
|
35
|
+
* @return {Object} style
|
|
36
|
+
*/
|
|
37
|
+
const getUnderlineStyle = (focused, hasError, errorColor) => {
|
|
38
|
+
const primaryColor = getCSSCustomProp('--color-primary') || colors.primary;
|
|
39
|
+
let focusColor = '--color-primary';
|
|
40
|
+
if (color(primaryColor).luminosity() >= 0.8) {
|
|
41
|
+
focusColor = '--color-secondary';
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
borderBottomColor: hasError ? errorColor : `var(${focusColor}, ${colors.focus})`,
|
|
45
|
+
...(!focused && !hasError && {
|
|
46
|
+
transform: 'scale3d(0,1,1)'
|
|
47
|
+
})
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Renders the underline element.
|
|
53
|
+
* @param {Object} props The component props.
|
|
9
54
|
* @return {JSX}
|
|
10
55
|
*/
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
56
|
+
const Underline = props => {
|
|
57
|
+
const theme = useTheme();
|
|
58
|
+
const {
|
|
59
|
+
classes,
|
|
60
|
+
cx
|
|
61
|
+
} = useStyles();
|
|
62
|
+
return /*#__PURE__*/_jsx("div", {
|
|
63
|
+
className: cx(classes.underlineWrapper, 'underline'),
|
|
64
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
65
|
+
className: classes.underline,
|
|
66
|
+
style: getUnderlineStyle(props.isFocused, props.hasErrorMessage, theme.palette.error.main)
|
|
67
|
+
})
|
|
68
|
+
});
|
|
69
|
+
};
|
|
19
70
|
Underline.defaultProps = {
|
|
20
71
|
isFocused: false,
|
|
21
72
|
hasErrorMessage: false
|