@telus-uds/components-base 1.75.0 → 1.76.0

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 (44) hide show
  1. package/CHANGELOG.md +17 -2
  2. package/lib/Carousel/CarouselThumbnail.js +10 -4
  3. package/lib/Carousel/CarouselThumbnailNavigation.js +3 -3
  4. package/lib/Footnote/Footnote.js +9 -13
  5. package/lib/Link/ChevronLink.js +2 -0
  6. package/lib/Link/InlinePressable.js +15 -2
  7. package/lib/Link/LinkBase.js +1 -0
  8. package/lib/OrderedList/OrderedList.js +21 -20
  9. package/lib/PriceLockup/PriceLockup.js +220 -0
  10. package/lib/PriceLockup/index.js +10 -0
  11. package/lib/PriceLockup/utils/renderFootnoteContent.js +93 -0
  12. package/lib/PriceLockup/utils/renderFootnoteLinks.js +36 -0
  13. package/lib/PriceLockup/utils/renderPrice.js +147 -0
  14. package/lib/PriceLockup/utils/renderTypography.js +31 -0
  15. package/lib/index.js +8 -0
  16. package/lib-module/Carousel/CarouselThumbnail.js +10 -4
  17. package/lib-module/Carousel/CarouselThumbnailNavigation.js +3 -3
  18. package/lib-module/Footnote/Footnote.js +9 -13
  19. package/lib-module/Link/ChevronLink.js +2 -0
  20. package/lib-module/Link/InlinePressable.js +16 -2
  21. package/lib-module/Link/LinkBase.js +1 -0
  22. package/lib-module/OrderedList/OrderedList.js +21 -20
  23. package/lib-module/PriceLockup/PriceLockup.js +214 -0
  24. package/lib-module/PriceLockup/index.js +2 -0
  25. package/lib-module/PriceLockup/utils/renderFootnoteContent.js +87 -0
  26. package/lib-module/PriceLockup/utils/renderFootnoteLinks.js +28 -0
  27. package/lib-module/PriceLockup/utils/renderPrice.js +141 -0
  28. package/lib-module/PriceLockup/utils/renderTypography.js +23 -0
  29. package/lib-module/index.js +1 -0
  30. package/package.json +1 -1
  31. package/src/Carousel/CarouselThumbnail.jsx +8 -6
  32. package/src/Carousel/CarouselThumbnailNavigation.jsx +3 -4
  33. package/src/Footnote/Footnote.jsx +3 -6
  34. package/src/Link/ChevronLink.jsx +5 -1
  35. package/src/Link/InlinePressable.jsx +36 -15
  36. package/src/Link/LinkBase.jsx +1 -0
  37. package/src/OrderedList/OrderedList.jsx +17 -20
  38. package/src/PriceLockup/PriceLockup.jsx +218 -0
  39. package/src/PriceLockup/index.js +3 -0
  40. package/src/PriceLockup/utils/renderFootnoteContent.jsx +77 -0
  41. package/src/PriceLockup/utils/renderFootnoteLinks.jsx +38 -0
  42. package/src/PriceLockup/utils/renderPrice.jsx +201 -0
  43. package/src/PriceLockup/utils/renderTypography.jsx +13 -0
  44. package/src/index.js +1 -0
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
9
+ var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
10
+ var _Text = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Text"));
11
+ var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
12
+ var _A11yText = _interopRequireDefault(require("../../A11yText"));
13
+ var _renderTypography = _interopRequireDefault(require("./renderTypography"));
14
+ var _renderFootnoteLinks = _interopRequireDefault(require("./renderFootnoteLinks"));
15
+ var _jsxRuntime = require("react/jsx-runtime");
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+ const selectStrikeThroughStyles = _ref => {
18
+ let {
19
+ strikeThroughColor
20
+ } = _ref;
21
+ return {
22
+ textDecorationColor: strikeThroughColor
23
+ };
24
+ };
25
+ const selectFootnoteLinksStyles = _ref2 => {
26
+ let {
27
+ bottomLinksMarginLeft
28
+ } = _ref2;
29
+ return {
30
+ marginLeft: bottomLinksMarginLeft
31
+ };
32
+ };
33
+ const renderCurrencySymbol = (currencySymbol, currencySymbolTypographyTokens, ratePosition, fontColor) => (0, _renderTypography.default)(`${currencySymbol}`, currencySymbolTypographyTokens, ratePosition, fontColor);
34
+ const renderAmount = (amount, amountTypographyTokens, strikeThrough, a11yText, fontColor, themeTokens) => {
35
+ const amountText = (0, _renderTypography.default)(amount, amountTypographyTokens, undefined, fontColor); // undefined is ratePosition
36
+ if (strikeThrough) {
37
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
38
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_A11yText.default, {
39
+ text: a11yText
40
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
41
+ style: [staticStyles.strikeThroughContainer, selectStrikeThroughStyles(themeTokens)],
42
+ children: amountText
43
+ })]
44
+ });
45
+ }
46
+ return amountText;
47
+ };
48
+ const renderPrice = (price, rateText, ratePosition, signDirection, currencySymbol, currencySymbolTypographyTokens, amountTypographyTokens, centsTypographyTokens, rateTypographyTokens, fontColor, strikeThrough, a11yText, bottomText, bottomLinksMarginLeft, footnoteLinks, onClickFootnote, themeTokens) => {
49
+ const priceString = price;
50
+ const lastDotPosition = priceString.lastIndexOf('.');
51
+ const lastCommaPosition = priceString.lastIndexOf(',');
52
+ const [separator, separatorPosition] = lastDotPosition > lastCommaPosition ? ['.', lastDotPosition] : [',', lastCommaPosition];
53
+
54
+ // If the separator is at the fourth character from the end of the string or more, it's most probably
55
+ // a part of the amount, and the cents are not included in the price string
56
+ const EXCLUDE_CENTS = 3;
57
+ const hasCents = separatorPosition !== -1 && separatorPosition >= priceString.length - EXCLUDE_CENTS;
58
+ const amount = hasCents ? priceString.substring(0, separatorPosition) : priceString;
59
+ const cents = hasCents ? priceString.substring(separatorPosition + 1) : null;
60
+ const footnoteLinkPositionStyles = rateText ? staticStyles.footnoteLinksWithoutBottomText : staticStyles.footnoteLinksWithoutBottomTextAndRateText;
61
+ const MAX_FOOTNOTE_LINKS_ALLOWED = 3;
62
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
63
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
64
+ style: ratePosition === 'bottom' ? staticStyles.priceContainerColumn : staticStyles.priceContainerRow,
65
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
66
+ style: staticStyles.priceContainer,
67
+ children: [signDirection === 'left' ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
68
+ children: renderCurrencySymbol(currencySymbol, currencySymbolTypographyTokens, ratePosition, fontColor)
69
+ }) : null, renderAmount(amount, amountTypographyTokens, strikeThrough, a11yText, fontColor, themeTokens), cents ? (0, _renderTypography.default)(`${separator}${cents}`, centsTypographyTokens, undefined, fontColor) : null, signDirection === 'right' ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
70
+ style: staticStyles.currencySymbol,
71
+ children: renderCurrencySymbol(currencySymbol, currencySymbolTypographyTokens, ratePosition, fontColor)
72
+ }) : null]
73
+ }), rateText ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
74
+ style: ratePosition === 'bottom' ? staticStyles.rateTextVerticalPosition : [staticStyles.rateTextPosition, staticStyles.rateTextVerticalPosition],
75
+ children: (0, _renderTypography.default)(rateText, rateTypographyTokens, ratePosition, fontColor)
76
+ }) : null, !bottomText && footnoteLinks.length <= MAX_FOOTNOTE_LINKS_ALLOWED ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
77
+ style: [footnoteLinkPositionStyles, selectFootnoteLinksStyles({
78
+ bottomLinksMarginLeft
79
+ })],
80
+ children: (0, _renderFootnoteLinks.default)(footnoteLinks, themeTokens, onClickFootnote)
81
+ }) : null]
82
+ }), !bottomText && footnoteLinks.length > MAX_FOOTNOTE_LINKS_ALLOWED ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
83
+ style: staticStyles.verticalFootnoteLinkContainer,
84
+ children: (0, _renderFootnoteLinks.default)(footnoteLinks, themeTokens, onClickFootnote)
85
+ }) : null]
86
+ });
87
+ };
88
+ var _default = renderPrice;
89
+ exports.default = _default;
90
+ const staticStyles = _StyleSheet.default.create({
91
+ priceContainerRow: {
92
+ flexDirection: 'row'
93
+ },
94
+ priceContainerColumn: {
95
+ flexDirection: 'column'
96
+ },
97
+ priceContainer: {
98
+ flexDirection: 'row',
99
+ alignSelf: 'flex-start',
100
+ marginTop: 4
101
+ },
102
+ currencySymbol: {
103
+ paddingLeft: 4
104
+ },
105
+ verticalFootnoteLinkContainer: {
106
+ ..._Platform.default.select({
107
+ ios: {
108
+ top: 10
109
+ },
110
+ android: {
111
+ top: -2
112
+ }
113
+ })
114
+ },
115
+ footnoteLinksWithoutBottomText: {
116
+ ..._Platform.default.select({
117
+ ios: {
118
+ alignSelf: 'flex-end',
119
+ top: -10
120
+ },
121
+ android: {
122
+ alignSelf: 'center',
123
+ top: -14
124
+ }
125
+ })
126
+ },
127
+ footnoteLinksWithoutBottomTextAndRateText: {
128
+ ..._Platform.default.select({
129
+ ios: {
130
+ alignSelf: 'center'
131
+ },
132
+ android: {
133
+ alignSelf: 'flex-start'
134
+ }
135
+ })
136
+ },
137
+ strikeThroughContainer: {
138
+ textDecorationLine: 'line-through',
139
+ textDecorationThickness: '1px'
140
+ },
141
+ rateTextPosition: {
142
+ alignSelf: 'flex-end'
143
+ },
144
+ rateTextVerticalPosition: {
145
+ top: -8
146
+ }
147
+ });
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _Typography = _interopRequireDefault(require("../../Typography"));
9
+ var _jsxRuntime = require("react/jsx-runtime");
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ const renderTypography = (value, themeTokens, ratePosition, fontColor) => {
12
+ const customProps = ratePosition === 'bottom' ? {
13
+ variant: {
14
+ size: 'micro'
15
+ },
16
+ tokens: {
17
+ color: fontColor
18
+ }
19
+ } : {
20
+ tokens: {
21
+ ...themeTokens,
22
+ color: fontColor
23
+ }
24
+ };
25
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
26
+ ...customProps,
27
+ children: value
28
+ });
29
+ };
30
+ var _default = renderTypography;
31
+ exports.default = _default;
package/lib/index.js CHANGED
@@ -36,6 +36,7 @@ var _exportNames = {
36
36
  Notification: true,
37
37
  OrderedList: true,
38
38
  Pagination: true,
39
+ PriceLockup: true,
39
40
  Progress: true,
40
41
  QuickLinks: true,
41
42
  QuickLinksFeature: true,
@@ -285,6 +286,12 @@ Object.defineProperty(exports, "PressableCardBase", {
285
286
  return _Card.PressableCardBase;
286
287
  }
287
288
  });
