@telus-uds/components-base 1.10.0 → 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 (45) hide show
  1. package/CHANGELOG.md +21 -3
  2. package/component-docs.json +346 -51
  3. package/lib/Carousel/Carousel.js +81 -28
  4. package/lib/Carousel/CarouselItem/CarouselItem.js +24 -9
  5. package/lib/Carousel/dictionary.js +23 -0
  6. package/lib/InputSupports/InputSupports.js +10 -3
  7. package/lib/InputSupports/useInputSupports.js +3 -2
  8. package/lib/Modal/Modal.js +4 -0
  9. package/lib/Skeleton/Skeleton.js +1 -0
  10. package/lib/StepTracker/StepTracker.js +10 -10
  11. package/lib/TextInput/TextInput.js +3 -1
  12. package/lib/index.js +9 -0
  13. package/lib/utils/props/clickProps.js +2 -2
  14. package/lib/utils/props/handlerProps.js +77 -31
  15. package/lib/utils/useScrollBlocking.js +66 -0
  16. package/lib/utils/useScrollBlocking.native.js +11 -0
  17. package/lib-module/Carousel/Carousel.js +76 -29
  18. package/lib-module/Carousel/CarouselItem/CarouselItem.js +25 -10
  19. package/lib-module/Carousel/dictionary.js +16 -0
  20. package/lib-module/InputSupports/InputSupports.js +10 -3
  21. package/lib-module/InputSupports/useInputSupports.js +3 -2
  22. package/lib-module/Modal/Modal.js +3 -0
  23. package/lib-module/Skeleton/Skeleton.js +1 -0
  24. package/lib-module/StepTracker/StepTracker.js +9 -10
  25. package/lib-module/TextInput/TextInput.js +3 -1
  26. package/lib-module/index.js +1 -0
  27. package/lib-module/utils/props/clickProps.js +2 -2
  28. package/lib-module/utils/props/handlerProps.js +78 -31
  29. package/lib-module/utils/useScrollBlocking.js +58 -0
  30. package/lib-module/utils/useScrollBlocking.native.js +2 -0
  31. package/package.json +3 -3
  32. package/src/Carousel/Carousel.jsx +93 -30
  33. package/src/Carousel/CarouselItem/CarouselItem.jsx +26 -8
  34. package/src/Carousel/dictionary.js +16 -0
  35. package/src/InputSupports/InputSupports.jsx +18 -3
  36. package/src/InputSupports/useInputSupports.js +2 -2
  37. package/src/Modal/Modal.jsx +3 -1
  38. package/src/Skeleton/Skeleton.jsx +1 -0
  39. package/src/StepTracker/StepTracker.jsx +9 -3
  40. package/src/TextInput/TextInput.jsx +1 -1
  41. package/src/index.js +1 -0
  42. package/src/utils/props/clickProps.js +2 -2
  43. package/src/utils/props/handlerProps.js +64 -16
  44. package/src/utils/useScrollBlocking.js +57 -0
  45. package/src/utils/useScrollBlocking.native.js +2 -0
@@ -37,6 +37,8 @@ var _StackView = _interopRequireDefault(require("../StackView"));
37
37
 
38
38
  var _IconButton = _interopRequireDefault(require("../IconButton"));
39
39
 
40
+ var _dictionary = _interopRequireDefault(require("./dictionary"));
41
+
40
42
  var _jsxRuntime = require("react/jsx-runtime");
41
43
 
42
44
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -103,14 +105,6 @@ const selectPreviousNextNavigationButtonStyles = (previousNextNavigationButtonWi
103
105
  return styles;
104
106
  };
105
107
 
106
- const defaultPanelNavigationDictionary = {
107
- en: {
108
- stepTrackerLabel: 'Showing %{stepNumber} of %{stepCount}'
109
- },
110
- fr: {
111
- stepTrackerLabel: 'Étape %{stepNumber} sur %{stepCount}: %{stepLabel}'
112
- }
113
- };
114
108
  const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
