@telus-uds/components-base 1.73.0 → 1.75.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 (35) hide show
  1. package/CHANGELOG.md +27 -3
  2. package/lib/ExpandCollapse/Panel.js +1 -1
  3. package/lib/Footnote/Footnote.js +328 -0
  4. package/lib/Footnote/FootnoteLink.js +108 -0
  5. package/lib/Footnote/dictionary.js +19 -0
  6. package/lib/Footnote/index.js +12 -0
  7. package/lib/Notification/Notification.js +213 -35
  8. package/lib/Responsive/Responsive.js +8 -0
  9. package/lib/Responsive/ResponsiveWithMediaQueryStyleSheet.js +6 -3
  10. package/lib/Typography/Typography.js +3 -1
  11. package/lib/index.js +8 -0
  12. package/lib/utils/ssr-media-query/create-stylesheet/index.js +1 -2
  13. package/lib-module/ExpandCollapse/Panel.js +1 -1
  14. package/lib-module/Footnote/Footnote.js +319 -0
  15. package/lib-module/Footnote/FootnoteLink.js +101 -0
  16. package/lib-module/Footnote/dictionary.js +12 -0
  17. package/lib-module/Footnote/index.js +4 -0
  18. package/lib-module/Notification/Notification.js +216 -38
  19. package/lib-module/Responsive/Responsive.js +8 -0
  20. package/lib-module/Responsive/ResponsiveWithMediaQueryStyleSheet.js +6 -3
  21. package/lib-module/Typography/Typography.js +3 -1
  22. package/lib-module/index.js +1 -0
  23. package/lib-module/utils/ssr-media-query/create-stylesheet/index.js +1 -2
  24. package/package.json +2 -2
  25. package/src/ExpandCollapse/Panel.jsx +1 -1
  26. package/src/Footnote/Footnote.jsx +316 -0
  27. package/src/Footnote/FootnoteLink.jsx +95 -0
  28. package/src/Footnote/dictionary.js +12 -0
  29. package/src/Footnote/index.js +6 -0
  30. package/src/Notification/Notification.jsx +213 -34
  31. package/src/Responsive/Responsive.jsx +8 -2
  32. package/src/Responsive/ResponsiveWithMediaQueryStyleSheet.jsx +6 -4
  33. package/src/Typography/Typography.jsx +6 -1
  34. package/src/index.js +1 -0
  35. package/src/utils/ssr-media-query/create-stylesheet/index.js +3 -2
