@telus-uds/components-base 1.8.5 → 1.11.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 (69) hide show
  1. package/CHANGELOG.md +47 -2
  2. package/component-docs.json +666 -27
  3. package/lib/Card/Card.js +9 -4
  4. package/lib/Carousel/Carousel.js +672 -0
  5. package/lib/Carousel/CarouselContext.js +59 -0
  6. package/lib/Carousel/CarouselItem/CarouselItem.js +92 -0
  7. package/lib/Carousel/CarouselItem/index.js +13 -0
  8. package/lib/Carousel/dictionary.js +23 -0
  9. package/lib/Carousel/index.js +32 -0
  10. package/lib/ExpandCollapse/Panel.js +10 -1
  11. package/lib/InputSupports/InputSupports.js +10 -3
  12. package/lib/InputSupports/useInputSupports.js +3 -2
  13. package/lib/Modal/Modal.js +4 -0
  14. package/lib/Skeleton/Skeleton.js +1 -0
  15. package/lib/StepTracker/StepTracker.js +15 -12
  16. package/lib/TextInput/TextInput.js +3 -12
  17. package/lib/TextInput/TextInputBase.js +9 -0
  18. package/lib/TextInput/propTypes.js +3 -8
  19. package/lib/index.js +23 -0
  20. package/lib/utils/props/clickProps.js +2 -2
  21. package/lib/utils/props/handlerProps.js +77 -31
  22. package/lib/utils/props/textInputProps.js +8 -1
  23. package/lib/utils/useScrollBlocking.js +66 -0
  24. package/lib/utils/useScrollBlocking.native.js +11 -0
  25. package/lib-module/Card/Card.js +5 -4
  26. package/lib-module/Carousel/Carousel.js +617 -0
  27. package/lib-module/Carousel/CarouselContext.js +43 -0
  28. package/lib-module/Carousel/CarouselItem/CarouselItem.js +75 -0
  29. package/lib-module/Carousel/CarouselItem/index.js +2 -0
  30. package/lib-module/Carousel/dictionary.js +16 -0
  31. package/lib-module/Carousel/index.js +2 -0
  32. package/lib-module/ExpandCollapse/Panel.js +9 -1
  33. package/lib-module/InputSupports/InputSupports.js +10 -3
  34. package/lib-module/InputSupports/useInputSupports.js +3 -2
  35. package/lib-module/Modal/Modal.js +3 -0
  36. package/lib-module/Skeleton/Skeleton.js +1 -0
  37. package/lib-module/StepTracker/StepTracker.js +14 -12
  38. package/lib-module/TextInput/TextInput.js +3 -9
  39. package/lib-module/TextInput/TextInputBase.js +10 -1
  40. package/lib-module/TextInput/propTypes.js +4 -8
  41. package/lib-module/index.js +2 -0
  42. package/lib-module/utils/props/clickProps.js +2 -2
  43. package/lib-module/utils/props/handlerProps.js +78 -31
  44. package/lib-module/utils/props/textInputProps.js +8 -1
  45. package/lib-module/utils/useScrollBlocking.js +58 -0
  46. package/lib-module/utils/useScrollBlocking.native.js +2 -0
  47. package/package.json +3 -3
  48. package/src/Card/Card.jsx +6 -4
  49. package/src/Carousel/Carousel.jsx +649 -0
  50. package/src/Carousel/CarouselContext.jsx +30 -0
  51. package/src/Carousel/CarouselItem/CarouselItem.jsx +66 -0
  52. package/src/Carousel/CarouselItem/index.js +3 -0
  53. package/src/Carousel/dictionary.js +16 -0
  54. package/src/Carousel/index.js +2 -0
  55. package/src/ExpandCollapse/Panel.jsx +8 -1
  56. package/src/InputSupports/InputSupports.jsx +18 -3
  57. package/src/InputSupports/useInputSupports.js +2 -2
  58. package/src/Modal/Modal.jsx +3 -1
  59. package/src/Skeleton/Skeleton.jsx +1 -0
  60. package/src/StepTracker/StepTracker.jsx +21 -8
  61. package/src/TextInput/TextInput.jsx +2 -9
  62. package/src/TextInput/TextInputBase.jsx +11 -1
  63. package/src/TextInput/propTypes.js +3 -7
  64. package/src/index.js +2 -0
  65. package/src/utils/props/clickProps.js +2 -2
  66. package/src/utils/props/handlerProps.js +64 -16
  67. package/src/utils/props/textInputProps.js +7 -1
  68. package/src/utils/useScrollBlocking.js +57 -0
  69. package/src/utils/useScrollBlocking.native.js +2 -0
