@telus-uds/components-base 1.86.0 → 1.88.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 (53) hide show
  1. package/CHANGELOG.md +34 -2
  2. package/lib/ActionCard/ActionCard.js +350 -0
  3. package/lib/ActionCard/index.js +10 -0
  4. package/lib/Card/Card.js +3 -3
  5. package/lib/Card/PressableCardBase.js +1 -1
  6. package/lib/Checkbox/Checkbox.js +4 -0
  7. package/lib/List/List.js +9 -2
  8. package/lib/Modal/WebModal.js +2 -1
  9. package/lib/Notification/Notification.js +20 -15
  10. package/lib/OrderedList/Item.js +14 -23
  11. package/lib/Radio/Radio.js +4 -0
  12. package/lib/Radio/RadioGroup.js +1 -1
  13. package/lib/Tabs/Tabs.js +4 -1
  14. package/lib/Tabs/TabsItem.js +7 -1
  15. package/lib/Validator/Validator.js +18 -9
  16. package/lib/index.js +8 -0
  17. package/lib/utils/animation/useVerticalExpandAnimation.js +3 -3
  18. package/lib/utils/props/tokens.js +2 -2
  19. package/lib-module/ActionCard/ActionCard.js +343 -0
  20. package/lib-module/ActionCard/index.js +2 -0
  21. package/lib-module/Card/Card.js +4 -4
  22. package/lib-module/Card/PressableCardBase.js +1 -1
  23. package/lib-module/Checkbox/Checkbox.js +4 -0
  24. package/lib-module/List/List.js +9 -2
  25. package/lib-module/Modal/WebModal.js +2 -1
  26. package/lib-module/Notification/Notification.js +20 -15
  27. package/lib-module/OrderedList/Item.js +14 -23
  28. package/lib-module/Radio/Radio.js +4 -0
  29. package/lib-module/Radio/RadioGroup.js +1 -1
  30. package/lib-module/Tabs/Tabs.js +4 -1
  31. package/lib-module/Tabs/TabsItem.js +7 -1
  32. package/lib-module/Validator/Validator.js +18 -9
  33. package/lib-module/index.js +1 -0
  34. package/lib-module/utils/animation/useVerticalExpandAnimation.js +3 -3
  35. package/lib-module/utils/props/tokens.js +2 -2
  36. package/package.json +2 -2
  37. package/src/ActionCard/ActionCard.jsx +306 -0
  38. package/src/ActionCard/index.js +3 -0
  39. package/src/Card/Card.jsx +6 -4
  40. package/src/Card/PressableCardBase.jsx +1 -1
  41. package/src/Checkbox/Checkbox.jsx +3 -1
  42. package/src/List/List.jsx +7 -2
  43. package/src/Modal/WebModal.jsx +2 -1
  44. package/src/Notification/Notification.jsx +36 -16
  45. package/src/OrderedList/Item.jsx +12 -16
  46. package/src/Radio/Radio.jsx +3 -1
  47. package/src/Radio/RadioGroup.jsx +1 -1
  48. package/src/Tabs/Tabs.jsx +4 -1
  49. package/src/Tabs/TabsItem.jsx +5 -1
  50. package/src/Validator/Validator.jsx +21 -9
  51. package/src/index.js +1 -0
  52. package/src/utils/animation/useVerticalExpandAnimation.js +3 -3
  53. package/src/utils/props/tokens.js +4 -2
@@ -18,7 +18,7 @@ const selectCodeTextInputTokens = ({ outerBorderColor, outerBackgroundColor }) =
18
18
  }
19
19
 
