@telus-uds/components-web 1.3.0 → 1.5.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 (128) hide show
  1. package/CHANGELOG.md +32 -2
  2. package/lib/Breadcrumbs/Breadcrumbs.js +247 -0
  3. package/lib/Breadcrumbs/Item/Item.js +165 -0
  4. package/lib/Breadcrumbs/index.js +15 -0
  5. package/lib/Callout/Callout.js +121 -0
  6. package/lib/Callout/index.js +13 -0
  7. package/lib/DatePicker/CalendarContainer.js +221 -0
  8. package/lib/DatePicker/DatePicker.js +329 -0
  9. package/lib/DatePicker/dictionary.js +134 -0
  10. package/lib/DatePicker/index.js +13 -0
  11. package/lib/DatePicker/reactDatesCss.js +12 -0
  12. package/lib/ExpandCollapseMini/ExpandCollapseMini.js +75 -0
  13. package/lib/ExpandCollapseMini/ExpandCollapseMiniControl.js +95 -0
  14. package/lib/ExpandCollapseMini/index.js +13 -0
  15. package/lib/Footnote/Footnote.js +571 -0
  16. package/lib/Footnote/FootnoteLink.js +149 -0
  17. package/lib/Footnote/dictionary.js +19 -0
  18. package/lib/Footnote/index.js +16 -0
  19. package/lib/Paragraph/Paragraph.js +107 -0
  20. package/lib/Paragraph/index.js +13 -0
  21. package/lib/PreviewCard/AuthorDate.js +64 -0
  22. package/lib/PreviewCard/PreviewCard.js +236 -0
  23. package/lib/PreviewCard/index.js +13 -0
  24. package/lib/PriceLockup/PriceLockup.js +237 -0
  25. package/lib/PriceLockup/index.js +13 -0
  26. package/lib/PriceLockup/tokens.js +131 -0
  27. package/lib/ResponsiveImage/ResponsiveImage.js +115 -0
  28. package/lib/ResponsiveImage/index.js +13 -0
  29. package/lib/Ribbon/Ribbon.js +0 -1
  30. package/lib/Span/Span.js +88 -0
  31. package/lib/Span/index.js +13 -0
  32. package/lib/index.js +91 -1
  33. package/lib/shared/FullBleedContent/FullBleedContent.js +121 -0
  34. package/lib/shared/FullBleedContent/getFullBleedBorderRadius.js +73 -0
  35. package/lib/shared/FullBleedContent/index.js +29 -0
  36. package/lib/shared/FullBleedContent/useFullBleedContentProps.js +73 -0
  37. package/lib/utils/index.js +32 -0
  38. package/lib/utils/logger.js +31 -0
  39. package/lib/utils/media.js +54 -0
  40. package/lib/utils/renderStructuredContent.js +89 -0
  41. package/lib/utils/useTypographyTheme.js +32 -0
  42. package/lib-module/Breadcrumbs/Breadcrumbs.js +228 -0
  43. package/lib-module/Breadcrumbs/Item/Item.js +141 -0
  44. package/lib-module/Breadcrumbs/index.js +1 -0
  45. package/lib-module/Callout/Callout.js +106 -0
  46. package/lib-module/Callout/index.js +2 -0
  47. package/lib-module/DatePicker/CalendarContainer.js +208 -0
  48. package/lib-module/DatePicker/DatePicker.js +302 -0
  49. package/lib-module/DatePicker/dictionary.js +127 -0
  50. package/lib-module/DatePicker/index.js +2 -0
  51. package/lib-module/DatePicker/reactDatesCss.js +3 -0
  52. package/lib-module/ExpandCollapseMini/ExpandCollapseMini.js +56 -0
  53. package/lib-module/ExpandCollapseMini/ExpandCollapseMiniControl.js +80 -0
  54. package/lib-module/ExpandCollapseMini/index.js +2 -0
  55. package/lib-module/Footnote/Footnote.js +541 -0
  56. package/lib-module/Footnote/FootnoteLink.js +130 -0
  57. package/lib-module/Footnote/dictionary.js +12 -0
  58. package/lib-module/Footnote/index.js +4 -0
  59. package/lib-module/Paragraph/Paragraph.js +89 -0
  60. package/lib-module/Paragraph/index.js +2 -0
  61. package/lib-module/PreviewCard/AuthorDate.js +53 -0
  62. package/lib-module/PreviewCard/PreviewCard.js +211 -0
  63. package/lib-module/PreviewCard/index.js +2 -0
  64. package/lib-module/PriceLockup/PriceLockup.js +213 -0
  65. package/lib-module/PriceLockup/index.js +2 -0
  66. package/lib-module/PriceLockup/tokens.js +120 -0
  67. package/lib-module/ResponsiveImage/ResponsiveImage.js +100 -0
  68. package/lib-module/ResponsiveImage/index.js +2 -0
  69. package/lib-module/Ribbon/Ribbon.js +1 -2
  70. package/lib-module/Span/Span.js +70 -0
  71. package/lib-module/Span/index.js +2 -0
  72. package/lib-module/index.js +10 -0
  73. package/lib-module/shared/FullBleedContent/FullBleedContent.js +106 -0
  74. package/lib-module/shared/FullBleedContent/getFullBleedBorderRadius.js +65 -0
  75. package/lib-module/shared/FullBleedContent/index.js +4 -0
  76. package/lib-module/shared/FullBleedContent/useFullBleedContentProps.js +65 -0
  77. package/lib-module/utils/index.js +5 -1
  78. package/lib-module/utils/logger.js +18 -0
  79. package/lib-module/utils/media.js +46 -0
  80. package/lib-module/utils/renderStructuredContent.js +77 -0
  81. package/lib-module/utils/useTypographyTheme.js +24 -0
  82. package/package.json +9 -5
  83. package/src/Breadcrumbs/Breadcrumbs.jsx +222 -0
  84. package/src/Breadcrumbs/Item/Item.jsx +127 -0
  85. package/src/Breadcrumbs/index.js +1 -0
  86. package/src/Callout/Callout.jsx +76 -0
  87. package/src/Callout/index.js +3 -0
  88. package/src/DatePicker/CalendarContainer.jsx +210 -0
  89. package/src/DatePicker/DatePicker.jsx +303 -0
  90. package/src/DatePicker/dictionary.js +92 -0
  91. package/src/DatePicker/index.js +3 -0
  92. package/src/DatePicker/reactDatesCss.js +892 -0
  93. package/src/ExpandCollapseMini/ExpandCollapseMini.jsx +48 -0
  94. package/src/ExpandCollapseMini/ExpandCollapseMiniControl.jsx +67 -0
  95. package/src/ExpandCollapseMini/index.js +3 -0
  96. package/src/Footnote/Footnote.jsx +468 -0
  97. package/src/Footnote/FootnoteLink.jsx +120 -0
  98. package/src/Footnote/dictionary.js +12 -0
  99. package/src/Footnote/index.js +6 -0
  100. package/src/Paragraph/Paragraph.jsx +79 -0
  101. package/src/Paragraph/index.js +3 -0
  102. package/src/PreviewCard/AuthorDate.jsx +31 -0
  103. package/src/PreviewCard/PreviewCard.jsx +201 -0
  104. package/src/PreviewCard/index.js +3 -0
  105. package/src/PriceLockup/PriceLockup.jsx +210 -0
  106. package/src/PriceLockup/index.js +3 -0
  107. package/src/PriceLockup/tokens.js +58 -0
  108. package/src/ResponsiveImage/ResponsiveImage.jsx +77 -0
  109. package/src/ResponsiveImage/index.js +3 -0
  110. package/src/Ribbon/Ribbon.jsx +0 -1
  111. package/src/Span/Span.jsx +66 -0
  112. package/src/Span/index.js +3 -0
  113. package/src/index.js +10 -0
  114. package/src/shared/FullBleedContent/FullBleedContent.jsx +90 -0
  115. package/src/shared/FullBleedContent/getFullBleedBorderRadius.js +55 -0
  116. package/src/shared/FullBleedContent/index.js +6 -0
  117. package/src/shared/FullBleedContent/useFullBleedContentProps.js +63 -0
  118. package/src/utils/index.js +5 -1
  119. package/src/utils/logger.js +20 -0
  120. package/src/utils/media.js +40 -0
  121. package/src/utils/renderStructuredContent.jsx +73 -0
  122. package/src/utils/useTypographyTheme.js +14 -0
  123. package/types/Callout.d.ts +13 -0
  124. package/types/DatePicker.d.ts +21 -0
  125. package/types/Footnote.d.ts +21 -0
  126. package/types/FootnoteLink.d.ts +20 -0
  127. package/types/PriceLockup.d.ts +22 -0
  128. package/types/common.d.ts +14 -0
