@telus-uds/components-base 1.21.0 → 1.23.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 (42) hide show
  1. package/CHANGELOG.md +30 -2
  2. package/component-docs.json +470 -1
  3. package/lib/Button/ButtonGroup.js +9 -0
  4. package/lib/Checkbox/CheckboxGroup.js +2 -0
  5. package/lib/ExpandCollapse/Control.js +3 -1
  6. package/lib/Feedback/Feedback.js +5 -2
  7. package/lib/Fieldset/Fieldset.js +42 -13
  8. package/lib/Fieldset/FieldsetContainer.js +9 -3
  9. package/lib/List/PressableListItemBase.js +1 -0
  10. package/lib/QuickLinksFeature/QuickLinksFeature.js +91 -0
  11. package/lib/QuickLinksFeature/QuickLinksFeatureItem.js +157 -0
  12. package/lib/QuickLinksFeature/index.js +16 -0
  13. package/lib/Radio/RadioGroup.js +5 -1
  14. package/lib/RadioCard/RadioCardGroup.js +2 -0
  15. package/lib/index.js +9 -0
  16. package/lib-module/Button/ButtonGroup.js +9 -0
  17. package/lib-module/Checkbox/CheckboxGroup.js +2 -0
  18. package/lib-module/ExpandCollapse/Control.js +3 -1
  19. package/lib-module/Feedback/Feedback.js +5 -2
  20. package/lib-module/Fieldset/Fieldset.js +39 -12
  21. package/lib-module/Fieldset/FieldsetContainer.js +9 -3
  22. package/lib-module/List/PressableListItemBase.js +1 -0
  23. package/lib-module/QuickLinksFeature/QuickLinksFeature.js +69 -0
  24. package/lib-module/QuickLinksFeature/QuickLinksFeatureItem.js +130 -0
  25. package/lib-module/QuickLinksFeature/index.js +4 -0
  26. package/lib-module/Radio/RadioGroup.js +5 -1
  27. package/lib-module/RadioCard/RadioCardGroup.js +2 -0
  28. package/lib-module/index.js +1 -0
  29. package/package.json +2 -2
  30. package/src/Button/ButtonGroup.jsx +10 -0
  31. package/src/Checkbox/CheckboxGroup.jsx +2 -0
  32. package/src/ExpandCollapse/Control.jsx +3 -2
  33. package/src/Feedback/Feedback.jsx +11 -3
  34. package/src/Fieldset/Fieldset.jsx +45 -13
  35. package/src/Fieldset/FieldsetContainer.jsx +29 -12
  36. package/src/List/PressableListItemBase.jsx +1 -0
  37. package/src/QuickLinksFeature/QuickLinksFeature.jsx +65 -0
  38. package/src/QuickLinksFeature/QuickLinksFeatureItem.jsx +114 -0
  39. package/src/QuickLinksFeature/index.js +6 -0
  40. package/src/Radio/RadioGroup.jsx +5 -3
  41. package/src/RadioCard/RadioCardGroup.jsx +2 -0
  42. package/src/index.js +1 -0
