@telus-uds/components-web 1.12.0 → 2.1.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.
package/package.json CHANGED
@@ -5,21 +5,21 @@
5
5
  ],
6
6
  "dependencies": {
7
7
  "@gorhom/portal": "^1.0.14",
8
- "@telus-uds/components-base": "1.41.0",
9
- "@telus-uds/system-constants": "^1.2.0",
8
+ "@telus-uds/components-base": "1.43.0",
9
+ "@telus-uds/system-constants": "^1.2.1",
10
10
  "fscreen": "^1.2.0",
11
11
  "lodash.omit": "^4.5.0",
12
12
  "react-dates": "^21.8.0",
13
13
  "react-helmet-async": "^1.3.0",
14
14
  "react-moment-proptypes": "^1.8.1",
15
- "@telus-uds/system-theme-tokens": "^2.26.0",
15
+ "@telus-uds/system-theme-tokens": "^2.26.1",
16
16
  "prop-types": "^15.7.2",
17
17
  "lodash.throttle": "^4.1.1",
18
18
  "react-youtube": "^10.1.0"
19
19
  },
20
20
  "description": "UDS mult-brand web components",
21
21
  "devDependencies": {
22
- "@telus-uds/browserslist-config": "^1.0.4",
22
+ "@telus-uds/browserslist-config": "^1.0.5",
23
23
  "@testing-library/jest-dom": "^5.16.1",
24
24
  "@testing-library/react": "^13.3.0",
25
25
  "@types/react": "^18.0.0",
@@ -32,7 +32,7 @@
32
32
  "webpack": "5.x"
33
33
  },
34
34
  "homepage": "https://github.com/telus/universal-design-system#readme",
35
- "license": "UNLICENSED",
35
+ "license": "MIT",
36
36
  "main": "lib/index.js",
37
37
  "module": "lib-module/index.js",
38
38
  "name": "@telus-uds/components-web",
@@ -47,10 +47,11 @@
47
47
  "url": "git+https://github.com/telus/universal-design-system.git"
48
48
  },
49
49
  "scripts": {
50
- "build": "npm run build:code",
50
+ "build": "npm run build:code && npm run build:docs",
51
51
  "build:main": "babel src -d lib",
52
52
  "build:module": "babel src -d lib-module --env-name module",
53
53
  "build:code": "npm run build:main && npm run build:module",
54
+ "build:docs": "babel-node --plugins=@telus-uds/babel-plugin-react-docgen generate-component-docs.js",
54
55
  "format": "prettier --write .",
55
56
  "lint": "telus-standard",
56
57
  "lint:fix": "telus-standard --fix",
@@ -61,5 +62,5 @@
61
62
  "skip": true
62
63
  },
63
64
  "types": "types/index.d.ts",
64
- "version": "1.12.0"
65
+ "version": "2.1.0"
65
66
  }
@@ -74,10 +74,13 @@ const getItems = (items, params, concatenatePaths) => {
74
74
  const isLast = i === filteredItems.length - 1
75
75
  const breadcrumbName = getBreadcrumbName(item, params)
76
76
  const href = getPath(item.path, params, concatenatePaths, paths)
77
+ const { LinkRouter, linkRouterProps } = item
77
78
  return {
78
79
  breadcrumbName,
79
80
  href,
80
81
  current: isLast,
82
+ LinkRouter,
83
+ linkRouterProps,
81
84
  ...omitProps(selectProps(item))
82
85
  }
83
86
  })
@@ -103,7 +106,6 @@ const Breadcrumbs = ({
103
106
  linkRouterProps,
104
107
  params = {},
105
108
  tokens,
106
- reactRouterLinkComponent,
107
109
  routes,
108
110
  variant,
109
111
  LinkRouter,
@@ -157,25 +159,25 @@ const Breadcrumbs = ({
157
159
  href,
158
160
  current,
159
161
  breadcrumbName,
160
- reactRouterLinkComponent: linkComponent = reactRouterLinkComponent,
161
162
  LinkRouter: ItemLinkRouter = LinkRouter,
162
163
  linkRouterProps: itemLinkRouterProps,
163
164
  ...itemRest
164
- }) => (
165
- <Item
166
- {...itemRest}
167
- current={current}
168
- href={href}
169
- tokens={tokens}
170
- key={href}
171
- linkRouterProps={{ ...linkRouterProps, itemLinkRouterProps }}
172
- reactRouterLinkComponent={linkComponent}
173
- variant={{ ...variant, size: 'micro' }}
174
- LinkRouter={ItemLinkRouter}
175
- >
176
- {breadcrumbName}
177
- </Item>
178
- )
165
+ }) => {
166
+ return (
167
+ <Item
168
+ {...itemRest}
169
+ current={current}
170
+ href={href}
171
+ tokens={tokens}
172
+ key={href}
173
+ linkRouterProps={{ ...linkRouterProps, ...itemLinkRouterProps }}
174
+ variant={{ ...variant, size: 'micro' }}
175
+ LinkRouter={ItemLinkRouter}
176
+ >
177
+ {breadcrumbName}
178
+ </Item>
179
+ )
180
+ }
179
181
  )}