@@ -0,0 +1,100 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { selectSystemProps } from '@telus-uds/components-base';
4
+ import { viewports } from '@telus-uds/system-constants';
5
+ import { htmlAttrs } from '../utils';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ import { jsxs as _jsxs } from "react/jsx-runtime";
8
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
9
+ const staticStyles = {
10
+ image: {
11
+ display: 'block',
12
+ width: '100%'
13
+ }
14
+ };
15
+ /**
16
+ * Provide different image sources for different screen sizes.
17
+ */
18
+
19
+ const ResponsiveImage = _ref => {
20
+ let {
21
+ xsSrc,
22
+ smSrc,
23
+ mdSrc,
24
+ lgSrc,
25
+ xlSrc,
26
+ fallbackSrc,
27
+ alt,
28
+ loading = 'eager',
29
+ ...rest
30
+ } = _ref;
31
+ return /*#__PURE__*/_jsxs("picture", { ...selectProps(rest),
32
+ children: [/*#__PURE__*/_jsx("source", {
33
+ srcSet: xlSrc,
34
+ media: `(min-width: ${viewports.map.get(viewports.xl)}px)`
35
+ }), /*#__PURE__*/_jsx("source", {
36
+ srcSet: lgSrc,
37
+ media: `(min-width: ${viewports.map.get(viewports.lg)}px)`
38
+ }), /*#__PURE__*/_jsx("source", {
39
+ srcSet: mdSrc,
40
+ media: `(min-width: ${viewports.map.get(viewports.md)}px)`
41
+ }), /*#__PURE__*/_jsx("source", {
42
+ srcSet: smSrc,
43
+ media: `(min-width: ${viewports.map.get(viewports.sm)}px)`
44
+ }), /*#__PURE__*/_jsx("source", {
45
+ srcSet: xsSrc,
46
+ media: `(max-width: ${viewports.map.get(viewports.sm) - 1}px)`
47
+ }), /*#__PURE__*/_jsx("img", {
48
+ src: fallbackSrc,
49
+ alt: alt,
50
+ style: staticStyles.image,
51
+ loading: loading
52
+ })]
53
+ });
54
+ };
55
+
56
+ ResponsiveImage.propTypes = { ...selectedSystemPropTypes,
57
+
58
+ /**
59
+ * The src attribute used for screen widths up to 575px
60
+ */
61
+ xsSrc: PropTypes.string.isRequired,
62
+
63
+ /**
64
+ * The src attribute used for screen widths greater than 576px
65
+ */
66
+ smSrc: PropTypes.string.isRequired,
67
+
68
+ /**
69
+ * The src attribute used for screen widths greater than 768px
70
+ */
71
+ mdSrc: PropTypes.string,
72
+
73
+ /**
74
+ * The src attribute used for screen widths greater than 992px
75
+ */
76
+ lgSrc: PropTypes.string,
77
+
78
+ /**
79
+ * The src attribute used for screen widths greater than 1200px
80
+ */
81
+ xlSrc: PropTypes.string,
82
+
83
+ /**
84
+ * The src attribute used for browsers that don't support responsive images (InternetExplorer)
85
+ */
86
+ fallbackSrc: PropTypes.string.isRequired,
87
+
88
+ /**
89
+ * The alt attribute for the HTML img element. Setting this attribute to an empty string (alt="") indicates that this image is not a key part of the content, and that non-visual browsers may omit it from rendering.
90
+ */
91
+ alt: PropTypes.string.isRequired,
92
+
93
+ /**
94
+ * Loading strategy.
95
+ * @default 'eager'
96
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attr-loading
97
+ */
98
+ loading: PropTypes.oneOf(['eager', 'lazy'])
99
+ };
100
+ export default ResponsiveImage;
@@ -0,0 +1,2 @@
1
+ import ResponsiveImage from './ResponsiveImage';
2
+ export default ResponsiveImage;
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { selectSystemProps, Typography, useThemeTokens } from '@telus-uds/components-base'; // import palette from '@telus-uds/palette-allium/build/web/palette'
4
-
3
+ import { selectSystemProps, Typography, useThemeTokens } from '@telus-uds/components-base';
5
4
  import styled from 'styled-components';
