@telus-uds/components-web 1.2.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/CHANGELOG.md +34 -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/OrderedList/Item.js +162 -0
  20. package/lib/OrderedList/ItemBase.js +42 -0
  21. package/lib/OrderedList/OrderedList.js +94 -0
  22. package/lib/OrderedList/OrderedListBase.js +68 -0
  23. package/lib/OrderedList/constants.js +9 -0
  24. package/lib/OrderedList/index.js +16 -0
  25. package/lib/PreviewCard/AuthorDate.js +64 -0
  26. package/lib/PreviewCard/PreviewCard.js +236 -0
  27. package/lib/PreviewCard/index.js +13 -0
  28. package/lib/PriceLockup/PriceLockup.js +237 -0
  29. package/lib/PriceLockup/index.js +13 -0
  30. package/lib/PriceLockup/tokens.js +131 -0
  31. package/lib/ResponsiveImage/ResponsiveImage.js +115 -0
  32. package/lib/ResponsiveImage/index.js +13 -0
  33. package/lib/Ribbon/Ribbon.js +0 -1
  34. package/lib/Span/Span.js +88 -0
  35. package/lib/Span/index.js +13 -0
  36. package/lib/index.js +91 -1
  37. package/lib/shared/FullBleedContent/FullBleedContent.js +121 -0
  38. package/lib/shared/FullBleedContent/getFullBleedBorderRadius.js +73 -0
  39. package/lib/shared/FullBleedContent/index.js +29 -0
  40. package/lib/shared/FullBleedContent/useFullBleedContentProps.js +73 -0
  41. package/lib/utils/index.js +32 -0
  42. package/lib/utils/logger.js +31 -0
  43. package/lib/utils/media.js +54 -0
  44. package/lib/utils/renderStructuredContent.js +89 -0
  45. package/lib/utils/useTypographyTheme.js +32 -0
  46. package/lib-module/Breadcrumbs/Breadcrumbs.js +228 -0
  47. package/lib-module/Breadcrumbs/Item/Item.js +141 -0
  48. package/lib-module/Breadcrumbs/index.js +1 -0
  49. package/lib-module/Callout/Callout.js +106 -0
  50. package/lib-module/Callout/index.js +2 -0
  51. package/lib-module/DatePicker/CalendarContainer.js +208 -0
  52. package/lib-module/DatePicker/DatePicker.js +302 -0
  53. package/lib-module/DatePicker/dictionary.js +127 -0
  54. package/lib-module/DatePicker/index.js +2 -0
  55. package/lib-module/DatePicker/reactDatesCss.js +3 -0
  56. package/lib-module/ExpandCollapseMini/ExpandCollapseMini.js +56 -0
  57. package/lib-module/ExpandCollapseMini/ExpandCollapseMiniControl.js +80 -0
  58. package/lib-module/ExpandCollapseMini/index.js +2 -0
  59. package/lib-module/Footnote/Footnote.js +541 -0
  60. package/lib-module/Footnote/FootnoteLink.js +130 -0
  61. package/lib-module/Footnote/dictionary.js +12 -0
  62. package/lib-module/Footnote/index.js +4 -0
  63. package/lib-module/OrderedList/Item.js +139 -0
  64. package/lib-module/OrderedList/ItemBase.js +28 -0
  65. package/lib-module/OrderedList/OrderedList.js +71 -0
  66. package/lib-module/OrderedList/OrderedListBase.js +48 -0
  67. package/lib-module/OrderedList/constants.js +2 -0
  68. package/lib-module/OrderedList/index.js +4 -0
  69. package/lib-module/PreviewCard/AuthorDate.js +53 -0
  70. package/lib-module/PreviewCard/PreviewCard.js +211 -0
  71. package/lib-module/PreviewCard/index.js +2 -0
  72. package/lib-module/PriceLockup/PriceLockup.js +213 -0
  73. package/lib-module/PriceLockup/index.js +2 -0
  74. package/lib-module/PriceLockup/tokens.js +120 -0
  75. package/lib-module/ResponsiveImage/ResponsiveImage.js +100 -0
  76. package/lib-module/ResponsiveImage/index.js +2 -0
  77. package/lib-module/Ribbon/Ribbon.js +1 -2
  78. package/lib-module/Span/Span.js +70 -0
  79. package/lib-module/Span/index.js +2 -0
  80. package/lib-module/index.js +10 -0
  81. package/lib-module/shared/FullBleedContent/FullBleedContent.js +106 -0
  82. package/lib-module/shared/FullBleedContent/getFullBleedBorderRadius.js +65 -0
  83. package/lib-module/shared/FullBleedContent/index.js +4 -0
  84. package/lib-module/shared/FullBleedContent/useFullBleedContentProps.js +65 -0
  85. package/lib-module/utils/index.js +5 -1
  86. package/lib-module/utils/logger.js +18 -0
  87. package/lib-module/utils/media.js +46 -0
  88. package/lib-module/utils/renderStructuredContent.js +77 -0
  89. package/lib-module/utils/useTypographyTheme.js +24 -0
  90. package/package.json +9 -4
  91. package/src/Breadcrumbs/Breadcrumbs.jsx +222 -0
  92. package/src/Breadcrumbs/Item/Item.jsx +127 -0
  93. package/src/Breadcrumbs/index.js +1 -0
  94. package/src/Callout/Callout.jsx +76 -0
  95. package/src/Callout/index.js +3 -0
  96. package/src/DatePicker/CalendarContainer.jsx +210 -0
  97. package/src/DatePicker/DatePicker.jsx +303 -0
  98. package/src/DatePicker/dictionary.js +92 -0
  99. package/src/DatePicker/index.js +3 -0
  100. package/src/DatePicker/reactDatesCss.js +892 -0
  101. package/src/ExpandCollapseMini/ExpandCollapseMini.jsx +48 -0
  102. package/src/ExpandCollapseMini/ExpandCollapseMiniControl.jsx +67 -0
  103. package/src/ExpandCollapseMini/index.js +3 -0
  104. package/src/Footnote/Footnote.jsx +468 -0
  105. package/src/Footnote/FootnoteLink.jsx +120 -0
  106. package/src/Footnote/dictionary.js +12 -0
  107. package/src/Footnote/index.js +6 -0
  108. package/src/OrderedList/Item.jsx +121 -0
  109. package/src/OrderedList/ItemBase.jsx +18 -0
  110. package/src/OrderedList/OrderedList.jsx +61 -0
  111. package/src/OrderedList/OrderedListBase.jsx +38 -0
  112. package/src/OrderedList/constants.js +2 -0
  113. package/src/OrderedList/index.js +6 -0
  114. package/src/PreviewCard/AuthorDate.jsx +31 -0
  115. package/src/PreviewCard/PreviewCard.jsx +201 -0
  116. package/src/PreviewCard/index.js +3 -0
  117. package/src/PriceLockup/PriceLockup.jsx +210 -0
  118. package/src/PriceLockup/index.js +3 -0
  119. package/src/PriceLockup/tokens.js +58 -0
  120. package/src/ResponsiveImage/ResponsiveImage.jsx +77 -0
  121. package/src/ResponsiveImage/index.js +3 -0
  122. package/src/Ribbon/Ribbon.jsx +0 -1
  123. package/src/Span/Span.jsx +66 -0
  124. package/src/Span/index.js +3 -0
  125. package/src/index.js +10 -0
  126. package/src/shared/FullBleedContent/FullBleedContent.jsx +90 -0
  127. package/src/shared/FullBleedContent/getFullBleedBorderRadius.js +55 -0
  128. package/src/shared/FullBleedContent/index.js +6 -0
  129. package/src/shared/FullBleedContent/useFullBleedContentProps.js +63 -0
  130. package/src/utils/index.js +5 -1
  131. package/src/utils/logger.js +20 -0
  132. package/src/utils/media.js +40 -0
  133. package/src/utils/renderStructuredContent.jsx +73 -0
  134. package/src/utils/useTypographyTheme.js +14 -0
  135. package/types/Callout.d.ts +13 -0
  136. package/types/DatePicker.d.ts +21 -0
  137. package/types/Footnote.d.ts +21 -0
  138. package/types/FootnoteLink.d.ts +20 -0
  139. package/types/PriceLockup.d.ts +22 -0
  140. package/types/common.d.ts +14 -0