115
109
  /**
116
110
  * Carousel is a general-purpose content slider that can be used to render content in terms of slides.
@@ -172,6 +166,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
172
166
  tokens,
173
167
  variant,
174
168
  children,
169
+ itemLabel = 'item',
175
170
  previousNextNavigationPosition = 'inside',
176
171
  previousNextIconSize = 'default',
177
172
  minDistanceToCapture = 5,
@@ -181,9 +176,10 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
181
176
  onIndexChanged,
182
177
  springConfig = undefined,
183
178
  onRenderPanelNavigation,
184
- panelNavigationTextDictionary = defaultPanelNavigationDictionary,
179
+ tag = 'ul',
185
180
  accessibilityRole = 'adjustable',
186
181
  accessibilityLabel = 'carousel',
182
+ copy,
187
183
  ...rest
188
184
  } = _ref;
189
185
  const viewport = (0, _ViewportProvider.useViewport)();
@@ -200,6 +196,23 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
200
196
 
201
197
  const [activeIndex, setActiveIndex] = _react.default.useState(0);
202
198
 
199
+ const [isAnimating, setIsAnimating] = _react.default.useState(false);
200
+
201
+ const handleAnimationStart = _react.default.useCallback(function () {
202
+ if (typeof onAnimationStart === 'function') onAnimationStart(...arguments);
203
+ setIsAnimating(true);
204
+ }, [onAnimationStart]);
205
+
206
+ const handleAnimationEnd = _react.default.useCallback(function () {
207
+ if (typeof onAnimationEnd === 'function') onAnimationEnd(...arguments);
208
+ setIsAnimating(false);
209
+ }, [onAnimationEnd]);
210
+
211
+ const getCopy = (0, _utils.useCopy)({
212
+ dictionary: _dictionary.default,
213
+ copy
214
+ });
215
+
203
216
  const childrenArray = _react.default.Children.toArray(children);
204
217
 
205
218
  const systemProps = selectProps({ ...rest,
@@ -276,20 +289,28 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
276
289
  });
277
290
  }, [activeIndex, containerLayout.width, pan, animatedX]);
278
291
 
279
- const animate = _react.default.useCallback(toValue => {
292
+ const animate = _react.default.useCallback((toValue, toIndex) => {
293
+ const handleAnimationEndToIndex = function () {
294
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
295
+ args[_key] = arguments[_key];
296
+ }
297
+
298
+ return handleAnimationEnd(toIndex, ...args);
299
+ };
300
+
280
301
  if (reduceMotionEnabled) {
281
302
  _Animated.default.timing(pan, {
282
303
  toValue,
283
304
  duration: 1,
284
305
  useNativeDriver: false
285
- }).start();
306
+ }).start(handleAnimationEndToIndex);
286
307
  } else {
287
308
  _Animated.default.spring(pan, { ...springConfig,
288
309
  toValue,
289
310
  useNativeDriver: false
290
- }).start();
311
+ }).start(handleAnimationEndToIndex);
291
312
  }
292
- }, [pan, springConfig, reduceMotionEnabled]);
313
+ }, [pan, springConfig, reduceMotionEnabled, handleAnimationEnd]);
293
314
 
294
315
  const updateIndex = _react.default.useCallback(function () {
295
316
  let delta = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
@@ -308,25 +329,25 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
308
329
  calcDelta = -1 * activeIndex + delta - 1;
309
330
  }
310
331
 
332
+ const index = activeIndex + calcDelta;
333
+
311
334
  if (skipChanges) {
312
- animate(toValue);
335
+ animate(toValue, index);
313
336
  return calcDelta;
314
337
  }
315
338
 
316
- const index = activeIndex + calcDelta;
317
339
  setActiveIndex(index);
318
340
  toValue.x = containerLayout.width * -1 * calcDelta;
319
- animate(toValue);
341
+ animate(toValue, index);
320
342
  if (onIndexChanged) onIndexChanged(calcDelta);
321
- if (onAnimationEnd) onAnimationEnd(index);
322
343
  return calcDelta;
323
- }, [containerLayout.width, activeIndex, animate, children.length, onIndexChanged, onAnimationEnd]);
344
+ }, [containerLayout.width, activeIndex, animate, children.length, onIndexChanged]);
324
345
 
325
346
  const fixOffsetAndGo = _react.default.useCallback(delta => {
326
347
  updateOffset();
327
- if (onAnimationStart) onAnimationStart(activeIndex);
348
+ handleAnimationStart(activeIndex);
328
349
  updateIndex(delta);
329
- }, [updateIndex, updateOffset, activeIndex, onAnimationStart]);
350
+ }, [updateIndex, updateOffset, activeIndex, handleAnimationStart]);
330
351
 
331
352
  const goToNeighboring = _react.default.useCallback(function () {
332
353
  let toPrev = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
@@ -349,7 +370,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
349
370
  return false;
350
371
  }
351
372
 
352
- if (onAnimationStart) onAnimationStart(activeIndex);
373
+ handleAnimationStart(activeIndex);
353
374
  return Math.abs(gestureState.dx) > minDistanceToCapture;
354
375
  },
355
376
  onPanResponderGrant: () => updateOffset(),
@@ -365,13 +386,13 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
365
386
  animate({
366
387
  x: 0,
367
388
  y: 0
368
- });
389
+ }, 0);
369
390
  } else {
370
391
  const delta = correction > 0 ? -1 : 1;
371
392
  updateIndex(delta);
372
393
  }
373
394
  }
374
- }), [containerLayout.width, updateIndex, updateOffset, animate, isSwipeAllowed, activeIndex, minDistanceForAction, onAnimationStart, minDistanceToCapture, pan.x]);
395
+ }), [containerLayout.width, updateIndex, updateOffset, animate, isSwipeAllowed, activeIndex, minDistanceForAction, handleAnimationStart, minDistanceToCapture, pan.x]);
375
396
 
376
397
  _react.default.useEffect(() => {
377
398
  pan.x.addListener(_ref4 => {
@@ -416,6 +437,13 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
416
437
  size: previousNextIconSize,
417
438
  raised: true
418
439
  };
440
+
441
+ const getCopyWithPlaceholders = copyKey => {
442
+ const copyText = getCopy(copyKey).replace(/%\{itemLabel\}/g, itemLabel).replace(/%\{stepNumber\}/g, activeIndex + 1).replace(/%\{stepCount\}/g, childrenArray.length); // First word might be a lowercase placeholder: capitalize the first letter
443
+
444
+ return "".concat(copyText[0].toUpperCase()).concat(copyText.slice(1));
445
+ };
446
+
419
447
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_CarouselContext.CarouselProvider, {
420
448
  activeIndex: activeIndex,
421
449
  totalItems: childrenArray.length,
@@ -434,7 +462,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
434
462
  icon: previousIcon,
435
463
  onPress: goToPrev,
436
464
  variant: previousNextIconButtonVariants,
437
- accessibilityLabel: "previous-button"
465
+ accessibilityLabel: getCopyWithPlaceholders('iconButtonLabel').replace('%{targetStep}', activeIndex)
438
466
  })
439
467
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
440
468
  style: selectContainerStyles(containerLayout.width),
@@ -447,9 +475,13 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
447
475
  }]
448
476
  }]),
449
477
  ...panResponder.panHandlers,
478
+ ...(0, _utils.getA11yPropsFromHtmlTag)(tag),
450
479
  children: childrenArray.map((element, index) => {
480
+ const hidden = !isAnimating && index !== activeIndex;
481
+
451
482
  const clonedElement = /*#__PURE__*/_react.default.cloneElement(element, {
452
- elementIndex: index
483
+ elementIndex: index,
484
+ hidden
453
485
  });
