@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
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.CarouselProvider = void 0;
7
+ exports.useCarousel = useCarousel;
8
+
9
+ var _react = _interopRequireDefault(require("react"));
10
+
11
+ var _propTypes = _interopRequireDefault(require("prop-types"));
12
+
13
+ var _jsxRuntime = require("react/jsx-runtime");
14
+
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
+
17
+ const CarouselContext = /*#__PURE__*/_react.default.createContext();
18
+
19
+ const CarouselProvider = _ref => {
20
+ let {
21
+ children,
22
+ activeIndex,
23
+ totalItems,
24
+ width,
25
+ goTo
26
+ } = _ref;
27
+
28
+ const value = _react.default.useMemo(() => ({
29
+ activeIndex,
30
+ totalItems,
31
+ width,
32
+ goTo
33
+ }), [activeIndex, totalItems, width, goTo]);
34
+
35
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(CarouselContext.Provider, {
36
+ value: value,
37
+ children: children
38
+ });
39
+ };
40
+
41
+ exports.CarouselProvider = CarouselProvider;
42
+
43
+ function useCarousel() {
44
+ const context = _react.default.useContext(CarouselContext);
45
+
46
+ if (context === undefined) {
47
+ throw new Error("'useCarousel' must be used within a 'CarouselProvider'");
48
+ }
49
+
50
+ return context;
51
+ }
52
+
53
+ CarouselProvider.propTypes = {
54
+ children: _propTypes.default.arrayOf(_propTypes.default.element).isRequired,
55
+ activeIndex: _propTypes.default.number.isRequired,
56
+ totalItems: _propTypes.default.number.isRequired,
57
+ width: _propTypes.default.number.isRequired,
58
+ goTo: _propTypes.default.func.isRequired
59
+ };
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
13
+
14
+ var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
15
+
16
+ var _utils = require("../../utils");
17
+
18
+ var _CarouselContext = require("../CarouselContext");
19
+
20
+ var _jsxRuntime = require("react/jsx-runtime");
21
+
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
+
24
+ const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
25
+ /**
26
+ * `Carousel.Item` is used to wrap the content of an individual slide and is suppsoed to be the
27
+ * only top-level component passed to the `Carousel`
28
+ */
29
+
30
+ const CarouselItem = _ref => {
31
+ let {
32
+ children,
33
+ elementIndex,
34
+ tag = 'li',
35
+ hidden,
36
+ ...rest
37
+ } = _ref;
38
+ const {
39
+ width,
40
+ activeIndex
41
+ } = (0, _CarouselContext.useCarousel)();
42
+ const selectedProps = selectProps({ ...rest,
43
+ ...(0, _utils.getA11yPropsFromHtmlTag)(tag, rest.accessibilityRole)
44
+ });
45
+ const focusabilityProps = activeIndex === elementIndex ? {} : _utils.a11yProps.nonFocusableProps;
46
+ const style = {
47
+ width
48
+ };
49
+
50
+ if (hidden && _Platform.default.OS === 'web') {
51
+ // On web, visibility: hidden makes all children non-focusable. It doesn't exist on native.
52
+ style.visibility = 'hidden';
53
+ }
54
+
55
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
56
+ style: style,
57
+ ...selectedProps,
58
+ ...focusabilityProps,
59
+ children: children
60
+ });
61
+ };
62
+
63
+ CarouselItem.propTypes = { ...selectedSystemPropTypes,
64
+
65
+ /**
66
+ * Index of the current slide
67
+ * Don't pass this prop when using `Carousel.Item` as it is already being passed by `Carousel` top-level component
68
+ */
69
+ elementIndex: _propTypes.default.number,
70
+
71
+ /**
72
+ * Provide custom accessibilityLabelledBy for Carousel slide
73
+ */
74
+ accessibilityLabelledBy: _propTypes.default.string,
75
+
76
+ /**
77
+ * Content of the slide
78
+ */
79
+ children: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.node), _propTypes.default.node]).isRequired,
80
+
81
+ /**
82
+ * Sets the HTML tag of the outer container. By default `'li'` so that assistive technology sees
83
+ * the Carousel as a list of items.
84
+ *
85
+ * Carousel's innermost container defaults to `'ul'` which can be overridden. If the tag of either
86
+ * `Carousel` or `Carousel.Item` is overriden, the other should be too, to avoid producing invalid HTML.
87
+ */
88
+ tag: _propTypes.default.oneOf(_utils.layoutTags)
89
+ };
90
+ CarouselItem.displayName = 'Carousel.Item';
91
+ var _default = CarouselItem;
92
+ exports.default = _default;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _CarouselItem = _interopRequireDefault(require("./CarouselItem"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ var _default = _CarouselItem.default;
13
+ exports.default = _default;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ // 'stepLabel' and 'stepTrackerLabel' are passed down to StepTracker
8
+ var _default = {
9
+ en: {
10
+ carouselLabel: '%{stepCount} items',
11
+ iconButtonLabel: 'Show %{itemLabel} %{targetStep} of %{stepCount}',
12
+ stepLabel: '%{itemLabel} %{stepNumber}',
13
+ stepTrackerLabel: '%{itemLabel} %{stepNumber} of %{stepCount}'
14
+ },
15
+ fr: {
16
+ // TODO: French translations here
17
+ carouselLabel: '(fr) %{stepCount} items',
18
+ iconButtonLabel: '(fr) Show %{itemLabel} %{targetStep} of %{stepCount}',
19
+ stepLabel: '(fr) %{itemLabel} %{stepNumber}',
20
+ stepTrackerLabel: '(fr) %{itemLabel} %{stepNumber} of %{stepCount}'
21
+ }
22
+ };
23
+ exports.default = _default;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {
7
+ Carousel: true
8
+ };
9
+ Object.defineProperty(exports, "Carousel", {
10
+ enumerable: true,
11
+ get: function () {
12
+ return _Carousel.default;
13
+ }
14
+ });
15
+
16
+ var _CarouselContext = require("./CarouselContext");
17
+
18
+ Object.keys(_CarouselContext).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
21
+ if (key in exports && exports[key] === _CarouselContext[key]) return;
22
+ Object.defineProperty(exports, key, {
23
+ enumerable: true,
24
+ get: function () {
25
+ return _CarouselContext[key];
26
+ }
27
+ });
28
+ });
29
+
30
+ var _Carousel = _interopRequireDefault(require("./Carousel"));
31
+
32
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -15,6 +15,8 @@ var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Vi
15
15
 
