@telus-uds/components-base 1.19.0 → 1.21.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 (97) hide show
  1. package/CHANGELOG.md +34 -2
  2. package/__tests17__/ThemeProvider/ThemeProvider.test.jsx +3 -1
  3. package/component-docs.json +838 -125
  4. package/lib/BaseProvider/index.js +2 -1
  5. package/lib/Box/Box.js +14 -1
  6. package/lib/Button/ButtonDropdown.js +207 -0
  7. package/lib/Button/index.js +8 -0
  8. package/lib/Carousel/Carousel.js +2 -2
  9. package/lib/Carousel/CarouselItem/CarouselItem.js +7 -1
  10. package/lib/Carousel/CarouselTabs/CarouselTabsPanel.js +21 -4
  11. package/lib/FlexGrid/Col/Col.js +1 -3
  12. package/lib/FlexGrid/FlexGrid.js +3 -5
  13. package/lib/FlexGrid/Row/Row.js +3 -3
  14. package/lib/IconButton/IconButton.js +12 -4
  15. package/lib/MultiSelectFilter/MultiSelectFilter.js +276 -0
  16. package/lib/MultiSelectFilter/dictionary.js +19 -0
  17. package/lib/MultiSelectFilter/index.js +13 -0
  18. package/lib/Search/Search.js +4 -1
  19. package/lib/Select/Picker.native.js +16 -13
  20. package/lib/Select/Select.js +7 -1
  21. package/lib/Select/constants.js +15 -0
  22. package/lib/StepTracker/Step.js +2 -1
  23. package/lib/TextInput/TextInput.js +9 -2
  24. package/lib/TextInput/TextInputBase.js +52 -8
  25. package/lib/TextInput/dictionary.js +15 -0
  26. package/lib/ThemeProvider/ThemeProvider.js +24 -7
  27. package/lib/ThemeProvider/utils/styles.js +3 -1
  28. package/lib/index.js +18 -0
  29. package/lib/utils/BaseView/BaseView.js +64 -0
  30. package/lib/utils/BaseView/BaseView.native.js +16 -0
  31. package/lib/utils/BaseView/index.js +13 -0
  32. package/lib/utils/index.js +10 -1
  33. package/lib/utils/input.js +11 -3
  34. package/lib/utils/props/handlerProps.js +5 -0
  35. package/lib-module/BaseProvider/index.js +2 -1
  36. package/lib-module/Box/Box.js +14 -1
  37. package/lib-module/Button/ButtonDropdown.js +181 -0
  38. package/lib-module/Button/index.js +2 -1
  39. package/lib-module/Carousel/Carousel.js +2 -2
  40. package/lib-module/Carousel/CarouselItem/CarouselItem.js +8 -2
  41. package/lib-module/Carousel/CarouselTabs/CarouselTabsPanel.js +23 -6
  42. package/lib-module/FlexGrid/Col/Col.js +2 -3
  43. package/lib-module/FlexGrid/FlexGrid.js +2 -3
  44. package/lib-module/FlexGrid/Row/Row.js +2 -2
  45. package/lib-module/IconButton/IconButton.js +14 -4
  46. package/lib-module/MultiSelectFilter/MultiSelectFilter.js +248 -0
  47. package/lib-module/MultiSelectFilter/dictionary.js +12 -0
  48. package/lib-module/MultiSelectFilter/index.js +2 -0
  49. package/lib-module/Search/Search.js +4 -1
  50. package/lib-module/Select/Picker.native.js +15 -13
  51. package/lib-module/Select/Select.js +6 -1
  52. package/lib-module/Select/constants.js +5 -0
  53. package/lib-module/StepTracker/Step.js +2 -1
  54. package/lib-module/TextInput/TextInput.js +6 -0
  55. package/lib-module/TextInput/TextInputBase.js +52 -10
  56. package/lib-module/TextInput/dictionary.js +8 -0
  57. package/lib-module/ThemeProvider/ThemeProvider.js +24 -7
  58. package/lib-module/ThemeProvider/utils/styles.js +3 -1
  59. package/lib-module/index.js +2 -0
  60. package/lib-module/utils/BaseView/BaseView.js +43 -0
  61. package/lib-module/utils/BaseView/BaseView.native.js +6 -0
  62. package/lib-module/utils/BaseView/index.js +2 -0
  63. package/lib-module/utils/index.js +2 -1
  64. package/lib-module/utils/input.js +11 -3
  65. package/lib-module/utils/props/handlerProps.js +5 -0
  66. package/package.json +3 -3
  67. package/src/BaseProvider/index.jsx +4 -1
  68. package/src/Box/Box.jsx +14 -1
  69. package/src/Button/ButtonDropdown.jsx +179 -0
  70. package/src/Button/index.js +2 -1
  71. package/src/Carousel/Carousel.jsx +6 -3
  72. package/src/Carousel/CarouselItem/CarouselItem.jsx +9 -2
  73. package/src/Carousel/CarouselTabs/CarouselTabsPanel.jsx +19 -5
  74. package/src/FlexGrid/Col/Col.jsx +4 -4
  75. package/src/FlexGrid/FlexGrid.jsx +11 -10
  76. package/src/FlexGrid/Row/Row.jsx +4 -3
  77. package/src/IconButton/IconButton.jsx +3 -1
  78. package/src/MultiSelectFilter/MultiSelectFilter.jsx +227 -0
  79. package/src/MultiSelectFilter/dictionary.js +12 -0
  80. package/src/MultiSelectFilter/index.js +3 -0
  81. package/src/Search/Search.jsx +2 -1
  82. package/src/Select/Picker.native.jsx +29 -14
  83. package/src/Select/Select.jsx +7 -1
  84. package/src/Select/constants.js +5 -0
  85. package/src/StepTracker/Step.jsx +5 -1
  86. package/src/TextInput/TextInput.jsx +5 -0
  87. package/src/TextInput/TextInputBase.jsx +43 -8
  88. package/src/TextInput/dictionary.js +8 -0
  89. package/src/ThemeProvider/ThemeProvider.jsx +23 -6
  90. package/src/ThemeProvider/utils/styles.js +3 -1
  91. package/src/index.js +2 -0
  92. package/src/utils/BaseView/BaseView.jsx +38 -0
  93. package/src/utils/BaseView/BaseView.native.jsx +6 -0
  94. package/src/utils/BaseView/index.js +3 -0
  95. package/src/utils/index.js +1 -0
  96. package/src/utils/input.js +9 -4
  97. package/src/utils/props/handlerProps.js +4 -0