454
486
 
455
487
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.default.Fragment, {
@@ -465,7 +497,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
465
497
  icon: nextIcon,
466
498
  onPress: goToNext,
467
499
  variant: previousNextIconButtonVariants,
468
- accessibilityLabel: "next-button"
500
+ accessibilityLabel: getCopyWithPlaceholders('iconButtonLabel').replace('%{targetStep}', activeIndex + 2)
469
501
  })
470
502
  })]
471
503
  }), showPanelNavigation ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_StackView.default, {
@@ -477,7 +509,11 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
477
509
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_StepTracker.default, {
478
510
  current: activeIndex,
479
511
  steps: childrenArray.map((_, index) => String(index)),
480
- dictionary: panelNavigationTextDictionary,
512
+ copy: {
513
+ // Give StepTracker copy from Carousel's language and dictionary
514
+ stepLabel: getCopyWithPlaceholders('stepLabel'),
515
+ stepTrackerLabel: getCopyWithPlaceholders('stepTrackerLabel')
516
+ },
481
517
  tokens: panelNavigationTokens
482
518
  })
483
519
  }) : null]
@@ -493,6 +529,14 @@ Carousel.propTypes = { ...selectedSystemPropTypes,
493
529
  */
494
530
  children: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.node), _propTypes.default.node]).isRequired,
495
531
 
532
+ /**
533
+ * Lowercase language-appropriate user-facing description of what each Carousel slide represents.
534
+ * This is used when generating item labels. For example, if a carousel contains offers,
535
+ * pass itemLabel="summer offer" (or copy="fr" and an appropriate French translation) to genereate
536
+ * accessible labels such as "Summer offer 1 of 3" and "Show summer offer 2 of 3".
537
+ */
538
+ itemLabel: _propTypes.default.string,
539
+
496
540
  /**
497
541
  * `inside` renders the previous and next buttons inside the slide
498
542
  * `outside` renders the previous and next buttons outside the slide
@@ -611,7 +655,16 @@ Carousel.propTypes = { ...selectedSystemPropTypes,
611
655
  /**
612
656
  * Provide custom accessibilityLabel for Carousel container
613
657
  */
