@telus-uds/components-base 1.0.1 → 1.3.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 (193) hide show
  1. package/.storybook/main.js +4 -0
  2. package/.storybook/preview.js +37 -0
  3. package/.turbo/turbo-build.log +5 -0
  4. package/CHANGELOG.md +32 -0
  5. package/README.md +1 -1
  6. package/__fixtures__/Accessible.js +4 -2
  7. package/__fixtures__/Accessible.native.js +5 -2
  8. package/__fixtures__/testTheme.js +9 -0
  9. package/__tests__/FlexGrid/Col.test.jsx +6 -10
  10. package/__tests__/HorizontalScroll/HorizontalScroll.test.jsx +1 -0
  11. package/__tests__/ToggleSwitch/ToggleSwitch.test.jsx +10 -0
  12. package/__tests__/ToggleSwitch/ToggleSwitchGroup.test.jsx +192 -0
  13. package/__tests__/utils/props.test.js +36 -0
  14. package/__tests__/utils/semantics.test.jsx +1 -10
  15. package/babel.config.js +9 -16
  16. package/component-docs.json +10142 -0
  17. package/generate-component-docs.js +59 -0
  18. package/lib/A11yText/index.js +2 -2
  19. package/lib/ActivityIndicator/index.js +3 -3
  20. package/lib/Box/Box.js +4 -4
  21. package/lib/Button/Button.js +2 -2
  22. package/lib/Button/ButtonBase.js +20 -6
  23. package/lib/Button/ButtonGroup.js +10 -12
  24. package/lib/Button/ButtonLink.js +4 -4
  25. package/lib/Button/propTypes.js +4 -2
  26. package/lib/Card/Card.js +2 -2
  27. package/lib/Card/CardBase.js +6 -9
  28. package/lib/Card/PressableCardBase.js +12 -6
  29. package/lib/Checkbox/Checkbox.js +3 -5
  30. package/lib/Divider/Divider.js +2 -2
  31. package/lib/FlexGrid/FlexGrid.js +4 -4
  32. package/lib/FlexGrid/helpers/index.js +1 -4
  33. package/lib/IconButton/IconButton.js +11 -6
  34. package/lib/Link/LinkBase.js +19 -12
  35. package/lib/List/List.js +4 -5
  36. package/lib/List/ListItem.js +14 -27
  37. package/lib/List/index.js +15 -0
  38. package/lib/Pagination/PageButton.js +4 -8
  39. package/lib/Pagination/Pagination.js +16 -4
  40. package/lib/Pagination/SideButton.js +3 -1
  41. package/lib/Progress/Progress.js +2 -2
  42. package/lib/Progress/ProgressBar.js +2 -2
  43. package/lib/Radio/Radio.js +3 -5
  44. package/lib/Spacer/Spacer.js +2 -2
  45. package/lib/StackView/StackWrap.js +9 -5
  46. package/lib/StackView/getStackedContent.js +1 -1
  47. package/lib/StepTracker/StepTracker.js +2 -2
  48. package/lib/Tabs/Tabs.js +12 -4
  49. package/lib/Tabs/TabsItem.js +12 -6
  50. package/lib/Tags/Tags.js +9 -9
  51. package/lib/ThemeProvider/useThemeTokens.js +3 -3
  52. package/lib/ThemeProvider/utils/theme-tokens.js +3 -3
  53. package/lib/ToggleSwitch/ToggleSwitch.js +105 -43
  54. package/lib/ToggleSwitch/ToggleSwitchGroup.js +230 -0
  55. package/lib/ToggleSwitch/index.js +14 -4
  56. package/lib/index.js +28 -9
  57. package/lib/utils/a11y/semantics.js +4 -3
  58. package/lib/utils/index.js +14 -5
  59. package/lib/utils/pressability.js +2 -2
  60. package/lib/utils/props/a11yProps.js +153 -0
  61. package/lib/utils/props/clickProps.js +36 -0
  62. package/lib/utils/props/componentPropType.js +70 -0
  63. package/lib/utils/props/copyPropTypes.js +14 -0
  64. package/lib/utils/props/getPropSelector.js +13 -0
  65. package/lib/utils/props/hrefAttrsProp.js +41 -0
  66. package/lib/utils/props/index.js +149 -0
  67. package/lib/utils/props/linkProps.js +64 -0
  68. package/lib/utils/props/paddingProp.js +20 -0
  69. package/lib/utils/props/pressProps.js +57 -0
  70. package/lib/utils/props/rectProp.js +20 -0
  71. package/lib/utils/props/responsiveProps.js +40 -0
  72. package/lib/utils/props/selectSystemProps.js +31 -0
  73. package/lib/utils/props/spacingProps.js +71 -0
  74. package/lib/utils/props/tokens.js +145 -0
  75. package/lib/utils/props/variantProp.js +28 -0
  76. package/lib/utils/props/viewProps.js +34 -0
  77. package/lib/utils/useResponsiveProp.js +1 -1
  78. package/lib/utils/useSpacingScale.js +4 -4
  79. package/lib/utils/withLinkRouter.js +98 -0
  80. package/package.json +9 -5
  81. package/release-context.json +4 -4
  82. package/src/A11yText/index.jsx +1 -1
  83. package/src/ActivityIndicator/index.jsx +1 -1
  84. package/src/Box/Box.jsx +5 -4
  85. package/src/Button/Button.jsx +1 -1
  86. package/src/Button/ButtonBase.jsx +11 -4
  87. package/src/Button/ButtonGroup.jsx +17 -8
  88. package/src/Button/ButtonLink.jsx +1 -1
  89. package/src/Button/propTypes.js +2 -1
  90. package/src/Card/Card.jsx +1 -1
  91. package/src/Card/CardBase.jsx +6 -5
  92. package/src/Card/PressableCardBase.jsx +7 -5
  93. package/src/Checkbox/Checkbox.jsx +1 -3
  94. package/src/Divider/Divider.jsx +2 -2
  95. package/src/FlexGrid/FlexGrid.jsx +11 -5
  96. package/src/FlexGrid/helpers/index.js +1 -3
  97. package/src/IconButton/IconButton.jsx +7 -5
  98. package/src/Link/LinkBase.jsx +7 -5
  99. package/src/List/List.jsx +2 -4
  100. package/src/List/ListItem.jsx +11 -26
  101. package/src/List/index.js +5 -0
  102. package/src/Pagination/PageButton.jsx +5 -8
  103. package/src/Pagination/Pagination.jsx +29 -2
  104. package/src/Pagination/SideButton.jsx +2 -2
  105. package/src/Progress/Progress.jsx +1 -1
  106. package/src/Progress/ProgressBar.jsx +1 -1
  107. package/src/Radio/Radio.jsx +1 -3
  108. package/src/Spacer/Spacer.jsx +2 -2
  109. package/src/StackView/StackWrap.jsx +7 -6
  110. package/src/StackView/getStackedContent.jsx +1 -1
  111. package/src/StepTracker/StepTracker.jsx +1 -1
  112. package/src/Tabs/Tabs.jsx +49 -22
  113. package/src/Tabs/TabsItem.jsx +11 -7
  114. package/src/Tags/Tags.jsx +1 -7
  115. package/src/ThemeProvider/useThemeTokens.js +3 -3
  116. package/src/ThemeProvider/utils/theme-tokens.js +3 -3
  117. package/src/ToggleSwitch/ToggleSwitch.jsx +93 -41
  118. package/src/ToggleSwitch/ToggleSwitchGroup.jsx +203 -0
  119. package/src/ToggleSwitch/index.js +2 -1
  120. package/src/index.js +2 -2
  121. package/src/utils/a11y/semantics.js +3 -2
  122. package/src/utils/index.js +2 -1
  123. package/src/utils/pressability.js +1 -1
  124. package/src/utils/props/a11yProps.js +151 -0
  125. package/src/utils/props/clickProps.js +31 -0
  126. package/src/utils/props/componentPropType.js +67 -0
  127. package/src/utils/props/copyPropTypes.js +3 -0
  128. package/src/utils/props/getPropSelector.js +14 -0
  129. package/src/utils/props/hrefAttrsProp.js +25 -0
  130. package/src/utils/props/index.js +15 -0
  131. package/src/utils/props/linkProps.js +43 -0
  132. package/src/utils/props/paddingProp.js +10 -0
  133. package/src/utils/props/pressProps.js +45 -0
  134. package/src/utils/props/rectProp.js +10 -0
  135. package/src/utils/props/responsiveProps.js +30 -0
  136. package/src/utils/props/selectSystemProps.js +25 -0
  137. package/src/utils/props/spacingProps.js +58 -0
  138. package/src/utils/props/tokens.js +150 -0
  139. package/src/utils/props/variantProp.js +20 -0
  140. package/src/utils/props/viewProps.js +23 -0
  141. package/src/utils/useResponsiveProp.js +1 -1
  142. package/src/utils/useSpacingScale.js +4 -4
  143. package/src/utils/withLinkRouter.jsx +68 -0
  144. package/stories/A11yText/A11yText.stories.jsx +1 -1
  145. package/stories/ActivityIndicator/ActivityIndicator.stories.jsx +1 -1
  146. package/stories/Box/Box.stories.jsx +1 -1
  147. package/stories/Button/Button.stories.jsx +1 -1
  148. package/stories/Button/ButtonGroup.stories.jsx +1 -1
  149. package/stories/Button/ButtonLink.stories.jsx +1 -1
  150. package/stories/Card/Card.stories.jsx +1 -1
  151. package/stories/Checkbox/Checkbox.stories.jsx +1 -1
  152. package/stories/Divider/Divider.stories.jsx +1 -1
  153. package/stories/ExpandCollapse/ExpandCollapse.stories.jsx +1 -1
  154. package/stories/Feedback/Feedback.stories.jsx +1 -1
  155. package/stories/FlexGrid/01 FlexGrid.stories.jsx +1 -1
  156. package/stories/FlexGrid/02 Row.stories.jsx +1 -1
  157. package/stories/FlexGrid/03 Col.stories.jsx +1 -1
  158. package/stories/Icon/Icon.stories.jsx +1 -1
  159. package/stories/IconButton/IconButton.stories.jsx +1 -1
  160. package/stories/InputLabel/InputLabel.stories.jsx +1 -1
  161. package/stories/Link/ChevronLink.stories.jsx +1 -1
  162. package/stories/Link/Link.stories.jsx +1 -1
  163. package/stories/Link/TextButton.stories.jsx +1 -1
  164. package/stories/List/List.stories.jsx +1 -1
  165. package/stories/Modal/Modal.stories.jsx +1 -1
  166. package/stories/Notification/Notification.stories.jsx +1 -1
  167. package/stories/Pagination/Pagination.stories.jsx +1 -1
  168. package/stories/Progress/Progress.stories.jsx +1 -1
  169. package/stories/Radio/Radio.stories.jsx +1 -1
  170. package/stories/RadioCard/RadioCard.stories.jsx +1 -1
  171. package/stories/Search/Search.stories.jsx +1 -1
  172. package/stories/Select/Select.stories.jsx +1 -1
  173. package/stories/SideNav/SideNav.stories.jsx +1 -1
  174. package/stories/SideNav/SideNavItem.stories.jsx +1 -1
  175. package/stories/SideNav/SideNavItemsGroup.stories.jsx +1 -1
  176. package/stories/Skeleton/Skeleton.stories.jsx +1 -1
  177. package/stories/Spacer/Spacer.stories.jsx +1 -1
  178. package/stories/StackView/StackView.stories.jsx +1 -1
  179. package/stories/StackView/StackWrap.stories.jsx +1 -1
  180. package/stories/StepTracker/StepTracker.stories.jsx +1 -1
  181. package/stories/Tabs/Tabs.stories.jsx +1 -1
  182. package/stories/Tags/Tags.stories.jsx +1 -1
  183. package/stories/TextInput/TextArea.stories.jsx +2 -1
  184. package/stories/TextInput/TextInput.stories.jsx +1 -1
  185. package/stories/ToggleSwitch/ToggleSwitch.stories.jsx +6 -2
  186. package/stories/ToggleSwitch/ToggleSwitchGroup.stories.jsx +81 -0
  187. package/stories/Tooltip/Tooltip.stories.jsx +1 -1
  188. package/stories/TooltipButton/TooltipButton.stories.jsx +1 -1
  189. package/stories/Typography/Typography.stories.jsx +1 -1
  190. package/stories/supports.jsx +2 -3
  191. package/.ultra.cache.json +0 -1
  192. package/lib/utils/propTypes.js +0 -623
  193. package/src/utils/propTypes.js +0 -640
