@telus-uds/components-web 1.5.0 → 1.6.1

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 (61) hide show
  1. package/CHANGELOG.md +26 -2
  2. package/lib/Image/Image.js +126 -0
  3. package/lib/Image/index.js +13 -0
  4. package/lib/Modal/Modal.js +142 -0
  5. package/lib/Modal/ModalContent.js +195 -0
  6. package/lib/Modal/index.js +13 -0
  7. package/lib/PreviewCard/PreviewCard.js +5 -1
  8. package/lib/Table/Body.js +29 -0
  9. package/lib/Table/Cell.js +200 -0
  10. package/lib/Table/Header.js +39 -0
  11. package/lib/Table/Row.js +35 -0
  12. package/lib/Table/SubHeading.js +37 -0
  13. package/lib/Table/Table.js +121 -0
  14. package/lib/Table/index.js +28 -0
  15. package/lib/Toast/Toast.js +136 -0
  16. package/lib/Toast/index.js +13 -0
  17. package/lib/WaffleGrid/WaffleGrid.js +176 -0
  18. package/lib/WaffleGrid/index.js +13 -0
  19. package/lib/baseExports.js +0 -6
  20. package/lib/index.js +46 -1
  21. package/lib-module/Image/Image.js +108 -0
  22. package/lib-module/Image/index.js +2 -0
  23. package/lib-module/Modal/Modal.js +128 -0
  24. package/lib-module/Modal/ModalContent.js +174 -0
  25. package/lib-module/Modal/index.js +2 -0
  26. package/lib-module/PreviewCard/PreviewCard.js +5 -1
  27. package/lib-module/Table/Body.js +17 -0
  28. package/lib-module/Table/Cell.js +176 -0
  29. package/lib-module/Table/Header.js +22 -0
  30. package/lib-module/Table/Row.js +19 -0
  31. package/lib-module/Table/SubHeading.js +20 -0
  32. package/lib-module/Table/Table.js +93 -0
  33. package/lib-module/Table/index.js +12 -0
  34. package/lib-module/Toast/Toast.js +117 -0
  35. package/lib-module/Toast/index.js +2 -0
  36. package/lib-module/WaffleGrid/WaffleGrid.js +155 -0
  37. package/lib-module/WaffleGrid/index.js +2 -0
  38. package/lib-module/baseExports.js +1 -1
  39. package/lib-module/index.js +5 -0
  40. package/package.json +4 -3
  41. package/src/Image/Image.jsx +95 -0
  42. package/src/Image/index.js +3 -0
  43. package/src/Modal/Modal.jsx +111 -0
  44. package/src/Modal/ModalContent.jsx +161 -0
  45. package/src/Modal/index.js +3 -0
  46. package/src/PreviewCard/PreviewCard.jsx +5 -1
  47. package/src/Table/Body.jsx +12 -0
  48. package/src/Table/Cell.jsx +148 -0
  49. package/src/Table/Header.jsx +17 -0
  50. package/src/Table/Row.jsx +18 -0
  51. package/src/Table/SubHeading.jsx +17 -0
  52. package/src/Table/Table.jsx +90 -0
  53. package/src/Table/index.js +14 -0
  54. package/src/Toast/Toast.jsx +151 -0
  55. package/src/Toast/index.js +3 -0
  56. package/src/WaffleGrid/WaffleGrid.jsx +137 -0
  57. package/src/WaffleGrid/index.js +3 -0
  58. package/src/baseExports.js +0 -1
  59. package/src/index.js +5 -0
  60. package/types/Cell.d.ts +13 -0
  61. package/types/Table.d.ts +12 -0
@@ -0,0 +1,2 @@
1
+ import Modal from './Modal';
2
+ export default Modal;
@@ -39,7 +39,11 @@ const FullBleedOffsetInner = /*#__PURE__*/styled.div.withConfig({
39
39
  });
40
40
  const defaultTokens = {
41
41
  minWidth: 0,
42
- shadow: null
42
+ shadow: null,
43
+ contentAlignItems: 'stretch',
44
+ contentJustifyContent: 'flex-start',
45
+ contentFlexGrow: 0,
46
+ contentFlexShrink: 0
43
47
  };