@@ -0,0 +1,114 @@
1
+ import React, { forwardRef, useState } from 'react'
2
+ import PropTypes from 'prop-types'
3
+
4
+ import { Image, Platform, Text, View } from 'react-native'
5
+ import {
6
+ getTokensPropType,
7
+ variantProp,
8
+ withLinkRouter,
9
+ a11yProps,
10
+ linkProps,
11
+ selectSystemProps
12
+ } from '../utils'
13
+ import { useViewport } from '../ViewportProvider'
14
+ import { useThemeTokensCallback } from '../ThemeProvider'
15
+ import { Link } from '../Link'
16
+ import { StackWrap } from '../StackView'
17
+
18
+ // pass through and type relevant system props - add more sets for interactive components
19
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, linkProps])
20
+
21
+ const selectImageStyle = (imageDimension) => ({
22
+ width: imageDimension,
23
+ height: imageDimension,
24
+ ...Platform.select({
25
+ // TODO: https://github.com/telus/universal-design-system/issues/487
26
+ web: { transition: 'width 200ms, height 200ms' }
27
+ })
28
+ })
29
+
30
+ const selectContainerStyle = ({ contentMaxDimension, textAlign }) => ({
31
+ textAlign,
32
+ width: contentMaxDimension,
33
+ overflow: 'hidden'
34
+ })
35
+
36
+ const selectImageContainerStyle = (contentMaxDimension) => ({
37
+ width: contentMaxDimension,
38
+ height: contentMaxDimension,
39
+ justifyContent: 'center',
40
+ alignItems: 'center'
41
+ })
42
+
43
+ /**
44
+ * Component export along with QuickLinksFeature to be used as children
45
+ *
46
+ * It will receive a image source and a accessibility label and will render a link accordingly with the theme tokens
47
+ */
48
+ const QuickLinksFeatureItem = forwardRef(
49
+ ({ tokens, variant, children, imageAccessibilityLabel, imageSource, ...rest }, ref) => {
50
+ const viewport = useViewport()
51
+ const getTokens = useThemeTokensCallback('QuickLinksFeatureItem', tokens, variant)
52
+ const [hover, setHover] = useState(false)
53
+ const {
54
+ contentDirection,
55
+ contentSpace,
56
+ contentAlignItems,
57
+ contentMaxDimension,
58
+ imageDimension,
59
+ textAlign
60
+ } = getTokens({ viewport, hover })
61
+
62
+ return (
63
+ <Link
64
+ ref={ref}
65
+ tokens={(state) => {
66
+ setHover(state.hover)
67
+ return getTokens(state)
68
+ }}
69
+ {...selectProps(rest)}
70
+ >
71
+ <View style={selectContainerStyle({ contentMaxDimension, textAlign })}>
72
+ <StackWrap
73
+ direction={contentDirection}
74
+ space={contentSpace}
75
+ tokens={{ alignItems: contentAlignItems }}
76
+ >
77
+ <View style={selectImageContainerStyle(contentMaxDimension)}>
78
+ <Image
79
+ accessibilityIgnoresInvertColors
80
+ imageAccessibilityLabel={imageAccessibilityLabel}
81
+ source={imageSource}
82
+ style={selectImageStyle(imageDimension)}
83
+ />
84
+ </View>
85
+ <Text>{children}</Text>
86
+ </StackWrap>
87
+ </View>
88
+ </Link>
89
+ )
90
+ }
91
+ )
92
+
93
+ QuickLinksFeatureItem.displayName = 'QuickLinksFeatureItem'
94
+
95
+ QuickLinksFeatureItem.propTypes = {
96
+ ...withLinkRouter.propTypes,
97
+ ...selectedSystemPropTypes,
98
+ tokens: getTokensPropType('QuickLinksFeatureItem'),
99
+ variant: variantProp.propType,
100
+ /**
101
+ * Text which will be rendered within the Link
102
+ */
103
+ children: PropTypes.node.isRequired,
104
+ /**
105
+ * Image accessibility label
106
+ */
107
+ imageAccessibilityLabel: PropTypes.string.isRequired,
108
+ /**
109
+ * Image node or Image url
110
+ */
111
+ imageSource: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired
112
+ }
113
+
114
+ export default withLinkRouter(QuickLinksFeatureItem)
@@ -0,0 +1,6 @@
1
+ import QuickLinksFeature from './QuickLinksFeature'
2
+ import QuickLinksFeatureItem from './QuickLinksFeatureItem'
3
+
4
+ QuickLinksFeature.Item = QuickLinksFeatureItem
5
+
6
+ export default QuickLinksFeature
@@ -116,17 +116,15 @@ const RadioGroup = forwardRef(
116
116
  }
117
117
 
118
118
  const radios = items.map(
119
- ({ label, id, onChange: itemOnChange, ref: itemRef, ...itemRest }, index) => {
119
+ ({ label, id, onChange: itemOnChange, ref: itemRef, description, ...itemRest }, index) => {
120
120
  const radioId = id || `Radio[${index}]`
121
121
  const isChecked = currentValue === radioId
122
122
  const handleChange = (newCheckedState, event) => {
123
123
  if (typeof itemOnChange === 'function') itemOnChange(newCheckedState, event)
124
124
  if (newCheckedState) setValue(radioId, event)
125
125
  }
126
-
127
126
  return (
128
127
  <Radio
129
- error={validation === 'error'}
130
128
  ref={itemRef}
131
129
  key={radioId}
132
130
  id={radioId}
@@ -137,6 +135,7 @@ const RadioGroup = forwardRef(
137
135
  name={inputGroupName}
138
136
  tokens={radioTokens}
139
137
  variant={variant}
138
+ description={description}
140
139
  {...selectItemProps(itemRest)}
141
140
  />
142
141
  )
@@ -156,6 +155,8 @@ const RadioGroup = forwardRef(
156
155
  feedback={feedback}
157
156
  inactive={inactive}
158
157
  validation={validation}
158
+ showIcon
159
+ showErrorBorder
159
160
  accessibilityRole="radiogroup"
160
161
  {...selectProps(rest)}
161
162
  >
@@ -193,6 +194,7 @@ RadioGroup.propTypes = {
193
194
  label: PropTypes.string,
194
195
  id: PropTypes.string,
195
196
  onChange: PropTypes.func,
197
+ description: PropTypes.string,
196
198
  ref: ABBPropTypes.ref()
197
199
  })
198
200
  ),
@@ -133,6 +133,8 @@ const RadioCardGroup = forwardRef(
133
133
  feedback={feedback}
134
134
  inactive={inactive || readOnly}
135
135
  validation={validation}
136
+ showErrorBorder
137
+ showIcon
136
138
  accessibilityRole="radiogroup"
137
139
  {...selectProps(rest)}
138
140
  >
package/src/index.js CHANGED
@@ -26,6 +26,7 @@ export { default as Notification } from './Notification'
26
26
  export { default as Pagination } from './Pagination'
27
27
  export { default as Progress } from './Progress'
28
28
  export { default as QuickLinks } from './QuickLinks'
29
+ export { default as QuickLinksFeature } from './QuickLinksFeature'
29
30
  export { default as Radio } from './Radio'
30
31
  export * from './Radio'
31
32
  export { default as RadioCard } from './RadioCard'