6
5
  import { htmlAttrs } from '../utils';
7
6
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -0,0 +1,70 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import styled from 'styled-components';
4
+ import { selectSystemProps } from '@telus-uds/components-base';
5
+ import { htmlAttrs, useTypographyTheme } from '../utils';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
8
+ const StyledSpan = /*#__PURE__*/styled.span.withConfig({
9
+ displayName: "Span__StyledSpan",
10
+ componentId: "components-web__sc-o7sihn-0"
11
+ })(["", "};"], _ref => {
12
+ let {
13
+ flex
14
+ } = _ref;
15
+ return flex ? 'display: inline-flex' : '';
16
+ });
17
+ /**
18
+ * Text as an HTML ```<span>``` element.
19
+ *
20
+ * Span may be used in cases where an inline span or direct access to HTML attributes is required.
21
+ * In most cases, `Typography` should be used for text, or Paragraph for body text.
22
+ */
23
+
24
+ const Span = _ref2 => {
25
+ let {
26
+ children,
27
+ variant,
28
+ tokens,
29
+ testID,
30
+ flex,
31
+ ...rest
32
+ } = _ref2;
33
+ const style = useTypographyTheme(variant, tokens);
34
+ return /*#__PURE__*/_jsx(StyledSpan, {
35
+ "data-testid": testID,
36
+ flex: flex,
37
+ style: style,
38
+ ...selectProps(rest),
39
+ children: children
40
+ });
41
+ };
42
+
43
+ Span.propTypes = { ...selectedSystemPropTypes,
44
+ children: PropTypes.node.isRequired,
45
+ testID: PropTypes.string,
46
+
47
+ /**
48
+ * Sets display to inline-flex so that children are laid out using the flex model.
49
+ * Use this if the span contains children that expect to be inside a flex container.
50
+ */
51
+ flex: PropTypes.bool,
52
+
53
+ /**
54
+ * Span takes the same tokens overrides as Typography
55
+ */
56
+ tokens: PropTypes.oneOf([PropTypes.object, PropTypes.func]),
57
+
58
+ /**
59
+ * Span can take any of Typography's theme variants
60
+ */
61
+ variant: PropTypes.exact({
62
+ bold: PropTypes.bool,
63
+ colour: PropTypes.oneOf(['secondary', 'tertiary']),
64
+ compact: PropTypes.bool,
65
+ inverse: PropTypes.bool,
66
+ size: PropTypes.oneOf(['micro', 'small', 'large', 'eyebrow', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'display1', 'display2']),
67
+ weight: PropTypes.oneOf(['semibold', 'bold'])
68
+ })
69
+ };
70
+ export default Span;
@@ -0,0 +1,2 @@
1
+ import Span from './Span';
2
+ export default Span;
@@ -1,5 +1,15 @@
1
1
  export { default as Badge } from './Badge';