16
16
  var _propTypes = _interopRequireDefault(require("prop-types"));
17
17
 
18
+ var _airbnbPropTypes = _interopRequireDefault(require("airbnb-prop-types"));
19
+
18
20
  var _Control = _interopRequireDefault(require("./Control"));
19
21
 
20
22
  var _ThemeProvider = require("../ThemeProvider");
@@ -70,6 +72,7 @@ const ExpandCollapsePanel = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) =>
70
72
  children,
71
73
  tokens,
72
74
  variant,
75
+ controlRef,
73
76
  ...rest
74
77
  } = _ref2;
75
78
  const [containerHeight, setContainerHeight] = (0, _react.useState)(null);
@@ -112,6 +115,7 @@ const ExpandCollapsePanel = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) =>
112
115
  isExpanded: isExpanded,
113
116
  tokens: controlTokens,
114
117
  onPress: handleControlPress,
118
+ ref: controlRef,
115
119
  children: control
116
120
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Animated.default.View, {
117
121
  ref: animatedRef,
@@ -167,7 +171,12 @@ ExpandCollapsePanel.propTypes = { ...selectedSystemPropTypes,
167
171
  /**
168
172
  * Optional theme token overrides that may be passed to the ExpandCollapseControl element.
169
173
  */
170
- controlTokens: (0, _utils.getTokensPropType)('ExpandCollapseControl')
174
+ controlTokens: (0, _utils.getTokensPropType)('ExpandCollapseControl'),
175
+
176
+ /**
177
+ * An optional ref to be attached to the control
178
+ */
179
+ controlRef: _airbnbPropTypes.default.ref()
171
180
  };
172
181
  var _default = ExpandCollapsePanel;
173
182
  exports.default = _default;
@@ -36,7 +36,8 @@ const InputSupports = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
36
36
  hintPosition = 'inline',
37
37
  feedback,
38
38
  tooltip,
39
- validation
39
+ validation,
40
+ nativeID
40
41
  } = _ref;
