@telus-uds/components-base 1.8.1 → 1.8.4

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 (288) hide show
  1. package/CHANGELOG.md +35 -2
  2. package/component-docs.json +711 -669
  3. package/lib/A11yInfoProvider/index.js +4 -3
  4. package/lib/A11yText/index.js +6 -5
  5. package/lib/ActivityIndicator/Spinner.js +14 -13
  6. package/lib/ActivityIndicator/Spinner.native.js +10 -8
  7. package/lib/ActivityIndicator/index.js +6 -5
  8. package/lib/ActivityIndicator/shared.js +1 -1
  9. package/lib/BaseProvider/index.js +13 -10
  10. package/lib/Box/Box.js +20 -19
  11. package/lib/Button/Button.js +7 -6
  12. package/lib/Button/ButtonBase.js +97 -79
  13. package/lib/Button/ButtonGroup.js +34 -32
  14. package/lib/Button/ButtonLink.js +9 -7
  15. package/lib/Button/index.js +4 -4
  16. package/lib/Button/propTypes.js +1 -1
  17. package/lib/Card/Card.js +8 -7
  18. package/lib/Card/CardBase.js +35 -31
  19. package/lib/Card/PressableCardBase.js +14 -12
  20. package/lib/Checkbox/Checkbox.js +97 -83
  21. package/lib/Checkbox/CheckboxGroup.js +29 -27
  22. package/lib/Checkbox/CheckboxInput.js +12 -10
  23. package/lib/Divider/Divider.js +10 -9
  24. package/lib/ExpandCollapse/Control.js +42 -36
  25. package/lib/ExpandCollapse/ExpandCollapse.js +11 -10
  26. package/lib/ExpandCollapse/Panel.js +29 -40
  27. package/lib/Feedback/Feedback.js +48 -35
  28. package/lib/Fieldset/Fieldset.js +16 -15
  29. package/lib/Fieldset/FieldsetContainer.js +16 -13
  30. package/lib/Fieldset/FieldsetContainer.native.js +11 -8
  31. package/lib/Fieldset/Legend.js +10 -7
  32. package/lib/Fieldset/Legend.native.js +10 -7
  33. package/lib/FlexGrid/Col/Col.js +18 -17
  34. package/lib/FlexGrid/FlexGrid.js +15 -14
  35. package/lib/FlexGrid/Row/Row.js +13 -12
  36. package/lib/HorizontalScroll/HorizontalScroll.js +25 -20
  37. package/lib/HorizontalScroll/HorizontalScrollButton.js +18 -14
  38. package/lib/HorizontalScroll/ScrollViewEnd.js +6 -5
  39. package/lib/HorizontalScroll/ScrollViewEnd.native.js +12 -9
  40. package/lib/HorizontalScroll/itemPositions.js +19 -13
  41. package/lib/Icon/Icon.js +11 -10
  42. package/lib/Icon/IconText.js +8 -7
  43. package/lib/Icon/index.js +5 -5
  44. package/lib/IconButton/IconButton.js +50 -42
  45. package/lib/InputLabel/InputLabel.js +37 -30
  46. package/lib/InputLabel/LabelContent.js +12 -9
  47. package/lib/InputLabel/LabelContent.native.js +9 -6
  48. package/lib/InputSupports/InputSupports.js +11 -10
  49. package/lib/InputSupports/useInputSupports.js +7 -6
  50. package/lib/Link/ChevronLink.js +9 -8
  51. package/lib/Link/InlinePressable.js +13 -10
  52. package/lib/Link/InlinePressable.native.js +20 -16
  53. package/lib/Link/Link.js +10 -9
  54. package/lib/Link/LinkBase.js +96 -78
  55. package/lib/Link/TextButton.js +9 -8
  56. package/lib/List/List.js +20 -13
  57. package/lib/List/ListItem.js +103 -79
  58. package/lib/Modal/Modal.js +74 -60
  59. package/lib/Notification/Notification.js +46 -33
  60. package/lib/Pagination/PageButton.js +13 -12
  61. package/lib/Pagination/Pagination.js +43 -30
  62. package/lib/Pagination/SideButton.js +21 -18
  63. package/lib/Pagination/usePagination.js +7 -6
  64. package/lib/Progress/Progress.js +23 -19
  65. package/lib/Progress/ProgressBar.js +25 -21
  66. package/lib/Progress/ProgressBarBackground.js +7 -6
  67. package/lib/Radio/Radio.js +80 -69
  68. package/lib/Radio/RadioButton.js +63 -53
  69. package/lib/Radio/RadioGroup.js +30 -28
  70. package/lib/Radio/RadioInput.js +12 -10
  71. package/lib/RadioCard/RadioCard.js +16 -15
  72. package/lib/RadioCard/RadioCardGroup.js +30 -28
  73. package/lib/Search/Search.js +52 -32
  74. package/lib/Select/Group.js +5 -4
  75. package/lib/Select/Group.native.js +4 -3
  76. package/lib/Select/Item.js +10 -7
  77. package/lib/Select/Item.native.js +1 -9
  78. package/lib/Select/Picker.js +16 -15
  79. package/lib/Select/Picker.native.js +49 -38
  80. package/lib/Select/Select.js +134 -113
  81. package/lib/SideNav/Item.js +39 -33
  82. package/lib/SideNav/ItemContent.js +15 -12
  83. package/lib/SideNav/ItemsGroup.js +13 -11
  84. package/lib/SideNav/SideNav.js +21 -18
  85. package/lib/Skeleton/Skeleton.js +60 -44
  86. package/lib/Skeleton/skeleton.constant.js +1 -1
  87. package/lib/Skeleton/skeletonWebAnimation.js +1 -1
  88. package/lib/Spacer/Spacer.js +6 -5
  89. package/lib/StackView/StackView.js +12 -11
  90. package/lib/StackView/StackWrap.js +5 -3
  91. package/lib/StackView/StackWrapBox.js +12 -11
  92. package/lib/StackView/StackWrapGap.js +11 -10
  93. package/lib/StackView/common.js +14 -11
  94. package/lib/StackView/getStackedContent.js +10 -9
  95. package/lib/StackView/index.js +1 -1
  96. package/lib/StepTracker/Step.js +122 -103
  97. package/lib/StepTracker/StepTracker.js +48 -38
  98. package/lib/Tabs/Tabs.js +57 -27
  99. package/lib/Tabs/TabsItem.js +78 -68
  100. package/lib/Tags/Tags.js +68 -62
  101. package/lib/TextInput/TextArea.js +26 -20
  102. package/lib/TextInput/TextInput.js +20 -15
  103. package/lib/TextInput/TextInputBase.js +74 -62
  104. package/lib/TextInput/index.js +4 -4
  105. package/lib/ThemeProvider/ThemeProvider.js +6 -5
  106. package/lib/ThemeProvider/index.js +5 -5
  107. package/lib/ThemeProvider/useSetTheme.js +6 -3
  108. package/lib/ThemeProvider/useThemeTokens.js +7 -2
  109. package/lib/ThemeProvider/utils/styles.js +50 -43
  110. package/lib/ThemeProvider/utils/theme-tokens.js +33 -21
  111. package/lib/ToggleSwitch/ToggleSwitch.js +90 -74
  112. package/lib/ToggleSwitch/ToggleSwitchGroup.js +37 -35
  113. package/lib/Tooltip/Backdrop.js +6 -13
  114. package/lib/Tooltip/Backdrop.native.js +5 -4
  115. package/lib/Tooltip/Tooltip.js +81 -65
  116. package/lib/Tooltip/getTooltipPosition.js +29 -18
  117. package/lib/TooltipButton/TooltipButton.js +28 -21
  118. package/lib/Typography/Typography.js +37 -33
  119. package/lib/ViewportProvider/ViewportProvider.js +4 -3
  120. package/lib/ViewportProvider/useViewportListener.js +6 -3
  121. package/lib/index.js +54 -54
  122. package/lib/utils/a11y/semantics.js +5 -2
  123. package/lib/utils/a11y/textSize.js +8 -6
  124. package/lib/utils/animation/useVerticalExpandAnimation.js +46 -19
  125. package/lib/utils/children.js +4 -3
  126. package/lib/utils/index.js +10 -10
  127. package/lib/utils/input.js +28 -29
  128. package/lib/utils/pressability.js +36 -22
  129. package/lib/utils/props/clickProps.js +2 -1
  130. package/lib/utils/props/componentPropType.js +3 -3
  131. package/lib/utils/props/getPropSelector.js +6 -3
  132. package/lib/utils/props/handlerProps.js +25 -19
  133. package/lib/utils/props/hrefAttrsProp.js +14 -11
  134. package/lib/utils/props/index.js +12 -12
  135. package/lib/utils/props/inputSupportsProps.js +15 -12
  136. package/lib/utils/props/linkProps.js +7 -6
  137. package/lib/utils/props/pressProps.js +1 -1
  138. package/lib/utils/props/selectSystemProps.js +2 -2
  139. package/lib/utils/props/tokens.js +29 -15
  140. package/lib/utils/ssr.js +6 -2
  141. package/lib/utils/useCopy.js +6 -4
  142. package/lib/utils/useHash.js +2 -1
  143. package/lib/utils/useResponsiveProp.js +1 -1
  144. package/lib/utils/useSpacingScale.js +3 -1
  145. package/lib/utils/useUniqueId.js +3 -2
  146. package/lib/utils/withLinkRouter.js +6 -5
  147. package/lib-module/A11yInfoProvider/index.js +4 -3
  148. package/lib-module/A11yText/index.js +6 -5
  149. package/lib-module/ActivityIndicator/Spinner.js +14 -13
  150. package/lib-module/ActivityIndicator/Spinner.native.js +9 -8
  151. package/lib-module/ActivityIndicator/index.js +6 -5
  152. package/lib-module/BaseProvider/index.js +13 -10
  153. package/lib-module/Box/Box.js +20 -19
  154. package/lib-module/Button/Button.js +7 -6
  155. package/lib-module/Button/ButtonBase.js +96 -79
  156. package/lib-module/Button/ButtonGroup.js +34 -32
  157. package/lib-module/Button/ButtonLink.js +8 -7
  158. package/lib-module/Card/Card.js +8 -7
  159. package/lib-module/Card/CardBase.js +35 -31
  160. package/lib-module/Card/PressableCardBase.js +12 -11
  161. package/lib-module/Checkbox/Checkbox.js +97 -83
  162. package/lib-module/Checkbox/CheckboxGroup.js +29 -27
  163. package/lib-module/Checkbox/CheckboxInput.js +12 -10
  164. package/lib-module/Divider/Divider.js +10 -9
  165. package/lib-module/ExpandCollapse/Control.js +42 -36
  166. package/lib-module/ExpandCollapse/ExpandCollapse.js +11 -10
  167. package/lib-module/ExpandCollapse/Panel.js +29 -37
  168. package/lib-module/Feedback/Feedback.js +46 -33
  169. package/lib-module/Fieldset/Fieldset.js +16 -15
  170. package/lib-module/Fieldset/FieldsetContainer.js +16 -13
  171. package/lib-module/Fieldset/FieldsetContainer.native.js +11 -8
  172. package/lib-module/Fieldset/Legend.js +10 -7
  173. package/lib-module/Fieldset/Legend.native.js +10 -7
  174. package/lib-module/FlexGrid/Col/Col.js +18 -17
  175. package/lib-module/FlexGrid/FlexGrid.js +15 -14
  176. package/lib-module/FlexGrid/Row/Row.js +13 -12
  177. package/lib-module/HorizontalScroll/HorizontalScroll.js +24 -19
  178. package/lib-module/HorizontalScroll/HorizontalScrollButton.js +18 -14
  179. package/lib-module/HorizontalScroll/ScrollViewEnd.js +6 -5
  180. package/lib-module/HorizontalScroll/ScrollViewEnd.native.js +12 -9
  181. package/lib-module/HorizontalScroll/itemPositions.js +18 -12
  182. package/lib-module/Icon/Icon.js +10 -9
  183. package/lib-module/Icon/IconText.js +9 -7
  184. package/lib-module/IconButton/IconButton.js +48 -41
  185. package/lib-module/InputLabel/InputLabel.js +37 -30
  186. package/lib-module/InputLabel/LabelContent.js +12 -9
  187. package/lib-module/InputLabel/LabelContent.native.js +9 -6
  188. package/lib-module/InputSupports/InputSupports.js +11 -10
  189. package/lib-module/InputSupports/useInputSupports.js +7 -6
  190. package/lib-module/Link/ChevronLink.js +9 -8
  191. package/lib-module/Link/InlinePressable.js +13 -10
  192. package/lib-module/Link/InlinePressable.native.js +20 -16
  193. package/lib-module/Link/Link.js +10 -9
  194. package/lib-module/Link/LinkBase.js +94 -77
  195. package/lib-module/Link/TextButton.js +9 -8
  196. package/lib-module/List/List.js +20 -13
  197. package/lib-module/List/ListItem.js +103 -78
  198. package/lib-module/Modal/Modal.js +74 -60
  199. package/lib-module/Notification/Notification.js +46 -33
  200. package/lib-module/Pagination/PageButton.js +13 -12
  201. package/lib-module/Pagination/Pagination.js +43 -30
  202. package/lib-module/Pagination/SideButton.js +21 -18
  203. package/lib-module/Pagination/usePagination.js +7 -6
  204. package/lib-module/Progress/Progress.js +23 -19
  205. package/lib-module/Progress/ProgressBar.js +25 -21
  206. package/lib-module/Progress/ProgressBarBackground.js +7 -6
  207. package/lib-module/Radio/Radio.js +80 -69
  208. package/lib-module/Radio/RadioButton.js +62 -52
  209. package/lib-module/Radio/RadioGroup.js +30 -28
  210. package/lib-module/Radio/RadioInput.js +12 -10
  211. package/lib-module/RadioCard/RadioCard.js +16 -15
  212. package/lib-module/RadioCard/RadioCardGroup.js +30 -28
  213. package/lib-module/Search/Search.js +52 -32
  214. package/lib-module/Select/Group.js +5 -4
  215. package/lib-module/Select/Group.native.js +4 -3
  216. package/lib-module/Select/Item.js +10 -7
  217. package/lib-module/Select/Item.native.js +1 -7
  218. package/lib-module/Select/Picker.js +16 -15
  219. package/lib-module/Select/Picker.native.js +46 -36
  220. package/lib-module/Select/Select.js +134 -113
  221. package/lib-module/SideNav/Item.js +39 -33
  222. package/lib-module/SideNav/ItemContent.js +14 -11
  223. package/lib-module/SideNav/ItemsGroup.js +13 -11
  224. package/lib-module/SideNav/SideNav.js +21 -18
  225. package/lib-module/Skeleton/Skeleton.js +60 -44
  226. package/lib-module/Skeleton/skeletonWebAnimation.js +1 -1
  227. package/lib-module/Spacer/Spacer.js +6 -5
  228. package/lib-module/StackView/StackView.js +12 -11
  229. package/lib-module/StackView/StackWrap.js +5 -3
  230. package/lib-module/StackView/StackWrapBox.js +12 -11
  231. package/lib-module/StackView/StackWrapGap.js +11 -10
  232. package/lib-module/StackView/common.js +14 -11
  233. package/lib-module/StackView/getStackedContent.js +10 -9
  234. package/lib-module/StepTracker/Step.js +122 -103
  235. package/lib-module/StepTracker/StepTracker.js +48 -38
  236. package/lib-module/Tabs/Tabs.js +57 -27
  237. package/lib-module/Tabs/TabsItem.js +77 -68
  238. package/lib-module/Tags/Tags.js +68 -62
  239. package/lib-module/TextInput/TextArea.js +26 -20
  240. package/lib-module/TextInput/TextInput.js +19 -15
  241. package/lib-module/TextInput/TextInputBase.js +74 -62
  242. package/lib-module/ThemeProvider/ThemeProvider.js +5 -4
  243. package/lib-module/ThemeProvider/useSetTheme.js +6 -3
  244. package/lib-module/ThemeProvider/useThemeTokens.js +7 -2
  245. package/lib-module/ThemeProvider/utils/styles.js +48 -41
  246. package/lib-module/ThemeProvider/utils/theme-tokens.js +32 -20
  247. package/lib-module/ToggleSwitch/ToggleSwitch.js +90 -74
  248. package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +37 -35
  249. package/lib-module/Tooltip/Backdrop.js +6 -13
  250. package/lib-module/Tooltip/Backdrop.native.js +5 -4
  251. package/lib-module/Tooltip/Tooltip.js +81 -65
  252. package/lib-module/Tooltip/getTooltipPosition.js +29 -18
  253. package/lib-module/TooltipButton/TooltipButton.js +28 -21
  254. package/lib-module/Typography/Typography.js +35 -31
  255. package/lib-module/ViewportProvider/ViewportProvider.js +4 -3
  256. package/lib-module/ViewportProvider/useViewportListener.js +6 -3
  257. package/lib-module/utils/a11y/semantics.js +4 -1
  258. package/lib-module/utils/a11y/textSize.js +7 -5
  259. package/lib-module/utils/animation/useVerticalExpandAnimation.js +47 -20
  260. package/lib-module/utils/children.js +4 -3
  261. package/lib-module/utils/input.js +28 -29
  262. package/lib-module/utils/pressability.js +35 -21
  263. package/lib-module/utils/props/clickProps.js +2 -1
  264. package/lib-module/utils/props/componentPropType.js +3 -3
  265. package/lib-module/utils/props/getPropSelector.js +6 -3
  266. package/lib-module/utils/props/handlerProps.js +24 -18
  267. package/lib-module/utils/props/hrefAttrsProp.js +14 -11
  268. package/lib-module/utils/props/inputSupportsProps.js +15 -12
  269. package/lib-module/utils/props/linkProps.js +7 -6
  270. package/lib-module/utils/props/selectSystemProps.js +2 -2
  271. package/lib-module/utils/props/tokens.js +27 -14
  272. package/lib-module/utils/ssr.js +5 -2
  273. package/lib-module/utils/useCopy.js +6 -4
  274. package/lib-module/utils/useHash.js +2 -1
  275. package/lib-module/utils/useSpacingScale.js +3 -1
  276. package/lib-module/utils/useUniqueId.js +3 -2
  277. package/lib-module/utils/withLinkRouter.js +6 -5
  278. package/package.json +13 -11
  279. package/src/ExpandCollapse/Panel.jsx +2 -19
  280. package/src/List/List.jsx +34 -19
  281. package/src/List/ListItem.jsx +12 -2
  282. package/src/Modal/Modal.jsx +2 -1
  283. package/src/Pagination/Pagination.jsx +3 -0
  284. package/src/Search/Search.jsx +11 -0
  285. package/src/Select/Item.native.jsx +0 -7
  286. package/src/Tabs/Tabs.jsx +24 -2
  287. package/src/Tabs/TabsItem.jsx +6 -5
  288. package/src/utils/animation/useVerticalExpandAnimation.js +47 -13