180
182
  </StyledList>
181
183
  {metadata}
@@ -198,11 +200,6 @@ Breadcrumbs.propTypes = {
198
200
  * React Router params.
199
201
  */
200
202
  params: PropTypes.object,
201
- /**
202
- * React Router Link component.
203
- * @deprecated please use `LinkRouter` and `linkRouterProps` instead
204
- */
205
- reactRouterLinkComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
206
203
  /**
207
204
  * An array of routes to be displayed as breadcrumbs.
208
205
  */
@@ -7,8 +7,7 @@ import {
7
7
  applyTextStyles,
8
8
  clickProps,
9
9
  selectSystemProps,
10
- useThemeTokens,
11
- withLinkRouter
10
+ useThemeTokens
12
11
  } from '@telus-uds/components-base'
13
12
  import { htmlAttrs } from '../../utils'
14
13
 
@@ -31,11 +30,12 @@ const Item = forwardRef(
31
30
  (
32
31
  {
33
32
  href,
34
- reactRouterLinkComponent: ReactRouterLink,
35
33
  children,
36
34
  current = false,
37
35
  tokens,
38
36
  variant = { light: true }, // `light` variant (shared with the `Link` component) is default by design
37
+ LinkRouter,
38
+ linkRouterProps,
39
39
  ...rest
40
40
  },
41
41
  ref
@@ -50,13 +50,7 @@ const Item = forwardRef(
50
50
  ...themeTokens
51
51
  } = useThemeTokens('Breadcrumbs', tokens, variant)
52
52
 
53
- const linkOptions = clickProps.toPressProps(selectProps(rest))
54
-
55
- if (ReactRouterLink) {
56
- linkOptions.to = href
57
- } else {
58
- linkOptions.href = href
59
- }
53
+ const linkOptions = { ...clickProps.toPressProps(selectProps(rest)), href }
60
54
 
61
55
  return (
62
56
  <StyledItemContainer {...themeTokens}>
@@ -66,29 +60,16 @@ const Item = forwardRef(
66
60
  </Typography>
67
61
  ) : (
68
62
  <>
69
- {ReactRouterLink ? (
70
- <ReactRouterLink
71
- {...linkOptions}
72
- tokens={{ color, blockFontSize: fontSize }}
73
- // TODO refactor
74
- // eslint-disable-next-line react/no-unstable-nested-components
75
- component={(props) => {
76
- return <Link {...props} variant={variant} />
77
- }}
78
- ref={ref}
79
- >
80
- {children}
81
- </ReactRouterLink>
82
- ) : (
83
- <Link
84
- {...linkOptions}
85
- tokens={{ color, blockFontSize: fontSize }}
86
- ref={ref}
87
- variant={variant}
88
- >
89
- {children}
90
- </Link>
91
- )}
63
+ <Link
64
+ {...linkOptions}
65
+ ref={ref}
66
+ tokens={{ color, blockFontSize: fontSize }}
67
+ LinkRouter={LinkRouter}
68
+ linkRouterProps={linkRouterProps}
69
+ variant={variant}
70
+ >
71
+ {children}
72
+ </Link>
92
73
  <IconContainer {...themeTokens}>
93
74
  <ChevronRightIcon size={iconSize} color={iconColor} />
94
75
  </IconContainer>
@@ -114,16 +95,10 @@ Item.propTypes = {
114
95
  */
115
96
  current: PropTypes.bool,
116
97
  /**
117
- * Target URL. This will be converted to `to` if the `reactRouterLinkComponent`
98
+ * Target URL. This will be converted to `to` if the `LinkRouter`
118
99
  * prop is provided to the `Item` or parent `Breadcrumbs` element.
119
100
  */
120
101
  href: PropTypes.string.isRequired,
121
- /**
122
- * React Router Link component. This will be passed down from the parent
123
- * `<Breadcrumbs>` if the parent has a `reactRouterLinkComponent` provided.
124
- * @deprecated please use `LinkRouter` and `linkRouterProps` instead
125
- */
126
- reactRouterLinkComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
127
102
  /**
128
103
  * Variant to render.
129
104
  */
@@ -134,8 +109,7 @@ Item.propTypes = {
134
109
  // - probably related https://github.com/yannickcr/eslint-plugin-react/issues/2760
135
110
  Item.defaultProps = {
136
111
  current: false,
137
- reactRouterLinkComponent: undefined,
138
112
  variant: { light: true }
139
113
  }
140
114
 
141
- export default withLinkRouter(Item)
115
+ export default Item
@@ -32,7 +32,6 @@ const StyledFootnote = styled.div(
32
32
  width: '100vw',
33
33
  backgroundColor: footnoteBackground,
34
34
  display: 'block',
35
- boxShadow: '0 0 16px 0 rgba(0, 0, 0, 0.1)',
36
35
  transform: 'translateY(100%)',
37
36
  transition: 'transform 500ms ease-out',
38
37
  '@media() (prefers-reduced-motion: reduce)': {
@@ -63,13 +62,23 @@ const StyledFootnoteHeader = styled.div({
63
62
  width: '100%'
64
63
  })
65
64
 
66
- const StyledHeader = styled.div(({ headerMargin }) => ({
67
- alignItems: 'center',
68
- display: 'flex',
69
- flexDirection: 'row',
70
- justifyContent: 'space-between',
71
- margin: headerMargin
72
- }))
65
+ const StyledHeader = styled.div(
66
+ ({
67
+ footnoteHeaderPaddingLeft,
68
+ footnoteHeaderPaddingRight,
69
+ footnoteHeaderPaddingTop,
70
+ footnoteHeaderPaddingBottom
71
+ }) => ({
72
+ alignItems: 'center',
73
+ display: 'flex',
74
+ flexDirection: 'row',
75
+ justifyContent: 'space-between',
76
+ paddingTop: footnoteHeaderPaddingTop,
77
+ paddingBottom: footnoteHeaderPaddingBottom,
78
+ paddingRight: footnoteHeaderPaddingRight,
79
+ paddingLeft: footnoteHeaderPaddingLeft
80
+ })
81
+ )
73
82
 
74
83
  const StyledFootnoteBody = styled.div(
75
84
  {
@@ -134,6 +143,7 @@ const CloseButton = styled.button(
134
143
  cursor: 'pointer',
135
144
  display: 'flex',
136
145
  justifyContent: 'center',
146
+ backgroundColor: 'white',
137
147
  border: closeButtonBorder,
138
148
  height: closeButtonHeight,
139
149
  margin: closeButtonMargin,
@@ -208,6 +218,14 @@ const Footnote = (props) => {
208
218
  footnoteBodyPaddingRight,
209
219
  footnoteBodyPaddingTop,
210
220
  footnoteBodyPaddingBottom,
221
+ footnoteHeaderPaddingLeft,
222
+ footnoteHeaderPaddingRight,
223
+ footnoteHeaderPaddingTop,
224
+ footnoteHeaderPaddingBottom,
225
+ headerLineHeight,
226
+ headerFontSize,
227
+ headerFontName,
228
+ headerFontWeight,
211
229
  listPaddingLeft,
212
230
  listItemMarkerFontSize,
213
231
  listItemMarkerLineHeight,
@@ -423,10 +441,23 @@ const Footnote = (props) => {
423
441
  >
424
442
  <ContentContainer maxWidth={maxWidth}>
425
443
  <StyledFootnoteHeader ref={headerRef}>
426
- <StyledHeader ref={headingRef} headerMargin={headerMargin}>
427
- <Typography block heading tabIndex={-1} variant={{ size: 'h4' }}>
444
+ <StyledHeader
445
+ ref={headingRef}
446
+ footnoteHeaderPaddingLeft={footnoteHeaderPaddingLeft}
447
+ footnoteHeaderPaddingRight={footnoteHeaderPaddingRight}
448
+ footnoteHeaderPaddingTop={footnoteHeaderPaddingTop}
449
+ footnoteHeaderPaddingBottom={footnoteHeaderPaddingBottom}
450
+ headerMargin={headerMargin}
451
+ >
452
+ <h2
453
+ style={{
454
+ fontSize: `${headerFontSize}px`,
455
+ lineHeight: `${headerLineHeight}px`,
456
+ fontFamily: `${headerFontName}${headerFontWeight}normal`
457
+ }}
458
+ >
428
459
  {getCopy('heading')}
429
- </Typography>
460
+ </h2>
430
461
  <CloseButton
431
462
  closeButtonBorder={`${closeButtonBorderSize}px solid ${closeButtonBorderColor}`}
432
463
  closeButtonWidth={`${closeButtonWidth}px`}
package/src/index.js CHANGED
@@ -38,4 +38,6 @@ export { default as NavigationBar } from './NavigationBar'
38
38
  export { default as Progress } from './Progress'
39
39
  export { default as SkeletonProvider } from './SkeletonProvider'
40
40
 
41
+ export { ssrStyles } from './utils'
42
+
41
43
  export * from './baseExports'
@@ -1,17 +1,20 @@
1
+ import { warn, deprecate } from './logger'
1
2
  import { transformGradient } from './transforms'
2
3
  import useTypographyTheme from './useTypographyTheme'
3
4
  import htmlAttrs from './htmlAttrs'
4
- import { warn } from './logger'
5
5
  import media from './media'
6
+ import ssrStyles from './ssr'
6
7
  import renderStructuredContent from './renderStructuredContent'
7
8
  import useOverlaidPosition from './useOverlaidPosition'
8
9
 
9
10
  export {
11
+ deprecate,
10
12
  htmlAttrs,
11
13
  transformGradient,
12
14
  useTypographyTheme,
13
15
  warn,
14
16
  media,
15
17
  renderStructuredContent,
18
+ ssrStyles,
16
19
  useOverlaidPosition
17
20
  }
@@ -0,0 +1,37 @@
1
+ import { ServerStyleSheet } from 'styled-components'
2
+ import { ssrStyles as baseSsrStyles } from '@telus-uds/components-base'
3
+ /**
4
+ * Returns object with `renderApp` and `getStyles` functions.
5
+ * Weave these into your app's server-side render process:
6
+ *
7
+ * - Call `renderApp` first to do the actual server-side render
8
+ * - After the render is complete, call `getStyles`
9
+ * - Include the style tags returned by `getStyles` in the SSR <head>
10
+ *
11
+ * This wraps ssrStyles from @telus-uds/components-base and adds Styled Components support.
12
+ *
13
+ * @param {string} [appName] - optional unique identifier if ssrStyles is called multiple times for multiple apps
14
+ * @param {object} [options] -
15
+ * - `styleGetters`: optional array of additional style getter functions to call after render
16
+ * - `collectStyles`: optional function, takes the rendered app, returns either the same or a new app element
17
+ * @param {boolean} [options.styleGetters]
18
+ * @param {(ReactElement) => ReactElement} [options.collectStyles]
19
+ */
20
+ const ssrStyles = (
21
+ appName = 'Allium app',
22
+ { styleGetters = [], collectStyles = (renderedApp) => renderedApp } = {}
23
+ ) => {
24
+ const sheet = new ServerStyleSheet()
25
+ const getStyledComponentsStyles = () => {
26
+ const styles = sheet.getStyleElement()
27
+ sheet.seal()
28
+ return styles
29
+ }
30
+
31
+ return baseSsrStyles(appName, {
32
+ styleGetters: [getStyledComponentsStyles, ...styleGetters],
33
+ collectStyles: (renderedApp) => collectStyles(sheet.collectStyles(renderedApp))
34
+ })
35
+ }
36
+
37
+ export default ssrStyles
@@ -0,0 +1,16 @@
1
+ import type { ComponentType, ElementType, ReactNode } from 'react'
2
+ import type { HTMLAttrs } from './common'
3
+
4
+ export interface BlockQuoteProps extends HTMLAttrs {
5
+ children: ReactNode
6
+ link?: string
7
+ linkHref?: string
8
+ additionalInfo?: string
9
+ textStyle?: 'large' | 'heading'
10
+ LinkRouter?: ElementType
11
+ linkRouterProps?: Record<string, any>
12
+ }
13
+
14
+ declare const BlockQuote: ComponentType<BlockQuoteProps>
15
+
16
+ export default BlockQuote
package/types/Box.d.ts ADDED
@@ -0,0 +1,38 @@
1
+ import type { ReactNode } from 'react'
2
+ import type { A11yProps, LayoutTag, Tokens, Variant, ViewProps } from './common'
3
+ import { ComponentTypeWithForwardRef } from './ComponentTypeWithForwardRef'
4
+
5
+ export interface SpacingObjectProps {
6
+ xs?: number
7
+ sm?: number
8
+ md?: number
9
+ lg?: number
10
+ xl?: number
11
+ space?: number
12
+ options?: {
13
+ variant?: Variant
14
+ size?: number
15
+ }
16
+ }
17
+
18
+ export interface BoxProps extends A11yProps, ViewProps {
19
+ variant?: Variant
20
+ tokens?: Tokens
21
+ space?: number | SpacingObjectProps
22
+ vertical?: number | SpacingObjectProps
23
+ horizontal?: number | SpacingObjectProps
24
+ bottom?: number | SpacingObjectProps
25
+ left?: number | SpacingObjectProps
26
+ right?: number | SpacingObjectProps
27
+ top?: number | SpacingObjectProps
28
+ flex?: number
29
+ scroll?: boolean | Record<string, any>
30
+ tag?: LayoutTag
31
+ testID?: string
32
+ dataSet?: Record<string, any>
33
+ children: ReactNode
34
+ }
35
+
36
+ declare const Box: ComponentTypeWithForwardRef<BoxProps, any>
37
+
38
+ export default Box
@@ -0,0 +1,11 @@
1
+ import type { ComponentType, ReactNode } from 'react'
2
+
3
+ interface BreadcrumbItemProps {
4
+ href: string
5
+ children: ReactNode
6
+ current?: boolean
7
+ }
8
+
9
+ declare const BreadcrumbItem: ComponentType<BreadcrumbItemProps>
10
+
11
+ export default BreadcrumbItem
@@ -0,0 +1,21 @@
1
+ import type { ComponentType, ReactNode } from 'react'
2
+ import type { HTMLAttrs } from './common'
3
+ import BreadcrumbItem from './BreadcrumbItem'
4
+
5
+ export interface BreadcrumbRouteProps {
6
+ path?: string
7
+ breadcrumbName?: string
8
+ }
9
+
10
+ export interface BreadcrumbsProps extends HTMLAttrs {
11
+ routes?: BreadcrumbRouteProps[]
12
+ baseUrl?: string
13
+ params?: Record<string, any>
14
+ children?: ReactNode
15
+ }
16
+
17
+ declare const Breadcrumbs: ComponentType<BreadcrumbsProps> & {
18
+ Item: typeof BreadcrumbItem
19
+ }
20
+
21
+ export default Breadcrumbs
@@ -0,0 +1,5 @@
1
+ import { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from 'react'
2
+
3
+ // declare const ComponentTypeWithForwardRef: ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>;
4
+ export interface ComponentTypeWithForwardRef<P, T>
5
+ extends ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>> {}
@@ -0,0 +1,27 @@
1
+ import type { ComponentType } from 'react'
2
+
3
+ interface MultiSelectFilterItem {
4
+ label: string
5
+ id?: string
6
+ }
7
+
8
+ export interface MultiSelectFilterProps {
9
+ label: string
10
+ subtitle?: string
11
+ id?: string
12
+ variant?: string
13
+ tokens?: []
14
+ items: MultiSelectFilterItem[]
15
+ values?: string[]
16
+ initialValues?: string[]
17
+ maxValues?: number
18
+ onChange?: (e: string[]) => void
19
+ copy?: 'en' | 'fr'
20
+ readOnly?: string
21
+ inactive?: string
22
+ rowLimit?: number
23
+ }
24
+
25
+ declare const MultiSelectFilter: ComponentType<MultiSelectFilterProps>
26
+
27
+ export default MultiSelectFilter
@@ -0,0 +1,20 @@
1
+ import type { ComponentType } from 'react'
2
+ import type { HTMLAttrs, InputSupportsProps, Tokens } from './common'
3
+
4
+ export interface QuantitySelectorProps
5
+ extends HTMLAttrs,
6
+ Omit<InputSupportsProps, 'feedback' | 'validation'> {
7
+ minNumber?: number
8
+ maxNumber?: number
9
+ onChange?: (value: number, event: any) => void
10
+ defaultValue?: number
11
+ accessibilityLabel?: string
12
+ variant?: {
13
+ alternative: boolean
14
+ }
15
+ tokens?: Tokens
16
+ }
17
+
18
+ declare const QuantitySelector: ComponentType<QuantitySelectorProps>
19
+
20
+ export default QuantitySelector