20
20
  const Validator = React.forwardRef(
21
- ({ value = '', inactive, onChange, tokens = {}, variant = {}, ...rest }, ref) => {
21
+ ({ value = '', inactive, mask = '', onChange, tokens = {}, variant = {}, ...rest }, ref) => {
22
22
  const defaultRef = React.useRef()
23
23
  const codeRef = ref ?? defaultRef
24
24
 
@@ -62,6 +62,15 @@ const Validator = React.forwardRef(
62
62
  })
63
63
  }
64
64
 
65
+ const changeDataMasking = (boxElement) => {
66
+ let charMasking = ''
67
+ const element = boxElement
68
+ if (mask && mask.length === 1) charMasking = mask
69
+ else if (mask && mask.length > 1) charMasking = mask.substring(0, 1)
70
+
71
+ if (charMasking) element.value = charMasking
72
+ }
73
+
65
74
  const handleChangeCode = () => {
66
75
  let code = ''
67
76
  for (let i = 0; i < validatorsLength; i += 1) code += singleCodes[prefix + i]
@@ -76,20 +85,18 @@ const Validator = React.forwardRef(
76
85
  codeElement.value = singleCodes[codeId] ?? ''
77
86
  return
78
87
  }
79
- if (codeElement?.value?.length > 1) {
80
- const oldValue = singleCodes[codeId]
81
- const newValue = codeElement.value.replace(oldValue, '')
82
- codeElement.value = newValue
83
- handleSingleCodes(codeId, codeElement.value, 'success')
84
- }
85
88
 
86
89
  handleSingleCodes(codeId, codeElement?.value ?? singleCodes[codeId], 'success')
87
90
  handleChangeCode()
88
91
  if (nextIndex === validatorsLength) {
89
92
  codeElement.blur()
93
+ changeDataMasking(codeElement)
90
94
  return
91
95
  }
92
- if (codeElement?.value?.length > 0) codeReferences[prefix + nextIndex].current.focus()
96
+ if (codeElement?.value?.length > 0) {
97
+ codeReferences[prefix + nextIndex].current.focus()
98
+ changeDataMasking(codeElement)
99
+ }
93
100
  }
94
101
 
95
102
  const handleKeyPress = (event, currentIndex, previousIndex) => {
@@ -138,7 +145,8 @@ const Validator = React.forwardRef(
138
145
  /* eslint-disable react-hooks/exhaustive-deps */
139
146
  React.useEffect(() => {
140
147
  for (let i = 0; i < validatorsLength; i += 1) {
141
- codeReferences[prefix + i].current.value = text[i] ?? ''
148
+ if (mask && text[i]) codeReferences[prefix + i].current.value = mask
149
+ else codeReferences[prefix + i].current.value = text[i] ?? ''
142
150
  handleSingleCodes(prefix + i, text[i] ?? '', text[i] ? 'success' : '')
143
151
  }
144
152
  }, [text])
@@ -203,6 +211,10 @@ Validator.propTypes = {
203
211
  * If true, the component is inactive and non editable.
204
212
  */
205
213
  inactive: PropTypes.bool,
214
+ /**
215
+ * Show masked characters and obscure the actual input. For example: '*'
216
+ */
217
+ mask: PropTypes.string,
206
218
  /**
207
219
  * Use to react upon input's value changes. Required when the `value` prop is set. Will receive the input's value as an argument.
208
220
  */
package/src/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { default as A11yText } from './A11yText'
2
+ export { default as ActionCard } from './ActionCard'
2
3
  export { default as ActivityIndicator } from './ActivityIndicator'
3
4
  export { default as Autocomplete } from './Autocomplete'
4
5
  export { default as Box } from './Box'
@@ -53,8 +53,8 @@ function useVerticalExpandAnimation({ containerHeight, isExpanded, tokens }) {
53
53
 
54
54
  if (!isExpanded && !isAnimating && !expandStateChanged) {
55
55
  if (Platform.OS === 'web') {
56
- // Without `visibility: 'hidden', descendents are focusable on web even when collapsed.
57
- containerStyles.visibility = 'hidden'
56
+ // Without `display: 'none', descendents are focusable on web even when collapsed.
57
+ containerStyles.display = 'none'
58
58
  } else {
59
59
  // There's no `visibility: hidden` in React Native, and display: none causes a flicker on expand.
60
60
  // Without some form of hiding, some children leak through even when closed e.g. `List.Item` bullets.
@@ -68,7 +68,7 @@ function useVerticalExpandAnimation({ containerHeight, isExpanded, tokens }) {
68
68
  // on web we can hide the contents until we have the container measured and avoid occasional jitter
69
69
  // this won't work on native platforms
70
70
  containerStyles.height = 0
71
- containerStyles.visibility = 'hidden'
71
+ containerStyles.display = 'none'
72
72
  }
73
73
  } else if (Platform.OS === 'web') {
74
74
  const transitionDuration = isExpanded ? expandDuration : collapseDuration
@@ -122,7 +122,7 @@ export const getTokensPropType =
122
122
  * For example, for a set of tokens used in a common style, or for a set of tokens required by
123
123
  * a themeless component whose tokens are set by a parent but requires tokens of a certain shape.
124
124
  *
125
- * By default, requires an object with a complete set of tokens (allowing `null`, but not `undefined`).
125
+ * By default, requires an object with a complete set of tokens (allowing `null` and `undefined`).
126
126
  *
127
127
  * @param {string[]} componentTokenKeys - array of strings of token names
128
128
  * @param {object} [options]
@@ -142,7 +142,9 @@ export const getTokensSetPropType = (
142
142
  ? tokenValueType
143
143
  : // Some theme tokens can validly resolve to `null`, but .isRequired treats null as undefined
144
144
  (props, propName, ...args) =>
145
- props[propName] !== null && tokenValueType.isRequired(props, propName, ...args)
145
+ props[propName] !== null &&
146
+ props[propName] !== undefined &&
147
+ tokenValueType.isRequired(props, propName, ...args)
146
148
  ])
147
149
  )
148
150
  )