@@ -9,15 +9,47 @@ Object.defineProperty(exports, "htmlAttrs", {
9
9
  return _htmlAttrs.default;
10
10
  }
11
11
  });
12
+ Object.defineProperty(exports, "media", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _media.default;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "renderStructuredContent", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _renderStructuredContent.default;
22
+ }
23
+ });
12
24
  Object.defineProperty(exports, "transformGradient", {
13
25
  enumerable: true,
14
26
  get: function () {
15
27
  return _transforms.transformGradient;
16
28
  }
17
29
  });
30
+ Object.defineProperty(exports, "useTypographyTheme", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _useTypographyTheme.default;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "warn", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _logger.warn;
40
+ }
41
+ });
18
42
 
19
43
  var _transforms = require("./transforms");
20
44
 
45
+ var _useTypographyTheme = _interopRequireDefault(require("./useTypographyTheme"));
46
+
21
47
  var _htmlAttrs = _interopRequireDefault(require("./htmlAttrs"));
22
48
 
49
+ var _logger = require("./logger");
50
+
51
+ var _media = _interopRequireDefault(require("./media"));
52
+
53
+ var _renderStructuredContent = _interopRequireDefault(require("./renderStructuredContent"));
54
+
23
55
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.warn = exports.deprecate = exports.default = void 0;
7
+
8
+ const deprecate = (componentName, message) => {
9
+ if (process.env.NODE_ENV === 'production') {
10
+ return;
11
+ }
12
+
13
+ console.warn(`[Allium] [Deprecate] ${componentName}: ${message}`); // eslint-disable-line no-console
14
+ };
15
+
16
+ exports.deprecate = deprecate;
17
+
18
+ const warn = (componentName, message) => {
19
+ if (process.env.NODE_ENV === 'production') {
20
+ return;
21
+ }
22
+
23
+ console.warn(`[Allium] ${componentName}: ${message}`); // eslint-disable-line no-console
24
+ };
25
+
26
+ exports.warn = warn;
27
+ var _default = {
28
+ deprecate,
29
+ warn
30
+ };
31
+ exports.default = _default;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = media;
7
+
8
+ var _systemConstants = require("@telus-uds/system-constants");
9
+
10
+ function media() {
11
+ return {
12
+ query: {},
13
+
14
+ from(breakpoint) {
15
+ if (breakpoint !== _systemConstants.viewports.xs) {
16
+ this.query.minWidth = breakpoint;
17
+ }
18
+
19
+ return this;
20
+ },
21
+
22
+ until(breakpoint) {
23
+ this.query.maxWidth = breakpoint;
24
+ return this;
25
+ },
26
+
27
+ and(custom) {
28
+ this.query.and = custom;
29
+ return this;
30
+ },
31
+
32
+ css(style) {
33
+ const {
34
+ minWidth,
35
+ maxWidth,
36
+ and
37
+ } = this.query;
38
+ const min = minWidth ? `(min-width: ${_systemConstants.viewports.map.get(minWidth)}px)` : undefined;
39
+ const max = maxWidth ? `(max-width: ${_systemConstants.viewports.map.get(maxWidth) - 1}px)` : undefined;
40
+
41
+ if (typeof min !== 'undefined' || typeof max !== 'undefined' || typeof and !== 'undefined') {
42
+ const mediaQuery = `@media ${[min, max, and].filter(a => a).join(' and ')}`;
43
+ this.query = {};
44
+ return {
45
+ [mediaQuery]: { ...(typeof style === 'function' ? style() : style)
46
+ }
47
+ };
48
+ }
49
+
50
+ return typeof style === 'function' ? style() : style;
51
+ }
52
+
53
+ };
54
+ }
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _componentsBase = require("@telus-uds/components-base");
11
+
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+
14
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
+
16
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
+
18
+ /**
19
+ * Takes a string content and marks up all the links in it by wrapping them
20
+ * in `Link` component.
21
+ */
22
+ const generateLinks = content => {
23
+ const linkRegex = /<\s*a([^>]*)>(.*?)<\s*\/\s*a>/g;
24
+ const attributeRegex = /(\w+)\s*=\s*((["'])(.*?)\3|(?=\s|\/>))/g;
25
+ const parts = content.split(linkRegex);
26
+
27
+ if (parts.length === 1) {
28
+ return parts;
29
+ } // Start with first anchor text, attributes will be in the previous part
30
+
31
+
32
+ for (let i = 2; i < parts.length; i += 3) {
33
+ const o = {}; // Get attributes from previous part
34
+
35
+ const attributes = parts[i - 1].trim(); // Create object from attributes
36
+
37
+ const matchedAttributes = attributes.match(attributeRegex);
38
+
39
+ if (matchedAttributes) {
40
+ matchedAttributes.forEach(attribute => {
41
+ const split = attribute.split('=');
42
+ o[split[0]] = split[1].substr(1, split[1].length - 2);
43
+ });
44
+ } // Remove anchor attributes from parts
45
+
46
+
47
+ parts[i - 1] = undefined; // Replace anchor text with Link in parts
48
+
49
+ parts[i] = /*#__PURE__*/(0, _react.createElement)(_componentsBase.Link, { ...o,
50
+ key: i
51
+ }, parts[i]);
52
+ }
53
+
54
+ return parts;
55
+ };
56
+ /**
57
+ * Takes an array of strings and in each element replaces the breaks with `<br>` tags.
58
+ */
59
+
60
+
61
+ const generateBreaks = parts => {
62
+ const breakRegex = /<br\s?\/*>/g;
63
+ const partsWithBreaks = parts;
64
+
65
+ for (let i = 0; i < partsWithBreaks.length; i += 1) {
66
+ if (typeof partsWithBreaks[i] === 'string' && partsWithBreaks[i].search(breakRegex) !== -1) {
67
+ const toSplit = partsWithBreaks[i].split(breakRegex);
68
+
69
+ for (let x = 1; x < toSplit.length; x += 2) {
70
+ toSplit.splice(x, 0, /*#__PURE__*/(0, _jsxRuntime.jsx)("br", {}, `break-${i}-${x}`));
71
+ }
72
+
73
+ partsWithBreaks[i] = toSplit;
74
+ }
75
+ }
76
+
77
+ return partsWithBreaks;
78
+ };
79
+
80
+ const renderStructuredContent = content => {
81
+ if (typeof content !== 'string') {
82
+ return content;
83
+ }
84
+
85
+ return generateBreaks(generateLinks(content));
86
+ };
87
+
88
+ var _default = renderStructuredContent;
89
+ exports.default = _default;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _componentsBase = require("@telus-uds/components-base");
9
+
10
+ const useTypographyTheme = (variant, tokens) => {
11
+ const viewport = (0, _componentsBase.useViewport)();
12
+ const themeTokens = (0, _componentsBase.useThemeTokens)('Typography', tokens, variant, {
13
+ viewport
14
+ });
15
+ const {
16
+ themeOptions
17
+ } = (0, _componentsBase.useTheme)();
18
+ const {
19
+ fontSize,
20
+ lineHeight,
21
+ ...rnStyles
22
+ } = (0, _componentsBase.applyTextStyles)({ ...themeTokens,
23
+ themeOptions
24
+ });
25
+ return { ...rnStyles,
26
+ fontSize: `${fontSize}px`,
27
+ lineHeight: `${lineHeight}px`
28
+ };
29
+ };
30
+
31
+ var _default = useTypographyTheme;
32
+ exports.default = _default;
@@ -0,0 +1,228 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import styled from 'styled-components';
4
+ import { Helmet, HelmetProvider } from 'react-helmet-async';
5
+ import { componentPropType, selectSystemProps, unpackFragment, withLinkRouter } from '@telus-uds/components-base';
6
+ import { htmlAttrs } from '../utils';
7
+ import Item from './Item/Item';
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ import { createElement as _createElement } from "react";
10
+ import { jsxs as _jsxs } from "react/jsx-runtime";
11
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
12
+ const StyledList = /*#__PURE__*/styled.ol.withConfig({
13
+ displayName: "Breadcrumbs__StyledList",
14
+ componentId: "components-web__sc-gwwxrc-0"
15
+ })({
16
+ display: 'flex',
17
+ flexDirection: 'row',
18
+ flexWrap: 'wrap',
19
+ listStyle: 'none',
20
+ listStylePosition: 'inside',
21
+ margin: 0,
22
+ padding: 0
23
+ });
24
+
25
+ const omitProps = _ref => {
26
+ let {
27
+ current,
28
+ path,
29
+ breadcrumbName,
30
+ indexRoute,
31
+ childRoutes,
32
+ component,
33
+ ...props
34
+ } = _ref;
35
+ return props;
36
+ };
37
+
38
+ const getBreadcrumbName = (item, params) => {
39
+ if (!item.breadcrumbName) {
40
+ return null;
41
+ }
42
+
43
+ let {
44
+ breadcrumbName
45
+ } = item;
46
+ Object.keys(params).forEach(key => {
47
+ breadcrumbName = breadcrumbName.replace(`:${key}`, params[key]);
48
+ });
49
+ return breadcrumbName;
50
+ };
51
+
52
+ const getPath = (path, params, concatenatePaths, paths) => {
53
+ let p = path;
54
+
55
+ if (concatenatePaths) {
56
+ p = p.replace(/^\//, '');
57
+ Object.keys(params).forEach(key => {
58
+ p = p.replace(`:${key}`, params[key]);
59
+ });
60
+
61
+ if (p) {
62
+ paths.push(p);
63
+ }
64
+
65
+ return `/${paths.join('/')}`;
66
+ }
67
+
68
+ return p;
69
+ };
70
+
71
+ const getItems = (items, params, concatenatePaths) => {
72
+ const paths = [];
73
+ return items.filter(item => item.path).map((item, i, filteredItems) => {
74
+ const isLast = i === filteredItems.length - 1;
75
+ const breadcrumbName = getBreadcrumbName(item, params);
76
+ const href = getPath(item.path, params, concatenatePaths, paths);
77
+ return {
78
+ breadcrumbName,
79
+ href,
80
+ current: isLast,
81
+ ...omitProps(selectProps(item))
82
+ };
83
+ });
84
+ };
85
+
86
+ const getStructuredData = (items, baseUrl) => {
87
+ return items.map((item, index) => ({
88
+ '@type': 'ListItem',
89
+ position: index + 1,
90
+ item: {
91
+ '@id': `${baseUrl || ''}${item.href}`,
92
+ name: item.breadcrumbName
93
+ }
94
+ }));
95
+ };
96
+ /**
97
+ * Display a hierarchy of links, commonly used for navigation.
98
+ */
99
+
100
+
101
+ const Breadcrumbs = _ref2 => {
102
+ let {
103
+ baseUrl,
104
+ children,
105
+ linkRouterProps,
106
+ params = {},
107
+ tokens,
108
+ reactRouterLinkComponent,
109
+ routes,
110
+ variant,
111
+ LinkRouter,
112
+ ...rest
113
+ } = _ref2;
114
+ // React Helmet can cause a memory leak in SSR if not properly configured.
115
+ // Only run it in SSR if theme options tells us to.
116
+
117
+ /* const {
118
+ themeOptions: { enableHelmetSSR }
119
+ } = useTheme() */
120
+ // const isHydrating = useHydrationContext()
121
+ // const isSSR = typeof window === 'undefined' || isHydrating
122
+ // const hasMetadata = isSSR ? enableHelmetSSR : true
123
+ const helmetContext = {};
124
+ const activeRoutes = children ? React.Children.map(unpackFragment(children), _ref3 => {
125
+ let {
126
+ props: {
127
+ href,
128
+ children: breadcrumbName,
129
+ ...itemRest
130
+ },
131
+ ref
132
+ } = _ref3;
133
+ return {
134
+ path: href,
135
+ breadcrumbName,
136
+ ref,
137
+ ...itemRest
138
+ };
139
+ }) : routes.filter(route => route.path && route.breadcrumbName);
140
+ const items = getItems(activeRoutes, params, !children);
141
+
142
+ const metadata = /*#__PURE__*/_jsx(HelmetProvider, {
143
+ context: helmetContext,
144
+ children: /*#__PURE__*/_jsx(Helmet, {
145
+ children: /*#__PURE__*/_jsx("script", {
146
+ type: "application/ld+json",
147
+ children: `
148
+ {
149
+ "@context": "http://schema.org",
150
+ "@type": "BreadcrumbList",
151
+ "itemListElement": ${JSON.stringify(getStructuredData(items, baseUrl))}
152
+ }
153
+ `
154
+ })
155
+ })
156
+ });
157
+
158
+ return /*#__PURE__*/_jsxs("nav", { ...selectProps(rest),
159
+ children: [/*#__PURE__*/_jsx(StyledList, {
160
+ children: items.map(_ref4 => {
161
+ let {
162
+ href,
163
+ current,
164
+ breadcrumbName,
165
+ reactRouterLinkComponent: linkComponent = reactRouterLinkComponent,
166
+ LinkRouter: ItemLinkRouter = LinkRouter,
167
+ linkRouterProps: itemLinkRouterProps,
168
+ ...itemRest
169
+ } = _ref4;
170
+ return /*#__PURE__*/_createElement(Item, { ...itemRest,
171
+ current: current,
172
+ href: href,
173
+ tokens: tokens,
174
+ key: href,
175
+ linkRouterProps: { ...linkRouterProps,
176
+ itemLinkRouterProps
177
+ },
178
+ reactRouterLinkComponent: linkComponent,
179
+ variant: variant,
180
+ LinkRouter: ItemLinkRouter
181
+ }, breadcrumbName);
182
+ })
183
+ }), metadata]
184
+ });
185
+ };
186
+
187
+ Breadcrumbs.propTypes = { ...selectedSystemPropTypes,
188
+ ...withLinkRouter.propTypes,
189
+
190
+ /**
191
+ * Base URL used to build structured data.
192
+ */
193
+ baseUrl: PropTypes.string,
194
+
195
+ /**
196
+ * A list of Items to be used as an alternative to the `routes` prop.
197
+ */
198
+ children: componentPropType('Item'),
199
+
200
+ /**
201
+ * React Router params.
202
+ */
203
+ params: PropTypes.object,
204
+
205
+ /**
206
+ * React Router Link component.
207
+ * @deprecated please use `LinkRouter` and `linkRouterProps` instead
208
+ */
209
+ reactRouterLinkComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
210
+
211
+ /**
212
+ * An array of routes to be displayed as breadcrumbs.
213
+ */
214
+ routes: PropTypes.arrayOf(PropTypes.shape({
215
+ path: PropTypes.string,
216
+ breadcrumbName: PropTypes.string
217
+ })),
218
+
219
+ /**
220
+ * Variant to render.
221
+ */
222
+ variant: PropTypes.shape({
223
+ inverse: PropTypes.bool,
224
+ light: PropTypes.bool
225
+ })
226
+ };
227
+ Breadcrumbs.Item = Item;
228
+ export default Breadcrumbs;
@@ -0,0 +1,141 @@
1
+ import React, { forwardRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import styled from 'styled-components';
4
+ import { Link, Typography, clickProps, selectSystemProps, useThemeTokens, withLinkRouter } from '@telus-uds/components-base';
5
+ import { htmlAttrs } from '../../utils';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ import { Fragment as _Fragment } from "react/jsx-runtime";
8
+ import { jsxs as _jsxs } from "react/jsx-runtime";
9
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
10
+ const StyledItemContainer = /*#__PURE__*/styled.li.withConfig({
11
+ displayName: "Item__StyledItemContainer",
12
+ componentId: "components-web__sc-1rfdaul-0"
13
+ })({
14
+ display: 'flex',
15
+ paddingLeft: _ref => {
16
+ let {
17
+ listItemPadding
18
+ } = _ref;
19
+ return `${listItemPadding}px`;
20
+ }
21
+ });
22
+ const IconContainer = /*#__PURE__*/styled.span.withConfig({
23
+ displayName: "Item__IconContainer",
24
+ componentId: "components-web__sc-1rfdaul-1"
25
+ })({
26
+ display: 'inline-flex',
27
+ alignItems: 'center',
28
+ paddingLeft: _ref2 => {
29
+ let {
30
+ iconPadding
31
+ } = _ref2;
32
+ return `${iconPadding}px`;
33
+ },
34
+ paddingRight: _ref3 => {
35
+ let {
36
+ iconPadding
37
+ } = _ref3;
38
+ return `${iconPadding}px`;
39
+ }
40
+ });
41
+ const Item = /*#__PURE__*/forwardRef((_ref4, ref) => {
42
+ let {
43
+ href,
44
+ reactRouterLinkComponent: ReactRouterLink,
45
+ children,
46
+ current = false,
47
+ tokens,
48
+ variant = {
49
+ light: true
50
+ },
51
+ // `light` variant (shared with the `Link` component) is default by design
52
+ ...rest
53
+ } = _ref4;
54
+ const {
55
+ iconColor,
56
+ icon: ChevronRightIcon,
57
+ ...themeTokens
58
+ } = useThemeTokens('Breadcrumbs', tokens, variant);
59
+ const linkOptions = clickProps.toPressProps(selectProps(rest));
60
+
61
+ if (ReactRouterLink) {
62
+ linkOptions.to = href;
63
+ } else {
64
+ linkOptions.href = href;
65
+ }
66
+
67
+ return /*#__PURE__*/_jsx(StyledItemContainer, { ...themeTokens,
68
+ children: current ? /*#__PURE__*/_jsx(Typography, {
69
+ variant: { ...variant,
70
+ secondary: true
71
+ },
72
+ children: children
73
+ }) : /*#__PURE__*/_jsxs(_Fragment, {
74
+ children: [ReactRouterLink ? /*#__PURE__*/_jsx(ReactRouterLink, { ...linkOptions,
75
+ // TODO refactor
76
+ // eslint-disable-next-line react/no-unstable-nested-components
77
+ component: props => {
78
+ return /*#__PURE__*/_jsx(Link, { ...props,
79
+ variant: variant
80
+ });
81
+ },
82
+ ref: ref,
83
+ children: children
84
+ }) : /*#__PURE__*/_jsx(Link, { ...linkOptions,
85
+ ref: ref,
86
+ variant: variant,
87
+ children: children
88
+ }), /*#__PURE__*/_jsx(IconContainer, { ...themeTokens,
89
+ children: /*#__PURE__*/_jsx(ChevronRightIcon, {
90
+ size: 16,
91
+ color: iconColor
92
+ })
93
+ })]
94
+ })
95
+ });
96
+ });
97
+ Item.displayName = 'Item';
98
+ Item.propTypes = { ...selectedSystemPropTypes,
99
+
100
+ /**
101
+ * Breadcrumb text
102
+ */
103
+ children: PropTypes.node.isRequired,
104
+
105
+ /**
106
+ * @ignore
107
+ *
108
+ * Indicates whether or not the Item should be as current/active
109
+ */
110
+ current: PropTypes.bool,
111
+
112
+ /**
113
+ * Target URL. This will be converted to `to` if the `reactRouterLinkComponent`
114
+ * prop is provided to the `Item` or parent `Breadcrumbs` element.
115
+ */
116
+ href: PropTypes.string.isRequired,
117
+
118
+ /**
119
+ * React Router Link component. This will be passed down from the parent
120
+ * `<Breadcrumbs>` if the parent has a `reactRouterLinkComponent` provided.
121
+ * @deprecated please use `LinkRouter` and `linkRouterProps` instead
122
+ */
123
+ reactRouterLinkComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
124
+
125
+ /**
126
+ * Variant to render.
127
+ */
128
+ variant: PropTypes.shape({
129
+ inverse: PropTypes.bool
130
+ })
131
+ }; // Since react/require-default-props eslint rule doesn't pick up default arguments as default props when combined with `forwardRef`
132
+ // - probably related https://github.com/yannickcr/eslint-plugin-react/issues/2760
133
+
134
+ Item.defaultProps = {
135
+ current: false,
136
+ reactRouterLinkComponent: undefined,
137
+ variant: {
138
+ light: true
139
+ }
140
+ };
141
+ export default withLinkRouter(Item);
@@ -0,0 +1 @@
1
+ export { default } from './Breadcrumbs';