614
- accessibilityLabel: _propTypes.default.string
658
+ accessibilityLabel: _propTypes.default.string,
659
+
660
+ /**
661
+ * HTML tag to use for the Carousel item's immediate parent. Defaults to `'ul'` so that
662
+ * assistive technology tools know to intepret the carousel as a list.
663
+ *
664
+ * Note that if the immediate Carousel children do not all render as `'li'` elements,
665
+ * this should be changed (e.g. pass tag="div") because only 'li' is a valid child of 'ul'.
666
+ */
667
+ tag: _propTypes.default.oneOf(_utils.layoutTags)
615
668
  };
616
669
  Carousel.Item = _CarouselItem.default;
617
670
  Carousel.displayName = 'Carousel';
@@ -31,23 +31,29 @@ const CarouselItem = _ref => {
31
31
  let {
32
32
  children,
33
33
  elementIndex,
34
+ tag = 'li',
35
+ hidden,
34
36
  ...rest
35
37
  } = _ref;
36
38
  const {
37
39
  width,
38
- activeIndex,
39
- totalItems
40
+ activeIndex
40
41
  } = (0, _CarouselContext.useCarousel)();
41
42
  const selectedProps = selectProps({ ...rest,
42
- // `group` role crashes the app on Android so setting it to `none` for Android
43
- accessibilityRole: _Platform.default.OS === 'android' ? 'none' : 'group',
44
- accessibilityLabel: "Showing ".concat(elementIndex + 1, " of ").concat(totalItems)
43
+ ...(0, _utils.getA11yPropsFromHtmlTag)(tag, rest.accessibilityRole)
45
44
  });
46
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
+
47
55
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
48
- style: {
49
- width
50
- },
56
+ style: style,
51
57
  ...selectedProps,
52
58
  ...focusabilityProps,
53
59
  children: children
@@ -70,7 +76,16 @@ CarouselItem.propTypes = { ...selectedSystemPropTypes,
70
76
  /**
71
77
  * Content of the slide
72
78
  */
73
- children: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.node), _propTypes.default.node]).isRequired
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)
74
89
  };
75
90
  CarouselItem.displayName = 'Carousel.Item';
76
91
  var _default = CarouselItem;
@@ -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;
@@ -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
  };
@@ -179,19 +179,19 @@ const StepTracker = /*#__PURE__*/(0, _react.forwardRef)((_ref4, ref) => {
179
179
  })
180
180
  });
181
181
  });
182
- 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
+
183
189
  StepTracker.propTypes = { ...selectedSystemPropTypes,
184
190
  current: _propTypes.default.number,
185
- copy: _propTypes.default.oneOf(['en', 'fr']),
191
+ copy: _propTypes.default.oneOfType([_propTypes.default.oneOf(['en', 'fr']), dictionaryContentShape]),
186
192
  dictionary: _propTypes.default.shape({
187
- en: _propTypes.default.shape({
188
- stepLabel: _propTypes.default.string,
189
- stepTrackerLabel: _propTypes.default.string
190
- }),
191
- fr: _propTypes.default.shape({
192
- stepLabel: _propTypes.default.string,
193
- stepTrackerLabel: _propTypes.default.string
194
- })
193
+ en: dictionaryContentShape,
194
+ fr: dictionaryContentShape
195
195
  }),
196
196
  steps: _propTypes.default.arrayOf(_propTypes.default.string),
197
197
  tokens: (0, _utils.getTokensPropType)('StepTracker'),
@@ -59,7 +59,9 @@ const TextInput = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
59
59
  validation: supportsProps.validation
60
60
  }
61
61
  };
62
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputSupports.default, { ...supportsProps,
62
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputSupports.default, {
63
+ nativeID: selectedProps.nativeID,
64
+ ...supportsProps,
63
65
  children: _ref2 => {
64
66
  let {
65
67
  inputId,
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 () {
@@ -455,6 +462,8 @@ var _IconButton = _interopRequireDefault(require("./IconButton"));
455
462
 
456
463
  var _InputLabel = _interopRequireDefault(require("./InputLabel"));
457
464
 
465
+ var _InputSupports = _interopRequireDefault(require("./InputSupports"));
466
+
458
467
  var _Link = require("./Link");
459
468
 
460
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
+ };