@@ -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((_ref5, ref) => {
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
- } = _ref5;
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 contentMaxWidth = useResponsiveProp(themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.contentMaxWidth);
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: [staticStyles.container, selectContainerStyles(themeTokens)],
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: [staticStyles.content, selectContentContainerStyle(contentMaxWidth)],
347
+ style: notificationComponentRef.current.contentContainerStyles.contentContainer,
348
+ dataSet: mediaIdsRef && {
349
+ media: mediaIdsRef.current.contentContainerIds.contentContainer
350
+ },
168
351
  children: [/*#__PURE__*/_jsxs(View, {
169
- style: staticStyles.contentContainer,
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: selectIconContainerStyles(themeTokens),
357
+ style: notificationComponentRef.current.iconContainerStyles.iconContainer,
358
+ dataSet: mediaIdsRef && {
359
+ media: mediaIdsRef.current.iconContainerIds.iconContainer
360
+ },
172
361
  children: /*#__PURE__*/_jsx(IconComponent, {
173
- ...selectIconProps(themeTokens)
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: selectDismissButtonContainerStyles(themeTokens),
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(themeTokens)
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;
@@ -21,6 +21,7 @@ const Responsive = _ref => {
21
21
  let {
22
22
  min = 'xs',
23
23
  max,
24
+ inheritedStyles = [],
24
25
  children
25
26
  } = _ref;
26
27
  const {
@@ -30,6 +31,7 @@ const Responsive = _ref => {
30
31
  } = useTheme();
31
32
  if (enableMediaQueryStyleSheet) {
32
33
  return /*#__PURE__*/_jsx(ResponsiveWithMediaQueryStyleSheet, {
34
+ inheritedStyles: inheritedStyles,
33
35
  min: min,
34
36
  max: max,
35
37
  children: children
@@ -51,6 +53,12 @@ Responsive.propTypes = {
51
53
  * To hide children of `Responsive` if the current viewport is larger than `max`
52
54
  */
53
55
  max: PropTypes.oneOf(['sm', 'md', 'lg', 'xl']),
56
+ /**
57
+ * Styles to be inherited by `Responsive`.
58
+ * It should be an array of style property names.
59
+ * Note: This prop is only applicable when `enableMediaQueryStylesheet` is set to true in the `ThemeProvider`.
60
+ */
61
+ inheritedStyles: PropTypes.arrayOf(PropTypes.string),
54
62
  children: PropTypes.node.isRequired
55
63
  };
56
64
  export default Responsive;
@@ -28,6 +28,7 @@ const ResponsiveWithMediaQueryStyleSheet = _ref => {
28
28
  let {
29
29
  min,
30
30
  max,
31
+ inheritedStyles = [],
31
32
  children
32
33
  } = _ref;
33
34
  const {
@@ -35,9 +36,10 @@ const ResponsiveWithMediaQueryStyleSheet = _ref => {
35
36
  styles
36
37
  } = StyleSheet.create({
37
38
  responsive: {
38
- flexDirection: 'inherit',
39
- alignItems: 'inherit',
40
- justifyContent: 'inherit',
39
+ ...inheritedStyles.reduce((acc, prop) => {
40
+ acc[prop] = 'inherit';
41
+ return acc;
42
+ }, {}),
41
43
  ...generateResponsiveStyles(min, max)
42
44
  }
43
45
  });
@@ -59,6 +61,7 @@ ResponsiveWithMediaQueryStyleSheet.propTypes = {
59
61
  * To hide children of `Responsive` if the current viewport is larger than `max`
60
62
  */
61
63
  max: PropTypes.oneOf(['sm', 'md', 'lg', 'xl']),
64
+ inheritedStyles: PropTypes.arrayOf(PropTypes.string),
62
65
  children: PropTypes.node.isRequired
63
66
  };
64
67
  export default ResponsiveWithMediaQueryStyleSheet;
@@ -61,7 +61,9 @@ const Typography = /*#__PURE__*/forwardRef((_ref2, ref) => {
61
61
  enableMediaQueryStyleSheet
62
62
  } = themeOptions;
63
63
  const useTokens = enableMediaQueryStyleSheet ? useResponsiveThemeTokens : useThemeTokens;
64
- const themeTokens = useTokens('Typography', tokens, variant);
64
+ const themeTokens = useTokens('Typography', tokens, variant, !enableMediaQueryStyleSheet && {
65
+ viewport
66
+ });
65
67
  const maxFontSizeMultiplier = enableMediaQueryStyleSheet ? getMaxFontMultiplier(themeTokens[viewport]) : getMaxFontMultiplier(themeTokens);
66
68
  const textDecorationLine = strikeThrough ? 'line-through' : 'none';
67
69
  let textStyles;
@@ -17,6 +17,7 @@ export { default as ExpandCollapse, Accordion } from './ExpandCollapse';
17
17
  export { default as Feedback } from './Feedback';
18
18
  export { default as Fieldset } from './Fieldset';
19
19
  export { default as FlexGrid } from './FlexGrid';
20
+ export { default as Footnote } from './Footnote';
20
21
  export { default as HorizontalScroll } from './HorizontalScroll';
21
22
  export * from './HorizontalScroll';
22
23
  export { default as Icon } from './Icon';
@@ -8,12 +8,11 @@ const createStyleSheet = stylesWithQuery => {
8
8
  styles: {},
9
9
  fullStyles: {}
10
10
  };
11
- let cleanStyles;
12
11
  let ids = {};
12
+ const cleanStyles = deepClone(stylesWithQuery);
13
13
  Object.keys(stylesWithQuery).forEach(key => {
14
14
  if (!(stylesWithQuery !== null && stylesWithQuery !== void 0 && stylesWithQuery[key])) return;
15
15
  const mediaQueriesAndPseudoClasses = Object.keys(stylesWithQuery[key]).filter(isMediaOrPseudo);
16
- cleanStyles = deepClone(stylesWithQuery);
17
16
  mediaQueriesAndPseudoClasses.forEach(query => {
18
17
  var _ids;
19
18
  const css = createDeclarationBlock(stylesWithQuery[key][query]);
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "@floating-ui/react-native": "^0.8.1",
12
12
  "@gorhom/portal": "^1.0.14",
13
13
  "@telus-uds/system-constants": "^1.3.0",
14
- "@telus-uds/system-theme-tokens": "^2.49.0",
14
+ "@telus-uds/system-theme-tokens": "^2.50.1",
15
15
  "airbnb-prop-types": "^2.16.0",
16
16
  "css-mediaquery": "^0.1.2",
17
17
  "expo-linear-gradient": "^12.5.0",
@@ -85,5 +85,5 @@
85
85
  "standard-engine": {
86
86
  "skip": true
87
87
  },
88
- "version": "1.73.0"
88
+ "version": "1.75.0"
89
89
  }
@@ -168,7 +168,7 @@ const ExpandCollapsePanel = forwardRef(
168
168
  })
169
169
  }}
170
170
  >
171
- <View style={selectContainerStyles(themeTokens)}>{isExpanded ? children : null}</View>
171
+ <View style={selectContainerStyles(themeTokens)}>{children}</View>
172
172
  </View>
173
173
  </Animated.View>
174
174
  </View>