@telus-uds/components-web 1.2.0 → 1.4.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.
- package/CHANGELOG.md +34 -2
- package/lib/Breadcrumbs/Breadcrumbs.js +247 -0
- package/lib/Breadcrumbs/Item/Item.js +165 -0
- package/lib/Breadcrumbs/index.js +15 -0
- package/lib/Callout/Callout.js +121 -0
- package/lib/Callout/index.js +13 -0
- package/lib/DatePicker/CalendarContainer.js +221 -0
- package/lib/DatePicker/DatePicker.js +329 -0
- package/lib/DatePicker/dictionary.js +134 -0
- package/lib/DatePicker/index.js +13 -0
- package/lib/DatePicker/reactDatesCss.js +12 -0
- package/lib/ExpandCollapseMini/ExpandCollapseMini.js +75 -0
- package/lib/ExpandCollapseMini/ExpandCollapseMiniControl.js +95 -0
- package/lib/ExpandCollapseMini/index.js +13 -0
- package/lib/Footnote/Footnote.js +571 -0
- package/lib/Footnote/FootnoteLink.js +149 -0
- package/lib/Footnote/dictionary.js +19 -0
- package/lib/Footnote/index.js +16 -0
- package/lib/OrderedList/Item.js +162 -0
- package/lib/OrderedList/ItemBase.js +42 -0
- package/lib/OrderedList/OrderedList.js +94 -0
- package/lib/OrderedList/OrderedListBase.js +68 -0
- package/lib/OrderedList/constants.js +9 -0
- package/lib/OrderedList/index.js +16 -0
- package/lib/PreviewCard/AuthorDate.js +64 -0
- package/lib/PreviewCard/PreviewCard.js +236 -0
- package/lib/PreviewCard/index.js +13 -0
- package/lib/PriceLockup/PriceLockup.js +237 -0
- package/lib/PriceLockup/index.js +13 -0
- package/lib/PriceLockup/tokens.js +131 -0
- package/lib/ResponsiveImage/ResponsiveImage.js +115 -0
- package/lib/ResponsiveImage/index.js +13 -0
- package/lib/Ribbon/Ribbon.js +0 -1
- package/lib/Span/Span.js +88 -0
- package/lib/Span/index.js +13 -0
- package/lib/index.js +91 -1
- package/lib/shared/FullBleedContent/FullBleedContent.js +121 -0
- package/lib/shared/FullBleedContent/getFullBleedBorderRadius.js +73 -0
- package/lib/shared/FullBleedContent/index.js +29 -0
- package/lib/shared/FullBleedContent/useFullBleedContentProps.js +73 -0
- package/lib/utils/index.js +32 -0
- package/lib/utils/logger.js +31 -0
- package/lib/utils/media.js +54 -0
- package/lib/utils/renderStructuredContent.js +89 -0
- package/lib/utils/useTypographyTheme.js +32 -0
- package/lib-module/Breadcrumbs/Breadcrumbs.js +228 -0
- package/lib-module/Breadcrumbs/Item/Item.js +141 -0
- package/lib-module/Breadcrumbs/index.js +1 -0
- package/lib-module/Callout/Callout.js +106 -0
- package/lib-module/Callout/index.js +2 -0
- package/lib-module/DatePicker/CalendarContainer.js +208 -0
- package/lib-module/DatePicker/DatePicker.js +302 -0
- package/lib-module/DatePicker/dictionary.js +127 -0
- package/lib-module/DatePicker/index.js +2 -0
- package/lib-module/DatePicker/reactDatesCss.js +3 -0
- package/lib-module/ExpandCollapseMini/ExpandCollapseMini.js +56 -0
- package/lib-module/ExpandCollapseMini/ExpandCollapseMiniControl.js +80 -0
- package/lib-module/ExpandCollapseMini/index.js +2 -0
- package/lib-module/Footnote/Footnote.js +541 -0
- package/lib-module/Footnote/FootnoteLink.js +130 -0
- package/lib-module/Footnote/dictionary.js +12 -0
- package/lib-module/Footnote/index.js +4 -0
- package/lib-module/OrderedList/Item.js +139 -0
- package/lib-module/OrderedList/ItemBase.js +28 -0
- package/lib-module/OrderedList/OrderedList.js +71 -0
- package/lib-module/OrderedList/OrderedListBase.js +48 -0
- package/lib-module/OrderedList/constants.js +2 -0
- package/lib-module/OrderedList/index.js +4 -0
- package/lib-module/PreviewCard/AuthorDate.js +53 -0
- package/lib-module/PreviewCard/PreviewCard.js +211 -0
- package/lib-module/PreviewCard/index.js +2 -0
- package/lib-module/PriceLockup/PriceLockup.js +213 -0
- package/lib-module/PriceLockup/index.js +2 -0
- package/lib-module/PriceLockup/tokens.js +120 -0
- package/lib-module/ResponsiveImage/ResponsiveImage.js +100 -0
- package/lib-module/ResponsiveImage/index.js +2 -0
- package/lib-module/Ribbon/Ribbon.js +1 -2
- package/lib-module/Span/Span.js +70 -0
- package/lib-module/Span/index.js +2 -0
- package/lib-module/index.js +10 -0
- package/lib-module/shared/FullBleedContent/FullBleedContent.js +106 -0
- package/lib-module/shared/FullBleedContent/getFullBleedBorderRadius.js +65 -0
- package/lib-module/shared/FullBleedContent/index.js +4 -0
- package/lib-module/shared/FullBleedContent/useFullBleedContentProps.js +65 -0
- package/lib-module/utils/index.js +5 -1
- package/lib-module/utils/logger.js +18 -0
- package/lib-module/utils/media.js +46 -0
- package/lib-module/utils/renderStructuredContent.js +77 -0
- package/lib-module/utils/useTypographyTheme.js +24 -0
- package/package.json +9 -4
- package/src/Breadcrumbs/Breadcrumbs.jsx +222 -0
- package/src/Breadcrumbs/Item/Item.jsx +127 -0
- package/src/Breadcrumbs/index.js +1 -0
- package/src/Callout/Callout.jsx +76 -0
- package/src/Callout/index.js +3 -0
- package/src/DatePicker/CalendarContainer.jsx +210 -0
- package/src/DatePicker/DatePicker.jsx +303 -0
- package/src/DatePicker/dictionary.js +92 -0
- package/src/DatePicker/index.js +3 -0
- package/src/DatePicker/reactDatesCss.js +892 -0
- package/src/ExpandCollapseMini/ExpandCollapseMini.jsx +48 -0
- package/src/ExpandCollapseMini/ExpandCollapseMiniControl.jsx +67 -0
- package/src/ExpandCollapseMini/index.js +3 -0
- package/src/Footnote/Footnote.jsx +468 -0
- package/src/Footnote/FootnoteLink.jsx +120 -0
- package/src/Footnote/dictionary.js +12 -0
- package/src/Footnote/index.js +6 -0
- package/src/OrderedList/Item.jsx +121 -0
- package/src/OrderedList/ItemBase.jsx +18 -0
- package/src/OrderedList/OrderedList.jsx +61 -0
- package/src/OrderedList/OrderedListBase.jsx +38 -0
- package/src/OrderedList/constants.js +2 -0
- package/src/OrderedList/index.js +6 -0
- package/src/PreviewCard/AuthorDate.jsx +31 -0
- package/src/PreviewCard/PreviewCard.jsx +201 -0
- package/src/PreviewCard/index.js +3 -0
- package/src/PriceLockup/PriceLockup.jsx +210 -0
- package/src/PriceLockup/index.js +3 -0
- package/src/PriceLockup/tokens.js +58 -0
- package/src/ResponsiveImage/ResponsiveImage.jsx +77 -0
- package/src/ResponsiveImage/index.js +3 -0
- package/src/Ribbon/Ribbon.jsx +0 -1
- package/src/Span/Span.jsx +66 -0
- package/src/Span/index.js +3 -0
- package/src/index.js +10 -0
- package/src/shared/FullBleedContent/FullBleedContent.jsx +90 -0
- package/src/shared/FullBleedContent/getFullBleedBorderRadius.js +55 -0
- package/src/shared/FullBleedContent/index.js +6 -0
- package/src/shared/FullBleedContent/useFullBleedContentProps.js +63 -0
- package/src/utils/index.js +5 -1
- package/src/utils/logger.js +20 -0
- package/src/utils/media.js +40 -0
- package/src/utils/renderStructuredContent.jsx +73 -0
- package/src/utils/useTypographyTheme.js +14 -0
- package/types/Callout.d.ts +13 -0
- package/types/DatePicker.d.ts +21 -0
- package/types/Footnote.d.ts +21 -0
- package/types/FootnoteLink.d.ts +20 -0
- package/types/PriceLockup.d.ts +22 -0
- package/types/common.d.ts +14 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _lodash = _interopRequireDefault(require("lodash.omit"));
|
|
13
|
+
|
|
14
|
+
var _componentsBase = require("@telus-uds/components-base");
|
|
15
|
+
|
|
16
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
17
|
+
|
|
18
|
+
var _FullBleedContent = _interopRequireWildcard(require("../shared/FullBleedContent"));
|
|
19
|
+
|
|
20
|
+
var _AuthorDate = _interopRequireDefault(require("./AuthorDate"));
|
|
21
|
+
|
|
22
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
|
+
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
+
|
|
26
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
|
+
|
|
28
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
|
+
|
|
30
|
+
/* eslint-disable react/require-default-props */
|
|
31
|
+
// Passes React Native-oriented system props through UDS PressableCardBase
|
|
32
|
+
const [selectProps, selectedSystemPropTypes] = (0, _componentsBase.selectSystemProps)([_componentsBase.a11yProps, _componentsBase.focusHandlerProps, _componentsBase.viewProps]); // Stop changes to the card's inner border width causing the size and
|
|
33
|
+
// apparent position of the full bleed image to change.
|
|
34
|
+
|
|
35
|
+
const FullBleedOffsetOuter = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
36
|
+
displayName: "PreviewCard__FullBleedOffsetOuter",
|
|
37
|
+
componentId: "components-web__sc-1yfz4de-0"
|
|
38
|
+
})(_ref => {
|
|
39
|
+
let {
|
|
40
|
+
borderOffset
|
|
41
|
+
} = _ref;
|
|
42
|
+
return {
|
|
43
|
+
overflow: 'hidden',
|
|
44
|
+
marginTop: borderOffset * 2
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const FullBleedOffsetInner = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
49
|
+
displayName: "PreviewCard__FullBleedOffsetInner",
|
|
50
|
+
componentId: "components-web__sc-1yfz4de-1"
|
|
51
|
+
})(_ref2 => {
|
|
52
|
+
let {
|
|
53
|
+
borderOffset
|
|
54
|
+
} = _ref2;
|
|
55
|
+
return {
|
|
56
|
+
position: 'relative',
|
|
57
|
+
margin: 0 - borderOffset
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const defaultTokens = {
|
|
62
|
+
minWidth: 0,
|
|
63
|
+
shadow: null
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Showcase and guide users to another page, with a preview containing title and a footer.
|
|
67
|
+
* Whole card is interactive, width expands based on column or container.
|
|
68
|
+
*
|
|
69
|
+
* - Use `tag` to show category of content
|
|
70
|
+
* - Use `title` to show title of the story
|
|
71
|
+
* - Use `footer` to show text such as the author / date
|
|
72
|
+
* - Use `href` to set the target URL
|
|
73
|
+
* - Use `fullBleedContent` to set the thumbnail image
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
const PreviewCard = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
|
|
77
|
+
let {
|
|
78
|
+
tag,
|
|
79
|
+
title,
|
|
80
|
+
footer,
|
|
81
|
+
fullBleedImage,
|
|
82
|
+
fullBleedContent = fullBleedImage,
|
|
83
|
+
onPress,
|
|
84
|
+
href,
|
|
85
|
+
...rest
|
|
86
|
+
} = _ref3;
|
|
87
|
+
const {
|
|
88
|
+
fullBleedContentPosition,
|
|
89
|
+
contentStackDirection,
|
|
90
|
+
fullBleedContentProps
|
|
91
|
+
} = (0, _FullBleedContent.useFullBleedContentProps)({ ...fullBleedContent,
|
|
92
|
+
position: 'bottom'
|
|
93
|
+
});
|
|
94
|
+
const {
|
|
95
|
+
components: {
|
|
96
|
+
PreviewCard: theme
|
|
97
|
+
}
|
|
98
|
+
} = (0, _componentsBase.useTheme)();
|
|
99
|
+
|
|
100
|
+
const getPressableCardTokens = cardState => ({ ...(0, _lodash.default)((0, _componentsBase.getThemeTokens)(theme, {}, {}, cardState), 'separatorColor'),
|
|
101
|
+
...defaultTokens
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
const {
|
|
105
|
+
hrefAttrs,
|
|
106
|
+
rest: unusedRest
|
|
107
|
+
} = _componentsBase.hrefAttrsProp.bundle(rest);
|
|
108
|
+
|
|
109
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.PressableCardBase, {
|
|
110
|
+
onPress: onPress,
|
|
111
|
+
href: href,
|
|
112
|
+
hrefAttrs: hrefAttrs,
|
|
113
|
+
tokens: getPressableCardTokens,
|
|
114
|
+
ref: ref,
|
|
115
|
+
...selectProps(unusedRest),
|
|
116
|
+
children: cardState => {
|
|
117
|
+
const {
|
|
118
|
+
borderRadius,
|
|
119
|
+
borderWidth
|
|
120
|
+
} = getPressableCardTokens(cardState); // Stop content jumping around as border size changes
|
|
121
|
+
|
|
122
|
+
const borderOffset = borderWidth - theme.tokens.borderWidth;
|
|
123
|
+
const fullBleedBorderRadius = (0, _FullBleedContent.getFullBleedBorderRadius)(borderRadius + borderOffset, fullBleedContentPosition);
|
|
124
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_componentsBase.StackView, {
|
|
125
|
+
direction: contentStackDirection,
|
|
126
|
+
tokens: {
|
|
127
|
+
justifyContent: 'space-between',
|
|
128
|
+
flexGrow: 1
|
|
129
|
+
},
|
|
130
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_componentsBase.Box, {
|
|
131
|
+
horizontal: {
|
|
132
|
+
xs: 4,
|
|
133
|
+
lg: 5,
|
|
134
|
+
options: {
|
|
135
|
+
subtract: borderOffset
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
vertical: {
|
|
139
|
+
xs: 5,
|
|
140
|
+
lg: 7,
|
|
141
|
+
options: {
|
|
142
|
+
subtract: borderOffset
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
children: [Boolean(tag) && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
146
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
|
|
147
|
+
variant: {
|
|
148
|
+
size: 'eyebrow',
|
|
149
|
+
colour: 'secondary'
|
|
150
|
+
},
|
|
151
|
+
children: tag
|
|
152
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Spacer, {
|
|
153
|
+
space: 2
|
|
154
|
+
})]
|
|
155
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
|
|
156
|
+
variant: {
|
|
157
|
+
size: 'h4',
|
|
158
|
+
colour: 'secondary'
|
|
159
|
+
},
|
|
160
|
+
children: title
|
|
161
|
+
}), Boolean(footer) && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
162
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Spacer, {
|
|
163
|
+
space: 2
|
|
164
|
+
}), typeof footer === 'string' ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
|
|
165
|
+
variant: {
|
|
166
|
+
size: 'small',
|
|
167
|
+
colour: 'secondary'
|
|
168
|
+
},
|
|
169
|
+
children: footer
|
|
170
|
+
}) : footer]
|
|
171
|
+
})]
|
|
172
|
+
}), Boolean(fullBleedContentProps.src || fullBleedContentProps.content) && /*#__PURE__*/(0, _jsxRuntime.jsx)(FullBleedOffsetOuter, {
|
|
173
|
+
borderOffset: borderOffset,
|
|
174
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(FullBleedOffsetInner, {
|
|
175
|
+
borderOffset: borderOffset,
|
|
176
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_FullBleedContent.default, {
|
|
177
|
+
borderRadius: fullBleedBorderRadius,
|
|
178
|
+
...fullBleedContentProps
|
|
179
|
+
})
|
|
180
|
+
})
|
|
181
|
+
})]
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
PreviewCard.displayName = 'PreviewCard'; // Provide standard author/date footer as a preset with the export
|
|
187
|
+
|
|
188
|
+
PreviewCard.AuthorDate = _AuthorDate.default;
|
|
189
|
+
PreviewCard.propTypes = { ...selectedSystemPropTypes,
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* The URL of the story to be navigated to. Note that `Video` component does not play well when used within
|
|
193
|
+
* a `PreviewCard` with `href` prop set (the volume and progress sliders can be clicked but are not draggable).
|
|
194
|
+
* Please use `onPress` prop instead `href` to organize navigation in cases like this.
|
|
195
|
+
*
|
|
196
|
+
* @see https://github.com/telus/allium-design-system/issues/6
|
|
197
|
+
*/
|
|
198
|
+
href: _propTypes.default.string,
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Optional function to be called on press e.g. for within-page navigation.
|
|
202
|
+
*/
|
|
203
|
+
onPress: _propTypes.default.func,
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Text stating the category of the content.
|
|
207
|
+
*/
|
|
208
|
+
tag: _propTypes.default.string,
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Section containing additional information, such as author and date.
|
|
212
|
+
* Use `<PreviewCard.AuthorDate author={...} date={...} />` here for author and date.
|
|
213
|
+
*/
|
|
214
|
+
footer: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string]),
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Text stating the title or headline of the story.
|
|
218
|
+
*/
|
|
219
|
+
title: _propTypes.default.string.isRequired,
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Full bleed image to be placed on the card, deprecated in favor of `fullBleedContent`.
|
|
223
|
+
*
|
|
224
|
+
* @deprecated
|
|
225
|
+
*/
|
|
226
|
+
fullBleedImage: _propTypes.default.exact(_FullBleedContent.default.propTypes || {}),
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Full bleed content to be placed on the card.
|
|
230
|
+
*/
|
|
231
|
+
fullBleedContent: _propTypes.default.exact(_FullBleedContent.default.propTypes || {})
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
var _default = (0, _componentsBase.withLinkRouter)(PreviewCard);
|
|
235
|
+
|
|
236
|
+
exports.default = _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _PreviewCard = _interopRequireDefault(require("./PreviewCard"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
var _default = _PreviewCard.default;
|
|
13
|
+
exports.default = _default;
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _componentsBase = require("@telus-uds/components-base");
|
|
13
|
+
|
|
14
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
15
|
+
|
|
16
|
+
var _FootnoteLink = _interopRequireDefault(require("../Footnote/FootnoteLink"));
|
|
17
|
+
|
|
18
|
+
var _tokens = _interopRequireDefault(require("./tokens"));
|
|
19
|
+
|
|
20
|
+
var _utils = require("../utils");
|
|
21
|
+
|
|
22
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
|
+
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
+
|
|
26
|
+
const [selectProps, selectedSystemPropTypes] = (0, _componentsBase.selectSystemProps)([_utils.htmlAttrs]);
|
|
27
|
+
|
|
28
|
+
const PriceLockupContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
29
|
+
displayName: "PriceLockup__PriceLockupContainer",
|
|
30
|
+
componentId: "components-web__sc-1x6duay-0"
|
|
31
|
+
})(["display:flex;flex-direction:column;width:fit-content;"]);
|
|
32
|
+
|
|
33
|
+
const PriceContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
34
|
+
displayName: "PriceLockup__PriceContainer",
|
|
35
|
+
componentId: "components-web__sc-1x6duay-1"
|
|
36
|
+
})(["display:flex;margin-bottom:", ";"], _ref => {
|
|
37
|
+
let {
|
|
38
|
+
priceMarginBottom
|
|
39
|
+
} = _ref;
|
|
40
|
+
return priceMarginBottom;
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const FootnoteContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
44
|
+
displayName: "PriceLockup__FootnoteContainer",
|
|
45
|
+
componentId: "components-web__sc-1x6duay-2"
|
|
46
|
+
})(["display:flex;margin-top:", ";gap:", ";"], _ref2 => {
|
|
47
|
+
let {
|
|
48
|
+
footnoteMarginTop
|
|
49
|
+
} = _ref2;
|
|
50
|
+
return footnoteMarginTop;
|
|
51
|
+
}, _ref3 => {
|
|
52
|
+
let {
|
|
53
|
+
footnoteGap
|
|
54
|
+
} = _ref3;
|
|
55
|
+
return footnoteGap;
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const BottomTextContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
59
|
+
displayName: "PriceLockup__BottomTextContainer",
|
|
60
|
+
componentId: "components-web__sc-1x6duay-3"
|
|
61
|
+
})(["margin-top:", ";"], _ref4 => {
|
|
62
|
+
let {
|
|
63
|
+
bottomTextMarginTop
|
|
64
|
+
} = _ref4;
|
|
65
|
+
return bottomTextMarginTop;
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const BottomLinksContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
69
|
+
displayName: "PriceLockup__BottomLinksContainer",
|
|
70
|
+
componentId: "components-web__sc-1x6duay-4"
|
|
71
|
+
})(["align-self:center;margin-left:", ";"], _ref5 => {
|
|
72
|
+
let {
|
|
73
|
+
bottomLinksMarginLeft
|
|
74
|
+
} = _ref5;
|
|
75
|
+
return bottomLinksMarginLeft;
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const TopTextContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
79
|
+
displayName: "PriceLockup__TopTextContainer",
|
|
80
|
+
componentId: "components-web__sc-1x6duay-5"
|
|
81
|
+
})(["margin-bottom:", ";"], _ref6 => {
|
|
82
|
+
let {
|
|
83
|
+
topTextMarginBottom
|
|
84
|
+
} = _ref6;
|
|
85
|
+
return topTextMarginBottom;
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const RateTextContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
89
|
+
displayName: "PriceLockup__RateTextContainer",
|
|
90
|
+
componentId: "components-web__sc-1x6duay-6"
|
|
91
|
+
})(["align-self:flex-end;"]);
|
|
92
|
+
|
|
93
|
+
const StrikeThroughContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
94
|
+
displayName: "PriceLockup__StrikeThroughContainer",
|
|
95
|
+
componentId: "components-web__sc-1x6duay-7"
|
|
96
|
+
})(["display:flex;position:relative;align-items:center;::before{content:'';width:100%;height:", ";background:", ";position:absolute;}"], _ref7 => {
|
|
97
|
+
let {
|
|
98
|
+
strikeThroughHeight
|
|
99
|
+
} = _ref7;
|
|
100
|
+
return strikeThroughHeight;
|
|
101
|
+
}, _ref8 => {
|
|
102
|
+
let {
|
|
103
|
+
strikeThroughBackground
|
|
104
|
+
} = _ref8;
|
|
105
|
+
return strikeThroughBackground;
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const PriceLockup = _ref9 => {
|
|
109
|
+
let {
|
|
110
|
+
size = 'medium',
|
|
111
|
+
signDirection = 'left',
|
|
112
|
+
footnoteLinks = [],
|
|
113
|
+
topText,
|
|
114
|
+
price,
|
|
115
|
+
currencySymbol = '$',
|
|
116
|
+
rateText,
|
|
117
|
+
bottomText,
|
|
118
|
+
onClickFootnote,
|
|
119
|
+
strikeThrough,
|
|
120
|
+
a11yText,
|
|
121
|
+
tokens: priceLockupTokens,
|
|
122
|
+
variant = {},
|
|
123
|
+
...rest
|
|
124
|
+
} = _ref9;
|
|
125
|
+
const {
|
|
126
|
+
footnoteMarginTop,
|
|
127
|
+
footnoteGap,
|
|
128
|
+
bottomTextMarginTop,
|
|
129
|
+
priceMarginBottom,
|
|
130
|
+
bottomLinksMarginLeft,
|
|
131
|
+
topTextMarginBottom,
|
|
132
|
+
strikeThroughHeight,
|
|
133
|
+
strikeThroughBackground,
|
|
134
|
+
fontColor,
|
|
135
|
+
dividerColor
|
|
136
|
+
} = (0, _componentsBase.useThemeTokens)('PriceLockup', priceLockupTokens, variant);
|
|
137
|
+
const priceString = String(price);
|
|
138
|
+
const lastDotPosition = priceString.lastIndexOf('.');
|
|
139
|
+
const lastCommaPosition = priceString.lastIndexOf(',');
|
|
140
|
+
const [separator, separatorPosition] = lastDotPosition > lastCommaPosition ? ['.', lastDotPosition] : [',', lastCommaPosition]; // If the separator is at the fourth character from the end of the string or more, it's most probably
|
|
141
|
+
// a part of the amount, and the cents are not included in the price string
|
|
142
|
+
|
|
143
|
+
const hasCents = separatorPosition !== -1 && separatorPosition >= priceString.length - 3;
|
|
144
|
+
const amount = hasCents ? priceString.substring(0, separatorPosition) : priceString;
|
|
145
|
+
const cents = hasCents ? priceString.substring(separatorPosition + 1) : null;
|
|
146
|
+
const color = strikeThrough ? strikeThroughBackground : fontColor;
|
|
147
|
+
|
|
148
|
+
const renderTypography = (value, tokens) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
|
|
149
|
+
tokens: { ...tokens,
|
|
150
|
+
color
|
|
151
|
+
},
|
|
152
|
+
children: value
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
const renderCurrencySymbol = () => renderTypography(`${currencySymbol}`, _tokens.default.dollarSign[size]);
|
|
156
|
+
|
|
157
|
+
const renderFootnoteLinks = () => footnoteLinks && footnoteLinks.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_FootnoteLink.default, {
|
|
158
|
+
number: footnoteLinks,
|
|
159
|
+
onClick: onClickFootnote
|
|
160
|
+
}) : null;
|
|
161
|
+
|
|
162
|
+
const renderAmount = () => {
|
|
163
|
+
const amountComponent = renderTypography(amount, _tokens.default.amount[size]);
|
|
164
|
+
|
|
165
|
+
if (strikeThrough) {
|
|
166
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
167
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.A11yText, {
|
|
168
|
+
text: a11yText
|
|
169
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(StrikeThroughContainer, {
|
|
170
|
+
strikeThroughHeight: `${strikeThroughHeight}px`,
|
|
171
|
+
strikeThroughBackground: strikeThroughBackground,
|
|
172
|
+
children: amountComponent
|
|
173
|
+
})]
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return amountComponent;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const renderPrice = () => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
181
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(PriceContainer, {
|
|
182
|
+
priceMarginBottom: `${priceMarginBottom}px`,
|
|
183
|
+
children: [signDirection === 'left' && renderCurrencySymbol(), renderAmount(), cents && renderTypography(`${separator}${cents}`, _tokens.default.cents[size]), signDirection === 'right' && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
184
|
+
children: ["\xA0", renderCurrencySymbol()]
|
|
185
|
+
}), rateText && /*#__PURE__*/(0, _jsxRuntime.jsx)(RateTextContainer, {
|
|
186
|
+
children: renderTypography(rateText, _tokens.default.rate[size])
|
|
187
|
+
}), !bottomText && footnoteLinks.length <= 3 && /*#__PURE__*/(0, _jsxRuntime.jsx)(BottomLinksContainer, {
|
|
188
|
+
bottomLinksMarginLeft: `${bottomLinksMarginLeft}px`,
|
|
189
|
+
children: renderFootnoteLinks()
|
|
190
|
+
})]
|
|
191
|
+
}), !bottomText && footnoteLinks.length > 3 && renderFootnoteLinks()]
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
const renderFootnoteContent = () => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
195
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(FootnoteContainer, {
|
|
196
|
+
footnoteMarginTop: `${footnoteMarginTop}px`,
|
|
197
|
+
footnoteGap: `${footnoteGap}px`,
|
|
198
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(BottomTextContainer, {
|
|
199
|
+
bottomTextMarginTop: `${bottomTextMarginTop}px`,
|
|
200
|
+
children: renderTypography(bottomText, _tokens.default.bottomText[size])
|
|
201
|
+
}), footnoteLinks.length <= 3 && renderFootnoteLinks()]
|
|
202
|
+
}), footnoteLinks.length > 3 && renderFootnoteLinks()]
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
if (strikeThrough && !a11yText) {
|
|
206
|
+
(0, _utils.warn)('PriceLockup', 'a11yText must be provided with strikethrough pricing');
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(PriceLockupContainer, { ...selectProps(rest),
|
|
210
|
+
children: [topText && /*#__PURE__*/(0, _jsxRuntime.jsx)(TopTextContainer, {
|
|
211
|
+
topTextMarginBottom: `${topTextMarginBottom}px`,
|
|
212
|
+
children: renderTypography(topText, _tokens.default.topText[size])
|
|
213
|
+
}), renderPrice(), bottomText && /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Divider, {
|
|
214
|
+
testID: "price-lockup-divider",
|
|
215
|
+
role: "separator",
|
|
216
|
+
tokens: {
|
|
217
|
+
color: dividerColor
|
|
218
|
+
}
|
|
219
|
+
}), bottomText && renderFootnoteContent()]
|
|
220
|
+
});
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
PriceLockup.propTypes = { ...selectedSystemPropTypes,
|
|
224
|
+
size: _propTypes.default.oneOf(['small', 'medium', 'large']),
|
|
225
|
+
currencySymbol: _propTypes.default.string,
|
|
226
|
+
topText: _propTypes.default.string,
|
|
227
|
+
price: _propTypes.default.string.isRequired,
|
|
228
|
+
rateText: _propTypes.default.string,
|
|
229
|
+
bottomText: _propTypes.default.string,
|
|
230
|
+
signDirection: _propTypes.default.oneOf(['right', 'left']),
|
|
231
|
+
footnoteLinks: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])),
|
|
232
|
+
onClickFootnote: _propTypes.default.func,
|
|
233
|
+
strikeThrough: _propTypes.default.bool,
|
|
234
|
+
a11yText: _propTypes.default.string
|
|
235
|
+
};
|
|
236
|
+
var _default = PriceLockup;
|
|
237
|
+
exports.default = _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _PriceLockup = _interopRequireDefault(require("./PriceLockup"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
var _default = _PriceLockup.default;
|
|
13
|
+
exports.default = _default;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _palette = _interopRequireDefault(require("@telus-uds/palette-allium/build/rn/palette"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
const {
|
|
13
|
+
fontSize: {
|
|
14
|
+
size14,
|
|
15
|
+
size16,
|
|
16
|
+
size20,
|
|
17
|
+
size28,
|
|
18
|
+
size36,
|
|
19
|
+
size40,
|
|
20
|
+
size64
|
|
21
|
+
},
|
|
22
|
+
lineHeight: {
|
|
23
|
+
ratio1to1,
|
|
24
|
+
ratio10to7,
|
|
25
|
+
ratio3to2,
|
|
26
|
+
ratio8to5,
|
|
27
|
+
ratio5to4,
|
|
28
|
+
ratio6to5,
|
|
29
|
+
ratio9to8,
|
|
30
|
+
ratio4to3,
|
|
31
|
+
ratio8to7
|
|
32
|
+
},
|
|
33
|
+
letterSpacing: {
|
|
34
|
+
condensed
|
|
35
|
+
}
|
|
36
|
+
} = _palette.default;
|
|
37
|
+
const typographyTokens = {
|
|
38
|
+
topText: {
|
|
39
|
+
small: {
|
|
40
|
+
fontSize: size14,
|
|
41
|
+
lineHeight: ratio10to7
|
|
42
|
+
},
|
|
43
|
+
medium: {
|
|
44
|
+
fontSize: size16,
|
|
45
|
+
lineHeight: ratio3to2
|
|
46
|
+
},
|
|
47
|
+
large: {
|
|
48
|
+
fontSize: size20,
|
|
49
|
+
lineHeight: ratio8to5
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
dollarSign: {
|
|
53
|
+
small: {
|
|
54
|
+
fontSize: size16,
|
|
55
|
+
lineHeight: ratio5to4
|
|
56
|
+
},
|
|
57
|
+
medium: {
|
|
58
|
+
fontSize: size20,
|
|
59
|
+
lineHeight: ratio6to5
|
|
60
|
+
},
|
|
61
|
+
large: {
|
|
62
|
+
fontSize: size36,
|
|
63
|
+
lineHeight: ratio9to8
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
// TODO - fontWeight should have its own const on palette
|
|
67
|
+
amount: {
|
|
68
|
+
small: {
|
|
69
|
+
fontSize: size28,
|
|
70
|
+
lineHeight: ratio1to1,
|
|
71
|
+
letterSpacing: condensed,
|
|
72
|
+
fontWeight: '300'
|
|
73
|
+
},
|
|
74
|
+
medium: {
|
|
75
|
+
fontSize: size40,
|
|
76
|
+
lineHeight: ratio1to1,
|
|
77
|
+
letterSpacing: condensed,
|
|
78
|
+
fontWeight: '300'
|
|
79
|
+
},
|
|
80
|
+
large: {
|
|
81
|
+
fontSize: size64,
|
|
82
|
+
lineHeight: ratio1to1,
|
|
83
|
+
letterSpacing: condensed,
|
|
84
|
+
fontWeight: '300'
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
cents: {
|
|
88
|
+
small: {
|
|
89
|
+
fontSize: size16,
|
|
90
|
+
lineHeight: ratio4to3
|
|
91
|
+
},
|
|
92
|
+
medium: {
|
|
93
|
+
fontSize: size20,
|
|
94
|
+
lineHeight: ratio6to5
|
|
95
|
+
},
|
|
96
|
+
large: {
|
|
97
|
+
fontSize: size36,
|
|
98
|
+
lineHeight: ratio9to8
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
rate: {
|
|
102
|
+
small: {
|
|
103
|
+
fontSize: size14,
|
|
104
|
+
lineHeight: ratio8to7
|
|
105
|
+
},
|
|
106
|
+
medium: {
|
|
107
|
+
fontSize: size16,
|
|
108
|
+
lineHeight: ratio5to4
|
|
109
|
+
},
|
|
110
|
+
large: {
|
|
111
|
+
fontSize: size20,
|
|
112
|
+
lineHeight: ratio8to5
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
bottomText: {
|
|
116
|
+
small: {
|
|
117
|
+
fontSize: size14,
|
|
118
|
+
lineHeight: ratio10to7
|
|
119
|
+
},
|
|
120
|
+
medium: {
|
|
121
|
+
fontSize: size16,
|
|
122
|
+
lineHeight: ratio3to2
|
|
123
|
+
},
|
|
124
|
+
large: {
|
|
125
|
+
fontSize: size20,
|
|
126
|
+
lineHeight: ratio8to5
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
var _default = typographyTokens;
|
|
131
|
+
exports.default = _default;
|