@@ -66,7 +66,7 @@ export const useInputValue = (props = {}, hookName = 'useInputValue') => {
66
66
  const [isControlled] = useState(isCurrentlyControlled)
67
67
  validateProps(props, { isControlled, isCurrentlyControlled }, hookName)
68
68
 
69
- const { value, initialValue, onChange, readOnly = false } = props
69
+ const { value, initialValue, inputRef, onChange, readOnly = false } = props
70
70
  const [ownValue, setOwnValue] = useState(!isControlled && initialValue)
71
71
  const currentValue = isControlled ? value : ownValue
72
72
 
@@ -76,19 +76,24 @@ export const useInputValue = (props = {}, hookName = 'useInputValue') => {
76
76
  // Make current value accessible inside useCallback without rememoizing every time the value changes
77
77
  valueRef.current.value = currentValue
78
78
 
79
+ const isDirty = currentValue !== valueRef.current.initial
80
+
79
81
  const setValue = useCallback(
80
82
  (arg, event) => {
81
83
  if (readOnly) return
82
84
  const newValue = typeof arg === 'function' ? arg(valueRef.current.value) : arg
83
- if (!isControlled) setOwnValue(newValue)
85
+ if (!isControlled) {
86
+ setOwnValue(newValue)
87
+ if (inputRef?.current) inputRef.current.value = newValue ?? ''
88
+ }
84
89
  // Call onChange handler if there's something for it to handle (event or a changed value)
85
90
  if (onChange && (event || valueRef.current.value !== newValue)) onChange(newValue, event)
86
91
  },
87
- [isControlled, onChange, readOnly]
92
+ [inputRef, isControlled, onChange, readOnly]
88
93
  )
89
94
  const resetValue = useCallback((event) => setValue(valueRef.current.initial, event), [setValue])
90
95
 
91
- return { currentValue, setValue, resetValue, isControlled }
96
+ return { currentValue, setValue, resetValue, isControlled, isDirty }
92
97
  }
93
98
 
94
99
  /**
@@ -26,6 +26,10 @@ const textInputHandlerProps = {
26
26
  * onChangeText handler
27
27
  */
28
28
  onChangeText: PropTypes.func,
29
+ /**
30
+ * onClear handler
31
+ */
32
+ onClear: PropTypes.func,
29
33
  /**
30
34
  * onSubmit handler
31
35
  */