@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
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
- var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
9
8
  var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
10
9
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
10
  var _ThemeProvider = require("../ThemeProvider");
@@ -75,6 +74,156 @@ const selectDismissButtonContainerStyles = _ref4 => {
75
74
  const selectContentContainerStyle = maxWidth => ({
76
75
  width: maxWidth || '100%'
77
76
  });
77
+ const getMediaQueryStyles = (themeTokens, themeOptions, viewport, mediaIdsRef, dismissible) => {
78
+ const transformedSelectContainerStyles = Object.entries(themeTokens).reduce((acc, _ref5) => {
79
+ let [vp, viewportTokens] = _ref5;
80
+ acc[vp] = selectContainerStyles({
81
+ ...viewportTokens
82
+ });
83
+ return acc;
84
+ }, {});
85
+ const selectContainerMediaQueryStyles = (0, _utils.createMediaQueryStyles)(transformedSelectContainerStyles);
86
+ const {
87
+ ids: containerIds,
88
+ styles: containerStyles
89
+ } = _utils.StyleSheet.create({
90
+ container: {
91
+ flexDirection: 'row',
92
+ ...selectContainerMediaQueryStyles
93
+ }
94
+ });
95
+ const {
96
+ ids: contentContainerIds,
97
+ styles: contentContainerStyles
98
+ } = _utils.StyleSheet.create({
99
+ contentContainer: {
100
+ flexDirection: 'row',
101
+ flexShrink: 1,
102
+ justifyContent: 'space-between',
103
+ ...(0, _utils.createMediaQueryStyles)({
104
+ xs: {
105
+ width: (themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.contentMaxWidth.xs) || '100%'
106
+ },
107
+ md: {
108
+ width: (themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.contentMaxWidth.md) || '100%'
109
+ },
110
+ lg: {
111
+ width: (themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.contentMaxWidth.lg) || '100%'
112
+ },
113
+ sm: {
114
+ width: (themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.contentMaxWidth.sm) || '100%'
115
+ },
116
+ xl: {
117
+ width: (themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.contentMaxWidth.xl) || '100%'
118
+ }
119
+ })
120
+ }
121
+ });
122
+ const {
123
+ ids: staticContentContainerIds,
124
+ styles: staticContentContainerStyles
125
+ } = _utils.StyleSheet.create({
126
+ staticContentContainer: {
127
+ flexDirection: 'row',
128
+ flexShrink: 1
129
+ }
130
+ });
131
+ const {
132
+ ids: iconContainerIds,
133
+ styles: iconContainerStyles
134
+ } = _utils.StyleSheet.create({
135
+ iconContainer: selectIconContainerStyles(themeTokens[viewport])
136
+ });
137
+ const {
138
+ ids: dismissButtonContainerIds,
139
+ styles: dismissButtonContainerStyles
140
+ } = _utils.StyleSheet.create({
141
+ dismissButtonContainer: selectDismissButtonContainerStyles(themeTokens[viewport])
142
+ });
143
+ const {
144
+ ids: textIds,
145
+ styles: textStyles
146
+ } = _utils.StyleSheet.create({
147
+ text: selectTextStyles(themeTokens[viewport], themeOptions, dismissible)
148
+ });
149
+ const {
150
+ styles: selectIconPropsStyles
151
+ } = _utils.StyleSheet.create({
152
+ selectIconProps: selectIconProps(themeTokens[viewport])
153
+ });
154
+ const {
155
+ styles: selectDismissIconPropsStyles
156
+ } = _utils.StyleSheet.create({
157
+ selectDismissIconProps: selectDismissIconProps(themeTokens[viewport])
158
+ });
159
+
160
+ // eslint-disable-next-line no-param-reassign
161
+ mediaIdsRef.current = {
162
+ containerIds,
163
+ contentContainerIds,
164
+ staticContentContainerIds,
165
+ iconContainerIds,
166
+ dismissButtonContainerIds,
167
+ textIds
168
+ };
169
+ return {
170
+ containerStyles,
171
+ contentContainerStyles,
172
+ staticContentContainerStyles,
173
+ iconContainerStyles,
174
+ dismissButtonContainerStyles,
175
+ textStyles,
176
+ selectIconPropsStyles,
177
+ selectDismissIconPropsStyles
178
+ };
179
+ };
180
+ const getDefaultStyles = (themeTokens, themeOptions, maxWidth, dismissible) => ({
181
+ containerStyles: {
182
+ container: {
183
+ flexDirection: 'row',
184
+ ...selectContainerStyles(themeTokens)
185
+ }
186
+ },
187
+ contentContainerStyles: {
188
+ contentContainer: {
189
+ flexDirection: 'row',
190
+ flexShrink: 1,
191
+ justifyContent: 'space-between',
192
+ ...selectContentContainerStyle(maxWidth)
193
+ }
194
+ },
195
+ staticContentContainerStyles: {
196
+ staticContentContainer: {
197
+ flexDirection: 'row',
198
+ flexShrink: 1
199
+ }
200
+ },
201
+ iconContainerStyles: {
202
+ iconContainer: {
203
+ ...selectIconContainerStyles(themeTokens)
204
+ }
205
+ },
206
+ dismissButtonContainerStyles: {
207
+ dismissButtonContainer: {
208
+ ...selectDismissButtonContainerStyles(themeTokens)
209
+ }
210
+ },
211
+ textStyles: {
212
+ text: {
213
+ ...selectTextStyles(themeTokens, themeOptions, dismissible)
214
+ }
215
+ },
216
+ selectIconPropsStyles: {
217
+ selectIconProps: {
218
+ ...selectIconProps(themeTokens)
219
+ }
220
+ },
221
+ selectDismissIconPropsStyles: {
222
+ selectDismissIconProps: {
223
+ ...selectDismissIconProps(themeTokens)
224
+ }
225
+ }
226
+ });
78
227
 
79
228
  /**
80
229
  * A banner that highlights important messages:
@@ -127,7 +276,7 @@ const selectContentContainerStyle = maxWidth => ({
127
276
  * Use full-width `Notifications` to show system-based messages coming from the application, not in response to user action.
128
277
  * Show system notifications at the top of the page, below the navigation, and expands the full-width of the viewport
129
278
  */
130
- const Notification = /*#__PURE__*/(0, _react.forwardRef)((_ref5, ref) => {
279
+ const Notification = /*#__PURE__*/(0, _react.forwardRef)((_ref6, ref) => {
131
280
  let {
132
281
  children,
133
282
  system,
@@ -136,13 +285,9 @@ const Notification = /*#__PURE__*/(0, _react.forwardRef)((_ref5, ref) => {
136
285
  tokens,
137
286
  variant,
138
287
  ...rest
139
- } = _ref5;
288
+ } = _ref6;
140
289
  const [isDismissed, setIsDismissed] = (0, _react.useState)(false);
141
290
  const viewport = (0, _ViewportProvider.useViewport)();
142
- const themeTokens = (0, _ThemeProvider.useThemeTokens)('Notification', tokens, variant, {
143
- system,
144
- viewport
145
- });
146
291
  const getCopy = (0, _useCopy.default)({
147
292
  dictionary: _dictionary.default,
148
293
  copy
@@ -150,42 +295,89 @@ const Notification = /*#__PURE__*/(0, _react.forwardRef)((_ref5, ref) => {
150
295
  const {
151
296
  themeOptions
152
297
  } = (0, _ThemeProvider.useTheme)();
153
- const contentMaxWidth = (0, _utils.useResponsiveProp)(themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.contentMaxWidth);
298
+ const {
299
+ enableMediaQueryStyleSheet
300
+ } = themeOptions;
301
+ const useTokens = enableMediaQueryStyleSheet ? _ThemeProvider.useResponsiveThemeTokens : _ThemeProvider.useThemeTokens;
302
+ const themeTokens = useTokens('Notification', tokens, variant, {
303
+ system,
304
+ viewport
305
+ });
306
+ const maxWidth = (0, _utils.useResponsiveProp)(themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.contentMaxWidth);
307
+ const notificationComponentRef = (0, _react.useRef)({
308
+ containerStyles: {},
309
+ contentContainerStyles: {},
310
+ staticContentContainerStyles: {},
311
+ iconContainerStyles: {},
312
+ dismissButtonContainerStyles: {},
313
+ textStyles: {},
314
+ selectIconPropsStyles: {},
315
+ selectDismissIconPropsStyles: {}
316
+ });
317
+ const mediaIdsRef = (0, _react.useRef)({
318
+ containerIds: {},
319
+ contentContainerIds: {},
320
+ staticContentContainerIds: {},
321
+ iconContainerIds: {},
322
+ dismissButtonContainerIds: {},
323
+ textIds: {},
324
+ selectIconPropsIds: {},
325
+ selectDismissIconPropsIds: {}
326
+ });
327
+ if (enableMediaQueryStyleSheet) {
328
+ notificationComponentRef.current = getMediaQueryStyles(themeTokens, themeOptions, viewport, mediaIdsRef, dismissible);
329
+ } else {
330
+ notificationComponentRef.current = getDefaultStyles(themeTokens, themeOptions, maxWidth, dismissible);
331
+ }
154
332
  if (isDismissed) {
155
333
  return null;
156
334
  }
157
- const textStyles = selectTextStyles(themeTokens, themeOptions, dismissible);
158
335
  const content = (0, _utils.wrapStringsInText)(typeof children === 'function' ? children({
159
- textStyles,
336
+ textStyles: notificationComponentRef.current.textStyles.text,
160
337
  variant
161
338
  }) : children, {
162
- style: textStyles
339
+ style: notificationComponentRef.current.textStyles.text
163
340
  });
164
341
  const {
165
342
  icon: IconComponent,
166
343
  dismissIcon: DismissIconComponent,
167
344
  dismissIconColor
168
- } = themeTokens;
345
+ } = enableMediaQueryStyleSheet === false ? themeTokens : themeTokens[viewport];
169
346
  const onDismissPress = () => setIsDismissed(true);
170
347
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
171
348
  ref: ref,
172
- style: [staticStyles.container, selectContainerStyles(themeTokens)],
349
+ style: notificationComponentRef.current.containerStyles.container,
350
+ dataSet: mediaIdsRef && {
351
+ media: mediaIdsRef.current.containerIds.container
352
+ },
173
353
  ...selectProps(rest),
174
354
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
175
- style: [staticStyles.content, selectContentContainerStyle(contentMaxWidth)],
355
+ style: notificationComponentRef.current.contentContainerStyles.contentContainer,
356
+ dataSet: mediaIdsRef && {
357
+ media: mediaIdsRef.current.contentContainerIds.contentContainer
358
+ },
176
359
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
177
- style: staticStyles.contentContainer,
360
+ style: notificationComponentRef.current.staticContentContainerStyles.staticContentContainer,
361
+ dataSet: mediaIdsRef && {
362
+ media: mediaIdsRef.current.staticContentContainerIds.staticContentContainer
363
+ },
178
364
  children: [IconComponent && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
179
- style: selectIconContainerStyles(themeTokens),
365
+ style: notificationComponentRef.current.iconContainerStyles.iconContainer,
366
+ dataSet: mediaIdsRef && {
367
+ media: mediaIdsRef.current.iconContainerIds.iconContainer
368
+ },
180
369
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(IconComponent, {
181
- ...selectIconProps(themeTokens)
370
+ ...notificationComponentRef.current.selectIconPropsStyles.selectIconProps
182
371
  })
183
372
  }), content && typeof content === 'function' ? content({
184
- textStyles,
373
+ textStyles: notificationComponentRef.current.textStyles.text,
185
374
  variant
186
375
  }) : content]
187
376
  }), dismissible && DismissIconComponent && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
188
- style: selectDismissButtonContainerStyles(themeTokens),
377
+ style: notificationComponentRef.current.dismissButtonContainerStyles.dismissButtonContainer,
378
+ dataSet: mediaIdsRef && {
379
+ media: mediaIdsRef.current.dismissButtonContainerIds.dismissButtonContainer
380
+ },
189
381
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
190
382
  action: "close",
191
383
  onPress: onDismissPress,
@@ -197,7 +389,7 @@ const Notification = /*#__PURE__*/(0, _react.forwardRef)((_ref5, ref) => {
197
389
  size: 'small'
198
390
  },
199
391
  children: () => /*#__PURE__*/(0, _jsxRuntime.jsx)(DismissIconComponent, {
200
- ...selectDismissIconProps(themeTokens)
392
+ ...notificationComponentRef.current.selectDismissIconPropsStyles.selectDismissIconProps
201
393
  })
202
394
  })
203
395
  })]
@@ -229,18 +421,4 @@ Notification.propTypes = {
229
421
  variant: _utils.variantProp.propType
230
422
  };
231
423
  var _default = Notification;
232
- exports.default = _default;
233
- const staticStyles = _StyleSheet.default.create({
234
- container: {
235
- flexDirection: 'row'
236
- },
237
- contentContainer: {
238
- flexDirection: 'row',
239
- flexShrink: 1
240
- },
241
- content: {
242
- flexDirection: 'row',
243
- flexShrink: 1,
244
- justifyContent: 'space-between'
245
- }
246
- });
424
+ exports.default = _default;
@@ -26,6 +26,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
26
26
  let {
27
27
  min = 'xs',
28
28
  max,
29
+ inheritedStyles = [],
29
30
  children
30
31
  } = _ref;
31
32
  const {
@@ -35,6 +36,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
35
36
  } = (0, _ThemeProvider.useTheme)();
36
37
  if (enableMediaQueryStyleSheet) {
37
38
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ResponsiveWithMediaQueryStyleSheet.default, {
39
+ inheritedStyles: inheritedStyles,
38
40
  min: min,
39
41
  max: max,
40
42
  children: children
@@ -56,6 +58,12 @@ Responsive.propTypes = {
56
58
  * To hide children of `Responsive` if the current viewport is larger than `max`
57
59
  */
58
60
  max: _propTypes.default.oneOf(['sm', 'md', 'lg', 'xl']),
61
+ /**
62
+ * Styles to be inherited by `Responsive`.
63
+ * It should be an array of style property names.
64
+ * Note: This prop is only applicable when `enableMediaQueryStylesheet` is set to true in the `ThemeProvider`.
65
+ */
66
+ inheritedStyles: _propTypes.default.arrayOf(_propTypes.default.string),
59
67
  children: _propTypes.default.node.isRequired
60
68
  };
61
69
  var _default = Responsive;
@@ -35,6 +35,7 @@ const ResponsiveWithMediaQueryStyleSheet = _ref => {
35
35
  let {
36
36
  min,
37
37
  max,
38
+ inheritedStyles = [],
38
39
  children
39
40
  } = _ref;
40
41
  const {
@@ -42,9 +43,10 @@ const ResponsiveWithMediaQueryStyleSheet = _ref => {
42
43
  styles
43
44
  } = _utils.StyleSheet.create({
44
45
  responsive: {
45
- flexDirection: 'inherit',
46
- alignItems: 'inherit',
47
- justifyContent: 'inherit',
46
+ ...inheritedStyles.reduce((acc, prop) => {
47
+ acc[prop] = 'inherit';
48
+ return acc;
49
+ }, {}),
48
50
  ...generateResponsiveStyles(min, max)
49
51
  }
50
52
  });
@@ -66,6 +68,7 @@ ResponsiveWithMediaQueryStyleSheet.propTypes = {
66
68
  * To hide children of `Responsive` if the current viewport is larger than `max`
67
69
  */
68
70
  max: _propTypes.default.oneOf(['sm', 'md', 'lg', 'xl']),
71
+ inheritedStyles: _propTypes.default.arrayOf(_propTypes.default.string),
69
72
  children: _propTypes.default.node.isRequired
70
73
  };
71
74
  var _default = ResponsiveWithMediaQueryStyleSheet;
@@ -69,7 +69,9 @@ const Typography = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
69
69
  enableMediaQueryStyleSheet
70
70
  } = themeOptions;
71
71
  const useTokens = enableMediaQueryStyleSheet ? _ThemeProvider.useResponsiveThemeTokens : _ThemeProvider.useThemeTokens;
72
- const themeTokens = useTokens('Typography', tokens, variant);
72
+ const themeTokens = useTokens('Typography', tokens, variant, !enableMediaQueryStyleSheet && {
73
+ viewport
74
+ });
73
75
  const maxFontSizeMultiplier = enableMediaQueryStyleSheet ? (0, _utils2.getMaxFontMultiplier)(themeTokens[viewport]) : (0, _utils2.getMaxFontMultiplier)(themeTokens);
74
76
  const textDecorationLine = strikeThrough ? 'line-through' : 'none';
75
77
  let textStyles;
package/lib/index.js CHANGED
@@ -22,6 +22,7 @@ var _exportNames = {
22
22
  Feedback: true,
23
23
  Fieldset: true,
24
24
  FlexGrid: true,
25
+ Footnote: true,
25
26
  HorizontalScroll: true,
26
27
  Icon: true,
27
28
  IconButton: true,
@@ -182,6 +183,12 @@ Object.defineProperty(exports, "FlexGrid", {
182
183
  return _FlexGrid.default;
183
184
  }
184
185
  });
186
+ Object.defineProperty(exports, "Footnote", {
187
+ enumerable: true,
188
+ get: function () {
189
+ return _Footnote.default;
190
+ }
191
+ });
185
192
  Object.defineProperty(exports, "HorizontalScroll", {
186
193
  enumerable: true,
187
194
  get: function () {
@@ -539,6 +546,7 @@ var _ExpandCollapse = _interopRequireWildcard(require("./ExpandCollapse"));
539
546
  var _Feedback = _interopRequireDefault(require("./Feedback"));
540
547
  var _Fieldset = _interopRequireDefault(require("./Fieldset"));
541
548
  var _FlexGrid = _interopRequireDefault(require("./FlexGrid"));
549
+ var _Footnote = _interopRequireDefault(require("./Footnote"));
542
550
  var _HorizontalScroll = _interopRequireWildcard(require("./HorizontalScroll"));
543
551
  Object.keys(_HorizontalScroll).forEach(function (key) {
544
552
  if (key === "default" || key === "__esModule") return;
@@ -15,12 +15,11 @@ const createStyleSheet = stylesWithQuery => {
15
15
  styles: {},
16
16
  fullStyles: {}
17
17
  };
18
- let cleanStyles;
19
18
  let ids = {};
19
+ const cleanStyles = (0, _common.deepClone)(stylesWithQuery);
20
20
  Object.keys(stylesWithQuery).forEach(key => {
21
21
  if (!(stylesWithQuery !== null && stylesWithQuery !== void 0 && stylesWithQuery[key])) return;
22
22
  const mediaQueriesAndPseudoClasses = Object.keys(stylesWithQuery[key]).filter(_common.isMediaOrPseudo);
23
- cleanStyles = (0, _common.deepClone)(stylesWithQuery);
24
23
  mediaQueriesAndPseudoClasses.forEach(query => {
25
24
  var _ids;
26
25
  const css = (0, _createDeclarationBlock.default)(stylesWithQuery[key][query]);
@@ -166,7 +166,7 @@ const ExpandCollapsePanel = /*#__PURE__*/forwardRef((_ref4, ref) => {
166
166
  },
167
167
  children: /*#__PURE__*/_jsx(View, {
168
168
  style: selectContainerStyles(themeTokens),
169
- children: isExpanded ? children : null
169
+ children: children
170
170
  })
171
171
  })
172
172
  })]