44
48
  /**
45
49
  * Showcase and guide users to another page, with a preview containing title and a footer.
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+
5
+ const Body = _ref => {
6
+ let {
7
+ children
8
+ } = _ref;
9
+ return /*#__PURE__*/_jsx("tbody", {
10
+ children: children
11
+ });
12
+ };
13
+
14
+ Body.propTypes = {
15
+ children: PropTypes.node
16
+ };
17
+ export default Body;
@@ -0,0 +1,176 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import styled, { css } from 'styled-components';
4
+ import { Typography, useThemeTokens } from '@telus-uds/components-base';
5
+ import { useTableContext } from './Table';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ const stickyStyles = /*#__PURE__*/css(["position:sticky;left:0;z-index:2;clip-path:inset(0 -8px 0 0);&::before{content:'';box-shadow:", ";position:absolute;top:0;left:0;right:0;bottom:0;pointer-events:none;}"], _ref => {
8
+ let {
9
+ cellStickyShadow
10
+ } = _ref;
11
+ return cellStickyShadow;
12
+ });
13
+ const sharedStyles = /*#__PURE__*/css(["", ""], _ref2 => {
14
+ let {
15
+ isSticky,
16
+ cellBoxShadowColor,
17
+ align,
18
+ cellPaddingTop,
19
+ cellPaddingRight,
20
+ cellPaddingBottom,
21
+ cellPaddingLeft
22
+ } = _ref2;
23
+ return css(["", ";box-shadow:inset 0 -1px 0 ", ";text-align:", ";padding:", "px ", "px ", "px ", "px;"], isSticky ? stickyStyles : undefined, cellBoxShadowColor, align, cellPaddingTop, cellPaddingRight, cellPaddingBottom, cellPaddingLeft);
24
+ });
25
+ const StyledHeading = /*#__PURE__*/styled.th.withConfig({
26
+ displayName: "Cell__StyledHeading",
27
+ componentId: "components-web__sc-ltgfic-0"
28
+ })(["", ";", ""], sharedStyles, _ref3 => {
29
+ let {
30
+ cellHeadingBackground,
31
+ cellHeadingBoxShadowColor
32
+ } = _ref3;
33
+ return `
34
+ background-color: ${cellHeadingBackground};
35
+ box-shadow: inset 0 1px 0 ${cellHeadingBoxShadowColor}, inset 0 -1px 0 ${cellHeadingBoxShadowColor};`;
36
+ });
37
+ const StyledSubHeading = /*#__PURE__*/styled.th.withConfig({
38
+ displayName: "Cell__StyledSubHeading",
39
+ componentId: "components-web__sc-ltgfic-1"
40
+ })(["", ";background-color:", ";"], sharedStyles, _ref4 => {
41
+ let {
42
+ cellSubheadingBackground
43
+ } = _ref4;
44
+ return cellSubheadingBackground;
45
+ });
46
+ const StyledCell = /*#__PURE__*/styled.td.withConfig({
47
+ displayName: "Cell__StyledCell",
48
+ componentId: "components-web__sc-ltgfic-2"
49
+ })(["", ";background-color:", ";"], sharedStyles, _ref5 => {
50
+ let {
51
+ cellBackground
52
+ } = _ref5;
53
+ return cellBackground;
54
+ });
55
+ const StyledRowHeading = /*#__PURE__*/styled.th.withConfig({
56
+ displayName: "Cell__StyledRowHeading",
57
+ componentId: "components-web__sc-ltgfic-3"
58
+ })(["", ";background-color:", ";"], sharedStyles, _ref6 => {
59
+ let {
60
+ cellRowHeadingBackground
61
+ } = _ref6;
62
+ return cellRowHeadingBackground;
63
+ });
64
+
65
+ const Cell = _ref7 => {
66
+ let {
67
+ children,
68
+ type = 'default',
69
+ isFirstInRow,
70
+ align = 'left'
71
+ } = _ref7;
72
+ const {
73
+ text,
74
+ isScrollable: isTableScrollable,
75
+ variant,
76
+ tokens
77
+ } = useTableContext();
78
+ const {
79
+ cellHeadingBackground,
80
+ cellHeadingBoxShadowColor,
81
+ cellBoxShadowColor,
82
+ cellSubheadingBackground,
83
+ cellBackground,
84
+ cellRowHeadingBackground,
85
+ cellStickyShadow,
86
+ cellPaddingTop,
87
+ cellPaddingRight,
88
+ cellPaddingLeft,
89
+ cellPaddingBottom
90
+ } = useThemeTokens('Table', tokens, variant);
91
+ const sharedProps = {
92
+ align,
93
+ isSticky: isTableScrollable && isFirstInRow,
94
+ cellStickyShadow,
95
+ cellPaddingTop,
96
+ cellPaddingRight,
97
+ cellPaddingLeft,
98
+ cellPaddingBottom,
99
+ cellBoxShadowColor
100
+ };
101
+
102
+ switch (type) {
103
+ case 'heading':
104
+ return /*#__PURE__*/_jsx(StyledHeading, {
105
+ scope: "col",
106
+ cellHeadingBackground: cellHeadingBackground,
107
+ cellHeadingBoxShadowColor: cellHeadingBoxShadowColor,
108
+ ...sharedProps,
109
+ children: /*#__PURE__*/_jsx(Typography, {
110
+ variant: {
111
+ size: 'h4'
112
+ },
113
+ children: children
114
+ })
115
+ });
116
+
117
+ case 'subHeading':
118
+ return /*#__PURE__*/_jsx(StyledSubHeading, {
119
+ scope: "col",
120
+ cellSubheadingBackground: cellSubheadingBackground,
121
+ ...sharedProps,
122
+ children: /*#__PURE__*/_jsx(Typography, {
123
+ variant: {
124
+ size: 'h5'
125
+ },
126
+ children: children
127
+ })
128
+ });
129
+
130
+ case 'rowHeading':
131
+ return /*#__PURE__*/_jsx(StyledRowHeading, {
132
+ scope: "row",
133
+ cellRowHeadingBackground: cellRowHeadingBackground,
134
+ ...sharedProps,
135
+ children: /*#__PURE__*/_jsx(Typography, {
136
+ variant: {
137
+ size: text === 'small' ? 'h5' : 'h4'
138
+ },
139
+ children: children
140
+ })
141
+ });
142
+
143
+ default:
144
+ return /*#__PURE__*/_jsx(StyledCell, {
145
+ cellBackground: cellBackground,
146
+ ...sharedProps,
147
+ children: /*#__PURE__*/_jsx(Typography, {
148
+ variant: {
149
+ size: text
150
+ },
151
+ children: children
152
+ })
153
+ });
154
+ }
155
+ };
156
+
157
+ Cell.propTypes = {
158
+ children: PropTypes.node,
159
+
160
+ /**
161
+ * Defines the visual styles of a cell, and whether it should be a `td` or `th` element
162
+ */
163
+ type: PropTypes.oneOf(['default', 'heading', 'subHeading', 'rowHeading']),
164
+
165
+ /**
166
+ * @ignore
167
+ * Used internally for making the first column sticky
168
+ */
169
+ isFirstInRow: PropTypes.bool,
170
+
171
+ /**
172
+ * Defines the text alignment within the cell
173
+ */
174
+ align: PropTypes.oneOf(['left', 'center', 'right'])
175
+ };
176
+ export default Cell;
@@ -0,0 +1,22 @@
1
+ import React, { cloneElement } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import Row from './Row';
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+
6
+ const Header = _ref => {
7
+ let {
8
+ children
9
+ } = _ref;
10
+ return /*#__PURE__*/_jsx("thead", {
11
+ children: /*#__PURE__*/_jsx(Row, {
12
+ children: React.Children.map(children, child => /*#__PURE__*/cloneElement(child, {
13
+ type: 'heading'
14
+ }))
15
+ })
16
+ });
17
+ };
18
+
19
+ Header.propTypes = {
20
+ children: PropTypes.node
21
+ };
22
+ export default Header;
@@ -0,0 +1,19 @@
1
+ import React, { cloneElement } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+
5
+ const Row = _ref => {
6
+ let {
7
+ children
8
+ } = _ref;
9
+ return /*#__PURE__*/_jsx("tr", {
10
+ children: React.Children.map(children, (child, index) => /*#__PURE__*/cloneElement(child, {
11
+ isFirstInRow: index === 0
12
+ }))
13
+ });
14
+ };
15
+
16
+ Row.propTypes = {
17
+ children: PropTypes.node
18
+ };
19
+ export default Row;
@@ -0,0 +1,20 @@
1
+ import React, { cloneElement } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import Row from './Row';
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+
6
+ const Header = _ref => {
7
+ let {
8
+ children
9
+ } = _ref;
10
+ return /*#__PURE__*/_jsx(Row, {
11
+ children: React.Children.map(children, child => /*#__PURE__*/cloneElement(child, {
12
+ type: 'subHeading'
13
+ }))
14
+ });
15
+ };
16
+
17
+ Header.propTypes = {
18
+ children: PropTypes.node
19
+ };
20
+ export default Header;
@@ -0,0 +1,93 @@
1
+ import React, { useContext, useRef, useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import styled from 'styled-components';
4
+ import { selectSystemProps, useSafeLayoutEffect, useThemeTokens } from '@telus-uds/components-base';
5
+ import throttle from 'lodash.throttle';
6
+ import { htmlAttrs } from '../utils';
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
9
+ const StyledContainer = /*#__PURE__*/styled.div.withConfig({
10
+ displayName: "Table__StyledContainer",
11
+ componentId: "components-web__sc-10d9q3m-0"
12
+ })(["overflow:auto;padding-bottom:", ";"], props => props.isScrollable ? props.tablePaddingBottom : 0);
13
+ const StyledTable = /*#__PURE__*/styled.table.withConfig({
14
+ displayName: "Table__StyledTable",
15
+ componentId: "components-web__sc-10d9q3m-1"
16
+ })(["margin:0;padding:0;"]);
17
+ const TableContext = /*#__PURE__*/React.createContext({});
18
+ export const useTableContext = () => useContext(TableContext);
19
+ /**
20
+ * Use `Table` to display tabular data.
21
+ *
22
+ * - Takes an optional `spacing` variant (compact)
23
+ * - Available in 2 text styles (medium, small)
24
+ * - When `Table` exceeds viewport, the first column becomes sticky, enabling horizontal scrolling
25
+ * - Right-align prices and numbers that display decimal points
26
+ *
27
+ * ### Building up a `Table`
28
+ * - Use `Table.Header` and `Table.Body` as direct children of `Table`
29
+ * - Use `Table.SubHeading` to render an intermediate data heading row
30
+ * - Use `Table.Row` and `Table.Cell` to build up the tabular data
31
+ * - Use `Cell`'s `type` prop to visually mark it as a row heading (`type="rowHeading"`)
32
+ */
33
+
34
+ const Table = _ref => {
35
+ let {
36
+ children,
37
+ text = 'medium',
38
+ tokens,
39
+ variant,
40
+ ...rest
41
+ } = _ref;
42
+ const {
43
+ tablePaddingBottom
44
+ } = useThemeTokens('Table', tokens, variant);
45
+ const containerRef = useRef();
46
+ const tableRef = useRef();
47
+ const [containerWidth, setContainerWidth] = useState(0);
48
+ const [tableWidth, setTableWidth] = useState(0);
49
+ useSafeLayoutEffect(() => {
50
+ const updateDimensions = () => {
51
+ setContainerWidth(containerRef.current.clientWidth);
52
+ setTableWidth(tableRef.current.clientWidth);
53
+ };
54
+
55
+ const throttledUpdateDimensions = throttle(updateDimensions, 100, {
56
+ leading: false
57
+ });
58
+ updateDimensions(); // a pretty naive way of repeating the measurement after the fonts are loaded
59
+
60
+ window.addEventListener('load', updateDimensions);
61
+ window.addEventListener('resize', throttledUpdateDimensions);
62
+ return () => {
63
+ window.removeEventListener('load', updateDimensions);
64
+ window.removeEventListener('resize', throttledUpdateDimensions);
65
+ };
66
+ }, []);
67
+ const isScrollable = tableWidth > containerWidth;
68
+ return /*#__PURE__*/_jsx(StyledContainer, {
69
+ ref: containerRef,
70
+ isScrollable: isScrollable,
71
+ tablePaddingBottom: `${tablePaddingBottom}px`,
72
+ ...selectProps(rest),
73
+ children: /*#__PURE__*/_jsx(TableContext.Provider, {
74
+ value: {
75
+ text,
76
+ isScrollable,
77
+ tokens,
78
+ variant
79
+ },
80
+ children: /*#__PURE__*/_jsx(StyledTable, {
81
+ cellSpacing: 0,
82
+ ref: tableRef,
83
+ children: children
84
+ })
85
+ })
86
+ });
87
+ };
88
+
89
+ Table.propTypes = { ...selectedSystemPropTypes,
90
+ children: PropTypes.node,
91
+ text: PropTypes.oneOf(['medium', 'small'])
92
+ };
93
+ export default Table;
@@ -0,0 +1,12 @@
1
+ import Table from './Table';
2
+ import Header from './Header';
3
+ import Body from './Body';
4
+ import Row from './Row';
5
+ import SubHeading from './SubHeading';
6
+ import Cell from './Cell';
7
+ Table.Header = Header;
8
+ Table.Body = Body;
9
+ Table.Row = Row;
10
+ Table.SubHeading = SubHeading;
11
+ Table.Cell = Cell;
12
+ export default Table;
@@ -0,0 +1,117 @@
1
+ var _withLinkRouter$propT, _withLinkRouter$propT2;
2
+
3
+ import React from 'react';
4
+ import PropTypes from 'prop-types';
5
+ import { ChevronLink, selectSystemProps, useThemeTokens, Typography, withLinkRouter } from '@telus-uds/components-base';
6
+ import styled, { keyframes, css } from 'styled-components';
7
+ import { htmlAttrs } from '../utils';
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ import { jsxs as _jsxs } from "react/jsx-runtime";
10
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
11
+
12
+ const transform = property => (from, to) => keyframes(["from{", ":", ";}to{", ":", ";}"], property, from, property, to);
13
+
14
+ const slideDown = property => function (from, to) {
15
+ let end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : to;
16
+ return keyframes(["0%{", ":", ";}99%{", ":", ";}100%{", ":", ";}"], property, from, property, to, property, end);
17
+ };
18
+
19
+ const animation = props => css(["", " 1s ease-in-out 2s forwards,", " 1s ease-in-out 2s forwards,", " 1s ease-in-out 2s forwards,", " 1s ease-in-out 3.2s forwards;& *{animation:", " 1s ease-in-out 3s forwards;}& > a div{animation:", " 1s ease-in-out 3s forwards;}& > a svg{animation:", " 1s ease-in-out 3s forwards;}"], slideDown('height')(`${props.animationHeightBefore}px`, `${props.animationHeightAfter}px`, 'auto'), transform('padding-bottom')(`${props.animationPaddingBottomBefore}px`, `${props.animationPaddingBottomAfter}px`), transform('padding-top')(`${props.animationPaddingTopBefore}px`, `${props.animationPaddingTopAfter}px`), transform('background')(props.animationBackgroundColorBefore, props.animationBackgroundColorAfter), transform('color')(props.animationColorBefore, props.animationColorAfter), transform('color')(props.animationDivColorBefore, props.animationDivColorAfter), transform('fill')(props.animationFillColorBefore, props.animationFillColorAfter));
20
+
21
+ const ToastContainer = /*#__PURE__*/styled.div.withConfig({
22
+ displayName: "Toast__ToastContainer",
23
+ componentId: "components-web__sc-p78jdh-0"
24
+ })(["display:flex;justify-content:center;background:", ";gap:", ";height:0;overflow:hidden;animation:", ";"], _ref => {
25
+ let {
26
+ containerBackgroundColor
27
+ } = _ref;
28
+ return containerBackgroundColor;
29
+ }, _ref2 => {
30
+ let {
31
+ containerGap
32
+ } = _ref2;
33
+ return containerGap;
34
+ }, animation);
35
+
36
+ const Toast = _ref3 => {
37
+ let {
38
+ toast,
39
+ copy,
40
+ headline,
41
+ link,
42
+ tokens,
43
+ variant = {},
44
+ ...rest
45
+ } = _ref3;
46
+ const {
47
+ containerBackgroundColor,
48
+ containerGap,
49
+ animationHeightBefore,
50
+ animationHeightAfter,
51
+ animationPaddingBottomBefore,
52
+ animationPaddingBottomAfter,
53
+ animationPaddingTopBefore,
54
+ animationPaddingTopAfter,
55
+ animationBackgroundColorBefore,
56
+ animationBackgroundColorAfter,
57
+ animationColorBefore,
58
+ animationColorAfter,
59
+ animationFillColorBefore,
60
+ animationFillColorAfter
61
+ } = useThemeTokens('Toast', tokens, variant);
62
+
63
+ if (!toast) {
64
+ return null;
65
+ }
66
+
67
+ return /*#__PURE__*/_jsxs(ToastContainer, {
68
+ containerBackgroundColor: containerBackgroundColor,
69
+ containerGap: containerGap,
70
+ animationHeightBefore: animationHeightBefore,
71
+ animationHeightAfter: animationHeightAfter,
72
+ animationPaddingBottomBefore: animationPaddingBottomBefore,
73
+ animationPaddingBottomAfter: animationPaddingBottomAfter,
74
+ animationPaddingTopBefore: animationPaddingTopBefore,
75
+ animationPaddingTopAfter: animationPaddingTopAfter,
76
+ animationBackgroundColorBefore: animationBackgroundColorBefore,
77
+ animationBackgroundColorAfter: animationBackgroundColorAfter,
78
+ animationColorBefore: animationColorBefore,
79
+ animationColorAfter: animationColorAfter,
80
+ animationFillColorBefore: animationFillColorBefore,
81
+ animationFillColorAfter: animationFillColorAfter,
82
+ ...selectProps(rest),
83
+ children: [headline && /*#__PURE__*/_jsx(Typography, {
84
+ variant: {
85
+ bold: true,
86
+ inverse: true
87
+ },
88
+ children: headline
89
+ }), /*#__PURE__*/_jsx(Typography, {
90
+ variant: {
91
+ inverse: true
92
+ },
93
+ children: copy
94
+ }), link && /*#__PURE__*/_jsx(ChevronLink, {
95
+ variant: {
96
+ inverse: true
97
+ },
98
+ href: link.href,
99
+ LinkRouter: link.LinkRouter,
100
+ linkRouterProps: link.linkRouterProps,
101
+ children: link.text
102
+ })]
103
+ });
104
+ };
105
+
106
+ Toast.propTypes = { ...selectedSystemPropTypes,
107
+ toast: PropTypes.bool,
108
+ copy: PropTypes.string.isRequired,
109
+ headline: PropTypes.string,
110
+ link: PropTypes.shape({
111
+ href: PropTypes.string.isRequired,
112
+ text: PropTypes.string.isRequired,
113
+ LinkRouter: (_withLinkRouter$propT = withLinkRouter.propTypes) === null || _withLinkRouter$propT === void 0 ? void 0 : _withLinkRouter$propT.LinkRouter,
114
+ linkRouterProps: (_withLinkRouter$propT2 = withLinkRouter.propTypes) === null || _withLinkRouter$propT2 === void 0 ? void 0 : _withLinkRouter$propT2.linkRouterProps
115
+ })
116
+ };
117
+ export default Toast;
@@ -0,0 +1,2 @@
1
+ import Toast from './Toast';
2
+ export default Toast;
@@ -0,0 +1,155 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import styled from 'styled-components';
4
+ import { Link, responsiveProps, selectSystemProps, useResponsiveProp, useThemeTokens, withLinkRouter } from '@telus-uds/components-base';
5
+ import OrderedListBase from '../OrderedList/OrderedListBase';
6
+ import ItemBase from '../OrderedList/ItemBase';
7
+ import Image from '../Image';
8
+ import { htmlAttrs } from '../utils';
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ import { jsxs as _jsxs } from "react/jsx-runtime";
11
+ import { createElement as _createElement } from "react";
12
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
13
+ const DEFAULT_ROW_SIZE = {
14
+ sm: 2,
15
+ lg: 3,
16
+ xl: 6
17
+ };
18
+
19
+ const row = (rowSize, rowBorderSize) => ({
20
+ flexBasis: `calc(100% / ${rowSize})`,
21
+ [`:not(:nth-of-type(${rowSize}n + 1))`]: {
22
+ borderLeftWidth: `${rowBorderSize}px`
23
+ },
24
+ [`:nth-of-type(n+${rowSize + 1})`]: {
25
+ borderTopWidth: `${rowBorderSize}px`
26
+ }
27
+ });
28
+
29
+ const Container = /*#__PURE__*/styled(OrderedListBase).withConfig({
30
+ displayName: "WaffleGrid__Container",
31
+ componentId: "components-web__sc-ec8g0a-0"
32
+ })({
33
+ display: 'flex',
34
+ flexDirection: 'row',
35
+ flexWrap: 'wrap',
36
+ justifyContent: 'flex-start'
37
+ });
38
+ const Item = /*#__PURE__*/styled(ItemBase).withConfig({
39
+ displayName: "WaffleGrid__Item",
40
+ componentId: "components-web__sc-ec8g0a-1"
41
+ })(_ref => {
42
+ let {
43
+ rowSize,
44
+ itemPadding,
45
+ itemBorderColor,
46
+ rowBorderWidth
47
+ } = _ref;
48
+ return {
49
+ display: 'flex',
50
+ flexDirection: 'column',
51
+ flexGrow: 0,
52
+ flexShrink: 0,
53
+ padding: `${itemPadding}px`,
54
+ boxSizing: 'border-box',
55
+ borderStyle: 'solid',
56
+ borderColor: itemBorderColor,
57
+ borderWidth: 0,
58
+ '& > a': {
59
+ alignSelf: 'center'
60
+ },
61
+ ...row(rowSize, rowBorderWidth)
62
+ };
63
+ });
64
+ const Center = /*#__PURE__*/styled('div').withConfig({
65
+ displayName: "WaffleGrid__Center",
66
+ componentId: "components-web__sc-ec8g0a-2"
67
+ })({
68
+ display: 'flex',
69
+ flexDirection: 'column',
70
+ alignItems: 'center',
71
+ textAlign: 'center'
72
+ });
73
+ /**
74
+ * The WaffleGrid is used to show items in a waffle like manner with borders surrounding the element
75
+ */
76
+
77
+ const WaffleGrid = _ref2 => {
78
+ let {
79
+ items,
80
+ rowSize = DEFAULT_ROW_SIZE,
81
+ LinkRouter,
82
+ tokens,
83
+ variant,
84
+ linkRouterProps,
85
+ ...rest
86
+ } = _ref2;
87
+ const themeTokens = useThemeTokens('WaffleGrid', tokens, variant);
88
+ const currentRowSize = useResponsiveProp(rowSize);
89
+ return /*#__PURE__*/_jsx(Container, { ...selectProps(rest),
90
+ children: items.map(child => /*#__PURE__*/_createElement(Item, { ...themeTokens,
91
+ key: child.href,
92
+ rowSize: currentRowSize
93
+ }, /*#__PURE__*/_jsx(Link, {
94
+ href: child.href,
95
+ variant: {
96
+ alternative: true
97
+ },
98
+ LinkRouter: child.LinkRouter || LinkRouter,
99
+ linkRouterProps: { ...linkRouterProps,
100
+ ...child.linkRouterProps
101
+ },
102
+ children: /*#__PURE__*/_jsxs(Center, {
103
+ children: [typeof child.image === 'string' ?
104
+ /*#__PURE__*/
105
+ // Assuming that string passed is the image URL
106
+ _jsx(Image, {
107
+ src: child.image,
108
+ alt: child.imageAltText,
109
+ width: 64,
110
+ height: 64
111
+ }) : // Otherwise it must be an arbitrary content, which we just display by itself
112
+ child.image, /*#__PURE__*/_jsx("span", {
113
+ children: child.text
114
+ })]
115
+ })
116
+ })))
117
+ });
118
+ };
119
+
120
+ WaffleGrid.propTypes = { ...selectedSystemPropTypes,
121
+
122
+ /**
123
+ * The image and the link to display. `items` should be an array of objects with the following keys:
124
+ */
125
+ items: PropTypes.arrayOf(PropTypes.shape({
126
+ /**
127
+ * The src attribute for the HTML img element or custom JSX content to render instead
128
+ */
129
+ image: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
130
+
131
+ /**
132
+ * The alt attribute for the HTML img element (note that this is ignored if a custom
133
+ * JSX content is used instead of an image URL)
134
+ */
135
+ imageAltText: PropTypes.string,
136
+
137
+ /**
138
+ * The text displayed under the image
139
+ */
140
+ text: PropTypes.string,
141
+
142
+ /**
143
+ * Target URL
144
+ */
145
+ href: PropTypes.string,
146
+ ...withLinkRouter.propTypes
147
+ })).isRequired,
148
+
149
+ /**
150
+ * Row size, optionally depending on the viewport
151
+ */
152
+ rowSize: responsiveProps.getTypeOptionallyByViewport(PropTypes.number),
153
+ ...withLinkRouter.propTypes
154
+ };
155
+ export default WaffleGrid;
@@ -0,0 +1,2 @@
1
+ import WaffleGrid from './WaffleGrid';
2
+ export default WaffleGrid;
@@ -5,7 +5,7 @@ export {
5
5
  /**
6
6
  * Most base components should be re-exported as-is.
7
7
  */
8
- A11yText, ActivityIndicator, Box, Button, BaseProvider, A11yInfoProvider, ViewportProvider, ThemeProvider, ButtonDropdown, ButtonGroup, ButtonLink, Carousel, Card, CarouselTabs, Checkbox, CheckboxGroup, ChevronLink, Divider, ExpandCollapse, Feedback, FlexGrid, Icon, IconButton, InputLabel, InputSupports, Link, Modal, MultiSelectFilter, Notification, Pagination, QuickLinks, QuickLinksFeature, Radio, RadioGroup, RadioCard, RadioCardGroup, Responsive, Search, Select, SideNav, Skeleton, SkipLink, Spacer, StackView, StackWrap, StepTracker, Tabs, Tags, TextButton, TextArea, TextInput, Timeline, ToggleSwitch, ToggleSwitchGroup, TooltipButton, Tooltip, Typography,
8
+ A11yText, ActivityIndicator, Box, Button, BaseProvider, A11yInfoProvider, ViewportProvider, ThemeProvider, ButtonDropdown, ButtonGroup, ButtonLink, Carousel, Card, CarouselTabs, Checkbox, CheckboxGroup, ChevronLink, Divider, ExpandCollapse, Feedback, FlexGrid, Icon, IconButton, InputLabel, InputSupports, Link, MultiSelectFilter, Notification, Pagination, QuickLinks, QuickLinksFeature, Radio, RadioGroup, RadioCard, RadioCardGroup, Responsive, Search, Select, SideNav, Skeleton, SkipLink, Spacer, StackView, StackWrap, StepTracker, Tabs, Tags, TextButton, TextArea, TextInput, Timeline, ToggleSwitch, ToggleSwitchGroup, TooltipButton, Tooltip, Typography,
9
9
  /*
10
10
  * Most utilities exported from @telus-uds/components-base are for building systems, not apps.
11
11
  * Re-export only those utilities with a stable API and known use cases within apps / pages.
@@ -1,4 +1,5 @@
1
1
  export { default as Badge } from './Badge';
2
+ export { default as Modal } from './Modal';
2
3
  export { default as OrderedList } from './OrderedList';
3
4
  export { default as PreviewCard } from './PreviewCard';
4
5
  export { default as ResponsiveImage } from './ResponsiveImage';
@@ -12,4 +13,8 @@ export { default as PriceLockup } from './PriceLockup';
12
13
  export { default as Footnote } from './Footnote';
13
14
  export { transformGradient } from './utils';
14
15
  export { default as Breadcrumbs } from './Breadcrumbs';
16
+ export { default as Toast } from './Toast';
17
+ export { default as Table } from './Table';
18
+ export { default as Image } from './Image';
19
+ export { default as WaffleGrid } from './WaffleGrid';
15
20
  export * from './baseExports';