@@ -5,43 +5,39 @@ import { useCallback, useRef, useState } from 'react';
5
5
 
6
6
  const pluralHooks = ['useMultipleInputValues'];
7
7
 
8
- const validateProps = ({
9
- value,
10
- onChange,
11
- readOnly,
12
- initialValue
13
- }, {
14
- isCurrentlyControlled,
15
- isControlled
16
- }, hookName) => {
8
+ const validateProps = (_ref, _ref2, hookName) => {
9
+ let {
10
+ value,
11
+ onChange,
12
+ readOnly,
13
+ initialValue
14
+ } = _ref;
15
+ let {
16
+ isCurrentlyControlled,
17
+ isControlled
18
+ } = _ref2;
17
19
  const s = pluralHooks.includes(hookName) ? 's' : '';
18
20
 
19
21
  const usageError = error => {
20
22
  // Errors inside hooks in React Native get incomplete stack traces pointing at parent component only.
21
23
  // Help devs out by telling them exactly which hook threw the error as well as why.
22
- throw new Error(`${hookName} ${error}.
23
-
24
- Consumers of this hook must be one of:
25
- 1. An "uncontrolled" component responding directly to user actions, with an optional \`initialValue${s}\` but no \`value${s}\` prop,
26
- 2. A "controlled" component where an always-defined \`value${s}\` prop is managed by an \`onChange\` handler, with no \`initialValue${s}\`,
27
- 3. A "read-only" component, with \`readOnly\` prop set as \`true\`.
28
- `);
24
+ throw new Error("".concat(hookName, " ").concat(error, ".\n\nConsumers of this hook must be one of:\n1. An \"uncontrolled\" component responding directly to user actions, with an optional `initialValue").concat(s, "` but no `value").concat(s, "` prop,\n2. A \"controlled\" component where an always-defined `value").concat(s, "` prop is managed by an `onChange` handler, with no `initialValue").concat(s, "`,\n3. A \"read-only\" component, with `readOnly` prop set as `true`.\n"));
29
25
  };
30
26
 
31
27
  if (value && !onChange && !readOnly) {
32
- usageError(`has \`value${s}\` prop without \`onChange\` or \`readOnly\``);
28
+ usageError("has `value".concat(s, "` prop without `onChange` or `readOnly`"));
33
29
  }
34
30
 
35
31
  if (initialValue && value) {
36
- usageError(`has both \`initialValue${s}\` and \`value${s}\``);
32
+ usageError("has both `initialValue".concat(s, "` and `value").concat(s, "`"));
37
33
  }
38
34
 
39
35
  if (isControlled && !isCurrentlyControlled) {
40
- usageError(`stopped receiving \`value${s}\` from parent after delegating state management`);
36
+ usageError("stopped receiving `value".concat(s, "` from parent after delegating state management"));
41
37
  }
42
38
 
43
39
  if (!isControlled && isCurrentlyControlled) {
44
- usageError(`started receiving \`value${s}\` from parent after starting managing own state`);
40
+ usageError("started receiving `value".concat(s, "` from parent after starting managing own state"));
45
41
  }
46
42
  };
47
43
  /**
@@ -69,7 +65,9 @@ Consumers of this hook must be one of:
69
65
  */
70
66
 
71
67
 
72
- export const useInputValue = (props = {}, hookName = 'useInputValue') => {
68
+ export const useInputValue = function () {
69
+ let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
70
+ let hookName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'useInputValue';
73
71
  const isCurrentlyControlled = props.value !== undefined;
74
72
  const [isControlled] = useState(isCurrentlyControlled);
75
73
  validateProps(props, {
@@ -133,13 +131,14 @@ export const useInputValue = (props = {}, hookName = 'useInputValue') => {
133
131
  * }}
134
132
  */
135
133
 
136
- export const useMultipleInputValues = ({
137
- values,
138
- initialValues,
139
- maxValues,
140
- onChange,
141
- readOnly
142
- } = {}) => {
134
+ export const useMultipleInputValues = function () {
135
+ let {
136
+ values,
137
+ initialValues,
138
+ maxValues,
139
+ onChange,
140
+ readOnly
141
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
143
142
  const {
144
143
  currentValue,
145
144
  setValue,
@@ -149,7 +148,7 @@ export const useMultipleInputValues = ({
149
148
  onChange,
150
149
  value: values,
151
150
  // if we're controlling our own state, always start with an array
152
- initialValue: initialValues ?? (values === undefined ? [] : undefined)
151
+ initialValue: initialValues !== null && initialValues !== void 0 ? initialValues : values === undefined ? [] : undefined
153
152
  }, 'useMultipleInputValues');
154
153
  const enforceMaxValues = useCallback(newValues => {
155
154
  if (!maxValues) return newValues;
@@ -19,11 +19,12 @@ const shouldUseCursor = ['checkbox', 'radio', 'switch'];
19
19
  * @returns
20
20
  */
21
21
 
22
- export const getCursorStyle = ({
23
- inactive,
24
- disabled,
25
- accessibilityRole
26
- }) => {
22
+ export const getCursorStyle = _ref => {
23
+ let {
24
+ inactive,
25
+ disabled,
26
+ accessibilityRole
27
+ } = _ref;
27
28
  if (Platform.OS !== 'web') return undefined;
28
29
  if (inactive || disabled) return staticStyles.notAllowed;
29
30
  if (shouldUseCursor.includes(accessibilityRole)) return staticStyles.pointer;
@@ -44,15 +45,19 @@ export const getCursorStyle = ({
44
45
  * @returns {object}
45
46
  */
46
47
 
47
- export const resolvePressableState = ({
48
- pressed = false,
49
- focused = false,
50
- hovered = false
51
- } = {}, additionalState) => ({ ...additionalState,
52
- focus: focused,
53
- hover: hovered,
54
- pressed
55
- });
48
+ export const resolvePressableState = function () {
49
+ let {
50
+ pressed = false,
51
+ focused = false,
52
+ hovered = false
53
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
54
+ let additionalState = arguments.length > 1 ? arguments[1] : undefined;
55
+ return { ...additionalState,
56
+ focus: focused,
57
+ hover: hovered,
58
+ pressed
59
+ };
60
+ };
56
61
  /**
57
62
  * Takes a UDS `tokens` prop and, if it is a function, resolves it based on a state
58
63
  * object passed from the React Native `Pressable` component and optional extra properties.
@@ -85,13 +90,22 @@ const staticStyles = StyleSheet.create(Platform.select({
85
90
  * to pass in press handlers that are then called with state or values that is otherwise internal.
86
91
  */
87
92
 
88
- export const getPressHandlersWithArgs = (pressableProps = {}, args = []) => {
93
+ export const getPressHandlersWithArgs = function () {
94
+ let pressableProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
95
+ let args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
89
96
  // Allow handlers to be passed down for blur, hover, focus, pressIn, etc
90
- const pressHandlers = Object.fromEntries(Object.entries(pressProps.selectHandlers(pressableProps)).map(([key, handler]) => ({
91
- [key]: (...defaultArgs) => {
92
- // Pass each handler data on this button and current selection
93
- handler(...args, ...defaultArgs);
94
- }
95
- })));
97
+ const pressHandlers = Object.fromEntries(Object.entries(pressProps.selectHandlers(pressableProps)).map(_ref2 => {
98
+ let [key, handler] = _ref2;
99
+ return {
100
+ [key]: function () {
101
+ for (var _len = arguments.length, defaultArgs = new Array(_len), _key = 0; _key < _len; _key++) {
102
+ defaultArgs[_key] = arguments[_key];
103
+ }
104
+
105
+ // Pass each handler data on this button and current selection
106
+ handler(...args, ...defaultArgs);
107
+ }
108
+ };
109
+ }));
96
110
  return pressHandlers;
97
111
  };
@@ -18,7 +18,8 @@ export default {
18
18
  * web-oriented tooling that injects web-oriented event handlers directly. For example, for
19
19
  * to support use with NextJS's 'next/link' component, which injects `onClick` prop into its child.
20
20
  */
21
- toPressProps: props => Object.fromEntries(Object.entries(props).map(([originalName, value]) => {
21
+ toPressProps: props => Object.fromEntries(Object.entries(props).map(_ref => {
22
+ let [originalName, value] = _ref;
22
23
  const translatedName = clickHandlerMapping[originalName];
23
24
  return translatedName ? [translatedName, value] : [originalName, value];
24
25
  }))
@@ -26,8 +26,8 @@ export default function componentPropType(passedName) {
26
26
  const nameInProp = ((_props$propName$type = props[propName].type) === null || _props$propName$type === void 0 ? void 0 : _props$propName$type.displayName) || ((_props$propName$type2 = props[propName].type) === null || _props$propName$type2 === void 0 ? void 0 : _props$propName$type2.name);
27
27
 
28
28
  if (!nameInProp || !passedNames.includes(nameInProp)) {
29
- const propDescription = nameInProp ? `Component ${nameInProp}` : typeof props[propName];
30
- return new Error(`${componentName}: ${propDescription} was passed to \`${propName}\` prop; should be ${passedNames.join(' or ')}`);
29
+ const propDescription = nameInProp ? "Component ".concat(nameInProp) : typeof props[propName];
30
+ return new Error("".concat(componentName, ": ").concat(propDescription, " was passed to `").concat(propName, "` prop; should be ").concat(passedNames.join(' or ')));
31
31
  }
32
32
 
33
33
  return undefined;
@@ -35,7 +35,7 @@ export default function componentPropType(passedName) {
35
35
 
36
36
  const checkRequired = (props, propName, componentName) => {
37
37
  if (props[propName] === undefined) {
38
- return new Error(`The prop \`${propName}\` is marked as required in \`${componentName}\`, but its value is ${props[propName]}.`);
38
+ return new Error("The prop `".concat(propName, "` is marked as required in `").concat(componentName, "`, but its value is ").concat(props[propName], "."));
39
39
  }
40
40
 
41
41
  return undefined;
@@ -1,6 +1,9 @@
1
1
  export default function getPropSelector(propTypes, regexp) {
2
2
  const keys = Object.keys(propTypes);
3
- return props => Object.entries(props).reduce((items, [key, value]) => keys.includes(key) || regexp && regexp.test(key) ? { ...items,
4
- [key]: value
5
- } : items, {});
3
+ return props => Object.entries(props).reduce((items, _ref) => {
4
+ let [key, value] = _ref;
5
+ return keys.includes(key) || regexp && regexp.test(key) ? { ...items,
6
+ [key]: value
7
+ } : items;
8
+ }, {});
6
9
  }
@@ -11,13 +11,16 @@ export const focusHandlerProps = {
11
11
  */
12
12
  onFocus: PropTypes.func
13
13
  },
14
- select: ({
15
- onBlur,
16
- onFocus
17
- }) => ({
18
- onBlur,
19
- onFocus
20
- })
14
+ select: _ref => {
15
+ let {
16
+ onBlur,
17
+ onFocus
18
+ } = _ref;
19
+ return {
20
+ onBlur,
21
+ onFocus
22
+ };
23
+ }
21
24
  };
22
25
  export const textInputHandlerProps = {
23
26
  types: {
@@ -41,17 +44,20 @@ export const textInputHandlerProps = {
41
44
  */
42
45
  onSubmitEditing: PropTypes.func
43
46
  },
44
- select: ({
45
- onChange,
46
- onChangeText,
47
- onSubmit,
48
- onSubmitEditing
49
- }) => ({
50
- onChange,
51
- onChangeText,
52
- onSubmit,
53
- onSubmitEditing
54
- })
47
+ select: _ref2 => {
48
+ let {
49
+ onChange,
50
+ onChangeText,
51
+ onSubmit,
52
+ onSubmitEditing
53
+ } = _ref2;
54
+ return {
55
+ onChange,
56
+ onChangeText,
57
+ onSubmit,
58
+ onSubmitEditing
59
+ };
60
+ }
55
61
  };
56
62
  export default {
57
63
  focusHandlerProps,
@@ -14,17 +14,20 @@ export default {
14
14
  * Takes a props object, bundles any hrefAttrs props present into one object
15
15
  * and returns that keyed as `hrefAttrs` and non-hrefAttrs props keyed as `rest`
16
16
  */
17
- bundle: ({
18
- download,
19
- rel,
20
- target,
21
- ...rest
22
- }) => ({
23
- hrefAttrs: {
17
+ bundle: _ref => {
18
+ let {
24
19
  download,
25
20
  rel,
26
- target
27
- },
28
- rest
29
- })
21
+ target,
22
+ ...rest
23
+ } = _ref;
24
+ return {
25
+ hrefAttrs: {
26
+ download,
27
+ rel,
28
+ target
29
+ },
30
+ rest
31
+ };
32
+ }
30
33
  };
@@ -37,16 +37,8 @@ export default {
37
37
  */
38
38
  validation: PropTypes.oneOf(['error', 'success'])
39
39
  },
40
- select: ({
41
- copy,
42
- label,
43
- hint,
44
- hintPosition,
45
- feedback,
46
- tooltip,
47
- validation
48
- }) => ({
49
- supportsProps: {
40
+ select: _ref => {
41
+ let {
50
42
  copy,
51
43
  label,
52
44
  hint,
@@ -54,6 +46,17 @@ export default {
54
46
  feedback,
55
47
  tooltip,
56
48
  validation
57
- }
58
- })
49
+ } = _ref;
50
+ return {
51
+ supportsProps: {
52
+ copy,
53
+ label,
54
+ hint,
55
+ hintPosition,
56
+ feedback,
57
+ tooltip,
58
+ validation
59
+ }
60
+ };
61
+ }
59
62
  };
@@ -28,14 +28,15 @@ export default {
28
28
  * @returns {(() => void)|undefined} Returns a press handler, or undefined on web if no press
29
29
  * handler is provided (expects calling component to render as `<a href={href}>` on web).
30
30
  */
31
- handleHref: ({
32
- onPress,
33
- href
34
- }) => {
31
+ handleHref: _ref => {
32
+ let {
33
+ onPress,
34
+ href
35
+ } = _ref;
35
36
  return Platform.select({
36
37
  web: onPress,
37
- default: (...args) => {
38
- if (onPress) onPress(...args);
38
+ default: function () {
39
+ if (onPress) onPress(...arguments);
39
40
  if (href) Linking.openURL(href);
40
41
  }
41
42
  });
@@ -3,7 +3,7 @@
3
3
  export default function selectSystemProps(systemPropHelpers) {
4
4
  const selectProps = props => systemPropHelpers.reduce((acc, propHelper) => {
5
5
  if (typeof (propHelper === null || propHelper === void 0 ? void 0 : propHelper.select) !== 'function') {
6
- throw new Error(`An invalid system prop helper has been passed to 'selectSystemProps': prop selector ('.select') is missing in ${propHelper}`);
6
+ throw new Error("An invalid system prop helper has been passed to 'selectSystemProps': prop selector ('.select') is missing in ".concat(propHelper));
7
7
  }
8
8
 
9
9
  return { ...acc,
@@ -13,7 +13,7 @@ export default function selectSystemProps(systemPropHelpers) {
13
13
 
14
14
  const selectedPropTypes = systemPropHelpers.reduce((acc, propHelper) => {
15
15
  if (!(propHelper !== null && propHelper !== void 0 && propHelper.types)) {
16
- throw new Error(`An invalid system prop helper has been passed to 'selectSystemProps': types selector ('.types') is missing in ${propHelper}`);
16
+ throw new Error("An invalid system prop helper has been passed to 'selectSystemProps': types selector ('.types') is missing in ".concat(propHelper));
17
17
  }
18
18
 
19
19
  return { ...acc,
@@ -9,7 +9,7 @@ export const getTokenNames = componentName => {
9
9
  const componentTokenSchema = tokenKeys[componentName];
10
10
 
11
11
  if (!componentTokenSchema) {
12
- throw new Error(`No "${componentName}" tokenKeys in @telus-uds/system-theme-tokens`);
12
+ throw new Error("No \"".concat(componentName, "\" tokenKeys in @telus-uds/system-theme-tokens"));
13
13
  }
14
14
 
15
15
  return Object.keys(componentTokenSchema);
@@ -47,7 +47,7 @@ export const getTokenNames = componentName => {
47
47
  export const selectTokens = (specifier, tokens, prefix) => {
48
48
  const tokenNames = typeof specifier === 'string' ? getTokenNames(specifier) : specifier;
49
49
  const filteredTokens = tokenNames.reduce((validTokens, key) => {
50
- const prefixedKey = prefix ? `${prefix}${key[0].toUpperCase()}${key.slice(1)}` : key;
50
+ const prefixedKey = prefix ? "".concat(prefix).concat(key[0].toUpperCase()).concat(key.slice(1)) : key;
51
51
  const token = tokens[prefixedKey];
52
52
  return token !== undefined ? { ...validTokens,
53
53
  [key]: token
@@ -84,16 +84,22 @@ export const selectTokens = (specifier, tokens, prefix) => {
84
84
  * }
85
85
  */
86
86
 
87
- export const getTokensPropType = (...componentsNames) => (props, propName, componentName) => {
88
- PropTypes.checkPropTypes({
89
- [propName]: PropTypes.oneOfType([PropTypes.object, PropTypes.func])
90
- }, props, propName, componentName);
87
+ export const getTokensPropType = function () {
88
+ for (var _len = arguments.length, componentsNames = new Array(_len), _key = 0; _key < _len; _key++) {
89
+ componentsNames[_key] = arguments[_key];
90
+ }
91
91
 
92
- if (typeof props[propName] !== 'function') {
92
+ return (props, propName, componentName) => {
93
93
  PropTypes.checkPropTypes({
94
- [propName]: PropTypes.exact(Object.fromEntries(componentsNames.flatMap(component => getTokenNames(component).map(key => [key, tokenValueType]))))
94
+ [propName]: PropTypes.oneOfType([PropTypes.object, PropTypes.func])
95
95
  }, props, propName, componentName);
96
- }
96
+
97
+ if (typeof props[propName] !== 'function') {
98
+ PropTypes.checkPropTypes({
99
+ [propName]: PropTypes.exact(Object.fromEntries(componentsNames.flatMap(component => getTokenNames(component).map(key => [key, tokenValueType]))))
100
+ }, props, propName, componentName);
101
+ }
102
+ };
97
103
  };
98
104
  /**
99
105
  * Get a proptypes validator for a set of tokens that is not based on a component in the theme schema.
@@ -110,11 +116,18 @@ export const getTokensPropType = (...componentsNames) => (props, propName, compo
110
116
  * @returns
111
117
  */
112
118
 
113
- export const getTokensSetPropType = (componentTokenKeys, {
114
- partial = false,
115
- allowFunction = false
116
- } = {}) => {
119
+ export const getTokensSetPropType = function (componentTokenKeys) {
120
+ let {
121
+ partial = false,
122
+ allowFunction = false
123
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
117
124
  const tokensObjectValidator = PropTypes.exact(Object.fromEntries(componentTokenKeys.map(key => [key, partial ? tokenValueType : // Some theme tokens can validly resolve to `null`, but .isRequired treats null as undefined
118
- (props, propName, ...args) => props[propName] !== null && tokenValueType.isRequired(props, propName, ...args)])));
125
+ function (props, propName) {
126
+ for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
127
+ args[_key2 - 2] = arguments[_key2];
128
+ }
129
+
130
+ return props[propName] !== null && tokenValueType.isRequired(props, propName, ...args);
131
+ }])));
119
132
  return allowFunction ? PropTypes.oneOfType([tokensObjectValidator, PropTypes.func]) : tokensObjectValidator;
120
133
  };
@@ -12,7 +12,8 @@ import AppRegistry from "react-native-web/dist/exports/AppRegistry";
12
12
  * @returns {ReactElement[]}
13
13
  */
14
14
 
15
- export const getReactNativeWebSSRStyles = (AppRoot, appName = 'app') => {
15
+ export const getReactNativeWebSSRStyles = function (AppRoot) {
16
+ let appName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'app';
16
17
  AppRegistry.registerComponent(appName, () => AppRoot);
17
18
  const {
18
19
  getStyleElement
@@ -29,7 +30,9 @@ export const getReactNativeWebSSRStyles = (AppRoot, appName = 'app') => {
29
30
  * @returns {ReactElement[]}
30
31
  */
31
32
 
32
- export const getSSRStyles = (AppRoot, appName = 'app', existingStyles = []) => {
33
+ export const getSSRStyles = function (AppRoot) {
34
+ let appName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'app';
35
+ let existingStyles = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
33
36
  return [...existingStyles, ...getReactNativeWebSSRStyles(AppRoot, appName) // if any other CSS-in-JS is added e.g. styled-components generate and add its styles here
34
37
  ];
35
38
  };
@@ -27,10 +27,12 @@ export const DEFAULT_COPY = 'en';
27
27
  * @return {function(string): string}
28
28
  */
29
29
 
30
- function useCopy({
31
- dictionary,
32
- copy = DEFAULT_COPY
33
- }) {
30
+ function useCopy(_ref) {
31
+ let {
32
+ dictionary,
33
+ copy = DEFAULT_COPY
34
+ } = _ref;
35
+
34
36
  if (typeof copy === 'string') {
35
37
  return key => key ? dictionary[copy][key] : dictionary[copy];
36
38
  } // support overriding the entire copy dictionary with an object for a single language
@@ -22,7 +22,8 @@ const doAction = (action, event) => {
22
22
  */
23
23
 
24
24
 
25
- const useHash = (action, isReady = true) => {
25
+ const useHash = function (action) {
26
+ let isReady = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
26
27
  const [isDone, setIsDone] = useState(false); // Do the action just once when ready after component mount, from hash on page load
27
28
 
28
29
  const isToDo = isReady && !isDone;
@@ -101,6 +101,8 @@ const resolveSpacingOptions = space => {
101
101
 
102
102
 
103
103
  const useSpacingScale = spaceValue => {
104
+ var _spaceValue$space;
105
+
104
106
  // In future, may need to consider window height as well as width, particularly for native apps,
105
107
  // e.g. to ensure designs don't look lost on large, tall, not-so-wide portrait screens.
106
108
  const viewport = useViewport();
@@ -110,7 +112,7 @@ const useSpacingScale = spaceValue => {
110
112
  overridden,
111
113
  subtract = 0
112
114
  } = resolveSpacingOptions(spaceValue);
113
- const space = !overridden && ((spaceValue === null || spaceValue === void 0 ? void 0 : spaceValue.space) ?? resolveResponsiveProp(spaceValue, viewport, 0));
115
+ const space = !overridden && ((_spaceValue$space = spaceValue === null || spaceValue === void 0 ? void 0 : spaceValue.space) !== null && _spaceValue$space !== void 0 ? _spaceValue$space : resolveResponsiveProp(spaceValue, viewport, 0));
114
116
  const {
115
117
  size
116
118
  } = useThemeTokens('spacingScale', tokens, variant, {
@@ -1,10 +1,11 @@
1
1
  import { useState } from 'react';
2
2
  let id = 0;
3
3
 
4
- function useUniqueId(prefix = '') {
4
+ function useUniqueId() {
5
+ let prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
5
6
  const [uniqueId] = useState(() => {
6
7
  id += 1;
7
- return `${prefix}-${id}`;
8
+ return "".concat(prefix, "-").concat(id);
8
9
  });
9
10
  return uniqueId;
10
11
  }
@@ -35,11 +35,12 @@ const hasOwnProperty = (object, prop) => Object.prototype.hasOwnProperty.call(ob
35
35
 
36
36
 
37
37
  const withLinkRouter = Component => {
38
- const wrappedComponent = /*#__PURE__*/forwardRef(({
39
- LinkRouter,
40
- linkRouterProps,
41
- ...props
42
- }, ref) => {
38
+ const wrappedComponent = /*#__PURE__*/forwardRef((_ref, ref) => {
39
+ let {
40
+ LinkRouter,
41
+ linkRouterProps,
42
+ ...props
43
+ } = _ref;
43
44
  if (!LinkRouter) return /*#__PURE__*/_jsx(Component, { ...props,
44
45
  ref: ref
45
46
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telus-uds/components-base",
3
- "version": "1.8.1",
3
+ "version": "1.8.4",
4
4
  "description": "Base components",
5
5
  "keywords": [
6
6
  "base"
@@ -22,16 +22,17 @@
22
22
  },
23
23
  "scripts": {
24
24
  "test": "jest",
25
- "lint": "yarn --cwd ../.. lint:path --color packages/components-base",
26
- "lint:fix": "yarn --cwd ../.. lint:path --fix packages/components-base",
25
+ "lint": "npm run --prefix ../.. lint:path -- --color packages/components-base",
26
+ "lint:fix": "npm run --prefix ../.. lint:path -- --fix packages/components-base",
27
27
  "format": "prettier --write .",
28
- "build": "yarn build:code && yarn build:docs",
28
+ "build": "npm run build:code && npm run build:docs",
29
29
  "build:main": "babel src -d lib",
30
30
  "build:module": "babel src -d lib-module --env-name module",
31
- "build:code": "yarn build:main && yarn build:module",
31
+ "build:code": "npm run build:main && npm run build:module",
32
32
  "build:docs": "babel-node --plugins=@nearform/babel-plugin-react-docgen generate-component-docs.js",
33
33
  "storybook": "start-storybook",
34
- "dev": "yarn build:code --watch"
34
+ "build-storybook": "build-storybook",
35
+ "dev": "npm run build:code --watch"
35
36
  },
36
37
  "bugs": {
37
38
  "url": "https://github.com/telus/universal-design-system/issues"
@@ -44,7 +45,7 @@
44
45
  ],
45
46
  "peerDependencies": {
46
47
  "react": "^17.0.2",
47
- "react-dom": "*",
48
+ "react-dom": "^17.0.2",
48
49
  "react-native": "*",
49
50
  "react-native-web": "^0.17.0"
50
51
  },
@@ -55,16 +56,17 @@
55
56
  "@storybook/react": "^6.5.6",
56
57
  "@storybook/builder-webpack5": "^6.5.6",
57
58
  "@storybook/manager-webpack5": "^6.5.6",
58
- "@telus-uds/browserslist-config": "^1.0.2",
59
+ "@telus-uds/browserslist-config": "^1.0.4",
59
60
  "@testing-library/jest-native": "^4.0.1",
60
61
  "@testing-library/react-hooks": "^7.0.1",
61
62
  "@testing-library/react-native": "^7.2.0",
62
- "react-test-renderer": "^16.3.2"
63
+ "react-test-renderer": "^16.3.2",
64
+ "webpack": "5.x"
63
65
  },
64
66
  "dependencies": {
65
67
  "airbnb-prop-types": "^2.16.0",
66
- "@telus-uds/system-constants": "^1.0.3",
67
- "@telus-uds/system-theme-tokens": "^2.0.1",
68
+ "@telus-uds/system-constants": "^1.0.4",
69
+ "@telus-uds/system-theme-tokens": "^2.0.2",
68
70
  "lodash.debounce": "^4.0.8",
69
71
  "lodash.merge": "^4.6.2",
70
72
  "prop-types": "^15.7.2",