2
2
  export { default as OrderedList } from './OrderedList';
3
+ export { default as PreviewCard } from './PreviewCard';
4
+ export { default as ResponsiveImage } from './ResponsiveImage';
3
5
  export { default as Ribbon } from './Ribbon';
6
+ export { default as DatePicker } from './DatePicker';
7
+ export { default as Paragraph } from './Paragraph';
8
+ export { default as Span } from './Span';
9
+ export { default as ExpandCollapseMini } from './ExpandCollapseMini';
10
+ export { default as Callout } from './Callout';
11
+ export { default as PriceLockup } from './PriceLockup';
12
+ export { default as Footnote } from './Footnote';
4
13
  export { transformGradient } from './utils';
14
+ export { default as Breadcrumbs } from './Breadcrumbs';
5
15
  export * from './baseExports';
@@ -0,0 +1,106 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import styled from 'styled-components';
4
+ import ResponsiveImage from '../../ResponsiveImage';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+
7
+ const selectFullBleedContentProps = _ref => {
8
+ let {
9
+ alt,
10
+ height,
11
+ loading,
12
+ src,
13
+ width,
14
+ fallbackSrc = src,
15
+ lgSrc = src,
16
+ mdSrc = src,
17
+ smSrc = src,
18
+ xlSrc = src,
19
+ xsSrc = src
20
+ } = _ref;
21
+ return {
22
+ alt,
23
+ height,
24
+ loading,
25
+ src,
26
+ width,
27
+ fallbackSrc,
28
+ lgSrc,
29
+ mdSrc,
30
+ smSrc,
31
+ xlSrc,
32
+ xsSrc
33
+ };
34
+ };
35
+
36
+ const FullBleedContentContainer = /*#__PURE__*/styled.div.withConfig({
37
+ displayName: "FullBleedContent__FullBleedContentContainer",
38
+ componentId: "components-web__sc-1130ea5-0"
39
+ })(_ref2 => {
40
+ let {
41
+ borderBottomLeftRadius,
42
+ borderBottomRightRadius,
43
+ borderTopLeftRadius,
44
+ borderTopRightRadius
45
+ } = _ref2;
46
+ return {
47
+ overflow: 'hidden',
48
+ borderBottomLeftRadius,
49
+ borderBottomRightRadius,
50
+ borderTopLeftRadius,
51
+ borderTopRightRadius
52
+ };
53
+ });
54
+ /**
55
+ * Full bleed content component can accept either a single source,
56
+ * a number of sources corresponding to the `ResponsiveImage` component API,
57
+ * or a custom component.
58
+ */
59
+
60
+ const FullBleedContent = _ref3 => {
61
+ let {
62
+ borderRadius,
63
+ content,
64
+ ...rest
65
+ } = _ref3;
66
+ return /*#__PURE__*/_jsx(FullBleedContentContainer, { ...borderRadius,
67
+ children: content ?? /*#__PURE__*/_jsx(ResponsiveImage, { ...selectFullBleedContentProps(rest)
68
+ })
69
+ });
70
+ };
71
+
72
+ FullBleedContent.propTypes = {
73
+ /**
74
+ * Content border radius matching the edge values on the parent card.
75
+ */
76
+ borderRadius: PropTypes.shape({
77
+ borderBottomLeftRadius: PropTypes.number,
78
+ borderBottomRightRadius: PropTypes.number,
79
+ borderTopLeftRadius: PropTypes.number,
80
+ borderTopRightRadius: PropTypes.number
81
+ }),
82
+
83
+ /**
84
+ * Custom JSX to be used for rendering the content (defaults to `ResponsiveImage` receiving other props).
85
+ */
86
+ content: PropTypes.node,
87
+
88
+ /**
89
+ * Image source.
90
+ */
91
+ src: PropTypes.string,
92
+
93
+ /**
94
+ * Also accept props for `ResponsiveImage`...
95
+ */
96
+ ...ResponsiveImage.propTypes,
97
+
98
+ /**
99
+ * ...but make the required ones optional.
100
+ */
101
+ alt: PropTypes.string,
102
+ xsSrc: PropTypes.string,
103
+ smSrc: PropTypes.string,
104
+ fallbackSrc: PropTypes.string
105
+ };
106
+ export default FullBleedContent;
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Gets the border radius values for an item of content that goes right up to
3
+ * the edges of its container, to the top, bottom, left or right of other content.
4
+ *
5
+ * Gives the full bleed item the same border radius as the container on the corners
6
+ * that are flush with the corners of the container.
7
+ *
8
+ * @param {number} borderRadius
9
+ * @param {'top'|'bottom'|'left'|'right'} position
10
+ * @param {boolean} hasFooter
11
+ * @returns
12
+ */
13
+ const getFullBleedBorderRadius = function (borderRadius, position) {
14
+ let hasFooter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
15
+ const innerBorderRadius = {
16
+ borderBottomLeftRadius: 0,
17
+ borderBottomRightRadius: 0,
18
+ borderTopLeftRadius: 0,
19
+ borderTopRightRadius: 0
20
+ };
21
+
22
+ if (position && position !== 'none') {
23
+ if (borderRadius) {
24
+ // Depending on the position of the image, we need to round some
25
+ // corners, but not the others
26
+ switch (position) {
27
+ case 'bottom':
28
+ if (!hasFooter) {
29
+ innerBorderRadius.borderBottomLeftRadius = borderRadius;
30
+ innerBorderRadius.borderBottomRightRadius = borderRadius;
31
+ }
32
+
33
+ break;
34
+
35
+ case 'left':
36
+ if (!hasFooter) {
37
+ innerBorderRadius.borderBottomLeftRadius = borderRadius;
38
+ }
39
+
40
+ innerBorderRadius.borderTopLeftRadius = borderRadius;
41
+ break;
42
+
43
+ case 'right':
44
+ if (!hasFooter) {
45
+ innerBorderRadius.borderBottomRightRadius = borderRadius;
46
+ }
47
+
48
+ innerBorderRadius.borderTopRightRadius = borderRadius;
49
+ break;
50
+
51
+ case 'top':
52
+ innerBorderRadius.borderTopLeftRadius = borderRadius;
53
+ innerBorderRadius.borderTopRightRadius = borderRadius;
54
+ break;
55
+
56
+ default:
57
+ break;
58
+ }
59
+ }
60
+ }
61
+
62
+ return innerBorderRadius;
63
+ };
64
+
65
+ export default getFullBleedBorderRadius;
@@ -0,0 +1,4 @@
1
+ import FullBleedContent from './FullBleedContent';
2
+ export default FullBleedContent;
3
+ export { default as getFullBleedBorderRadius } from './getFullBleedBorderRadius';
4
+ export { default as useFullBleedContentProps } from './useFullBleedContentProps';
@@ -0,0 +1,65 @@
1
+ import { useResponsiveProp } from '@telus-uds/components-base';
2
+
3
+ const getContentStackDirection = fullBleedContentPosition => {
4
+ switch (fullBleedContentPosition) {
5
+ case 'left':
6
+ return 'row-reverse';
7
+
8
+ case 'right':
9
+ return 'row';
10
+
11
+ case 'top':
12
+ return 'column-reverse';
13
+
14
+ default:
15
+ return 'column';
16
+ }
17
+ };
18
+
19
+ const getContentStackAlign = fullBleedContentAlign => {
20
+ switch (fullBleedContentAlign) {
21
+ case 'center':
22
+ return 'center';
23
+
24
+ case 'end':
25
+ case 'flex-end':
26
+ return 'flex-end';
27
+
28
+ case 'start':
29
+ case 'flex-start':
30
+ return 'flex-start';
31
+
32
+ default:
33
+ return 'stretch';
34
+ }
35
+ };
36
+ /**
37
+ * Resolves a set of `FullBleedContent` props into the variables a container needs to
38
+ * correctly position a `FullBleedContent` component for the current viewport.
39
+ *
40
+ * @param {object} [fullBleedContent] - a set of valid proptypes for FullBleedContent
41
+ * @returns
42
+ */
43
+
44
+
45
+ const useFullBleedContentProps = fullBleedContent => {
46
+ const {
47
+ align: fullBleedContentAlignProp,
48
+ position: fullBleedContentPositionProp,
49
+ ...fullBleedContentProps
50
+ } = fullBleedContent ?? {
51
+ position: 'none'
52
+ };
53
+ const fullBleedContentPosition = useResponsiveProp(fullBleedContentPositionProp, 'none');
54
+ const contentStackDirection = getContentStackDirection(fullBleedContentPosition);
55
+ const fullBleedContentAlign = useResponsiveProp(fullBleedContentAlignProp, 'stretch');
56
+ const contentStackAlign = getContentStackAlign(fullBleedContentAlign);
57
+ return {
58
+ contentStackAlign,
59
+ contentStackDirection,
60
+ fullBleedContentPosition,
61
+ fullBleedContentProps
62
+ };
63
+ };
64
+
65
+ export default useFullBleedContentProps;
@@ -1,3 +1,7 @@
1
1
  import { transformGradient } from './transforms';
