@telus-uds/components-base 1.74.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.
- package/CHANGELOG.md +26 -2
- package/lib/Carousel/CarouselThumbnail.js +10 -4
- package/lib/Carousel/CarouselThumbnailNavigation.js +3 -3
- package/lib/Footnote/Footnote.js +9 -13
- package/lib/Link/ChevronLink.js +2 -0
- package/lib/Link/InlinePressable.js +15 -2
- package/lib/Link/LinkBase.js +1 -0
- package/lib/Notification/Notification.js +213 -35
- package/lib/OrderedList/OrderedList.js +21 -20
- package/lib/PriceLockup/PriceLockup.js +220 -0
- package/lib/PriceLockup/index.js +10 -0
- package/lib/PriceLockup/utils/renderFootnoteContent.js +93 -0
- package/lib/PriceLockup/utils/renderFootnoteLinks.js +36 -0
- package/lib/PriceLockup/utils/renderPrice.js +147 -0
- package/lib/PriceLockup/utils/renderTypography.js +31 -0
- package/lib/index.js +8 -0
- package/lib/utils/ssr-media-query/create-stylesheet/index.js +1 -2
- package/lib-module/Carousel/CarouselThumbnail.js +10 -4
- package/lib-module/Carousel/CarouselThumbnailNavigation.js +3 -3
- package/lib-module/Footnote/Footnote.js +9 -13
- package/lib-module/Link/ChevronLink.js +2 -0
- package/lib-module/Link/InlinePressable.js +16 -2
- package/lib-module/Link/LinkBase.js +1 -0
- package/lib-module/Notification/Notification.js +216 -38
- package/lib-module/OrderedList/OrderedList.js +21 -20
- package/lib-module/PriceLockup/PriceLockup.js +214 -0
- package/lib-module/PriceLockup/index.js +2 -0
- package/lib-module/PriceLockup/utils/renderFootnoteContent.js +87 -0
- package/lib-module/PriceLockup/utils/renderFootnoteLinks.js +28 -0
- package/lib-module/PriceLockup/utils/renderPrice.js +141 -0
- package/lib-module/PriceLockup/utils/renderTypography.js +23 -0
- package/lib-module/index.js +1 -0
- package/lib-module/utils/ssr-media-query/create-stylesheet/index.js +1 -2
- package/package.json +2 -2
- package/src/Carousel/CarouselThumbnail.jsx +8 -6
- package/src/Carousel/CarouselThumbnailNavigation.jsx +3 -4
- package/src/Footnote/Footnote.jsx +3 -6
- package/src/Link/ChevronLink.jsx +5 -1
- package/src/Link/InlinePressable.jsx +36 -15
- package/src/Link/LinkBase.jsx +1 -0
- package/src/Notification/Notification.jsx +213 -34
- package/src/OrderedList/OrderedList.jsx +17 -20
- package/src/PriceLockup/PriceLockup.jsx +218 -0
- package/src/PriceLockup/index.js +3 -0
- package/src/PriceLockup/utils/renderFootnoteContent.jsx +77 -0
- package/src/PriceLockup/utils/renderFootnoteLinks.jsx +38 -0
- package/src/PriceLockup/utils/renderPrice.jsx +201 -0
- package/src/PriceLockup/utils/renderTypography.jsx +13 -0
- package/src/index.js +1 -0
- package/src/utils/ssr-media-query/create-stylesheet/index.js +3 -2
|
@@ -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
|
-
|
|
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);
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import React, { forwardRef, useState } from 'react';
|
|
2
|
-
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
1
|
+
import React, { forwardRef, useState, useRef } from 'react';
|
|
3
2
|
import View from "react-native-web/dist/exports/View";
|
|
4
3
|
import PropTypes from 'prop-types';
|
|
5
|
-
import { applyTextStyles, useTheme, useThemeTokens } from '../ThemeProvider';
|
|
6
|
-
import { a11yProps, getTokensPropType, selectSystemProps, selectTokens, variantProp, viewProps, wrapStringsInText, useResponsiveProp } from '../utils';
|
|
4
|
+
import { applyTextStyles, useTheme, useThemeTokens, useResponsiveThemeTokens } from '../ThemeProvider';
|
|
5
|
+
import { a11yProps, getTokensPropType, selectSystemProps, selectTokens, variantProp, viewProps, wrapStringsInText, useResponsiveProp, createMediaQueryStyles, StyleSheet } from '../utils';
|
|
7
6
|
import IconButton from '../IconButton';
|
|
8
7
|
import useCopy from '../utils/useCopy';
|
|
9
8
|
import dictionary from './dictionary';
|
|
@@ -67,6 +66,156 @@ const selectDismissButtonContainerStyles = _ref4 => {
|
|
|
67
66
|
const selectContentContainerStyle = maxWidth => ({
|
|
68
67
|
width: maxWidth || '100%'
|
|
69
68
|
});
|
|
69
|
+
const getMediaQueryStyles = (themeTokens, themeOptions, viewport, mediaIdsRef, dismissible) => {
|
|
70
|
+
const transformedSelectContainerStyles = Object.entries(themeTokens).reduce((acc, _ref5) => {
|
|
71
|
+
let [vp, viewportTokens] = _ref5;
|
|
72
|
+
acc[vp] = selectContainerStyles({
|
|
73
|
+
...viewportTokens
|
|
74
|
+
});
|
|
75
|
+
return acc;
|
|
76
|
+
}, {});
|
|
77
|
+
const selectContainerMediaQueryStyles = createMediaQueryStyles(transformedSelectContainerStyles);
|
|
78
|
+
const {
|
|
79
|
+
ids: containerIds,
|
|
80
|
+
styles: containerStyles
|
|
81
|
+
} = StyleSheet.create({
|
|
82
|
+
container: {
|
|
83
|
+
flexDirection: 'row',
|
|
84
|
+
...selectContainerMediaQueryStyles
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
const {
|
|
88
|
+
ids: contentContainerIds,
|
|
89
|
+
styles: contentContainerStyles
|
|
90
|
+
} = StyleSheet.create({
|
|
91
|
+
contentContainer: {
|
|
92
|
+
flexDirection: 'row',
|
|
93
|
+
flexShrink: 1,
|
|
94
|
+
justifyContent: 'space-between',
|
|
95
|
+
...createMediaQueryStyles({
|
|
96
|
+
xs: {
|
|
97
|
+
width: (themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.contentMaxWidth.xs) || '100%'
|
|
98
|
+
},
|
|
99
|
+
md: {
|
|
100
|
+
width: (themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.contentMaxWidth.md) || '100%'
|
|
101
|
+
},
|
|
102
|
+
lg: {
|
|
103
|
+
width: (themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.contentMaxWidth.lg) || '100%'
|
|
104
|
+
},
|
|
105
|
+
sm: {
|
|
106
|
+
width: (themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.contentMaxWidth.sm) || '100%'
|
|
107
|
+
},
|
|
108
|
+
xl: {
|
|
109
|
+
width: (themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.contentMaxWidth.xl) || '100%'
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
const {
|
|
115
|
+
ids: staticContentContainerIds,
|
|
116
|
+
styles: staticContentContainerStyles
|
|
117
|
+
} = StyleSheet.create({
|
|
118
|
+
staticContentContainer: {
|
|
119
|
+
flexDirection: 'row',
|
|
120
|
+
flexShrink: 1
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
const {
|
|
124
|
+
ids: iconContainerIds,
|
|
125
|
+
styles: iconContainerStyles
|
|
126
|
+
} = StyleSheet.create({
|
|
127
|
+
iconContainer: selectIconContainerStyles(themeTokens[viewport])
|
|
128
|
+
});
|
|
129
|
+
const {
|
|
130
|
+
ids: dismissButtonContainerIds,
|
|
131
|
+
styles: dismissButtonContainerStyles
|
|
132
|
+
} = StyleSheet.create({
|
|
133
|
+
dismissButtonContainer: selectDismissButtonContainerStyles(themeTokens[viewport])
|
|
134
|
+
});
|
|
135
|
+
const {
|
|
136
|
+
ids: textIds,
|
|
137
|
+
styles: textStyles
|
|
138
|
+
} = StyleSheet.create({
|
|
139
|
+
text: selectTextStyles(themeTokens[viewport], themeOptions, dismissible)
|
|
140
|
+
});
|
|
141
|
+
const {
|
|
142
|
+
styles: selectIconPropsStyles
|
|
143
|
+
} = StyleSheet.create({
|
|
144
|
+
selectIconProps: selectIconProps(themeTokens[viewport])
|
|
145
|
+
});
|
|
146
|
+
const {
|
|
147
|
+
styles: selectDismissIconPropsStyles
|
|
148
|
+
} = StyleSheet.create({
|
|
149
|
+
selectDismissIconProps: selectDismissIconProps(themeTokens[viewport])
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
// eslint-disable-next-line no-param-reassign
|
|
153
|
+
mediaIdsRef.current = {
|
|
154
|
+
containerIds,
|
|
155
|
+
contentContainerIds,
|
|
156
|
+
staticContentContainerIds,
|
|
157
|
+
iconContainerIds,
|
|
158
|
+
dismissButtonContainerIds,
|
|
159
|
+
textIds
|
|
160
|
+
};
|
|
161
|
+
return {
|
|
162
|
+
containerStyles,
|
|
163
|
+
contentContainerStyles,
|
|
164
|
+
staticContentContainerStyles,
|
|
165
|
+
iconContainerStyles,
|
|
166
|
+
dismissButtonContainerStyles,
|
|
167
|
+
textStyles,
|
|
168
|
+
selectIconPropsStyles,
|
|
169
|
+
selectDismissIconPropsStyles
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
const getDefaultStyles = (themeTokens, themeOptions, maxWidth, dismissible) => ({
|
|
173
|
+
containerStyles: {
|
|
174
|
+
container: {
|
|
175
|
+
flexDirection: 'row',
|
|
176
|
+
...selectContainerStyles(themeTokens)
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
contentContainerStyles: {
|
|
180
|
+
contentContainer: {
|
|
181
|
+
flexDirection: 'row',
|
|
182
|
+
flexShrink: 1,
|
|
183
|
+
justifyContent: 'space-between',
|
|
184
|
+
...selectContentContainerStyle(maxWidth)
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
staticContentContainerStyles: {
|
|
188
|
+
staticContentContainer: {
|
|
189
|
+
flexDirection: 'row',
|
|
190
|
+
flexShrink: 1
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
iconContainerStyles: {
|
|
194
|
+
iconContainer: {
|
|
195
|
+
...selectIconContainerStyles(themeTokens)
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
dismissButtonContainerStyles: {
|
|
199
|
+
dismissButtonContainer: {
|
|
200
|
+
...selectDismissButtonContainerStyles(themeTokens)
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
textStyles: {
|
|
204
|
+
text: {
|
|
205
|
+
...selectTextStyles(themeTokens, themeOptions, dismissible)
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
selectIconPropsStyles: {
|
|
209
|
+
selectIconProps: {
|
|
210
|
+
...selectIconProps(themeTokens)
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
selectDismissIconPropsStyles: {
|
|
214
|
+
selectDismissIconProps: {
|
|
215
|
+
...selectDismissIconProps(themeTokens)
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
});
|
|
70
219
|
|
|
71
220
|
/**
|
|
72
221
|
* A banner that highlights important messages:
|
|
@@ -119,7 +268,7 @@ const selectContentContainerStyle = maxWidth => ({
|
|
|
119
268
|
* Use full-width `Notifications` to show system-based messages coming from the application, not in response to user action.
|
|
120
269
|
* Show system notifications at the top of the page, below the navigation, and expands the full-width of the viewport
|
|
121
270
|
*/
|
|
122
|
-
const Notification = /*#__PURE__*/forwardRef((
|
|
271
|
+
const Notification = /*#__PURE__*/forwardRef((_ref6, ref) => {
|
|
123
272
|
let {
|
|
124
273
|
children,
|
|
125
274
|
system,
|
|
@@ -128,13 +277,9 @@ const Notification = /*#__PURE__*/forwardRef((_ref5, ref) => {
|
|
|
128
277
|
tokens,
|
|
129
278
|
variant,
|
|
130
279
|
...rest
|
|
131
|
-
} =
|
|
280
|
+
} = _ref6;
|
|
132
281
|
const [isDismissed, setIsDismissed] = useState(false);
|
|
133
282
|
const viewport = useViewport();
|
|
134
|
-
const themeTokens = useThemeTokens('Notification', tokens, variant, {
|
|
135
|
-
system,
|
|
136
|
-
viewport
|
|
137
|
-
});
|
|
138
283
|
const getCopy = useCopy({
|
|
139
284
|
dictionary,
|
|
140
285
|
copy
|
|
@@ -142,42 +287,89 @@ const Notification = /*#__PURE__*/forwardRef((_ref5, ref) => {
|
|
|
142
287
|
const {
|
|
143
288
|
themeOptions
|
|
144
289
|
} = useTheme();
|
|
145
|
-
const
|
|
290
|
+
const {
|
|
291
|
+
enableMediaQueryStyleSheet
|
|
292
|
+
} = themeOptions;
|
|
293
|
+
const useTokens = enableMediaQueryStyleSheet ? useResponsiveThemeTokens : useThemeTokens;
|
|
294
|
+
const themeTokens = useTokens('Notification', tokens, variant, {
|
|
295
|
+
system,
|
|
296
|
+
viewport
|
|
297
|
+
});
|
|
298
|
+
const maxWidth = useResponsiveProp(themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.contentMaxWidth);
|
|
299
|
+
const notificationComponentRef = useRef({
|
|
300
|
+
containerStyles: {},
|
|
301
|
+
contentContainerStyles: {},
|
|
302
|
+
staticContentContainerStyles: {},
|
|
303
|
+
iconContainerStyles: {},
|
|
304
|
+
dismissButtonContainerStyles: {},
|
|
305
|
+
textStyles: {},
|
|
306
|
+
selectIconPropsStyles: {},
|
|
307
|
+
selectDismissIconPropsStyles: {}
|
|
308
|
+
});
|
|
309
|
+
const mediaIdsRef = useRef({
|
|
310
|
+
containerIds: {},
|
|
311
|
+
contentContainerIds: {},
|
|
312
|
+
staticContentContainerIds: {},
|
|
313
|
+
iconContainerIds: {},
|
|
314
|
+
dismissButtonContainerIds: {},
|
|
315
|
+
textIds: {},
|
|
316
|
+
selectIconPropsIds: {},
|
|
317
|
+
selectDismissIconPropsIds: {}
|
|
318
|
+
});
|
|
319
|
+
if (enableMediaQueryStyleSheet) {
|
|
320
|
+
notificationComponentRef.current = getMediaQueryStyles(themeTokens, themeOptions, viewport, mediaIdsRef, dismissible);
|
|
321
|
+
} else {
|
|
322
|
+
notificationComponentRef.current = getDefaultStyles(themeTokens, themeOptions, maxWidth, dismissible);
|
|
323
|
+
}
|
|
146
324
|
if (isDismissed) {
|
|
147
325
|
return null;
|
|
148
326
|
}
|
|
149
|
-
const textStyles = selectTextStyles(themeTokens, themeOptions, dismissible);
|
|
150
327
|
const content = wrapStringsInText(typeof children === 'function' ? children({
|
|
151
|
-
textStyles,
|
|
328
|
+
textStyles: notificationComponentRef.current.textStyles.text,
|
|
152
329
|
variant
|
|
153
330
|
}) : children, {
|
|
154
|
-
style: textStyles
|
|
331
|
+
style: notificationComponentRef.current.textStyles.text
|
|
155
332
|
});
|
|
156
333
|
const {
|
|
157
334
|
icon: IconComponent,
|
|
158
335
|
dismissIcon: DismissIconComponent,
|
|
159
336
|
dismissIconColor
|
|
160
|
-
} = themeTokens;
|
|
337
|
+
} = enableMediaQueryStyleSheet === false ? themeTokens : themeTokens[viewport];
|
|
161
338
|
const onDismissPress = () => setIsDismissed(true);
|
|
162
339
|
return /*#__PURE__*/_jsx(View, {
|
|
163
340
|
ref: ref,
|
|
164
|
-
style:
|
|
341
|
+
style: notificationComponentRef.current.containerStyles.container,
|
|
342
|
+
dataSet: mediaIdsRef && {
|
|
343
|
+
media: mediaIdsRef.current.containerIds.container
|
|
344
|
+
},
|
|
165
345
|
...selectProps(rest),
|
|
166
346
|
children: /*#__PURE__*/_jsxs(View, {
|
|
167
|
-
style:
|
|
347
|
+
style: notificationComponentRef.current.contentContainerStyles.contentContainer,
|
|
348
|
+
dataSet: mediaIdsRef && {
|
|
349
|
+
media: mediaIdsRef.current.contentContainerIds.contentContainer
|
|
350
|
+
},
|
|
168
351
|
children: [/*#__PURE__*/_jsxs(View, {
|
|
169
|
-
style:
|
|
352
|
+
style: notificationComponentRef.current.staticContentContainerStyles.staticContentContainer,
|
|
353
|
+
dataSet: mediaIdsRef && {
|
|
354
|
+
media: mediaIdsRef.current.staticContentContainerIds.staticContentContainer
|
|
355
|
+
},
|
|
170
356
|
children: [IconComponent && /*#__PURE__*/_jsx(View, {
|
|
171
|
-
style:
|
|
357
|
+
style: notificationComponentRef.current.iconContainerStyles.iconContainer,
|
|
358
|
+
dataSet: mediaIdsRef && {
|
|
359
|
+
media: mediaIdsRef.current.iconContainerIds.iconContainer
|
|
360
|
+
},
|
|
172
361
|
children: /*#__PURE__*/_jsx(IconComponent, {
|
|
173
|
-
...selectIconProps
|
|
362
|
+
...notificationComponentRef.current.selectIconPropsStyles.selectIconProps
|
|
174
363
|
})
|
|
175
364
|
}), content && typeof content === 'function' ? content({
|
|
176
|
-
textStyles,
|
|
365
|
+
textStyles: notificationComponentRef.current.textStyles.text,
|
|
177
366
|
variant
|
|
178
367
|
}) : content]
|
|
179
368
|
}), dismissible && DismissIconComponent && /*#__PURE__*/_jsx(View, {
|
|
180
|
-
style:
|
|
369
|
+
style: notificationComponentRef.current.dismissButtonContainerStyles.dismissButtonContainer,
|
|
370
|
+
dataSet: mediaIdsRef && {
|
|
371
|
+
media: mediaIdsRef.current.dismissButtonContainerIds.dismissButtonContainer
|
|
372
|
+
},
|
|
181
373
|
children: /*#__PURE__*/_jsx(IconButton, {
|
|
182
374
|
action: "close",
|
|
183
375
|
onPress: onDismissPress,
|
|
@@ -189,7 +381,7 @@ const Notification = /*#__PURE__*/forwardRef((_ref5, ref) => {
|
|
|
189
381
|
size: 'small'
|
|
190
382
|
},
|
|
191
383
|
children: () => /*#__PURE__*/_jsx(DismissIconComponent, {
|
|
192
|
-
...selectDismissIconProps
|
|
384
|
+
...notificationComponentRef.current.selectDismissIconPropsStyles.selectDismissIconProps
|
|
193
385
|
})
|
|
194
386
|
})
|
|
195
387
|
})]
|
|
@@ -220,18 +412,4 @@ Notification.propTypes = {
|
|
|
220
412
|
tokens: getTokensPropType('Notification'),
|
|
221
413
|
variant: variantProp.propType
|
|
222
414
|
};
|
|
223
|
-
export default Notification;
|
|
224
|
-
const staticStyles = StyleSheet.create({
|
|
225
|
-
container: {
|
|
226
|
-
flexDirection: 'row'
|
|
227
|
-
},
|
|
228
|
-
contentContainer: {
|
|
229
|
-
flexDirection: 'row',
|
|
230
|
-
flexShrink: 1
|
|
231
|
-
},
|
|
232
|
-
content: {
|
|
233
|
-
flexDirection: 'row',
|
|
234
|
-
flexShrink: 1,
|
|
235
|
-
justifyContent: 'space-between'
|
|
236
|
-
}
|
|
237
|
-
});
|
|
415
|
+
export default Notification;
|
|
@@ -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(() =>
|
|
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
|
+
});
|