289
+ Object.defineProperty(exports, "PriceLockup", {
290
+ enumerable: true,
291
+ get: function () {
292
+ return _PriceLockup.default;
293
+ }
294
+ });
288
295
  Object.defineProperty(exports, "Progress", {
289
296
  enumerable: true,
290
297
  get: function () {
@@ -592,6 +599,7 @@ var _MultiSelectFilter = _interopRequireDefault(require("./MultiSelectFilter"));
592
599
  var _Notification = _interopRequireDefault(require("./Notification"));
593
600
  var _OrderedList = _interopRequireDefault(require("./OrderedList"));
594
601
  var _Pagination = _interopRequireDefault(require("./Pagination"));
602
+ var _PriceLockup = _interopRequireDefault(require("./PriceLockup"));
595
603
  var _Progress = _interopRequireDefault(require("./Progress"));
596
604
  var _QuickLinks = _interopRequireDefault(require("./QuickLinks"));
597
605
  var _QuickLinksFeature = _interopRequireDefault(require("./QuickLinksFeature"));
@@ -54,7 +54,8 @@ const CarouselThumbnail = _ref2 => {
54
54
  padding,
55
55
  selectedBorderColor,
56
56
  selectedBorderWidth,
57
- size
57
+ size,
58
+ margin
58
59
  } = getThumbnailTokens({
59
60
  viewport
60
61
  });
@@ -66,7 +67,12 @@ const CarouselThumbnail = _ref2 => {
66
67
  selected: {
67
68
  borderColor: selectedBorderColor,
68
69
  borderWidth: selectedBorderWidth,
69
- padding: padding - selectedBorderWidth + borderWidth
70
+ padding: padding - selectedBorderWidth,
71
+ marginBottom: margin + selectedBorderWidth
72
+ },
73
+ nonSelected: {
74
+ padding: padding - borderWidth,
75
+ marginBottom: margin + selectedBorderWidth
70
76
  }
71
77
  };
72
78
  return /*#__PURE__*/_jsx(Pressable, {
@@ -83,9 +89,9 @@ const CarouselThumbnail = _ref2 => {
83
89
  pressed,
84
90
  focus: focused
85
91
  }));
86
- return [pressableStyles, index === activeIndex && styles.selected, {
92
+ return [pressableStyles, index === activeIndex ? [styles.selected, {
87
93
  outline: 'none'
88
- }];
94
+ }] : styles.nonSelected];
89
95
  },
90
96
  children: /*#__PURE__*/_jsx(Image, {
91
97
  accessibilityIgnoresInvertColors: true,
@@ -24,8 +24,7 @@ const CarouselThumbnailNavigation = /*#__PURE__*/forwardRef((_ref, ref) => {
24
24
  throw new Error('Thumbnail set provided does not match the number of slides in the carousel');
25
25
  }
26
26
  const {
27
- containerPaddingTop: thumbnailContainerPaddingTop,
28
- margin: thumbnailMargin
27
+ containerPaddingTop: thumbnailContainerPaddingTop
29
28
  } = useThemeTokens('CarouselThumbnail');
30
29
  const stackWrapTokens = {
31
30
  justifyContent: 'flex-start'
@@ -33,13 +32,14 @@ const CarouselThumbnailNavigation = /*#__PURE__*/forwardRef((_ref, ref) => {
33
32
  const containerStyles = {
34
33
  justifyContent: 'center',
35
34
  alignItems,
36
- paddingTop: thumbnailContainerPaddingTop - thumbnailMargin
35
+ paddingTop: thumbnailContainerPaddingTop
37
36
  };
38
37
  return /*#__PURE__*/_jsx(View, {
39
38
  style: containerStyles,
40
39
  children: /*#__PURE__*/_jsx(StackWrap, {
41
40
  direction: "row",
42
41
  tokens: stackWrapTokens,
42
+ space: 2,
43
43
  ref: ref,
44
44
  children: thumbnails.map((_ref2, index) => {
45
45
  let {
@@ -165,19 +165,15 @@ const Footnote = _ref6 => {
165
165
  children: content
166
166
  });
167
167
  }
168
- return (
169
- /*#__PURE__*/
170
- // TODO: Extract the OrderedList.Item from the array when the issue #4361 is fixed
171
- _jsx(OrderedList, {
172
- start: number,
173
- children: [/*#__PURE__*/_jsx(OrderedList.Item, {
174
- children: /*#__PURE__*/_jsx(Text, {
175
- style: selectCustomContentFontStyle(themeTokens),
176
- children: content
177
- })
178
- }, number)]
179
- })
180
- );
168
+ return /*#__PURE__*/_jsx(OrderedList, {
169
+ start: number,
170
+ children: /*#__PURE__*/_jsx(OrderedList.Item, {
171
+ children: /*#__PURE__*/_jsx(Text, {
172
+ style: selectCustomContentFontStyle(themeTokens),
173
+ children: content
174
+ })
175
+ }, number)
176
+ });
181
177
  }, [content, number, themeTokens]);
182
178
  useEffect(() => {
183
179
  if (isOpen) {
@@ -18,6 +18,7 @@ const ChevronLink = /*#__PURE__*/forwardRef((_ref, ref) => {
18
18
  tokens = {},
19
19
  variant,
20
20
  dataSet,
21
+ onPress,
21
22
  ...otherlinkProps
22
23
  } = _ref;
23
24
  const getChevronTokens = useThemeTokensCallback('ChevronLink', tokens, variant);
@@ -46,6 +47,7 @@ const ChevronLink = /*#__PURE__*/forwardRef((_ref, ref) => {
46
47
  tokens: getTokens,
47
48
  dataSet: dataSet,
48
49
  ref: ref,
50
+ onPress: onPress,
49
51
  children: children
50
52
  });
51
53
  });
@@ -1,6 +1,7 @@
1
- import React, { forwardRef } from 'react';
1
+ import React, { forwardRef, useCallback } from 'react';
2
2
  import Pressable from "react-native-web/dist/exports/Pressable";
3
3
  import StyleSheet from "react-native-web/dist/exports/StyleSheet";
4
+ import Platform from "react-native-web/dist/exports/Platform";
4
5
  /**
5
6
  * @typedef {import('react-native').PressableProps} PressableProps
6
7
  */
@@ -13,18 +14,31 @@ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
13
14
  * @param {PressableProps} PressableProps
14
15
  */
15
16
  // React Native exports prop Types but not propTypes, use JSDoc types here rather than duplicate RN
16
- // eslint-disable-next-line react/prop-types
17
+ /* eslint-disable react/prop-types */
17
18
  import { jsx as _jsx } from "react/jsx-runtime";
18
19
  const InlinePressable = /*#__PURE__*/forwardRef((_ref, ref) => {
19
20
  let {
20
21
  children,
21
22
  inlineFlex = true,
22
23
  style,
24
+ onPress,
23
25
  ...props
24
26
  } = _ref;
27
+ const handlePress = useCallback(() => {
28
+ if (onPress) {
29
+ onPress();
30
+ }
31
+ }, [onPress]);
32
+ const handleKeyPress = useCallback(e => {
33
+ if (e.key === 'Enter' || e.key === ' ') {
34
+ handlePress();
35
+ }
36
+ }, [handlePress]);
25
37
  return /*#__PURE__*/_jsx(Pressable, {
26
38
  ref: ref,
27
39
  style: pressState => [typeof style === 'function' ? style(pressState) : style, staticStyles[inlineFlex ? 'inlineFlex' : 'inline']],
40
+ onPress: handlePress,
41
+ onKeyDown: Platform.OS === 'web' ? handleKeyPress : undefined,
28
42
  ...props,
29
43
  children: pressState => typeof children === 'function' ? children(pressState) : children
30
44
  });
@@ -178,6 +178,7 @@ const LinkBase = /*#__PURE__*/forwardRef((_ref6, ref) => {
178
178
  // assuming links without icons should be inline (even if they are long)
179
179
  ,
180
180
  ref: ref,
181
+ keyboardShouldPersistTaps: "handled",
181
182
  style: linkState => {
182
183
  const themeTokens = resolveLinkTokens(linkState);
183
184
  const outerBorderStyles = selectOuterBorderStyles(themeTokens);
@@ -5,25 +5,6 @@ import OrderedListBase from './OrderedListBase';
5
5
  import Item from './Item';
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  const [selectProps, selectedSystemPropsTypes] = selectSystemProps([htmlAttrs, viewProps]);
8
- const getChildrenWithParentVariants = (variant, children, start) => {
9
- if (variant) return children.map((child, i) => {
10
- var _child$props;
11
- const existingChildVariants = ((_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.variant) ?? {};
12
- return {
13
- ...child,
14
- props: {
15
- ...child.props,
16
- index: start + i,
17
- isLastChild: i === children.length - 1,
18
- variant: {
19
- ...existingChildVariants,
20
- ...variant
21
- }
22
- }
23
- };
24
- });
25
- return children;
26
- };
27
8
  const OrderedList = /*#__PURE__*/forwardRef((_ref, ref) => {
28
9
  let {
29
10
  children,
@@ -31,7 +12,27 @@ const OrderedList = /*#__PURE__*/forwardRef((_ref, ref) => {
31
12
  variant,
32
13
  ...rest
33
14
  } = _ref;
34
- const childrenWithParentVariants = useMemo(() => getChildrenWithParentVariants(variant, children, start), [children, variant, start]);
15
+ const childrenWithParentVariants = useMemo(() => {
16
+ const addVariantToProps = (child, i, isLastChild) => {
17
+ var _child$props;
18
+ const existingChildVariants = ((_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.variant) ?? {};
19
+ return /*#__PURE__*/React.cloneElement(child, {
20
+ index: start + i,
21
+ isLastChild,
22
+ variant: {
23
+ ...existingChildVariants,
24
+ ...variant
25
+ }
26
+ });
27
+ };
28
+ if (variant) {
29
+ if (Array.isArray(children)) {
30
+ return children.map((child, i) => addVariantToProps(child, i, i === children.length - 1));
31
+ }
32
+ return [addVariantToProps(children, 0, true)];
33
+ }
34
+ return children;
35
+ }, [children, variant, start]);
35
36
  return /*#__PURE__*/_jsx(OrderedListBase, {
36
37
  ref: ref,
37
38
  ...selectProps(rest),
@@ -0,0 +1,214 @@
1
+ import React from 'react';
2
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
3
+ import View from "react-native-web/dist/exports/View";
4
+ import PropTypes from 'prop-types';
5
+ import Divider from '../Divider';
6
+ import { useViewport } from '../ViewportProvider';
7
+ import { useThemeTokens } from '../ThemeProvider';
8
+ import { selectSystemProps, getTokensPropType, htmlAttrs, viewProps } from '../utils';
9
+ import renderFootnoteContent from './utils/renderFootnoteContent';
10
+ import renderPrice from './utils/renderPrice';
11
+ import renderTypography from './utils/renderTypography';
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { Fragment as _Fragment } from "react/jsx-runtime";
14
+ import { jsxs as _jsxs } from "react/jsx-runtime";
15
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs, viewProps]);
16
+ const selectTopTextTypographyTokens = _ref => {
17
+ let {
18
+ topTextFontSize,
19
+ topTextLineHeight
20
+ } = _ref;
21
+ return {
22
+ fontSize: topTextFontSize,
23
+ lineHeight: topTextLineHeight
24
+ };
25
+ };
26
+ const selectCurrencySymbolTypographyTokens = _ref2 => {
27
+ let {
28
+ currencySymbolFontSize,
29
+ currencySymbolLineHeight,
30
+ currencySymbolFontWeight
31
+ } = _ref2;
32
+ return {
33
+ fontSize: currencySymbolFontSize,
34
+ lineHeight: currencySymbolLineHeight,
35
+ fontWeight: currencySymbolFontWeight
36
+ };
37
+ };
38
+ const selectAmountTypographyTokens = _ref3 => {
39
+ let {
40
+ amountFontSize,
41
+ amountLineHeight,
42
+ amountLetterSpacing,
43
+ amountFontWeight,
44
+ fontColor
45
+ } = _ref3;
46
+ // This is used to apply the proper line height to the amount
47
+ const lineHeightMultiplier = 1.18;
48
+ return {
49
+ color: fontColor,
50
+ fontSize: amountFontSize,
51
+ lineHeight: amountLineHeight * lineHeightMultiplier,
52
+ letterSpacing: amountLetterSpacing,
53
+ fontWeight: amountFontWeight
54
+ };
55
+ };
56
+ const selectCentsTypographyTokens = _ref4 => {
57
+ let {
58
+ centsFontSize,
59
+ centsLineHeight,
60
+ centsFontWeight
61
+ } = _ref4;
62
+ return {
63
+ fontSize: centsFontSize,
64
+ lineHeight: centsLineHeight,
65
+ fontWeight: centsFontWeight
66
+ };
67
+ };
68
+ const selectRateTypographyTokens = _ref5 => {
69
+ let {
70
+ rateFontSize,
71
+ rateLineHeight,
72
+ rateFontWeight
73
+ } = _ref5;
74
+ return {
75
+ fontSize: rateFontSize,
76
+ lineHeight: rateLineHeight,
77
+ fontWeight: rateFontWeight
78
+ };
79
+ };
80
+ const selectBottomTextTypographyTokens = _ref6 => {
81
+ let {
82
+ bottomTextFontSize,
83
+ bottomTextLineHeight
84
+ } = _ref6;
85
+ return {
86
+ fontSize: bottomTextFontSize,
87
+ lineHeight: bottomTextLineHeight
88
+ };
89
+ };
90
+ const PriceLockup = _ref7 => {
91
+ let {
92
+ size = 'medium',
93
+ signDirection = 'left',
94
+ footnoteLinks,
95
+ topText,
96
+ price,
97
+ currencySymbol = '$',
98
+ rateText,
99
+ ratePosition = 'right',
100
+ bottomText,
101
+ onClickFootnote,
102
+ strikeThrough,
103
+ a11yText,
104
+ tokens: priceLockupTokens,
105
+ variant = {},
106
+ ...rest
107
+ } = _ref7;
108
+ const viewport = useViewport();
109
+ const {
110
+ footnoteMarginTop,
111
+ footnoteGap,
112
+ bottomTextMarginTop,
113
+ priceMarginBottom,
114
+ bottomLinksMarginLeft,
115
+ topTextMarginBottom,
116
+ fontColor,
117
+ dividerColor,
118
+ ...themeTokens
119
+ } = useThemeTokens('PriceLockup', priceLockupTokens, {
120
+ ...variant,
121
+ size
122
+ }, {
123
+ viewport,
124
+ strikeThrough
125
+ });
126
+ const currencySymbolTypographyTokens = selectCurrencySymbolTypographyTokens(themeTokens);
127
+ const amountTypographyTokens = selectAmountTypographyTokens(themeTokens);
128
+ const centsTypographyTokens = selectCentsTypographyTokens(themeTokens);
129
+ const rateTypographyTokens = selectRateTypographyTokens(themeTokens);
130
+ const topTextTypographyTokens = selectTopTextTypographyTokens(themeTokens);
131
+ const bottomTextTypographyTokens = selectBottomTextTypographyTokens(themeTokens);
132
+ return /*#__PURE__*/_jsxs(View, {
133
+ style: [staticStyles.priceLockupContainer, {
134
+ ...selectProps(rest)
135
+ }],
136
+ children: [topText ? /*#__PURE__*/_jsx(View, {
137
+ children: renderTypography(topText, topTextTypographyTokens)
138
+ }) : null, renderPrice(price, rateText, ratePosition, signDirection, currencySymbol, currencySymbolTypographyTokens, amountTypographyTokens, centsTypographyTokens, rateTypographyTokens, fontColor, strikeThrough, a11yText, bottomText, bottomLinksMarginLeft, footnoteLinks, onClickFootnote, themeTokens), bottomText ? /*#__PURE__*/_jsxs(_Fragment, {
139
+ children: [/*#__PURE__*/_jsx(Divider, {
140
+ testID: "price-lockup-divider",
141
+ role: "separator",
142
+ tokens: {
143
+ color: dividerColor
144
+ }
145
+ }), renderFootnoteContent(footnoteMarginTop, bottomTextMarginTop, bottomText, bottomTextTypographyTokens, fontColor, footnoteLinks, bottomLinksMarginLeft, onClickFootnote, themeTokens)]
146
+ }) : null]
147
+ });
148
+ };
149
+ PriceLockup.displayName = 'PriceLockup';
150
+ PriceLockup.propTypes = {
151
+ ...selectedSystemPropTypes,
152
+ /**
153
+ * Size of the component
154
+ *
155
+ * Small for pricing in product catalogue pages, medium for pricing in product comparison cards.
156
+ */
157
+ size: PropTypes.oneOf(['small', 'medium']),
158
+ /**
159
+ * If currency symbol other than `$` to be used
160
+ */
161
+ currencySymbol: PropTypes.string,
162
+ /**
163
+ * Shows additional info above the price
164
+ */
165
+ topText: PropTypes.string,
166
+ /**
167
+ * Monetary value (including decimals separated by ".")
168
+ */
169
+ price: PropTypes.string.isRequired,
170
+ /**
171
+ * Shows month/year unit
172
+ */
173
+ rateText: PropTypes.string,
174
+ /**
175
+ * Shows additional info below the price with a `Divider`
176
+ */
177
+ bottomText: PropTypes.string,
178
+ /**
179
+ * Displays which side the currency should appear (left, right)
180
+ */
181
+ signDirection: PropTypes.oneOf(['right', 'left']),
182
+ /**
183
+ * Displays where the rate should appear (bottom, right)
184
+ */
185
+ ratePosition: PropTypes.oneOf(['right', 'bottom']),
186
+ /**
187
+ * Shows additional link for context
188
+ */
189
+ footnoteLinks: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),
190
+ /**
191
+ * Function to be called when a footnote link is clicked
192
+ */
193
+ onClickFootnote: PropTypes.func,
194
+ /**
195
+ * To show price savings comparison
196
+ */
197
+ strikeThrough: PropTypes.bool,
198
+ /**
199
+ * To provide a11y text for `PriceLockup` component
200
+ *
201
+ * **Note:** a11yText will override strikethrough price, so it must include price (ie. "was 50 dollars per month")
202
+ */
203
+ a11yText: PropTypes.string,
204
+ /**
205
+ * `PriceLockup` tokens
206
+ */
207
+ tokens: getTokensPropType('PriceLockup')
208
+ };
209
+ export default PriceLockup;
210
+ const staticStyles = StyleSheet.create({
211
+ priceLockupContainer: {
212
+ alignSelf: 'flex-start'
213
+ }
214
+ });
@@ -0,0 +1,2 @@
1
+ import PriceLockup from './PriceLockup';
2
+ export default PriceLockup;