2
+ import useTypographyTheme from './useTypographyTheme';
2
3
  import htmlAttrs from './htmlAttrs';
3
- export { htmlAttrs, transformGradient };
4
+ import { warn } from './logger';
5
+ import media from './media';
6
+ import renderStructuredContent from './renderStructuredContent';
7
+ export { htmlAttrs, transformGradient, useTypographyTheme, warn, media, renderStructuredContent };
@@ -0,0 +1,18 @@
1
+ export const deprecate = (componentName, message) => {
2
+ if (process.env.NODE_ENV === 'production') {
3
+ return;
4
+ }
5
+
6
+ console.warn(`[Allium] [Deprecate] ${componentName}: ${message}`); // eslint-disable-line no-console
7
+ };
8
+ export const warn = (componentName, message) => {
9
+ if (process.env.NODE_ENV === 'production') {
10
+ return;
11
+ }
12
+
13
+ console.warn(`[Allium] ${componentName}: ${message}`); // eslint-disable-line no-console
14
+ };
15
+ export default {
16
+ deprecate,
17
+ warn
18
+ };
@@ -0,0 +1,46 @@
1
+ import { viewports } from '@telus-uds/system-constants';
2
+ export default function media() {
3
+ return {
4
+ query: {},
5
+
6
+ from(breakpoint) {
7
+ if (breakpoint !== viewports.xs) {
8
+ this.query.minWidth = breakpoint;
9
+ }
10
+
11
+ return this;
12
+ },
13
+
14
+ until(breakpoint) {
15
+ this.query.maxWidth = breakpoint;
16
+ return this;
17
+ },
18
+
19
+ and(custom) {
20
+ this.query.and = custom;
21
+ return this;
22
+ },
23
+
24
+ css(style) {
25
+ const {
26
+ minWidth,
27
+ maxWidth,
28
+ and
29
+ } = this.query;
30
+ const min = minWidth ? `(min-width: ${viewports.map.get(minWidth)}px)` : undefined;
31
+ const max = maxWidth ? `(max-width: ${viewports.map.get(maxWidth) - 1}px)` : undefined;
32
+
33
+ if (typeof min !== 'undefined' || typeof max !== 'undefined' || typeof and !== 'undefined') {
34
+ const mediaQuery = `@media ${[min, max, and].filter(a => a).join(' and ')}`;
35
+ this.query = {};
36
+ return {
37
+ [mediaQuery]: { ...(typeof style === 'function' ? style() : style)
38
+ }
39
+ };
40
+ }
41
+
42
+ return typeof style === 'function' ? style() : style;
43
+ }
44
+
45
+ };
46
+ }
@@ -0,0 +1,77 @@
1
+ import React from 'react';
2
+ import { Link } from '@telus-uds/components-base';
3
+ /**
4
+ * Takes a string content and marks up all the links in it by wrapping them
5
+ * in `Link` component.
6
+ */
7
+
8
+ import { createElement as _createElement } from "react";
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+
11
+ const generateLinks = content => {
12
+ const linkRegex = /<\s*a([^>]*)>(.*?)<\s*\/\s*a>/g;
13
+ const attributeRegex = /(\w+)\s*=\s*((["'])(.*?)\3|(?=\s|\/>))/g;
14
+ const parts = content.split(linkRegex);
15
+
16
+ if (parts.length === 1) {
17
+ return parts;
18
+ } // Start with first anchor text, attributes will be in the previous part
19
+
20
+
21
+ for (let i = 2; i < parts.length; i += 3) {
22
+ const o = {}; // Get attributes from previous part
23
+
24
+ const attributes = parts[i - 1].trim(); // Create object from attributes
25
+
26
+ const matchedAttributes = attributes.match(attributeRegex);
27
+
28
+ if (matchedAttributes) {
29
+ matchedAttributes.forEach(attribute => {
30
+ const split = attribute.split('=');
31
+ o[split[0]] = split[1].substr(1, split[1].length - 2);
32
+ });
33
+ } // Remove anchor attributes from parts
34
+
35
+
36
+ parts[i - 1] = undefined; // Replace anchor text with Link in parts
37
+
38
+ parts[i] = /*#__PURE__*/_createElement(Link, { ...o,
39
+ key: i
40
+ }, parts[i]);
41
+ }
42
+
43
+ return parts;
44
+ };
45
+ /**
46
+ * Takes an array of strings and in each element replaces the breaks with `<br>` tags.
47
+ */
48
+
49
+
50
+ const generateBreaks = parts => {
51
+ const breakRegex = /<br\s?\/*>/g;
52
+ const partsWithBreaks = parts;
53
+
54
+ for (let i = 0; i < partsWithBreaks.length; i += 1) {
55
+ if (typeof partsWithBreaks[i] === 'string' && partsWithBreaks[i].search(breakRegex) !== -1) {
56
+ const toSplit = partsWithBreaks[i].split(breakRegex);
57
+
58
+ for (let x = 1; x < toSplit.length; x += 2) {
59
+ toSplit.splice(x, 0, /*#__PURE__*/_jsx("br", {}, `break-${i}-${x}`));
60
+ }
61
+
62
+ partsWithBreaks[i] = toSplit;
63
+ }
64
+ }
65
+
66
+ return partsWithBreaks;
67
+ };
68
+
69
+ const renderStructuredContent = content => {
70
+ if (typeof content !== 'string') {
71
+ return content;
72
+ }
73
+
74
+ return generateBreaks(generateLinks(content));
75
+ };
76
+
77
+ export default renderStructuredContent;
@@ -0,0 +1,24 @@
1
+ import { applyTextStyles, useTheme, useThemeTokens, useViewport } from '@telus-uds/components-base';
2
+
3
+ const useTypographyTheme = (variant, tokens) => {
4
+ const viewport = useViewport();
5
+ const themeTokens = useThemeTokens('Typography', tokens, variant, {
6
+ viewport
7
+ });
8
+ const {
9
+ themeOptions
10
+ } = useTheme();
11
+ const {
12
+ fontSize,
13
+ lineHeight,
14
+ ...rnStyles
15
+ } = applyTextStyles({ ...themeTokens,
16
+ themeOptions
17
+ });
18
+ return { ...rnStyles,
19
+ fontSize: `${fontSize}px`,
20
+ lineHeight: `${lineHeight}px`
21
+ };
22
+ };
23
+
24
+ export default useTypographyTheme;
package/package.json CHANGED
@@ -4,14 +4,18 @@
4
4
  "extends @telus-uds/browserslist-config"