@@ -147,7 +147,14 @@ const crossPlatform = { ...textProps,
147
147
  const webOnly = {
148
148
  disabled: _propTypes.default.bool,
149
149
  dir: _propTypes.default.oneOf(['auto', 'ltr', 'rtl']),
150
- lang: _propTypes.default.string
150
+ lang: _propTypes.default.string,
151
+
152
+ /**
153
+ * Sets the HTML input `pattern` attr. Not supported by React Native Web, but is supported by UDS.
154
+ * Must also pass in a ref and check validity by calling the HTML element's checkValidity method:
155
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/checkValidity
156
+ */
157
+ pattern: _propTypes.default.string
151
158
  };
152
159
  /**
153
160
  * These props are supported in React Native but not React Native Web.
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = require("react");
9
+
10
+ const addScrollBlocking = (preventScrolling, stopPropagation, ref) => {
11
+ var _ref$current;
12
+
13
+ document.body.addEventListener('touchmove', preventScrolling, {
14
+ passive: false
15
+ });
16
+ (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.addEventListener('touchmove', stopPropagation);
17
+ document.body.style.overflow = 'hidden';
18
+ };
19
+
20
+ const removeScrollBlocking = (preventScrolling, stopPropagation, ref) => {
21
+ var _ref$current2;
22
+
23
+ document.body.removeEventListener('touchmove', preventScrolling);
24
+ (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.removeEventListener('touchmove', stopPropagation);
25
+ document.body.style.overflow = 'inherit';
26
+ };
27
+ /**
28
+ * Disables scrolling when passed `true` or an array where all items are `true`.
29
+ *
30
+ * Returns an optional callback ref. Pass this to an element if it or its children
31
+ * should allow touch-based scrolling within that element's bounds.
32
+ *
33
+ * @param {boolean | boolean[]} conditionProps
34
+ * @returns
35
+ */
36
+
37
+
38
+ const useScrollBlocking = conditionProps => {
39
+ // useRef refs are null on first render and don't trigger a re-render when they get their
40
+ // element. Force re-run when ref mounts to ensure the stopPropagation listener is attached.
41
+ const ref = (0, _react.useRef)();
42
+ const [refIsMounted, setRefIsMounted] = (0, _react.useState)(false);
43
+ const callbackRef = (0, _react.useCallback)(element => {
44
+ ref.current = element;
45
+ setRefIsMounted(Boolean(element));
46
+ }, []);
47
+ const conditionsMet = Array.isArray(conditionProps) ? conditionProps.every(condition => condition) : Boolean(conditionProps);
48
+ const preventScrolling = (0, _react.useCallback)(event => event.preventDefault(), []);
49
+ const stopPropagation = (0, _react.useCallback)(event => event.stopPropagation(), []);
50
+ (0, _react.useEffect)(() => {
51
+ const cleanup = () => removeScrollBlocking(preventScrolling, stopPropagation, ref);
52
+
53
+ if (conditionsMet) {
54
+ addScrollBlocking(preventScrolling, stopPropagation, ref);
55
+ } else {
56
+ cleanup();
57
+ }
58
+
59
+ return cleanup; // preventScrolling and stopPropagation are stable callbacks with no deps, so this
60
+ // will re-run when conditionsMet or refIsMounted flip between true and false.
61
+ }, [preventScrolling, conditionsMet, stopPropagation, refIsMounted]);
62
+ return callbackRef;
63
+ };
64
+
65
+ var _default = useScrollBlocking;
66
+ exports.default = _default;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ // This is a no-op to emphasize that the original hook is web-only
9
+ var _default = () => {};
10
+
11
+ exports.default = _default;
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { forwardRef } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { useThemeTokens } from '../ThemeProvider';
4
4
  import { getTokensPropType, variantProp } from '../utils';
@@ -56,7 +56,7 @@ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, vie
56
56
  * depending on what you are trying to achieve.
57
57
  */
58
58
 
59
- const Card = _ref => {
59
+ const Card = /*#__PURE__*/forwardRef((_ref, ref) => {
60
60
  let {
61
61
  children,
62
62
  tokens,
@@ -69,13 +69,14 @@ const Card = _ref => {
69
69
  viewport
70
70
  });
71
71
  return /*#__PURE__*/_jsx(CardBase, {
72
+ ref: ref,
72
73
  tokens: themeTokens,
73
74
  dataSet: dataSet,
74
75
  ...selectProps(rest),
75
76
  children: children
76
77
  });
77
- };
78
-
78
+ });
79
+ Card.displayName = 'Card';
79
80
  Card.propTypes = { ...selectedSystemPropTypes,
80
81
  children: PropTypes.node,
81
82
  tokens: getTokensPropType('Card'),