@shopgate/pwa-ui-shared 7.30.0-alpha.7 → 7.30.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AccordionContainer/index.js +39 -5
- package/AccordionContainer/spec.js +25 -2
- package/ActionButton/index.js +63 -7
- package/ActionButton/spec.js +63 -2
- package/ActionButton/style.js +22 -1
- package/AddToCartButton/index.js +184 -27
- package/AddToCartButton/mock.js +18 -4
- package/AddToCartButton/spec.js +65 -2
- package/AddToCartButton/style.js +127 -11
- package/Availability/index.js +34 -2
- package/Availability/spec.js +41 -1
- package/Availability/style.js +19 -1
- package/Button/index.js +76 -5
- package/Button/spec.js +33 -1
- package/Button/style.js +130 -21
- package/ButtonLink/connector.js +11 -2
- package/ButtonLink/index.js +44 -6
- package/ButtonLink/spec.js +23 -1
- package/Card/index.js +19 -2
- package/Card/style.js +11 -1
- package/CardList/components/Item/index.js +26 -2
- package/CardList/components/Item/style.js +7 -1
- package/CardList/index.js +34 -3
- package/CartTotalLine/components/Amount/index.js +28 -2
- package/CartTotalLine/components/Amount/style.js +8 -1
- package/CartTotalLine/components/Hint/index.js +23 -2
- package/CartTotalLine/components/Hint/style.js +12 -1
- package/CartTotalLine/components/Label/index.js +36 -2
- package/CartTotalLine/components/Label/style.js +17 -1
- package/CartTotalLine/components/Spacer/index.js +16 -2
- package/CartTotalLine/index.js +39 -2
- package/CartTotalLine/style.js +31 -1
- package/Checkbox/index.js +31 -2
- package/Checkbox/style.js +18 -1
- package/Chip/index.js +61 -2
- package/Chip/spec.js +24 -1
- package/Chip/style.js +71 -3
- package/ContextMenu/ContextMenu.hooks.js +6 -2
- package/ContextMenu/ContextMenuProvider.context.js +9 -3
- package/ContextMenu/ContextMenuProvider.js +21 -2
- package/ContextMenu/components/Item/index.js +67 -5
- package/ContextMenu/components/Item/style.js +32 -3
- package/ContextMenu/components/Position/index.js +61 -10
- package/ContextMenu/components/Position/style.js +11 -1
- package/ContextMenu/index.js +124 -3
- package/ContextMenu/spec.js +101 -2
- package/ContextMenu/style.js +45 -1
- package/Dialog/components/BasicDialog/index.js +5 -1
- package/Dialog/components/HtmlContentDialog/index.js +22 -2
- package/Dialog/components/HtmlContentDialog/spec.js +59 -1
- package/Dialog/components/PipelineErrorDialog/index.js +114 -25
- package/Dialog/components/PipelineErrorDialog/spec.js +92 -12
- package/Dialog/components/TextMessageDialog/index.js +28 -2
- package/Dialog/components/TextMessageDialog/spec.js +59 -1
- package/Dialog/components/VariantSelectModal/connector.js +11 -2
- package/Dialog/components/VariantSelectModal/index.js +65 -6
- package/Dialog/components/VariantSelectModal/spec.js +51 -2
- package/Dialog/constants.js +6 -1
- package/Dialog/index.js +114 -7
- package/Dialog/spec.js +81 -3
- package/DiscountBadge/index.js +30 -2
- package/DiscountBadge/spec.js +19 -1
- package/DiscountBadge/style.js +34 -2
- package/FavoritesButton/connector.js +18 -3
- package/FavoritesButton/index.js +118 -15
- package/FavoritesButton/mock.js +50 -4
- package/FavoritesButton/spec.js +120 -2
- package/FavoritesButton/style.js +26 -1
- package/Form/Builder/builders/buildCountryList.js +40 -6
- package/Form/Builder/builders/buildFormDefaults.js +35 -6
- package/Form/Builder/builders/buildFormElements.js +68 -10
- package/Form/Builder/builders/buildProvinceList.js +19 -2
- package/Form/Builder/builders/buildValidationErrorList.js +7 -2
- package/Form/Builder/classes/ActionListener/constants.js +22 -2
- package/Form/Builder/classes/ActionListener/index.js +441 -93
- package/Form/Builder/classes/ActionListener/spec.js +321 -19
- package/Form/Builder/components/CheckboxElement.js +35 -3
- package/Form/Builder/components/CountryElement.js +40 -3
- package/Form/Builder/components/ProvinceElement.js +40 -3
- package/Form/Builder/components/RadioElement.js +41 -3
- package/Form/Builder/components/SelectElement.js +39 -3
- package/Form/Builder/components/TextElement.js +49 -4
- package/Form/Builder/elementTypes.js +11 -1
- package/Form/Builder/index.js +298 -52
- package/Form/Builder/iso-3166-2.js +4943 -1
- package/Form/Builder/spec.js +308 -16
- package/Form/Checkbox/index.js +66 -4
- package/Form/Checkbox/style.js +25 -2
- package/Form/InfoField/index.js +50 -2
- package/Form/InfoField/spec.js +9 -1
- package/Form/InfoField/style.js +11 -1
- package/Form/Password/index.js +51 -6
- package/Form/Password/spec.js +34 -1
- package/Form/Password/style.js +11 -1
- package/Form/RadioGroup/components/Item/index.js +59 -3
- package/Form/RadioGroup/components/Item/style.js +32 -2
- package/Form/RadioGroup/index.js +101 -9
- package/Form/RadioGroup/spec.js +83 -3
- package/Form/RadioGroup/style.js +18 -2
- package/Form/Select/index.js +158 -10
- package/Form/Select/spec.js +36 -5
- package/Form/Select/style.js +27 -1
- package/Form/SelectContextChoices/index.js +77 -3
- package/Form/SelectContextChoices/spec.js +33 -4
- package/Form/SelectContextChoices/style.js +23 -1
- package/Form/TextField/index.js +92 -8
- package/Form/TextField/spec.js +110 -1
- package/Form/TextField/style.js +66 -8
- package/Form/index.js +54 -13
- package/FormElement/components/ErrorText/index.js +31 -2
- package/FormElement/components/ErrorText/style.js +13 -1
- package/FormElement/components/Label/index.js +35 -2
- package/FormElement/components/Label/style.js +76 -8
- package/FormElement/components/Placeholder/index.js +26 -2
- package/FormElement/components/Placeholder/style.js +48 -6
- package/FormElement/components/Underline/index.js +18 -2
- package/FormElement/components/Underline/style.js +51 -4
- package/FormElement/index.js +91 -6
- package/FormElement/spec.js +67 -2
- package/FormElement/style.js +13 -2
- package/Glow/index.js +90 -7
- package/Glow/spec.js +9 -1
- package/Glow/style.js +18 -1
- package/IndicatorCircle/index.js +33 -3
- package/IndicatorCircle/spec.js +28 -1
- package/IndicatorCircle/style.js +57 -3
- package/LoadingIndicator/index.js +29 -2
- package/LoadingIndicator/style.js +20 -1
- package/Manufacturer/index.js +20 -2
- package/Manufacturer/style.js +5 -1
- package/MessageBar/index.js +36 -2
- package/MessageBar/spec.js +79 -1
- package/MessageBar/style.js +38 -1
- package/NoResults/components/Icon/index.js +130 -2
- package/NoResults/components/Icon/style.js +17 -1
- package/NoResults/index.js +46 -2
- package/NoResults/style.js +31 -1
- package/Placeholder/index.js +25 -3
- package/Placeholder/style.js +11 -1
- package/PlaceholderLabel/index.js +27 -2
- package/PlaceholderLabel/spec.js +19 -1
- package/PlaceholderLabel/style.js +12 -1
- package/PlaceholderParagraph/index.js +36 -2
- package/PlaceholderParagraph/spec.js +19 -1
- package/Price/index.js +88 -7
- package/Price/style.js +22 -1
- package/PriceInfo/index.js +20 -2
- package/PriceInfo/style.js +5 -1
- package/PriceStriked/index.js +83 -12
- package/PriceStriked/style.js +33 -3
- package/ProductProperties/index.js +32 -2
- package/ProgressBar/index.js +101 -13
- package/ProgressBar/spec.js +13 -1
- package/ProgressBar/style.js +83 -2
- package/RadioButton/index.js +18 -2
- package/RadioButton/spec.js +21 -1
- package/RadioButton/style.js +21 -1
- package/RatingNumber/index.js +29 -2
- package/RatingStars/constants.js +2 -1
- package/RatingStars/index.js +130 -12
- package/RatingStars/spec.js +90 -3
- package/RatingStars/style.js +51 -2
- package/Ripple/components/RippleAnimation/index.js +88 -6
- package/Ripple/index.js +218 -40
- package/Ripple/style.js +18 -1
- package/RippleButton/index.js +52 -5
- package/RippleButton/spec.js +45 -1
- package/ScannerOverlay/components/CameraOverlay/index.js +13 -2
- package/ScannerOverlay/components/CameraOverlay/style.js +40 -1
- package/ScannerOverlay/components/ScannerBar/components/FlashlightButton/index.js +34 -2
- package/ScannerOverlay/components/ScannerBar/components/FlashlightButton/style.js +28 -1
- package/ScannerOverlay/components/ScannerBar/components/ScannerInstructions/index.js +11 -2
- package/ScannerOverlay/components/ScannerBar/index.js +31 -2
- package/ScannerOverlay/components/ScannerBar/style.js +20 -1
- package/ScannerOverlay/index.js +47 -7
- package/Sheet/components/Header/components/SearchBar/index.js +46 -2
- package/Sheet/components/Header/components/SearchBar/spec.js +21 -3
- package/Sheet/components/Header/components/SearchBar/style.js +47 -1
- package/Sheet/components/Header/index.js +75 -7
- package/Sheet/components/Header/spec.js +14 -1
- package/Sheet/components/Header/style.js +50 -1
- package/Sheet/index.js +170 -17
- package/Sheet/spec.js +85 -5
- package/Sheet/style.js +143 -2
- package/TaxDisclaimer/index.js +34 -4
- package/TaxDisclaimer/spec.js +31 -3
- package/TaxDisclaimer/style.js +9 -1
- package/TextField/components/ErrorText/index.js +33 -2
- package/TextField/components/ErrorText/style.js +25 -3
- package/TextField/components/FormElement/index.js +19 -2
- package/TextField/components/FormElement/style.js +32 -4
- package/TextField/components/Hint/index.js +21 -2
- package/TextField/components/Hint/style.js +40 -5
- package/TextField/components/Label/index.js +32 -3
- package/TextField/components/Label/style.js +68 -8
- package/TextField/components/Underline/index.js +19 -2
- package/TextField/components/Underline/style.js +51 -4
- package/TextField/index.js +189 -27
- package/TextField/spec.js +128 -3
- package/TextField/style.js +34 -4
- package/ToggleIcon/index.js +58 -8
- package/ToggleIcon/spec.js +35 -1
- package/icons/AccountBoxIcon.js +11 -2
- package/icons/AddMoreIcon.js +11 -2
- package/icons/ArrowDropIcon.js +11 -2
- package/icons/ArrowIcon.js +21 -2
- package/icons/BarcodeScannerIcon.js +11 -2
- package/icons/BoxIcon.js +11 -2
- package/icons/BrowseIcon.js +11 -2
- package/icons/BurgerIcon.js +11 -2
- package/icons/CalendarIcon.js +15 -3
- package/icons/CartCouponIcon.js +72 -2
- package/icons/CartIcon.js +11 -2
- package/icons/CartPlusIcon.js +11 -2
- package/icons/CheckIcon.js +11 -2
- package/icons/CheckedIcon.js +11 -2
- package/icons/ChevronIcon.js +11 -2
- package/icons/CreditCardIcon.js +11 -2
- package/icons/CrossIcon.js +11 -2
- package/icons/DescriptionIcon.js +11 -2
- package/icons/FilterIcon.js +11 -2
- package/icons/FlashDisabledIcon.js +11 -2
- package/icons/FlashEnabledIcon.js +11 -2
- package/icons/GridIcon.js +11 -2
- package/icons/HeartIcon.js +11 -2
- package/icons/HeartOutlineIcon.js +11 -2
- package/icons/HeartPlusIcon.js +12 -2
- package/icons/HeartPlusOutlineIcon.js +12 -2
- package/icons/HomeIcon.js +11 -2
- package/icons/InfoIcon.js +11 -2
- package/icons/InfoOutlineIcon.js +11 -2
- package/icons/ListIcon.js +11 -2
- package/icons/LocalShippingIcon.js +11 -2
- package/icons/LocationIcon.js +13 -3
- package/icons/LocatorIcon.js +11 -2
- package/icons/LockIcon.js +11 -2
- package/icons/LogoutIcon.js +11 -2
- package/icons/MagnifierIcon.js +11 -2
- package/icons/MapMarkerIcon.js +24 -3
- package/icons/MoreIcon.js +11 -2
- package/icons/MoreVertIcon.js +11 -2
- package/icons/NotificationIcon.js +14 -3
- package/icons/PersonIcon.js +12 -2
- package/icons/PhoneIcon.js +13 -3
- package/icons/PlaceholderIcon.js +11 -2
- package/icons/RadioCheckedIcon.js +11 -2
- package/icons/RadioUncheckedIcon.js +11 -2
- package/icons/SecurityIcon.js +11 -2
- package/icons/ShippingMethodIcon.js +18 -3
- package/icons/ShoppingCartIcon.js +11 -2
- package/icons/SortIcon.js +11 -2
- package/icons/StarHalfIcon.js +18 -2
- package/icons/StarIcon.js +18 -2
- package/icons/StarOutlineIcon.js +11 -2
- package/icons/StopIcon.js +11 -2
- package/icons/TickIcon.js +11 -2
- package/icons/TimeIcon.js +14 -3
- package/icons/TrashIcon.js +11 -2
- package/icons/TrashOutlineIcon.js +12 -2
- package/icons/UncheckedIcon.js +11 -2
- package/icons/ViewListIcon.js +11 -2
- package/icons/VisibilityIcon.js +11 -2
- package/icons/VisibilityOffIcon.js +11 -2
- package/icons/WarningIcon.js +11 -2
- package/index.js +13 -1
- package/package.json +5 -5
|
@@ -1,21 +1,89 @@
|
|
|
1
|
-
|
|
1
|
+
import { css } from 'glamor';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { themeConfig } from '@shopgate/pwa-common/helpers/config';
|
|
4
|
+
|
|
5
|
+
/**
|
|
2
6
|
* The style object for a one line text element with an ellipsis on overflow.
|
|
3
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
const ellipsisLine = {
|
|
9
|
+
overflow: 'hidden',
|
|
10
|
+
width: '100%',
|
|
11
|
+
whiteSpace: 'nowrap',
|
|
12
|
+
textOverflow: 'ellipsis'
|
|
13
|
+
};
|
|
14
|
+
const easing = '450ms cubic-bezier(0.23, 1, 0.32, 1)';
|
|
15
|
+
|
|
16
|
+
/**
|
|
4
17
|
* The styles for the error label.
|
|
5
|
-
*/
|
|
18
|
+
*/
|
|
19
|
+
const labelError = css({
|
|
20
|
+
color: `var(--color-state-alert, ${themeConfig.colors.error})`
|
|
21
|
+
}).toString();
|
|
22
|
+
|
|
23
|
+
/**
|
|
6
24
|
* Regular label is hidden, because placeholder is visible
|
|
7
|
-
*/
|
|
25
|
+
*/
|
|
26
|
+
const labelRegular = css({
|
|
27
|
+
opacity: 0
|
|
28
|
+
}).toString();
|
|
29
|
+
|
|
30
|
+
/**
|
|
8
31
|
* The styles for the focused label.
|
|
9
|
-
*/
|
|
32
|
+
*/
|
|
33
|
+
const labelFocus = css({
|
|
34
|
+
color: themeConfig.colors.focus
|
|
35
|
+
}).toString();
|
|
36
|
+
|
|
37
|
+
/**
|
|
10
38
|
* The styles for the floating label.
|
|
11
|
-
*/
|
|
39
|
+
*/
|
|
40
|
+
const labelFloating = css({
|
|
41
|
+
transform: 'translate3d(0, -22px, 0) scale3d(0.75, 0.75, 0.75)',
|
|
42
|
+
opacity: 1
|
|
43
|
+
}).toString();
|
|
44
|
+
|
|
45
|
+
/**
|
|
12
46
|
* The basic styles for the label.
|
|
13
47
|
* @type {string}
|
|
14
|
-
*/
|
|
48
|
+
*/
|
|
49
|
+
const label = css({
|
|
50
|
+
position: 'absolute',
|
|
51
|
+
left: 0,
|
|
52
|
+
top: 24,
|
|
53
|
+
lineHeight: '19px',
|
|
54
|
+
pointerEvents: 'none',
|
|
55
|
+
userSelect: 'none',
|
|
56
|
+
color: themeConfig.colors.shade12,
|
|
57
|
+
transformOrigin: 'left top 0px',
|
|
58
|
+
willChange: 'transform, color',
|
|
59
|
+
overflow: 'visible',
|
|
60
|
+
transition: `transform ${easing}, color ${easing}`,
|
|
61
|
+
...ellipsisLine
|
|
62
|
+
}).toString();
|
|
63
|
+
const labelStatic = css({
|
|
64
|
+
opacity: 1,
|
|
65
|
+
lineHeight: '19px',
|
|
66
|
+
pointerEvents: 'none',
|
|
67
|
+
userSelect: 'none',
|
|
68
|
+
color: themeConfig.colors.shade12
|
|
69
|
+
}).toString();
|
|
70
|
+
|
|
71
|
+
/**
|
|
15
72
|
* Gets the style classes for the label.
|
|
16
73
|
* @param {boolean} focused Whether the input field is focused.
|
|
17
74
|
* @param {boolean} floating Whether the label is floating.
|
|
18
75
|
* @param {boolean} error Whether the input field shows an error message.
|
|
19
76
|
* @param {boolean} isStatic Whether the label is static.
|
|
20
77
|
* @return {string} The style classes.
|
|
21
|
-
*/
|
|
78
|
+
*/
|
|
79
|
+
const labelStyles = (focused = false, floating = false, error = false, isStatic = false) => classNames({
|
|
80
|
+
[label]: !isStatic,
|
|
81
|
+
[labelStatic]: isStatic,
|
|
82
|
+
[labelFloating]: floating,
|
|
83
|
+
[labelRegular]: !focused,
|
|
84
|
+
[labelFocus]: !error && focused,
|
|
85
|
+
[labelError]: error && focused
|
|
86
|
+
});
|
|
87
|
+
export default {
|
|
88
|
+
labelStyles
|
|
89
|
+
};
|
|
@@ -1,8 +1,32 @@
|
|
|
1
|
-
import React from'react';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import I18n from '@shopgate/pwa-common/components/I18n';
|
|
5
|
+
import styles from "./style";
|
|
6
|
+
|
|
7
|
+
/**
|
|
2
8
|
* The form element placeholder component.
|
|
3
9
|
* @param {string} placeholder The placeholder text.
|
|
4
10
|
* @param {boolean} visible Sets the placeholder visibility.
|
|
5
11
|
* @param {boolean} props['aria-hidden'] Accessibility attribute to mark the placeholder as hidden
|
|
6
12
|
* @param {boolean} hasLeftElement Whether a left element is present
|
|
7
13
|
* @return {JSX.Element}
|
|
8
|
-
*/
|
|
14
|
+
*/
|
|
15
|
+
const Placeholder = ({
|
|
16
|
+
placeholder,
|
|
17
|
+
visible,
|
|
18
|
+
'aria-hidden': ariaHidden,
|
|
19
|
+
hasLeftElement
|
|
20
|
+
}) => /*#__PURE__*/React.createElement("div", {
|
|
21
|
+
className: classNames(styles.placeholderStyles(visible, hasLeftElement), 'placeholder'),
|
|
22
|
+
"aria-hidden": ariaHidden
|
|
23
|
+
}, /*#__PURE__*/React.createElement(I18n.Text, {
|
|
24
|
+
string: placeholder
|
|
25
|
+
}));
|
|
26
|
+
Placeholder.defaultProps = {
|
|
27
|
+
'aria-hidden': null,
|
|
28
|
+
hasLeftElement: false,
|
|
29
|
+
placeholder: '',
|
|
30
|
+
visible: false
|
|
31
|
+
};
|
|
32
|
+
export default Placeholder;
|
|
@@ -1,14 +1,56 @@
|
|
|
1
|
-
|
|
1
|
+
import { css } from 'glamor';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { themeConfig } from '@shopgate/pwa-common/helpers/config';
|
|
4
|
+
|
|
5
|
+
/**
|
|
2
6
|
* The style object for a one line text element with an ellipsis on overflow.
|
|
3
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
const ellipsisLine = {
|
|
9
|
+
overflow: 'hidden',
|
|
10
|
+
width: '100%',
|
|
11
|
+
whiteSpace: 'nowrap',
|
|
12
|
+
textOverflow: 'ellipsis'
|
|
13
|
+
};
|
|
14
|
+
const easing = '450ms cubic-bezier(0.23, 1, 0.32, 1)';
|
|
15
|
+
|
|
16
|
+
/**
|
|
4
17
|
* The styles for the placeholder text.
|
|
5
|
-
*/
|
|
18
|
+
*/
|
|
19
|
+
const placeholder = css({
|
|
20
|
+
position: 'absolute',
|
|
21
|
+
pointerEvents: 'none',
|
|
22
|
+
top: 24,
|
|
23
|
+
color: `var(--color-text-medium-emphasis, ${themeConfig.colors.shade6})`,
|
|
24
|
+
willChange: 'transform',
|
|
25
|
+
transition: `opacity ${easing}`,
|
|
26
|
+
...ellipsisLine
|
|
27
|
+
}).toString();
|
|
28
|
+
|
|
29
|
+
/**
|
|
6
30
|
* The styles for the invisible hint text.
|
|
7
|
-
*/
|
|
31
|
+
*/
|
|
32
|
+
const placeholderInactive = css({
|
|
33
|
+
opacity: 0
|
|
34
|
+
}).toString();
|
|
35
|
+
|
|
36
|
+
/**
|
|
8
37
|
* Additional left spacing when a left element is present
|
|
9
|
-
*/
|
|
38
|
+
*/
|
|
39
|
+
const leftOffset = css({
|
|
40
|
+
left: 'var(--form-element-left-offset, 26px)',
|
|
41
|
+
width: 'calc(100% - var(--form-element-left-offset, 26px))'
|
|
42
|
+
}).toString();
|
|
43
|
+
|
|
44
|
+
/**
|
|
10
45
|
* Gets the style classes for the underline element.
|
|
11
46
|
* @param {boolean} visible Whether the hint is visible.
|
|
12
47
|
* @param {boolean} hasLeftElement - Whether a left element is present.
|
|
13
48
|
* @return {string} The style classes.
|
|
14
|
-
*/
|
|
49
|
+
*/
|
|
50
|
+
const placeholderStyles = (visible = false, hasLeftElement = false) => classNames(placeholder, {
|
|
51
|
+
[placeholderInactive]: !visible,
|
|
52
|
+
[leftOffset]: hasLeftElement
|
|
53
|
+
});
|
|
54
|
+
export default {
|
|
55
|
+
placeholderStyles
|
|
56
|
+
};
|
|
@@ -1,5 +1,21 @@
|
|
|
1
|
-
import React from'react';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import styles from "./style";
|
|
5
|
+
|
|
6
|
+
/**
|
|
2
7
|
* Renders the label element.
|
|
3
8
|
* @param {Object} props The component props.
|
|
4
9
|
* @return {JSX}
|
|
5
|
-
*/
|
|
10
|
+
*/
|
|
11
|
+
const Underline = props => /*#__PURE__*/React.createElement("div", {
|
|
12
|
+
className: classNames(styles.underlineWrapper, 'underline')
|
|
13
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
14
|
+
className: styles.underline,
|
|
15
|
+
style: styles.underlineStyle(props.isFocused, props.hasErrorMessage)
|
|
16
|
+
}));
|
|
17
|
+
Underline.defaultProps = {
|
|
18
|
+
isFocused: false,
|
|
19
|
+
hasErrorMessage: false
|
|
20
|
+
};
|
|
21
|
+
export default Underline;
|
|
@@ -1,13 +1,60 @@
|
|
|
1
|
-
|
|
1
|
+
import { css } from 'glamor';
|
|
2
|
+
import color from 'color';
|
|
3
|
+
import { getCSSCustomProp } from '@shopgate/engage/styles';
|
|
4
|
+
import { themeConfig } from '@shopgate/pwa-common/helpers/config';
|
|
5
|
+
const {
|
|
6
|
+
colors
|
|
7
|
+
} = themeConfig;
|
|
8
|
+
const easing = '450ms cubic-bezier(0.23, 1, 0.32, 1)';
|
|
9
|
+
|
|
10
|
+
/**
|
|
2
11
|
* The styles for the underline wrapper element.
|
|
3
|
-
*/
|
|
12
|
+
*/
|
|
13
|
+
const underlineWrapper = css({
|
|
14
|
+
position: 'relative',
|
|
15
|
+
width: '100%',
|
|
16
|
+
borderBottom: `1px solid ${colors.shade12}`,
|
|
17
|
+
marginTop: 2,
|
|
18
|
+
marginBottom: 7
|
|
19
|
+
}).toString();
|
|
20
|
+
|
|
21
|
+
/**
|
|
4
22
|
* The styles for the underline element.
|
|
5
23
|
* @param {boolean} focused Whether the input field is focused.
|
|
6
24
|
* @param {boolean} error Whether the input field shows an error message.
|
|
7
25
|
* @return {string} The style class.
|
|
8
|
-
*/
|
|
26
|
+
*/
|
|
27
|
+
const underline = css({
|
|
28
|
+
position: 'relative',
|
|
29
|
+
width: '100%',
|
|
30
|
+
top: 1,
|
|
31
|
+
borderBottomWidth: 2,
|
|
32
|
+
borderBottomStyle: 'solid',
|
|
33
|
+
willChange: 'transform',
|
|
34
|
+
transition: `transform ${easing}`
|
|
35
|
+
}).toString();
|
|
36
|
+
|
|
37
|
+
/**
|
|
9
38
|
* Returns the underline style.
|
|
10
39
|
* @param {boolean} focused Is focused set or not.
|
|
11
40
|
* @param {boolean} hasError Has error set or not.
|
|
12
41
|
* @return {Object} style
|
|
13
|
-
*/
|
|
42
|
+
*/
|
|
43
|
+
const underlineStyle = (focused, hasError) => {
|
|
44
|
+
const primaryColor = getCSSCustomProp('--color-primary') || colors.primary;
|
|
45
|
+
let focusColor = '--color-primary';
|
|
46
|
+
if (color(primaryColor).luminosity() >= 0.8) {
|
|
47
|
+
focusColor = '--color-secondary';
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
borderBottomColor: hasError ? `var(--color-state-alert, ${colors.error})` : `var(${focusColor}, ${colors.focus})`,
|
|
51
|
+
...(!focused && !hasError && {
|
|
52
|
+
transform: 'scale3d(0,1,1)'
|
|
53
|
+
})
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export default {
|
|
57
|
+
underline,
|
|
58
|
+
underlineWrapper,
|
|
59
|
+
underlineStyle
|
|
60
|
+
};
|
package/FormElement/index.js
CHANGED
|
@@ -1,11 +1,96 @@
|
|
|
1
|
-
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import Label from "./components/Label";
|
|
5
|
+
import Underline from "./components/Underline";
|
|
6
|
+
import ErrorText from "./components/ErrorText";
|
|
7
|
+
import Placeholder from "./components/Placeholder";
|
|
8
|
+
import style from "./style";
|
|
9
|
+
|
|
10
|
+
/**
|
|
2
11
|
* A component that provides a styled form element in material design.
|
|
3
|
-
*/
|
|
12
|
+
*/
|
|
13
|
+
class FormElement extends Component {
|
|
14
|
+
/**
|
|
4
15
|
* @returns {boolean} Whether the label is currently floating.
|
|
5
|
-
*/
|
|
16
|
+
*/
|
|
17
|
+
get isLabelFloating() {
|
|
18
|
+
return !this.props.labelStatic && (this.props.isFocused || this.props.hasValue);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
6
22
|
* @returns {boolean} Whether the hint text is currently visible.
|
|
7
|
-
*/
|
|
23
|
+
*/
|
|
24
|
+
get isPlaceholderVisible() {
|
|
25
|
+
return !this.props.isFocused && !this.props.hasValue;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
8
29
|
* @returns {boolean} Whether the hint text is currently visible.
|
|
9
|
-
*/
|
|
30
|
+
*/
|
|
31
|
+
get hasErrorMessage() {
|
|
32
|
+
return !!this.props.errorText;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
10
36
|
* @return {JSX.Element}
|
|
11
|
-
*/
|
|
37
|
+
*/
|
|
38
|
+
render() {
|
|
39
|
+
const {
|
|
40
|
+
isFocused,
|
|
41
|
+
errorText,
|
|
42
|
+
translateErrorText,
|
|
43
|
+
placeholder,
|
|
44
|
+
hasLeftElement,
|
|
45
|
+
hasPlaceholder,
|
|
46
|
+
htmlFor,
|
|
47
|
+
label,
|
|
48
|
+
className,
|
|
49
|
+
disabled,
|
|
50
|
+
labelStatic,
|
|
51
|
+
showErrorText
|
|
52
|
+
} = this.props;
|
|
53
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
54
|
+
className: classNames(style.formElement, className, 'formElement', 'ui-shared__form-element', {
|
|
55
|
+
disabled
|
|
56
|
+
})
|
|
57
|
+
}, hasPlaceholder && (placeholder || label) && /*#__PURE__*/React.createElement(Placeholder, {
|
|
58
|
+
visible: this.isPlaceholderVisible,
|
|
59
|
+
placeholder: placeholder || label,
|
|
60
|
+
hasLeftElement: hasLeftElement,
|
|
61
|
+
"aria-hidden": true
|
|
62
|
+
}), label && /*#__PURE__*/React.createElement(Label, {
|
|
63
|
+
htmlFor: htmlFor,
|
|
64
|
+
label: label,
|
|
65
|
+
labelStatic: labelStatic,
|
|
66
|
+
isFocused: isFocused,
|
|
67
|
+
isFloating: this.isLabelFloating,
|
|
68
|
+
hasErrorMessage: this.hasErrorMessage
|
|
69
|
+
}), this.props.children, this.props.hasUnderline && /*#__PURE__*/React.createElement(Underline, {
|
|
70
|
+
isFocused: isFocused,
|
|
71
|
+
hasErrorMessage: this.hasErrorMessage
|
|
72
|
+
}), errorText && showErrorText && /*#__PURE__*/React.createElement(ErrorText, {
|
|
73
|
+
errorText: errorText,
|
|
74
|
+
translate: translateErrorText,
|
|
75
|
+
elementName: htmlFor
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
FormElement.defaultProps = {
|
|
80
|
+
children: null,
|
|
81
|
+
className: '',
|
|
82
|
+
errorText: '',
|
|
83
|
+
placeholder: '',
|
|
84
|
+
htmlFor: '',
|
|
85
|
+
label: '',
|
|
86
|
+
labelStatic: false,
|
|
87
|
+
isFocused: false,
|
|
88
|
+
hasLeftElement: false,
|
|
89
|
+
hasValue: false,
|
|
90
|
+
hasPlaceholder: true,
|
|
91
|
+
hasUnderline: true,
|
|
92
|
+
translateErrorText: true,
|
|
93
|
+
disabled: false,
|
|
94
|
+
showErrorText: true
|
|
95
|
+
};
|
|
96
|
+
export default FormElement;
|
package/FormElement/spec.js
CHANGED
|
@@ -1,2 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { mount } from 'enzyme';
|
|
4
|
+
import FormElement from "./index";
|
|
5
|
+
const inputProps = {
|
|
6
|
+
htmlFor: 'test-input'
|
|
7
|
+
};
|
|
8
|
+
describe('<FormElement />', () => {
|
|
9
|
+
// Simple tests for snapshots
|
|
10
|
+
const tests = {
|
|
11
|
+
'should render a form element with no children': {
|
|
12
|
+
props: {}
|
|
13
|
+
},
|
|
14
|
+
'should render a form element with 1 child': {
|
|
15
|
+
props: {
|
|
16
|
+
children: [/*#__PURE__*/React.createElement("input", {
|
|
17
|
+
key: "test-key"
|
|
18
|
+
})]
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
'should render a focused form element': {
|
|
22
|
+
props: {
|
|
23
|
+
isFocused: true
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
'should show the label': {
|
|
27
|
+
props: {
|
|
28
|
+
label: 'The label'
|
|
29
|
+
},
|
|
30
|
+
find: 'Label',
|
|
31
|
+
equal: 'The label'
|
|
32
|
+
},
|
|
33
|
+
'should show the error message': {
|
|
34
|
+
props: {
|
|
35
|
+
errorText: 'The error text'
|
|
36
|
+
},
|
|
37
|
+
find: 'ErrorText',
|
|
38
|
+
equal: 'The error text'
|
|
39
|
+
},
|
|
40
|
+
'should show the placeholder text': {
|
|
41
|
+
props: {
|
|
42
|
+
placeholder: 'The placeholder'
|
|
43
|
+
},
|
|
44
|
+
find: 'Placeholder',
|
|
45
|
+
equal: 'The placeholder'
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
Object.keys(tests).forEach(test => {
|
|
49
|
+
it(test, () => {
|
|
50
|
+
const testFixtures = tests[test];
|
|
51
|
+
const wrapper = mount(/*#__PURE__*/React.createElement(FormElement, _extends({}, inputProps, testFixtures.props)));
|
|
52
|
+
expect(wrapper).toMatchSnapshot();
|
|
53
|
+
if (testFixtures.find) {
|
|
54
|
+
expect(wrapper.find(testFixtures.find).find('Translate').props().string).toEqual(testFixtures.equal);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
it('Should hide placeholder with hasValue', () => {
|
|
59
|
+
const wrapper = mount(/*#__PURE__*/React.createElement(FormElement, _extends({
|
|
60
|
+
label: "testlabel"
|
|
61
|
+
}, inputProps, {
|
|
62
|
+
hasValue: true
|
|
63
|
+
})));
|
|
64
|
+
expect(wrapper).toMatchSnapshot();
|
|
65
|
+
expect(wrapper.find('Placeholder').props().visible).toEqual(false);
|
|
66
|
+
});
|
|
67
|
+
});
|
package/FormElement/style.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
import{css}from'glamor';
|
|
1
|
+
import { css } from 'glamor';
|
|
2
|
+
import { themeConfig } from '@shopgate/pwa-common/helpers/config';
|
|
3
|
+
|
|
4
|
+
/**
|
|
2
5
|
* The styles for the container element.
|
|
3
|
-
*/
|
|
6
|
+
*/
|
|
7
|
+
const formElement = css({
|
|
8
|
+
position: 'relative',
|
|
9
|
+
paddingBottom: themeConfig.variables.gap.big,
|
|
10
|
+
width: '100%'
|
|
11
|
+
}).toString();
|
|
12
|
+
export default {
|
|
13
|
+
formElement
|
|
14
|
+
};
|
package/Glow/index.js
CHANGED
|
@@ -1,13 +1,96 @@
|
|
|
1
|
-
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React, { Component } from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import { withForwardedRef } from '@shopgate/engage/core';
|
|
6
|
+
import { themeConfig } from '@shopgate/pwa-common/helpers/config';
|
|
7
|
+
import styles from "./style";
|
|
8
|
+
|
|
9
|
+
/**
|
|
2
10
|
* Renders a glowing component that is visible when the user interacts with the element.
|
|
3
|
-
*/
|
|
11
|
+
*/
|
|
12
|
+
class Glow extends Component {
|
|
13
|
+
/**
|
|
4
14
|
* The component constructor.
|
|
5
15
|
* @param {Object} props The component props.
|
|
6
|
-
*/
|
|
16
|
+
*/
|
|
17
|
+
constructor(props) {
|
|
18
|
+
super(props);
|
|
19
|
+
this.handleTouchTap = () => {
|
|
20
|
+
if (this.props.disabled) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
this.setState({
|
|
24
|
+
hover: true
|
|
25
|
+
});
|
|
26
|
+
this.timeout = setTimeout(() => {
|
|
27
|
+
this.setState({
|
|
28
|
+
hover: false
|
|
29
|
+
});
|
|
30
|
+
}, 250);
|
|
31
|
+
};
|
|
32
|
+
this.timeout = null;
|
|
33
|
+
this.state = {
|
|
34
|
+
hover: false
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
7
39
|
* Clears any previously set timeout.
|
|
8
|
-
*/
|
|
40
|
+
*/
|
|
41
|
+
componentWillUnmount() {
|
|
42
|
+
clearTimeout(this.timeout);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
9
45
|
* Renders the component.
|
|
10
46
|
* @returns {JSX.Element}
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
|
|
47
|
+
*/
|
|
48
|
+
render() {
|
|
49
|
+
const {
|
|
50
|
+
children,
|
|
51
|
+
styles: propStyles,
|
|
52
|
+
forwardedRef,
|
|
53
|
+
className,
|
|
54
|
+
color,
|
|
55
|
+
...rest
|
|
56
|
+
} = this.props;
|
|
57
|
+
let innerInlineStyles;
|
|
58
|
+
if (this.state.hover) {
|
|
59
|
+
innerInlineStyles = {
|
|
60
|
+
...propStyles.glow,
|
|
61
|
+
...propStyles.hover,
|
|
62
|
+
background: color
|
|
63
|
+
};
|
|
64
|
+
} else {
|
|
65
|
+
innerInlineStyles = {
|
|
66
|
+
...propStyles.glow
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* eslint-disable jsx-a11y/no-static-element-interactions,
|
|
71
|
+
jsx-a11y/click-events-have-key-events */
|
|
72
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
73
|
+
className: classNames(styles.container, className, 'ui-shared__glow'),
|
|
74
|
+
onClick: this.handleTouchTap,
|
|
75
|
+
style: propStyles.container,
|
|
76
|
+
ref: forwardedRef
|
|
77
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
78
|
+
className: styles.glow,
|
|
79
|
+
style: innerInlineStyles
|
|
80
|
+
}), children);
|
|
81
|
+
/* eslint-enable jsx-a11y/no-static-element-interactions,
|
|
82
|
+
jsx-a11y/click-events-have-key-events */
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
Glow.defaultProps = {
|
|
86
|
+
color: themeConfig.colors.shade8,
|
|
87
|
+
className: null,
|
|
88
|
+
forwardedRef: null,
|
|
89
|
+
disabled: false,
|
|
90
|
+
styles: {
|
|
91
|
+
container: null,
|
|
92
|
+
glow: null,
|
|
93
|
+
hover: null
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
export default withForwardedRef(Glow);
|
package/Glow/spec.js
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
import React from'react';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { mount } from 'enzyme';
|
|
3
|
+
import Glow from "./index";
|
|
4
|
+
describe('<Glow />', () => {
|
|
5
|
+
it('should render with a smile', () => {
|
|
6
|
+
const wrapper = mount(/*#__PURE__*/React.createElement(Glow, null, /*#__PURE__*/React.createElement("p", null, "Glowing!")));
|
|
7
|
+
expect(wrapper).toMatchSnapshot();
|
|
8
|
+
});
|
|
9
|
+
});
|
package/Glow/style.js
CHANGED
|
@@ -1 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { css } from 'glamor';
|
|
2
|
+
const container = css({
|
|
3
|
+
position: 'relative'
|
|
4
|
+
}).toString();
|
|
5
|
+
const glow = css({
|
|
6
|
+
position: 'absolute',
|
|
7
|
+
left: 0,
|
|
8
|
+
top: 0,
|
|
9
|
+
width: '100%',
|
|
10
|
+
height: '100%',
|
|
11
|
+
background: 'transparent',
|
|
12
|
+
transition: 'background 100ms cubic-bezier(0.25, 0.1, 0.25, 1)',
|
|
13
|
+
zIndex: 0
|
|
14
|
+
}).toString();
|
|
15
|
+
export default {
|
|
16
|
+
container,
|
|
17
|
+
glow
|
|
18
|
+
};
|