5
5
  ],
6
6
  "dependencies": {
7
- "@telus-uds/components-base": "1.33.0",
7
+ "@gorhom/portal": "^1.0.14",
8
+ "@telus-uds/components-base": "1.34.1",
8
9
  "@telus-uds/system-constants": "^1.2.0",
9
- "@telus-uds/system-theme-tokens": "^2.17.0",
10
- "prop-types": "^15.7.2"
10
+ "react-dates": "^21.8.0",
11
+ "react-moment-proptypes": "^1.8.1",
12
+ "@telus-uds/system-theme-tokens": "^2.18.0",
13
+ "prop-types": "^15.7.2",
14
+ "lodash.omit": "^4.5.0",
15
+ "react-helmet-async": "^1.3.0"
11
16
  },
12
17
  "description": "UDS mult-brand web components",
13
18
  "devDependencies": {
14
- "@telus-uds/palette-allium": "^2.12.3",
15
19
  "@telus-uds/browserslist-config": "^1.0.4",
16
20
  "@testing-library/jest-dom": "^5.16.1",
17
21
  "@testing-library/react": "^13.3.0",
@@ -54,5 +58,5 @@
54
58
  "skip": true
55
59
  },
56
60
  "types": "types/index.d.ts",
57
- "version": "1.3.0"
61
+ "version": "1.5.0"
58
62
  }