@@ -0,0 +1,150 @@
1
+ import PropTypes from 'prop-types'
2
+ import { components as tokenKeys } from '@telus-uds/system-theme-tokens'
3
+
4
+ // Tokens can be primitive values (e.g. `'rgba(0,0,0,0'`, `12`), or objects of such values,
5
+ // such as tokens that describe shadow (e.g. shadow: { inset: true, color: 'rgba(...)' ... }),
6
+ // or components (e.g. Icon tokens)
7
+ const tokenValue = PropTypes.oneOfType([
8
+ PropTypes.string,
9
+ PropTypes.number,
10
+ PropTypes.bool,
11
+ PropTypes.elementType
12
+ ])
13
+ const tokenValueType = PropTypes.oneOfType([tokenValue, PropTypes.objectOf(tokenValue)])
14
+
15
+ export const getTokenNames = (componentName) => {
16
+ const componentTokenSchema = tokenKeys[componentName]
17
+ if (!componentTokenSchema) {
18
+ throw new Error(`No "${componentName}" tokenKeys in @telus-uds/system-theme-tokens`)
19
+ }
20
+ return Object.keys(componentTokenSchema)
21
+ }
22
+
23
+ /**
24
+ * Returns the subset of a set of tokens that may be accepted by the `tokens` prop of a named component
25
+ * or by a provided array of tokens. A prefix may be provided, for example:
26
+ *
27
+ * @example
28
+ * ```jsx
29
+ * // returns tokens from `themeTokens` that exist in the theme schema for `Button`.
30
+ * selectTokens('Button', themeTokens)
31
+ * ```
32
+ *
33
+ * @example
34
+ * ```jsx
35
+ * // returns `{ backgroundColor, width }` where the values of those keys come from
36
+ * // the source object's `{ containerBackgroundColor, containerWidth }` properties.
37
+ * selectTokens(['backgroundColor', 'width'], themeTokens, 'container')
38
+ * ```
39
+ *
40
+ * @example
41
+ * ```jsx
42
+ * // returns tokens that are defined in the `Button` theme schema, from tokens with
43
+ * // a prefix `'button'` e.g. a token `buttonBorderWidth` outputs as `borderWidth`.
44
+ * selectTokens('Button', themeTokens, 'button')
45
+ * ```
46
+ *
47
+ * @param {string[]|string} specifier - a name of a component in the theme schema, or an array of token names
48
+ * @param {object} tokens - a source object of theme tokens
49
+ * @param {string} [prefix] - if provided, matches keys in the source object with this as the first camelCase item
50
+ * @returns {object} - subset of theme tokens
51
+ */
52
+ export const selectTokens = (specifier, tokens, prefix) => {
53
+ const tokenNames = typeof specifier === 'string' ? getTokenNames(specifier) : specifier
54
+ const filteredTokens = tokenNames.reduce((validTokens, key) => {
55
+ const prefixedKey = prefix ? `${prefix}${key[0].toUpperCase()}${key.slice(1)}` : key
56
+ const token = tokens[prefixedKey]
57
+ return token !== undefined ? { ...validTokens, [key]: token } : validTokens
58
+ }, {})
59
+ return filteredTokens
60
+ }
61
+
62
+ /**
63
+ * @typedef {string|number|boolean|{[key: string]:string|number|boolean}} TokenValue
64
+ * @typedef {{[key: string]: TokenValue}} TokensSet
65
+ * @typedef {(AppearanceSet) => TokensSet} TokensGetter
66
+ * @typedef {TokensSet|TokensGetter} TokensProp
67
+ */
68
+ /**
69
+ * 'tokens' is an optional object prop on all themable components. Its keys must match the
70
+ * token keys in the component's theme schema.
71
+ *
72
+ * This prop is intended to be used as an 'escape hatch' for difficult or exceptional cases
73
+ * where the main theming system doesn't apply. It is intentionally permissive about values.
74
+ *
75
+ * @param {...string} componentsNames - one or more ComponentName, which tokens keys are accepted
76
+ * @return {function} - a custom PropTypes validator
77
+ *
78
+ * @example
79
+ * Component.propTypes = {
80
+ * // accepts all tokens keys defined in Component schema
81
+ * tokens: getTokensPropType('Component')
82
+ * }
83
+ *
84
+ * Component.propTypes = {
85
+ * // accepts all tokens keys defined in schemas for Component1 and Component2
86
+ * tokens: getTokensPropType('Component1', 'Component2')
87
+ * }
88
+ */
89
+ export const getTokensPropType = (...componentsNames) => (props, propName, componentName) => {
90
+ PropTypes.checkPropTypes(
91
+ {
92
+ [propName]: PropTypes.oneOfType([PropTypes.object, PropTypes.func])
93
+ },
94
+ props,
95
+ propName,
96
+ componentName
97
+ )
98
+
99
+ if (typeof props[propName] !== 'function') {
100
+ PropTypes.checkPropTypes(
101
+ {
102
+ [propName]: PropTypes.exact(
103
+ Object.fromEntries(
104
+ componentsNames.flatMap((component) =>
105
+ getTokenNames(component).map((key) => [key, tokenValueType])
106
+ )
107
+ )
108
+ )
109
+ },
110
+ props,
111
+ propName,
112
+ componentName
113
+ )
114
+ }
115
+ }
116
+
117
+ /**
118
+ * Get a proptypes validator for a set of tokens that is not based on a component in the theme schema.
119
+ *
120
+ * For example, for a set of tokens used in a common style, or for a set of tokens required by
121
+ * a themeless component whose tokens are set by a parent but requires tokens of a certain shape.
122
+ *
123
+ * By default, requires an object with a complete set of tokens (allowing `null`, but not `undefined`).
124
+ *
125
+ * @param {string[]} componentTokenKeys - array of strings of token names
126
+ * @param {object} [options]
127
+ * @param {boolean} [options.partial] - if true, allows tokens to be undefined
128
+ * @param {boolean} [options.allowFunction] - if true, allows functions as well as tokens objects
129
+ * @returns
130
+ */
131
+ export const getTokensSetPropType = (
132
+ componentTokenKeys,
133
+ { partial = false, allowFunction = false } = {}
134
+ ) => {
135
+ const tokensObjectValidator = PropTypes.exact(
136
+ Object.fromEntries(
137
+ componentTokenKeys.map((key) => [
138
+ key,
139
+ partial
140
+ ? tokenValueType
141
+ : // Some theme tokens can validly resolve to `null`, but .isRequired treats null as undefined
142
+ (props, propName, ...args) =>
143
+ props[propName] !== null && tokenValueType.isRequired(props, propName, ...args)
144
+ ])
145
+ )
146
+ )
147
+ return allowFunction
148
+ ? PropTypes.oneOfType([tokensObjectValidator, PropTypes.func])
149
+ : tokensObjectValidator
150
+ }
@@ -0,0 +1,20 @@
1
+ import PropTypes from 'prop-types'
2
+
3
+ /**
4
+ * @typedef {{[key: string]: string|number|boolean}} AppearanceSet
5
+ * @typedef {AppearanceSet} VariantProp
6
+ */
7
+ export default {
8
+ /**
9
+ * 'variant' is an optional object prop on all themable components.
10
+ *
11
+ * Contains an object with keys that correspond to the current component theme's allowed
12
+ * appearances and values that correspond to the allowed values of that component.
13
+ *
14
+ * Since the particular keys and values depend on which theme is currently active,
15
+ * the exact shape of variant props is not enforced using PropTypes.
16
+ */
17
+ propType: PropTypes.objectOf(
18
+ PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool])
19
+ )
20
+ }
@@ -0,0 +1,23 @@
1
+ import PropTypes from 'prop-types'
2
+ import getPropSelector from './getPropSelector'
3
+
4
+ const viewPropTypes = {
5
+ pointerEvents: PropTypes.oneOf(['all', 'none', 'box-only', 'box-none']),
6
+ onLayout: PropTypes.func,
7
+ nativeID: PropTypes.string,
8
+ testID: PropTypes.string,
9
+ dataSet: PropTypes.object
10
+ }
11
+
12
+ export default {
13
+ /**
14
+ * Subset of `View` proptypes that could conceivably be needed on any component
15
+ * that renders a single View.
16
+ */
17
+ types: viewPropTypes,
18
+ /**
19
+ * Filters a props object, returning only cross-platform View props that are potentially
20
+ * relevant to any basic layout component that renders one View.
21
+ */
22
+ select: getPropSelector(viewPropTypes)
23
+ }
@@ -36,7 +36,7 @@ export const resolveResponsiveProp = (prop, viewport, defaultValue) => {
36
36
  * For example, if passed `{ sm: 4, lg: 8 }`, it will return 8 on `xl` and `lg` viewports,
37
37
  * 4 on `md` and `sm` viewports, and `undefined` (or a provided `defaultValue`) on `xs` viewports.
38
38
  *
39
- * To generate propTypes for responsive props, see `responsiveProps` in `./utils/propTypes.js`.
39
+ * To generate propTypes for responsive props, see `responsiveProps` in `./utils/props/responsiveProps.js`.
40
40
  *
41
41
  * @param {*} prop - any value which may be an object with viewport keys
42
42
  * @param {*} [defaultValue] - default value to provide if no matches found for the current viewport
@@ -3,10 +3,10 @@ import { useThemeTokens } from '../ThemeProvider'
3
3
  import { resolveResponsiveProp } from './useResponsiveProp'
4
4
  /**
5
5
  * @typedef {import('@telus-uds/system-constants/viewports').Viewport} Viewport
6
- * @typedef {import('./propTypes.js').SpacingValue} SpacingValue
7
- * @typedef {import('./propTypes.js').SpacingIndex} SpacingIndex
8
- * @typedef {import('./propTypes.js').SpacingObject} SpacingObject
9
- * @typedef {import('./propTypes.js').SpacingOptions} SpacingOptions
6
+ * @typedef {import('./props/spacingProps.js').SpacingValue} SpacingValue
7
+ * @typedef {import('./props/spacingProps.js').SpacingIndex} SpacingIndex
8
+ * @typedef {import('./props/spacingProps.js').SpacingObject} SpacingObject
9
+ * @typedef {import('./props/spacingProps.js').SpacingOptions} SpacingOptions
10
10
  */
11
11
 
12
12
  const resolveSpacingOptions = (space) => {
@@ -0,0 +1,68 @@
1
+ import React, { forwardRef } from 'react'
2
+ import PropTypes from 'prop-types'
3
+
4
+ // Prototype-safe alternative to (linter-forbidden) someObject.hasOwnProperty()
5
+ const hasOwnProperty = (object, prop) => Object.prototype.hasOwnProperty.call(object, prop)
6
+
7
+ /**
8
+ * Higher-order component that has no effect unless an additional prop `LinkRouter` is passed.
9
+ * This may be used to provide custom wrappers for integrations with third party libraries.
10
+ *
11
+ * If LinkRouter is passed, LinkRouter is rendered in place of the main component and is passed:
12
+ *
13
+ * - `linkRouterProps`: an optional object passed alongside LinkRouter, for props needed by the wrapper
14
+ * that are not valid props for the wrapped component.
15
+ * - `Component`: automatically provided, the original component to render inside the wrapper.
16
+ * - `ref`: forwarded `ref` passed down to `Component`
17
+ * - All other props passed to the outer component
18
+ *
19
+ * @example A LinkRouter component to be used with link-like components might look like:
20
+ *
21
+ * ```jsx
22
+ * const LinkLinkRouter = forwardRef(({ Component, linkRouterProps: { to, options }, href, ...rest }, ref) => {
23
+ * const { href: resolvedHref, onClick } = useSomeRouterHook({ to, href, options })
24
+ * return <Component href={resolvedHref} onPress={onClick} {...rest} />
25
+ * })
26
+ * ```
27
+ *
28
+ * Any component that takes href and onPress props may then use this wrapper:
29
+ *
30
+ * ```jsx
31
+ * <Link href={href} LinkRouter={LinkLinkRouter} linkRouterProps={{ to, options }}>Some link</Link>
32
+ * <IconButton icon={SomeIcon} LinkRouter={LinkLinkRouter} linkRouterProps={{ to, options }} ref={iconRef} />
33
+ * ```
34
+ */
35
+ const withLinkRouter = (Component) => {
36
+ const wrappedComponent = forwardRef(({ LinkRouter, linkRouterProps, ...props }, ref) => {
37
+ if (!LinkRouter) return <Component {...props} ref={ref} />
38
+ return (
39
+ <LinkRouter linkRouterProps={linkRouterProps} Component={Component} ref={ref} {...props} />
40
+ )
41
+ })
42
+
43
+ // Ensure the returned component has appropriate outer properties set:
44
+ /* eslint-disable-next-line react/forbid-foreign-prop-types */
45
+ const { displayName, name, propTypes, ...otherProperties } = Component
46
+
47
+ // Apply unique component name as a displayName
48
+ wrappedComponent.displayName = Component.displayName || Component.name
49
+
50
+ // Apply proptypes including wrapper props - is safely { ...undefined, ...undefined } in prod
51
+ wrappedComponent.propTypes = { ...Component.propTypes, ...withLinkRouter.propTypes }
52
+
53
+ // Forward any other properties explicitly set e.g. Component.SubComponent
54
+ Object.keys(otherProperties).forEach((key) => {
55
+ // Skip internal React properties from wrappedComponent's forwardRef (render, $$typeof, etc)
56
+ if (hasOwnProperty(Component, key) && !hasOwnProperty(wrappedComponent, key)) {
57
+ wrappedComponent[key] = Component[key]
58
+ }
59
+ })
60
+ return wrappedComponent
61
+ }
62
+
63
+ withLinkRouter.propTypes = {
64
+ LinkRouter: PropTypes.elementType,
65
+ linkRouterProps: PropTypes.object
66
+ }
67
+
68
+ export default withLinkRouter
@@ -12,7 +12,7 @@ const defaultArgs = {
12
12
  }
13
13
 
14
14
  export default {
15
- title: 'Base/A11yText',
15
+ title: 'A11yText',
16
16
  component: A11yText,
17
17
  parameters: defaultArgs
18
18
  }
@@ -4,7 +4,7 @@ import { ActivityIndicator } from '../../src'
4
4
  import { EachParentType, parentTypesParams } from '../supports'
5
5
 
6
6
  export default {
7
- title: 'Base/ActivityIndicator',
7
+ title: 'ActivityIndicator',
8
8
  component: ActivityIndicator,
9
9
  args: {
10
10
  label: 'loading...'
@@ -12,7 +12,7 @@ import {
12
12
  } from '../supports'
13
13
 
14
14
  export default {
15
- title: 'Base/Box',
15
+ title: 'Box',
16
16
  component: Box
17
17
  }
18
18
 
@@ -10,7 +10,7 @@ Default.storyName = 'Button'
10
10
  const defaultLabel = "I'm a button"
11
11
 
12
12
  export default {
13
- title: 'Base/Button',
13
+ title: 'Button',
14
14
  component: Button,
15
15
  args: {
16
16
  // eslint-disable-next-line no-console
@@ -22,7 +22,7 @@ const defaultControlledArgs = {
22
22
  }
23
23
 
24
24
  export default {
25
- title: 'Base/ButtonGroup',
25
+ title: 'ButtonGroup',
26
26
  component: ButtonGroup,
27
27
  args: {
28
28
  ...defaultArgs
@@ -3,7 +3,7 @@ import { ButtonLink } from '../../src'
3
3
  import { Container, useVariants } from '../supports'
4
4
 
5
5
  export default {
6
- title: 'Base/ButtonLink',
6
+ title: 'ButtonLink',
7
7
  component: ButtonLink,
8
8
  args: {
9
9
  children: "I'm a button link",
@@ -6,7 +6,7 @@ import { Card } from '../../src'
6
6
  import { Container, useVariants, EachParentType, parentTypesParams } from '../supports'
7
7
 
8
8
  export default {
9
- title: 'Base/Card',
9
+ title: 'Card',
10
10
  component: Card
11
11
  }
12
12
 
@@ -5,7 +5,7 @@ import { Checkbox, CheckboxGroup, Typography } from '../../src'
5
5
  import { Container, EachParentType, parentTypesParams } from '../supports'
6
6
 
7
7
  export default {
8
- title: 'Base/Checkbox',
8
+ title: 'Checkbox',
9
9
  component: Checkbox,
10
10
  argTypes: {
11
11
  checked: {
@@ -5,7 +5,7 @@ import { Divider, Typography } from '../../src'
5
5
  import { EachParentType, parentTypesParams } from '../supports'
6
6
 
7
7
  export default {
8
- title: 'Base/Divider',
8
+ title: 'Divider',
9
9
  component: Divider
10
10
  }
11
11
 
@@ -6,7 +6,7 @@ import { Container, EachParentType, parentTypesParams } from '../supports'
6
6
  import { useMultipleInputValues } from '../../src/utils'
7
7
 
8
8
  export default {
9
- title: 'Base/ExpandCollapse',
9
+ title: 'ExpandCollapse',
10
10
  component: ExpandCollapse,
11
11
  args: {
12
12
  children: () => {}
@@ -5,7 +5,7 @@ import { Feedback, Typography, TextInput } from '../../src'
5
5
  import { Container } from '../supports'
6
6
 
7
7
  export default {
8
- title: 'Base/Feedback',
8
+ title: 'Feedback',
9
9
  component: Feedback
10
10
  }
11
11
 
@@ -7,7 +7,7 @@ import { Placeholder, EachParentType, parentTypesParams } from '../supports'
7
7
  const { Row, Col } = FlexGrid
8
8
 
9
9
  export default {
10
- title: 'Base/FlexGrid/FlexGrid',
10
+ title: 'FlexGrid/FlexGrid',
11
11
  component: FlexGrid
12
12
  }
13
13
 
@@ -6,7 +6,7 @@ import { Placeholder } from '../supports'
6
6
  const { Row, Col } = FlexGrid
7
7
 
8
8
  export default {
9
- title: 'Base/FlexGrid/Row',
9
+ title: 'FlexGrid/Row',
10
10
  component: Row
11
11
  }
12
12
 
@@ -6,7 +6,7 @@ import { Placeholder } from '../supports'
6
6
  const { Row, Col } = FlexGrid
7
7
 
8
8
  export default {
9
- title: 'Base/FlexGrid/Col',
9
+ title: 'FlexGrid/Col',
10
10
  component: Col,
11
11
  argTypes: {
12
12
  xs: {
@@ -7,7 +7,7 @@ import { Container, useVariants, EachIcon, EachParentType, parentTypesParams } f
7
7
  import { Icon, StackWrap, Tooltip } from '../../src'
8
8
 
9
9
  export default {
10
- title: 'Base/Icon',
10
+ title: 'Icon',
11
11
  component: Icon,
12
12
  argTypes: {
13
13
  label: {
@@ -8,7 +8,7 @@ import { Box, IconButton, StackView } from '../../src'
8
8
  import { useVariants, EachParentType, parentTypesParams } from '../supports'
9
9
 
10
10
  export default {
11
- title: 'Base/IconButton',
11
+ title: 'IconButton',
12
12
  component: IconButton
13
13
  }
14
14
 
@@ -4,7 +4,7 @@ import React from 'react'
4
4
  import InputLabel from '../../src/InputLabel/InputLabel'
5
5
 
6
6
  export default {
7
- title: 'Base/InputLabel',
7
+ title: 'InputLabel',
8
8
  component: InputLabel
9
9
  }
10
10
 
@@ -5,7 +5,7 @@ import { ChevronLink } from '../../src'
5
5
  import { Container, EachParentType, parentTypesParams, useVariants } from '../supports'
6
6
 
7
7
  export default {
8
- title: 'Base/ChevronLink',
8
+ title: 'ChevronLink',
9
9
  component: ChevronLink,
10
10
  args: {
11
11
  href: 'https://example.com'
@@ -8,7 +8,7 @@ import { Link, Typography, variantProp } from '../../src'
8
8
  import { Container, EachIcon, EachParentType, parentTypesParams, useVariants } from '../supports'
9
9
 
10
10
  export default {
11
- title: 'Base/Link',
11
+ title: 'Link',
12
12
  component: Link,
13
13
  args: {
14
14
  href: `https://telus.com/?unvisited:${Date.now()}`,
@@ -10,7 +10,7 @@ import { TextButton, variantProp } from '../../src'
10
10
  import { Container, EachParentType, useVariants, parentTypesParams } from '../supports'
11
11
 
12
12
  export default {
13
- title: 'Base/TextButton',
13
+ title: 'TextButton',
14
14
  component: TextButton,
15
15
  args: {
16
16
  // eslint-disable-next-line no-console
@@ -9,7 +9,7 @@ import { useVariants, Container } from '../supports'
9
9
  import { List, Typography } from '../../src'
10
10
 
11
11
  export default {
12
- title: 'Base/List',
12
+ title: 'List',
13
13
  component: List
14
14
  }
15
15
 
@@ -3,7 +3,7 @@ import React, { useState } from 'react'
3
3
  import { Button, Modal, Spacer, Typography } from '../../src'
4
4
 
5
5
  export default {
6
- title: 'Base/Modal',
6
+ title: 'Modal',
7
7
  component: Modal
8
8
  }
9
9
 
@@ -6,7 +6,7 @@ import { Link, Notification, Typography } from '../../src'
6
6
  import { Container } from '../supports'
7
7
 
8
8
  export default {
9
- title: 'Base/Notification',
9
+ title: 'Notification',
10
10
  component: Notification
11
11
  }
12
12
 
@@ -6,7 +6,7 @@ import { Pagination, Typography } from '../../src'
6
6
  import { Container, EachParentType, parentTypesParams } from '../supports'
7
7
 
8
8
  export default {
9
- title: 'Base/Pagination',
9
+ title: 'Pagination',
10
10
  component: Pagination
11
11
  }
12
12
 
@@ -5,7 +5,7 @@ import { Progress, StackView, Typography } from '../../src'
5
5
  import { Container, EachParentType, parentTypesParams } from '../supports'
6
6
 
7
7
  export default {
8
- title: 'Base/Progress',
8
+ title: 'Progress',
9
9
  component: Progress.Bar,
10
10
  args: { accessibilityLabel: 'Progress Bar' }
11
11
  }
@@ -5,7 +5,7 @@ import { Radio, RadioGroup, Typography } from '../../src'
5
5
  import { Container, EachParentType, parentTypesParams } from '../supports'
6
6
 
7
7
  export default {
8
- title: 'Base/Radio',
8
+ title: 'Radio',
9
9
  component: Radio,
10
10
  argTypes: {
11
11
  checked: {
@@ -5,7 +5,7 @@ import { RadioCard, RadioCardGroup, Typography } from '../../src'
5
5
  import { Container, EachParentType, parentTypesParams } from '../supports'
6
6
 
7
7
  export default {
8
- title: 'Base/RadioCard',
8
+ title: 'RadioCard',
9
9
  component: RadioCard
10
10
  }
11
11
 
@@ -3,7 +3,7 @@ import React from 'react'
3
3
  import { Search } from '../../src'
4
4
 
5
5
  export default {
6
- title: 'Base/Search',
6
+ title: 'Search',
7
7
  component: Search
8
8
  }
9
9
 
@@ -4,7 +4,7 @@ import { Text } from 'react-native'
4
4
  import { Select } from '../../src'
5
5
 
6
6
  export default {
7
- title: 'Base/Select',
7
+ title: 'Select',
8
8
  component: Select
9
9
  }
10
10
 
@@ -5,7 +5,7 @@ import { SideNav } from '../../src'
5
5
  import { EachParentType, parentTypesParams } from '../supports'
6
6
 
7
7
  export default {
8
- title: 'Base/SideNav',
8
+ title: 'SideNav',
9
9
  component: SideNav
10
10
  }
11
11
 
@@ -2,7 +2,7 @@ import React from 'react'
2
2
  import { SideNav } from '../../src'
3
3
 
4
4
  export default {
5
- title: 'Base/SideNav/Item',
5
+ title: 'SideNav/Item',
6
6
  component: SideNav.Item
7
7
  }
8
8
 
@@ -2,7 +2,7 @@ import React from 'react'
2
2
  import { SideNav } from '../../src'
3
3
 
4
4
  export default {
5
- title: 'Base/SideNav/Items Group',
5
+ title: 'SideNav/Items Group',
6
6
  component: SideNav.ItemsGroup
7
7
  }
8
8
 
@@ -6,7 +6,7 @@ import StackView from '../../src/StackView'
6
6
  import { Skeleton } from '../../src'
7
7
 
8
8
  export default {
9
- title: 'Base/Skeleton',
9
+ title: 'Skeleton',
10
10
  component: Skeleton
11
11
  }
12
12
 
@@ -6,7 +6,7 @@ import { Spacer, Typography } from '../../src'
6
6
  import { Container } from '../supports'
7
7
 
8
8
  export default {
9
- title: 'Base/Spacer',
9
+ title: 'Spacer',
10
10
  component: Spacer
11
11
  }
12
12
 
@@ -6,7 +6,7 @@ import { View } from 'react-native'
6
6
  import { StackView, Card, Typography, Button } from '../../src'
7
7
 
8
8
  export default {
9
- title: 'Base/StackView',
9
+ title: 'StackView',
10
10
  component: StackView
11
11
  }
12
12
 
@@ -5,7 +5,7 @@ import { StyleSheet, View } from 'react-native'
5
5
  import { StackWrap, Button } from '../../src'
6
6
 
7
7
  export default {
8
- title: 'Base/StackWrap',
8
+ title: 'StackWrap',
9
9
  component: StackWrap
10
10
  }
11
11