41
42
  const {
42
43
  space
@@ -50,7 +51,8 @@ const InputSupports = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
50
51
  feedback,
51
52
  hint,
52
53
  label,
53
- validation
54
+ validation,
55
+ nativeID
54
56
  });
55
57
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_StackView.default, {
56
58
  space: space,
@@ -111,7 +113,12 @@ InputSupports.propTypes = {
111
113
  /**
112
114
  * Use to visually mark an input as valid or invalid.
113
115
  */
114
- validation: _propTypes.default.oneOf(['error', 'success'])
116
+ validation: _propTypes.default.oneOf(['error', 'success']),
117
+
118
+ /**
119
+ * ID for DOM element on web
120
+ */
121
+ nativeID: _propTypes.default.string
115
122
  };
116
123
  var _default = InputSupports;
117
124
  exports.default = _default;
@@ -16,7 +16,8 @@ const useInputSupports = _ref => {
16
16
  label,
17
17
  feedback,
18
18
  validation,
19
- hint
19
+ hint,
20
+ nativeID
20
21
  } = _ref;
21
22
  const hasValidationError = validation === 'error';
22
23
  const inputId = (0, _useUniqueId.default)('input');
@@ -31,7 +32,7 @@ const useInputSupports = _ref => {
31
32
  accessibilityInvalid: hasValidationError
32
33
  };
33
34
  return {
34
- inputId,
35
+ inputId: nativeID || inputId,
35
36
  hintId,
36
37
  feedbackId,
37
38
  a11yProps
@@ -29,6 +29,8 @@ var _IconButton = _interopRequireDefault(require("../IconButton"));
29
29
 
30
30
  var _dictionary = _interopRequireDefault(require("./dictionary"));
31
31
 
32
+ var _useScrollBlocking = _interopRequireDefault(require("../utils/useScrollBlocking"));
33
+
32
34
  var _jsxRuntime = require("react/jsx-runtime");
33
35
 
34
36
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -135,6 +137,7 @@ const Modal = /*#__PURE__*/(0, _react.forwardRef)((_ref5, ref) => {
135
137
  viewport,
136
138
  maxWidth
137
139
  });
140
+ const modalRef = (0, _useScrollBlocking.default)(isOpen);
138
141
  const {
139
142
  closeIcon: CloseIconComponent
140
143
  } = themeTokens;
@@ -165,6 +168,7 @@ const Modal = /*#__PURE__*/(0, _react.forwardRef)((_ref5, ref) => {
165
168
  ...selectProps(rest),
166
169
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
167
170
  style: [staticStyles.positioningContainer],
171
+ ref: modalRef,
168
172
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
169
173
  style: [staticStyles.sizingContainer, selectContainerStyles(themeTokens)],
170
174
  pointerEvents: "box-none" // don't capture backdrop press events
@@ -42,6 +42,7 @@ const selectSkeletonStyles = _ref => {
42
42
  return {
43
43
  backgroundColor: color,
44
44
  borderRadius: radius,
45
+ maxWidth: '100%',
45
46
  ...fadeAnimation
46
47
  };
47
48
  };
@@ -134,7 +134,10 @@ const StepTracker = /*#__PURE__*/(0, _react.forwardRef)((_ref4, ref) => {
134
134
  dictionary,
135
135
  copy
136
136
  });
137
- const stepTrackerLabel = getCopy('stepTrackerLabel').replace('%{stepNumber}', current < steps.length ? current + 1 : steps.length).replace('%{stepCount}', steps.length).replace('%{stepLabel}', current < steps.length ? steps[current] : steps[steps.length - 1]);
137
+ const stepTrackerLabel = showStepTrackerLabel ? getCopy('stepTrackerLabel').replace('%{stepNumber}', current < steps.length ? current + 1 : steps.length).replace('%{stepCount}', steps.length).replace('%{stepLabel}', current < steps.length ? steps[current] : steps[steps.length - 1]) : '';
138
+
139
+ const getStepLabel = index => themeTokens.showStepLabel ? getCopy('stepLabel').replace('%{stepNumber}', index + 1) : '';
140
+
138
141
  if (!steps.length) return null;
139
142
  const selectedProps = selectProps({
140
143
  accessibilityLabel: stepTrackerLabel,
@@ -160,7 +163,7 @@ const StepTracker = /*#__PURE__*/(0, _react.forwardRef)((_ref4, ref) => {
160
163
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Step.default, {
161
164
  status: current,
162
165
  label: label,
163
- name: getCopy('stepLabel').replace('%{stepNumber}', index + 1),
166
+ name: getStepLabel(index),
164
167
  stepIndex: index,
165
168
  stepCount: steps.length,
166
169
  tokens: themeTokens
@@ -176,19 +179,19 @@ const StepTracker = /*#__PURE__*/(0, _react.forwardRef)((_ref4, ref) => {
176
179
  })
177
180
  });
178
181
  });
179
- StepTracker.displayName = 'StepTracker';
182
+ StepTracker.displayName = 'StepTracker'; // If a language dictionary entry is provided, it must contain every key
183
+
184
+ const dictionaryContentShape = _propTypes.default.shape({
185
+ stepLabel: _propTypes.default.string.isRequired,
186
+ stepTrackerLabel: _propTypes.default.string.isRequired
187
+ });
188
+
180
189
  StepTracker.propTypes = { ...selectedSystemPropTypes,
181
190
  current: _propTypes.default.number,
182
- copy: _propTypes.default.oneOf(['en', 'fr']),
191
+ copy: _propTypes.default.oneOfType([_propTypes.default.oneOf(['en', 'fr']), dictionaryContentShape]),
183
192
  dictionary: _propTypes.default.shape({
184
- en: _propTypes.default.shape({
185
- stepLabel: _propTypes.default.string,
186
- stepTrackerLabel: _propTypes.default.string
187
- }),
188
- fr: _propTypes.default.shape({
189
- stepLabel: _propTypes.default.string,
190
- stepTrackerLabel: _propTypes.default.string
191
- })
193
+ en: dictionaryContentShape,
194
+ fr: dictionaryContentShape
192
195
  }),
193
196
  steps: _propTypes.default.arrayOf(_propTypes.default.string),
194
197
  tokens: (0, _utils.getTokensPropType)('StepTracker'),
@@ -7,8 +7,6 @@ exports.default = void 0;
7
7
 
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
 
10
- var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
11
-
12
10
  var _utils = require("../utils");
13
11
 
14
12
  var _InputSupports = _interopRequireDefault(require("../InputSupports"));
@@ -49,17 +47,8 @@ const TextInput = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
49
47
  let {
50
48
  tokens,
51
49
  variant = {},
52
- pattern,
53
50
  ...rest
54
51
  } = _ref;
55
-
56
- _react.default.useEffect(() => {
57
- if (_Platform.default.OS === 'web' && pattern && ref.current) {
58
- // eslint-disable-next-line no-param-reassign
59
- ref.current.pattern = pattern;
60
- }
61
- }, [ref, pattern]);
62
-
63
52
  const {
64
53
  supportsProps,
65
54
  ...selectedProps
@@ -70,7 +59,9 @@ const TextInput = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
70
59
  validation: supportsProps.validation
71
60
  }
72
61
  };
73
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputSupports.default, { ...supportsProps,
62
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputSupports.default, {
63
+ nativeID: selectedProps.nativeID,
64
+ ...supportsProps,
74
65
  children: _ref2 => {
75
66
  let {
76
67
  inputId,
@@ -156,6 +156,7 @@ const TextInputBase = /*#__PURE__*/(0, _react.forwardRef)((_ref5, ref) => {
156
156
  onBlur,
157
157
  onMouseOver,
158
158
  onMouseOut,
159
+ pattern,
159
160
  tokens,
160
161
  variant = {},
161
162
  ...rest
@@ -194,6 +195,14 @@ const TextInputBase = /*#__PURE__*/(0, _react.forwardRef)((_ref5, ref) => {
194
195
  onChange,
195
196
  readOnly
196
197
  });
198
+ const element = ref === null || ref === void 0 ? void 0 : ref.current;
199
+ (0, _react.useEffect)(() => {
200
+ if (_Platform.default.OS === 'web' && pattern && element) {
201
+ // React Native Web doesn't support `pattern`, so we have to attach it via a ref,
202
+ // which a `pattern` user must provide anyway to call .checkValidity() on the element.
203
+ element.pattern = pattern;
204
+ }
205
+ }, [element, pattern]);
197
206
 
198
207
  const handleChangeText = event => {
199
208
  var _event$nativeEvent, _event$target;
@@ -7,10 +7,10 @@ exports.default = void 0;
7
7
 
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
 
10
- var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
11
-
12
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
11
 
12
+ // These are prop types specific to UDS TextInput; see also ../utils/props/textInputProps
13
+ // for generic React Native props and HTML input attrs that are passed through.
14
14
  const textInputPropTypes = {
15
15
  /**
16
16
  * If the input's state is to be controlled by a parent component, use this prop
@@ -38,12 +38,7 @@ const textInputPropTypes = {
38
38
  * Use to react upon input's value changes. Required when the `value` prop is set.
39
39
  * Will receive the input's value as an argument.
40
40
  */
41
- onChange: _propTypes.default.func,
42
- ..._Platform.default.select({
43
- web: {
44
- pattern: _propTypes.default.string
45
- }
46
- })
41
+ onChange: _propTypes.default.func
47
42
  };
48
43
  var _default = textInputPropTypes;
49
44
  exports.default = _default;
package/lib/index.js CHANGED
@@ -20,6 +20,7 @@ var _exportNames = {
20
20
  Icon: true,
21
21
  IconButton: true,
22
22
  InputLabel: true,
23
+ InputSupports: true,
23
24
  List: true,
24
25
  ListItem: true,
25
26
  ListBase: true,
@@ -158,6 +159,12 @@ Object.defineProperty(exports, "InputLabel", {
158
159
  return _InputLabel.default;
159
160
  }
160
161
  });
162
+ Object.defineProperty(exports, "InputSupports", {
163
+ enumerable: true,
164
+ get: function () {
165
+ return _InputSupports.default;
166
+ }
167
+ });
161
168
  Object.defineProperty(exports, "List", {
162
169
  enumerable: true,
163
170
  get: function () {
@@ -385,6 +392,20 @@ Object.keys(_Button).forEach(function (key) {
385
392
 
386
393
  var _Card = _interopRequireWildcard(require("./Card"));
387
394
 
395
+ var _Carousel = require("./Carousel");
396
+
397
+ Object.keys(_Carousel).forEach(function (key) {
398
+ if (key === "default" || key === "__esModule") return;
399
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
400
+ if (key in exports && exports[key] === _Carousel[key]) return;
401
+ Object.defineProperty(exports, key, {
402
+ enumerable: true,
403
+ get: function () {
404
+ return _Carousel[key];
405
+ }
406
+ });
407
+ });
408
+
388
409
  var _Checkbox = _interopRequireWildcard(require("./Checkbox"));
389
410
 
390
411
  Object.keys(_Checkbox).forEach(function (key) {
@@ -441,6 +462,8 @@ var _IconButton = _interopRequireDefault(require("./IconButton"));
441
462
 
442
463
  var _InputLabel = _interopRequireDefault(require("./InputLabel"));
443
464
 
465
+ var _InputSupports = _interopRequireDefault(require("./InputSupports"));
466
+
444
467
  var _Link = require("./Link");
445
468
 
446
469
  Object.keys(_Link).forEach(function (key) {
@@ -11,8 +11,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
11
11
 
12
12
  const clickHandlerMapping = {
13
13
  onClick: 'onPress',
14
- mouseDown: 'onPressIn',
15
- mouseUp: 'onPressOut'
14
+ onMouseDown: 'onPressIn',
15
+ onMouseUp: 'onPressOut'
16
16
  };
17
17
  var _default = {
18
18
  /**
@@ -3,10 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.textInputHandlerProps = exports.focusHandlerProps = exports.default = void 0;
6
+ exports.textInputHandlerProps = exports.focusHandlerProps = void 0;
7
7
 
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
 
10
+ var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
11
+
12
+ var _getPropSelector = _interopRequireDefault(require("./getPropSelector"));
13
+
10
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
15
 
12
16
  const focusHandlerProps = {
@@ -20,19 +24,10 @@ const focusHandlerProps = {
20
24
  * onFocus handler
21
25
  */
22
26
  onFocus: _propTypes.default.func
23
- },
24
- select: _ref => {
25
- let {
26
- onBlur,
27
- onFocus
28
- } = _ref;
29
- return {
30
- onBlur,
31
- onFocus
32
- };
33
27
  }
34
28
  };
35
29
  exports.focusHandlerProps = focusHandlerProps;
30
+ focusHandlerProps.select = (0, _getPropSelector.default)(focusHandlerProps.types);
36
31
  const textInputHandlerProps = {
37
32
  types: {
38
33
  /**
@@ -53,26 +48,77 @@ const textInputHandlerProps = {
53
48
  /**
54
49
  * onSubmitEditing handler
55
50
  */
56
- onSubmitEditing: _propTypes.default.func
57
- },
58
- select: _ref2 => {
59
- let {
60
- onChange,
61
- onChangeText,
62
- onSubmit,
63
- onSubmitEditing
64
- } = _ref2;
65
- return {
66
- onChange,
67
- onChangeText,
68
- onSubmit,
69
- onSubmitEditing
70
- };
51
+ onSubmitEditing: _propTypes.default.func,
52
+
53
+ /**
54
+ * onContentSizeChange handler
55
+ */
56
+ onContentSizeChange: _propTypes.default.func,
57
+
58
+ /**
59
+ * onEndEditing handler
60
+ */
61
+ onEndEditing: _propTypes.default.func,
62
+
63
+ /**
64
+ * onScroll handler
65
+ */
66
+ onScroll: _propTypes.default.func,
67
+
68
+ /**
69
+ * onSelectionChange handler
70
+ */
71
+ onSelectionChange: _propTypes.default.func,
72
+
73
+ /**
74
+ * onKeyPress handler
75
+ */
76
+ onKeyPress: _propTypes.default.func,
77
+
78
+ /**
79
+ * onKeyUp handler (only supported on Web)
80
+ */
81
+ onKeyUp: _propTypes.default.func,
82
+
83
+ /**
84
+ * onKeyDown handler (only supported on Web)
85
+ */
86
+ onKeyDown: _propTypes.default.func
71
87
  }
72
88
  };
73
89
  exports.textInputHandlerProps = textInputHandlerProps;
74
- var _default = {
75
- focusHandlerProps,
76
- textInputHandlerProps
77
- };
78
- exports.default = _default;
90
+ const selectTextInputHandlers = (0, _getPropSelector.default)(textInputHandlerProps.types);
91
+
92
+ textInputHandlerProps.select = props => {
93
+ // Support for onKeyPress/onKeyUp/onKeyDown is inconsistent between React Native and React Native Web
94
+ const {
95
+ onKeyPress,
96
+ onKeyUp,
97
+ onKeyDown,
98
+ ...resolvedProps
99
+ } = selectTextInputHandlers(props);
100
+
101
+ if (onKeyPress || onKeyUp || onKeyDown) {
102
+ if (_Platform.default.OS !== 'web') {
103
+ // React Native only supports onKeyPress. Call any key handlers supplied in expected order.
104
+ resolvedProps.onKeyPress = event => {
105
+ if (typeof onKeyDown === 'function') onKeyDown(event);
106
+ if (typeof onKeyPress === 'function') onKeyPress(event);
107
+ if (typeof onKeyUp === 'function') onKeyUp(event);
108
+ };
109
+ } else {
110
+ // React Native Web supports onKeyUp the normal way.
111
+ if (onKeyUp) resolvedProps.onKeyUp = onKeyUp; // React Native Web doesn't support the `onKeyDown` prop name, but maps a supplied onKeyPress handler
112
+ // to the onKeyDown event and calls it with a keydown event. Make React Native Web call either or both.
113
+
114
+ if (onKeyPress || onKeyDown) {
115
+ resolvedProps.onKeyPress = event => {
116
+ if (typeof onKeyDown === 'function') onKeyDown(event);
117
+ if (typeof onKeyPress === 'function') onKeyPress(event);
118
+ };
119
+ }
120
+ }
121
+ }
122
+
123
+ return resolvedProps;
124
+ };