@hero-design/rn 7.5.0 → 7.6.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 (74) hide show
  1. package/.turbo/turbo-build.log +8 -8
  2. package/es/index.js +474 -110
  3. package/lib/index.js +474 -108
  4. package/package.json +2 -2
  5. package/playground/.turbo/turbo-type-check.log +7 -0
  6. package/playground/package.json +3 -3
  7. package/playground/src/App.tsx +6 -0
  8. package/playground/src/ContentNavigator.tsx +3 -10
  9. package/playground/src/Select.tsx +32 -0
  10. package/playground/src/Switch.tsx +80 -0
  11. package/src/components/BottomSheet/Header.tsx +1 -1
  12. package/src/components/BottomSheet/__tests__/__snapshots__/index.spec.tsx.snap +8 -8
  13. package/src/components/BottomSheet/index.tsx +6 -0
  14. package/src/components/Radio/RadioGroup.tsx +31 -7
  15. package/src/components/Radio/types.ts +1 -0
  16. package/src/components/SectionHeading/StyledHeading.tsx +5 -5
  17. package/src/components/SectionHeading/__tests__/{StyledHeading.tsx → StyledHeading.spec.tsx} +0 -0
  18. package/src/components/SectionHeading/__tests__/__snapshots__/{StyledHeading.tsx.snap → StyledHeading.spec.tsx.snap} +0 -0
  19. package/src/components/Select/MultiSelect/Footer.tsx +15 -0
  20. package/src/components/Select/MultiSelect/OptionList.tsx +76 -0
  21. package/src/components/Select/MultiSelect/StyledMultiSelect.tsx +30 -0
  22. package/src/components/Select/MultiSelect/__tests__/StyledMultiSelect.spec.tsx +49 -0
  23. package/src/components/Select/MultiSelect/__tests__/__snapshots__/StyledMultiSelect.spec.tsx.snap +108 -0
  24. package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +1630 -0
  25. package/src/components/Select/MultiSelect/__tests__/index.spec.tsx +94 -0
  26. package/src/components/Select/MultiSelect/index.tsx +103 -0
  27. package/src/components/Select/MultiSelect/types.ts +1 -0
  28. package/src/components/Select/index.tsx +5 -0
  29. package/src/components/Switch/StyledSwitch.tsx +50 -0
  30. package/src/components/Switch/__tests__/StyledHeading.spec.tsx +42 -0
  31. package/src/components/Switch/__tests__/__snapshots__/StyledHeading.spec.tsx.snap +74 -0
  32. package/src/components/Switch/__tests__/__snapshots__/index.spec.tsx.snap +129 -0
  33. package/src/components/Switch/__tests__/index.spec.tsx +24 -0
  34. package/src/components/Switch/index.tsx +87 -0
  35. package/src/components/TextInput/StyledTextInput.tsx +2 -6
  36. package/src/components/TextInput/__tests__/StyledTextInput.spec.tsx +1 -7
  37. package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +1 -22
  38. package/src/components/TextInput/__tests__/index.spec.tsx +2 -1
  39. package/src/components/TextInput/index.tsx +19 -6
  40. package/src/index.ts +4 -0
  41. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +58 -1
  42. package/src/theme/components/sectionHeading.ts +18 -0
  43. package/src/theme/components/select.ts +23 -0
  44. package/src/theme/components/switch.ts +50 -0
  45. package/src/theme/components/textInput.ts +1 -1
  46. package/src/theme/global/colors.ts +1 -0
  47. package/src/theme/index.ts +12 -3
  48. package/types/components/BottomSheet/index.d.ts +5 -1
  49. package/types/components/Radio/RadioGroup.d.ts +11 -8
  50. package/types/components/Radio/index.d.ts +1 -1
  51. package/types/components/Radio/types.d.ts +5 -0
  52. package/types/components/SectionHeading/__tests__/{StyledHeading.d.ts → StyledHeading.spec.d.ts} +0 -0
  53. package/types/components/Select/MultiSelect/Footer.d.ts +5 -0
  54. package/types/components/Select/MultiSelect/OptionList.d.ts +3 -0
  55. package/types/components/Select/MultiSelect/StyledMultiSelect.d.ts +26 -0
  56. package/types/components/Select/MultiSelect/__tests__/StyledMultiSelect.spec.d.ts +1 -0
  57. package/types/components/Select/MultiSelect/__tests__/index.spec.d.ts +1 -0
  58. package/types/components/Select/MultiSelect/index.d.ts +39 -0
  59. package/types/components/Select/MultiSelect/types.d.ts +5 -0
  60. package/types/components/Select/index.d.ts +5 -0
  61. package/types/components/Switch/StyledSwitch.d.ts +36 -0
  62. package/types/components/Switch/__tests__/StyledHeading.spec.d.ts +1 -0
  63. package/types/components/Switch/__tests__/index.spec.d.ts +1 -0
  64. package/types/components/Switch/index.d.ts +30 -0
  65. package/types/components/TextInput/StyledTextInput.d.ts +1 -5
  66. package/types/components/TextInput/index.d.ts +13 -5
  67. package/types/index.d.ts +3 -1
  68. package/types/theme/components/sectionHeading.d.ts +13 -0
  69. package/types/theme/components/select.d.ts +17 -0
  70. package/types/theme/components/switch.d.ts +32 -0
  71. package/types/theme/components/textInput.d.ts +1 -1
  72. package/types/theme/global/colors.d.ts +1 -0
  73. package/types/theme/global/index.d.ts +1 -0
  74. package/types/theme/index.d.ts +8 -2
package/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as ReactNative from 'react-native';
2
- import ReactNative__default, { Dimensions, StyleSheet as StyleSheet$1, Text as Text$1, View, TouchableOpacity, Image, Animated, Platform, TouchableWithoutFeedback, Pressable, Easing, Modal, TouchableHighlight, requireNativeComponent, UIManager, I18nManager, Keyboard, FlatList, TextInput as TextInput$1 } from 'react-native';
2
+ import ReactNative__default, { Dimensions, StyleSheet as StyleSheet$1, Text as Text$1, View, TouchableOpacity, Image, Animated, Platform, TouchableWithoutFeedback, Pressable, Easing, Modal, TouchableHighlight, TextInput as TextInput$1, requireNativeComponent, UIManager, I18nManager, Keyboard, FlatList } from 'react-native';
3
3
  import React, { useContext, createElement, createContext, forwardRef, useRef, useEffect, useState, useCallback, Children } from 'react';
4
4
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
5
5
 
@@ -1723,7 +1723,8 @@ var systemPalette = {
1723
1723
  invertedText: palette.white,
1724
1724
  outline: palette.greyLight60,
1725
1725
  archived: palette.greyLight45,
1726
- black: palette.black
1726
+ black: palette.black,
1727
+ inactiveBackground: palette.greyDark30
1727
1728
  };
1728
1729
 
1729
1730
  var BASE_WIDTH = 390; // Based on iPhone 13's viewport size
@@ -2230,25 +2231,6 @@ var getProgressTheme = function getProgressTheme(theme) {
2230
2231
  };
2231
2232
  };
2232
2233
 
2233
- var getSpinnerTheme = function getSpinnerTheme(theme) {
2234
- var color = {
2235
- "default": theme.colors.primary
2236
- };
2237
- var space = {
2238
- spinnerDot: theme.space.medium,
2239
- spinnerDotPadding: theme.space.small,
2240
- spinnerTextPaddingTop: theme.space.small
2241
- };
2242
- var radii = {
2243
- "default": theme.radii.medium
2244
- };
2245
- return {
2246
- color: color,
2247
- space: space,
2248
- radii: radii
2249
- };
2250
- };
2251
-
2252
2234
  var getRadioTheme = function getRadioTheme(theme) {
2253
2235
  var colors = {
2254
2236
  circle: theme.colors.black,
@@ -2280,6 +2262,102 @@ var getRadioTheme = function getRadioTheme(theme) {
2280
2262
  };
2281
2263
  };
2282
2264
 
2265
+ var getSectionHeadingTheme = function getSectionHeadingTheme(theme) {
2266
+ var colors = {
2267
+ background: theme.colors.outline
2268
+ };
2269
+ var space = {
2270
+ headingVerticalPadding: theme.space.small,
2271
+ headingHorizontalPadding: theme.space.medium,
2272
+ headingMarginBottom: theme.space.medium,
2273
+ iconMarginRight: theme.space.small
2274
+ };
2275
+ return {
2276
+ colors: colors,
2277
+ space: space
2278
+ };
2279
+ };
2280
+
2281
+ var getSelectTheme = function getSelectTheme(theme) {
2282
+ var colors = {
2283
+ option: theme.colors.platformBackground,
2284
+ checkedOption: theme.colors.primaryBackground,
2285
+ footerText: theme.colors.primary
2286
+ };
2287
+ var space = {
2288
+ optionPadding: theme.space.medium,
2289
+ optionListPadding: theme.space.medium,
2290
+ optionListSpacing: theme.space.xsmall
2291
+ };
2292
+ var radii = {
2293
+ option: theme.radii.base
2294
+ };
2295
+ return {
2296
+ space: space,
2297
+ colors: colors,
2298
+ radii: radii
2299
+ };
2300
+ };
2301
+
2302
+ var getSpinnerTheme = function getSpinnerTheme(theme) {
2303
+ var color = {
2304
+ "default": theme.colors.primary
2305
+ };
2306
+ var space = {
2307
+ spinnerDot: theme.space.medium,
2308
+ spinnerDotPadding: theme.space.small,
2309
+ spinnerTextPaddingTop: theme.space.small
2310
+ };
2311
+ var radii = {
2312
+ "default": theme.radii.medium
2313
+ };
2314
+ return {
2315
+ color: color,
2316
+ space: space,
2317
+ radii: radii
2318
+ };
2319
+ };
2320
+
2321
+ var getSwitchTheme = function getSwitchTheme(theme) {
2322
+ var colors = {
2323
+ thumb: theme.colors.platformBackground,
2324
+ active: theme.colors.primary,
2325
+ inactive: theme.colors.inactiveBackground
2326
+ };
2327
+ var thumbSizes = {
2328
+ small: theme.space.medium,
2329
+ medium: theme.space.medium * 1.3
2330
+ };
2331
+ var widths = {
2332
+ small: theme.space.xxxlarge,
2333
+ medium: theme.space.xxxxlarge
2334
+ };
2335
+ var heights = {
2336
+ small: theme.space.large,
2337
+ medium: theme.space.large * 1.2
2338
+ };
2339
+ var spaces = {
2340
+ small: theme.space.xsmall,
2341
+ medium: theme.space.xsmall,
2342
+ inactive: 0
2343
+ };
2344
+ var radii = {
2345
+ rounded: theme.radii.rounded
2346
+ };
2347
+ var borderWidths = {
2348
+ "default": theme.borderWidths.base
2349
+ };
2350
+ return {
2351
+ colors: colors,
2352
+ thumbSizes: thumbSizes,
2353
+ widths: widths,
2354
+ heights: heights,
2355
+ spaces: spaces,
2356
+ radii: radii,
2357
+ borderWidths: borderWidths
2358
+ };
2359
+ };
2360
+
2283
2361
  var getTabsTheme = function getTabsTheme(theme) {
2284
2362
  var colors = {
2285
2363
  active: theme.colors.primary,
@@ -2360,7 +2438,7 @@ var getTextInputTheme = function getTextInputTheme(theme) {
2360
2438
  labelLeft: theme.space.medium,
2361
2439
  labelTop: theme.lineHeights.small / -2,
2362
2440
  labelHorizontalPadding: theme.space.xsmall,
2363
- prefixMarginRight: theme.space.small
2441
+ inputHorizontalMargin: theme.space.small
2364
2442
  };
2365
2443
  var fontSizes = {
2366
2444
  text: theme.fontSizes.large
@@ -2429,9 +2507,12 @@ var getTheme = function getTheme() {
2429
2507
  drawer: getDrawerTheme(globalTheme),
2430
2508
  fab: getFABTheme(globalTheme),
2431
2509
  icon: getIconTheme(globalTheme),
2432
- spinner: getSpinnerTheme(globalTheme),
2433
2510
  progress: getProgressTheme(globalTheme),
2434
2511
  radio: getRadioTheme(globalTheme),
2512
+ sectionHeading: getSectionHeadingTheme(globalTheme),
2513
+ select: getSelectTheme(globalTheme),
2514
+ spinner: getSpinnerTheme(globalTheme),
2515
+ "switch": getSwitchTheme(globalTheme),
2435
2516
  tabs: getTabsTheme(globalTheme),
2436
2517
  tag: getTagTheme(globalTheme),
2437
2518
  textInput: getTextInputTheme(globalTheme),
@@ -14831,7 +14912,7 @@ var Divider = function Divider(_ref) {
14831
14912
  };
14832
14913
 
14833
14914
  var AnimatedPressable$1 = Animated.createAnimatedComponent(Pressable);
14834
- var StyledWrapper$3 = index$2(View)(_objectSpread2(_objectSpread2({}, StyleSheet$1.absoluteFillObject), {}, {
14915
+ var StyledWrapper$4 = index$2(View)(_objectSpread2(_objectSpread2({}, StyleSheet$1.absoluteFillObject), {}, {
14835
14916
  flexDirection: 'column-reverse'
14836
14917
  }));
14837
14918
  var StyledBottomSheet = index$2(Animated.View)(function (_ref) {
@@ -14894,7 +14975,7 @@ var StyledIconWrapper$1 = index$2(View)(function (_ref6) {
14894
14975
  };
14895
14976
  });
14896
14977
 
14897
- var Footer = function Footer(_ref) {
14978
+ var Footer$1 = function Footer(_ref) {
14898
14979
  var children = _ref.children,
14899
14980
  showDivider = _ref.showDivider;
14900
14981
  return /*#__PURE__*/React.createElement(View, null, showDivider ? /*#__PURE__*/React.createElement(Divider, null) : null, /*#__PURE__*/React.createElement(StyledFooter, null, children));
@@ -15357,7 +15438,7 @@ var Header = function Header(_ref) {
15357
15438
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StyledHeaderWrapper, null, typeof content === 'string' ? /*#__PURE__*/React.createElement(StyledHeader, {
15358
15439
  adjacentIcon: showCloseButton
15359
15440
  }, /*#__PURE__*/React.createElement(Typography.Text, {
15360
- fontSize: "xlarge",
15441
+ fontSize: "large",
15361
15442
  fontWeight: "semi-bold"
15362
15443
  }, content)) : /*#__PURE__*/React.createElement(View, {
15363
15444
  style: {
@@ -15378,6 +15459,7 @@ var BottomSheet = function BottomSheet(_ref) {
15378
15459
  children = _ref.children,
15379
15460
  onOpen = _ref.onOpen,
15380
15461
  onRequestClose = _ref.onRequestClose,
15462
+ onDismiss = _ref.onDismiss,
15381
15463
  _ref$showCloseButton = _ref.showCloseButton,
15382
15464
  showCloseButton = _ref$showCloseButton === void 0 ? true : _ref$showCloseButton,
15383
15465
  _ref$hasBackdrop = _ref.hasBackdrop,
@@ -15413,6 +15495,7 @@ var BottomSheet = function BottomSheet(_ref) {
15413
15495
 
15414
15496
  if (endValueOfTransition === 0 && value === endValueOfTransition) {
15415
15497
  setVisibility(false);
15498
+ onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
15416
15499
  }
15417
15500
  });
15418
15501
  return function () {
@@ -15446,7 +15529,7 @@ var BottomSheet = function BottomSheet(_ref) {
15446
15529
  transparent: true,
15447
15530
  testID: testID,
15448
15531
  onShow: onOpen
15449
- }, /*#__PURE__*/React.createElement(StyledWrapper$3, {
15532
+ }, /*#__PURE__*/React.createElement(StyledWrapper$4, {
15450
15533
  pointerEvents: "box-none"
15451
15534
  }, /*#__PURE__*/React.createElement(StyledBackdrop$2, {
15452
15535
  style: {
@@ -15470,7 +15553,7 @@ var BottomSheet = function BottomSheet(_ref) {
15470
15553
  showDivider: showDivider,
15471
15554
  onRequestClose: onRequestClose,
15472
15555
  showCloseButton: showCloseButton
15473
- }) : null, children, footer ? /*#__PURE__*/React.createElement(Footer, {
15556
+ }) : null, children, footer ? /*#__PURE__*/React.createElement(Footer$1, {
15474
15557
  showDivider: showDivider
15475
15558
  }, footer) : null)));
15476
15559
  };
@@ -15519,7 +15602,7 @@ var Card = function Card(_ref) {
15519
15602
  }), children);
15520
15603
  };
15521
15604
 
15522
- var StyledWrapper$2 = index$2(Animated.View)(function () {
15605
+ var StyledWrapper$3 = index$2(Animated.View)(function () {
15523
15606
  return {
15524
15607
  margin: 0,
15525
15608
  padding: 0,
@@ -15579,7 +15662,7 @@ var Collapse = function Collapse(_ref) {
15579
15662
  var height = _ref2.height;
15580
15663
  setContentHeight(height);
15581
15664
  }, [contentHeight]);
15582
- return /*#__PURE__*/React.createElement(StyledWrapper$2, {
15665
+ return /*#__PURE__*/React.createElement(StyledWrapper$3, {
15583
15666
  style: [style, {
15584
15667
  height: collapseAnim
15585
15668
  }],
@@ -16174,7 +16257,7 @@ var ProgressCircle = function ProgressCircle(_ref2) {
16174
16257
  }, "".concat(value, "%")))));
16175
16258
  };
16176
16259
 
16177
- var StyledWrapper$1 = index$2(View)(function (_ref) {
16260
+ var StyledWrapper$2 = index$2(View)(function (_ref) {
16178
16261
  var theme = _ref.theme;
16179
16262
  return {
16180
16263
  height: theme.__hd__.progress.sizes.barHeight,
@@ -16229,7 +16312,7 @@ var ProgressBar = function ProgressBar(_ref) {
16229
16312
  outputRange: [999, 0],
16230
16313
  extrapolate: 'clamp'
16231
16314
  });
16232
- return /*#__PURE__*/React.createElement(StyledWrapper$1, _extends$3({}, nativeProps, {
16315
+ return /*#__PURE__*/React.createElement(StyledWrapper$2, _extends$3({}, nativeProps, {
16233
16316
  testID: testID,
16234
16317
  style: style
16235
16318
  }), /*#__PURE__*/React.createElement(StyledInner, {
@@ -16392,7 +16475,7 @@ var InnerCircle = index$2(View)(function (_ref3) {
16392
16475
  backgroundColor: theme.__hd__.radio.colors.checkedCircle
16393
16476
  };
16394
16477
  });
16395
- var Spacer = index$2(View)(function (_ref4) {
16478
+ var Spacer$1 = index$2(View)(function (_ref4) {
16396
16479
  var theme = _ref4.theme;
16397
16480
  return {
16398
16481
  marginTop: theme.__hd__.radio.space.groupTopMargin
@@ -16424,10 +16507,25 @@ var Radio = function Radio(_ref) {
16424
16507
  })));
16425
16508
  };
16426
16509
 
16510
+ function getKey$1(option, index, keyExtractor) {
16511
+ var key = '';
16512
+
16513
+ if (keyExtractor !== undefined) {
16514
+ key = keyExtractor(option, index);
16515
+ } else if (option.key !== undefined) {
16516
+ key = option.key;
16517
+ } else {
16518
+ key = index;
16519
+ }
16520
+
16521
+ return key;
16522
+ }
16523
+
16427
16524
  var RadioGroup = function RadioGroup(_ref) {
16428
16525
  var value = _ref.value,
16429
16526
  _onPress = _ref.onPress,
16430
16527
  options = _ref.options,
16528
+ keyExtractor = _ref.keyExtractor,
16431
16529
  style = _ref.style,
16432
16530
  testID = _ref.testID;
16433
16531
  return /*#__PURE__*/React.createElement(View, {
@@ -16435,8 +16533,8 @@ var RadioGroup = function RadioGroup(_ref) {
16435
16533
  testID: testID
16436
16534
  }, options.map(function (option, index) {
16437
16535
  return /*#__PURE__*/React.createElement(React.Fragment, {
16438
- key: option.value
16439
- }, index !== 0 && /*#__PURE__*/React.createElement(Spacer, null), /*#__PURE__*/React.createElement(Radio, {
16536
+ key: getKey$1(option, index, keyExtractor)
16537
+ }, index !== 0 && /*#__PURE__*/React.createElement(Spacer$1, null), /*#__PURE__*/React.createElement(Radio, {
16440
16538
  text: option.text,
16441
16539
  checked: option.value === value,
16442
16540
  onPress: function onPress() {
@@ -16453,10 +16551,10 @@ var CompoundRadio = {
16453
16551
  var StyledHeading = index$2(View)(function (_ref) {
16454
16552
  var theme = _ref.theme;
16455
16553
  return {
16456
- paddingVertical: theme.space.small,
16457
- paddingHorizontal: theme.space.medium,
16458
- backgroundColor: theme.colors.outline,
16459
- marginBottom: theme.space.medium,
16554
+ paddingVertical: theme.__hd__.sectionHeading.space.headingVerticalPadding,
16555
+ paddingHorizontal: theme.__hd__.sectionHeading.space.headingHorizontalPadding,
16556
+ backgroundColor: theme.__hd__.sectionHeading.colors.background,
16557
+ marginBottom: theme.__hd__.sectionHeading.space.headingMarginBottom,
16460
16558
  display: 'flex',
16461
16559
  flexDirection: 'row',
16462
16560
  alignContent: 'center',
@@ -16466,10 +16564,10 @@ var StyledHeading = index$2(View)(function (_ref) {
16466
16564
  var StyledIconWrapper = index$2(View)(function (_ref2) {
16467
16565
  var theme = _ref2.theme;
16468
16566
  return {
16469
- marginRight: theme.space.small
16567
+ marginRight: theme.__hd__.sectionHeading.space.iconMarginRight
16470
16568
  };
16471
16569
  });
16472
- var StyledWrapper = index$2(View)(function () {
16570
+ var StyledWrapper$1 = index$2(View)(function () {
16473
16571
  return {
16474
16572
  display: 'flex',
16475
16573
  flexDirection: 'row'
@@ -16503,7 +16601,7 @@ var SectionHeading = function SectionHeading(_ref) {
16503
16601
  return /*#__PURE__*/React.createElement(StyledHeading, {
16504
16602
  style: style,
16505
16603
  testID: testID
16506
- }, /*#__PURE__*/React.createElement(StyledWrapper, null, /*#__PURE__*/React.createElement(StyledIconWrapper, null, icon && /*#__PURE__*/React.createElement(Icon, {
16604
+ }, /*#__PURE__*/React.createElement(StyledWrapper$1, null, /*#__PURE__*/React.createElement(StyledIconWrapper, null, icon && /*#__PURE__*/React.createElement(Icon, {
16507
16605
  icon: icon,
16508
16606
  size: ICON_SIZE_MAP[fontSize],
16509
16607
  intent: ICON_INTENT_MAP[intent]
@@ -16514,6 +16612,337 @@ var SectionHeading = function SectionHeading(_ref) {
16514
16612
  }, text)), rightChildren);
16515
16613
  };
16516
16614
 
16615
+ var Container = index$2(View)(function (_ref) {
16616
+ var theme = _ref.theme;
16617
+ return {
16618
+ position: 'relative',
16619
+ width: '100%',
16620
+ borderWidth: theme.__hd__.textInput.borderWidths.container,
16621
+ borderRadius: theme.__hd__.textInput.radii.container,
16622
+ padding: theme.__hd__.textInput.space.containerPadding,
16623
+ flexDirection: 'row',
16624
+ alignItems: 'center'
16625
+ };
16626
+ });
16627
+ var Label = index$2(Typography.Text)(function (_ref2) {
16628
+ var theme = _ref2.theme;
16629
+ return {
16630
+ position: 'absolute',
16631
+ left: theme.__hd__.textInput.space.labelLeft,
16632
+ top: theme.__hd__.textInput.space.labelTop,
16633
+ backgroundColor: theme.__hd__.textInput.colors.labelBackground,
16634
+ zIndex: 1,
16635
+ paddingHorizontal: theme.__hd__.textInput.space.labelHorizontalPadding
16636
+ };
16637
+ });
16638
+ var StyledTextInput = index$2(TextInput$1)(function (_ref3) {
16639
+ var theme = _ref3.theme;
16640
+ return {
16641
+ flex: 1,
16642
+ fontSize: theme.__hd__.textInput.fontSizes.text,
16643
+ marginHorizontal: theme.__hd__.textInput.space.inputHorizontalMargin
16644
+ };
16645
+ });
16646
+
16647
+ var _excluded$1 = ["label", "prefix", "suffix", "style", "textStyle", "testID", "accessibilityLabelledBy"];
16648
+
16649
+ var TextInput = function TextInput(_ref) {
16650
+ var label = _ref.label,
16651
+ prefix = _ref.prefix,
16652
+ suffix = _ref.suffix,
16653
+ style = _ref.style,
16654
+ textStyle = _ref.textStyle,
16655
+ testID = _ref.testID,
16656
+ accessibilityLabelledBy = _ref.accessibilityLabelledBy,
16657
+ nativeProps = _objectWithoutProperties$1(_ref, _excluded$1);
16658
+
16659
+ return /*#__PURE__*/React.createElement(Container, {
16660
+ style: style,
16661
+ testID: testID
16662
+ }, label && /*#__PURE__*/React.createElement(Label, {
16663
+ nativeID: accessibilityLabelledBy,
16664
+ testID: "input-label",
16665
+ fontSize: "small"
16666
+ }, label), prefix && /*#__PURE__*/React.createElement(Icon, {
16667
+ testID: "input-prefix",
16668
+ icon: prefix,
16669
+ size: "xsmall"
16670
+ }), /*#__PURE__*/React.createElement(StyledTextInput, _extends$3({
16671
+ style: textStyle,
16672
+ testID: "text-input" // @ts-ignore
16673
+ ,
16674
+ accessibilityLabelledBy: accessibilityLabelledBy
16675
+ }, nativeProps)), suffix && /*#__PURE__*/React.createElement(Icon, {
16676
+ testID: "input-suffix",
16677
+ icon: suffix,
16678
+ size: "xsmall"
16679
+ }));
16680
+ };
16681
+
16682
+ var OptionWrapper = index$2(TouchableOpacity)(function (_ref) {
16683
+ var theme = _ref.theme,
16684
+ themeSelected = _ref.themeSelected;
16685
+ return {
16686
+ flexDirection: 'row',
16687
+ justifyContent: 'space-between',
16688
+ alignItems: 'center',
16689
+ borderRadius: theme.__hd__.select.radii.option,
16690
+ padding: theme.__hd__.select.space.optionPadding,
16691
+ backgroundColor: themeSelected ? theme.__hd__.select.colors.checkedOption : theme.__hd__.select.colors.option
16692
+ };
16693
+ });
16694
+ var OptionListWrapper = index$2(View)(function (_ref2) {
16695
+ var theme = _ref2.theme;
16696
+ return {
16697
+ padding: theme.__hd__.select.space.optionListPadding
16698
+ };
16699
+ });
16700
+ var Spacer = index$2(View)(function (_ref3) {
16701
+ var theme = _ref3.theme;
16702
+ return {
16703
+ marginTop: theme.__hd__.select.space.optionListSpacing
16704
+ };
16705
+ });
16706
+ var FooterText = index$2(Typography.Text)(function (_ref4) {
16707
+ var theme = _ref4.theme;
16708
+ return {
16709
+ color: theme.__hd__.select.colors.footerText
16710
+ };
16711
+ });
16712
+
16713
+ function Footer(_ref) {
16714
+ var label = _ref.label,
16715
+ onPress = _ref.onPress;
16716
+ return /*#__PURE__*/React.createElement(TouchableOpacity, {
16717
+ onPress: onPress
16718
+ }, /*#__PURE__*/React.createElement(FooterText, {
16719
+ fontSize: "large",
16720
+ fontWeight: "semi-bold"
16721
+ }, label));
16722
+ }
16723
+
16724
+ function Option(_ref) {
16725
+ var text = _ref.text,
16726
+ selected = _ref.selected,
16727
+ onPress = _ref.onPress;
16728
+ return /*#__PURE__*/React.createElement(OptionWrapper, {
16729
+ themeSelected: selected,
16730
+ onPress: onPress
16731
+ }, /*#__PURE__*/React.createElement(View, {
16732
+ style: {
16733
+ flex: 1
16734
+ }
16735
+ }, /*#__PURE__*/React.createElement(Typography.Text, {
16736
+ fontSize: "large"
16737
+ }, text)), selected && /*#__PURE__*/React.createElement(Icon, {
16738
+ icon: "checkmark",
16739
+ size: "small"
16740
+ }));
16741
+ }
16742
+
16743
+ function getKey(option, index, keyExtractor) {
16744
+ var key = '';
16745
+
16746
+ if (keyExtractor !== undefined) {
16747
+ key = keyExtractor(option, index);
16748
+ } else if (option.key !== undefined) {
16749
+ key = option.key;
16750
+ } else {
16751
+ key = index;
16752
+ }
16753
+
16754
+ return key;
16755
+ }
16756
+
16757
+ function OptionList(_ref2) {
16758
+ var value = _ref2.value,
16759
+ options = _ref2.options,
16760
+ _onPress = _ref2.onPress,
16761
+ keyExtractor = _ref2.keyExtractor;
16762
+ return /*#__PURE__*/React.createElement(OptionListWrapper, null, options.map(function (opt, index) {
16763
+ return /*#__PURE__*/React.createElement(React.Fragment, {
16764
+ key: getKey(opt, index, keyExtractor)
16765
+ }, index !== 0 && /*#__PURE__*/React.createElement(Spacer, null), /*#__PURE__*/React.createElement(Option, {
16766
+ text: opt.text,
16767
+ selected: value.includes(opt.value),
16768
+ onPress: function onPress() {
16769
+ if (value.includes(opt.value)) {
16770
+ _onPress(value.filter(function (val) {
16771
+ return val !== opt.value;
16772
+ }));
16773
+ } else {
16774
+ _onPress([].concat(_toConsumableArray$1(value), [opt.value]));
16775
+ }
16776
+ }
16777
+ }));
16778
+ }));
16779
+ }
16780
+
16781
+ function MultiSelect(_ref) {
16782
+ var options = _ref.options,
16783
+ value = _ref.value,
16784
+ testID = _ref.testID,
16785
+ style = _ref.style,
16786
+ label = _ref.label,
16787
+ footerLabel = _ref.footerLabel,
16788
+ _onPress = _ref.onPress;
16789
+ var theme = useTheme();
16790
+
16791
+ var _useState = useState(false),
16792
+ _useState2 = _slicedToArray(_useState, 2),
16793
+ open = _useState2[0],
16794
+ setOpen = _useState2[1];
16795
+
16796
+ var _useState3 = useState(value),
16797
+ _useState4 = _slicedToArray(_useState3, 2),
16798
+ selectingValue = _useState4[0],
16799
+ setSelectingValue = _useState4[1];
16800
+
16801
+ var displayedValue = options.filter(function (opt) {
16802
+ return value.includes(opt.value);
16803
+ }).map(function (opt) {
16804
+ return opt.text;
16805
+ }).join(', ');
16806
+ return /*#__PURE__*/React.createElement(TouchableOpacity, {
16807
+ onPress: function onPress() {
16808
+ return setOpen(true);
16809
+ }
16810
+ }, /*#__PURE__*/React.createElement(TextInput, {
16811
+ label: label,
16812
+ value: displayedValue,
16813
+ onPressIn: function onPressIn() {
16814
+ return setOpen(true);
16815
+ },
16816
+ editable: false // when input is not editable on Android, the text color is gray
16817
+ // hence, adding this to make the text color the same as iOS
16818
+ ,
16819
+ textStyle: {
16820
+ color: theme.colors.text
16821
+ },
16822
+ suffix: "arrow-down",
16823
+ multiline: true,
16824
+ style: style,
16825
+ testID: testID
16826
+ }), /*#__PURE__*/React.createElement(BottomSheet, {
16827
+ open: open,
16828
+ onRequestClose: function onRequestClose() {
16829
+ return setOpen(false);
16830
+ },
16831
+ onDismiss: function onDismiss() {
16832
+ return setSelectingValue(value);
16833
+ },
16834
+ header: label,
16835
+ footer: /*#__PURE__*/React.createElement(Footer, {
16836
+ label: footerLabel,
16837
+ onPress: function onPress() {
16838
+ setOpen(false);
16839
+
16840
+ _onPress(selectingValue);
16841
+ }
16842
+ })
16843
+ }, /*#__PURE__*/React.createElement(OptionList, {
16844
+ options: options,
16845
+ value: selectingValue,
16846
+ onPress: setSelectingValue
16847
+ })));
16848
+ }
16849
+
16850
+ var CompoundSelect = {
16851
+ Multi: MultiSelect
16852
+ };
16853
+
16854
+ var StyledWrapper = index$2(View)(function (_ref) {
16855
+ var theme = _ref.theme,
16856
+ themeChecked = _ref.themeChecked,
16857
+ themeSize = _ref.themeSize;
16858
+ return {
16859
+ height: theme.__hd__["switch"].heights[themeSize],
16860
+ width: theme.__hd__["switch"].widths[themeSize],
16861
+ paddingHorizontal: theme.__hd__["switch"].spaces[themeSize],
16862
+ borderRadius: theme.__hd__["switch"].radii.rounded,
16863
+ backgroundColor: themeChecked ? theme.__hd__["switch"].colors.active : theme.__hd__["switch"].colors.inactive
16864
+ };
16865
+ });
16866
+ var StyledDisabledWrapper = index$2(View)(function (_ref2) {
16867
+ var theme = _ref2.theme,
16868
+ themeSize = _ref2.themeSize;
16869
+ return {
16870
+ position: 'absolute',
16871
+ height: theme.__hd__["switch"].heights[themeSize],
16872
+ width: theme.__hd__["switch"].widths[themeSize],
16873
+ borderRadius: theme.__hd__["switch"].radii.rounded,
16874
+ backgroundColor: theme.__hd__["switch"].colors.thumb,
16875
+ zIndex: 9999,
16876
+ opacity: 0.8
16877
+ };
16878
+ });
16879
+ var StyledThumbWrapper = index$2(View)(function (_ref3) {
16880
+ var theme = _ref3.theme,
16881
+ themeSize = _ref3.themeSize;
16882
+ return {
16883
+ height: theme.__hd__["switch"].heights[themeSize],
16884
+ width: theme.__hd__["switch"].widths[themeSize],
16885
+ borderRadius: theme.__hd__["switch"].radii.rounded,
16886
+ display: 'flex',
16887
+ justifyContent: 'center'
16888
+ };
16889
+ });
16890
+ var StyledKnot = index$2(Animated.View)(function (_ref4) {
16891
+ var theme = _ref4.theme,
16892
+ themeSize = _ref4.themeSize;
16893
+ return {
16894
+ width: theme.__hd__["switch"].thumbSizes[themeSize],
16895
+ height: theme.__hd__["switch"].thumbSizes[themeSize],
16896
+ backgroundColor: theme.__hd__["switch"].colors.thumb,
16897
+ borderRadius: theme.__hd__["switch"].radii.rounded
16898
+ };
16899
+ });
16900
+
16901
+ var Switch = function Switch(_ref) {
16902
+ var _ref$size = _ref.size,
16903
+ size = _ref$size === void 0 ? 'medium' : _ref$size,
16904
+ _ref$disabled = _ref.disabled,
16905
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
16906
+ checked = _ref.checked,
16907
+ onPress = _ref.onPress,
16908
+ style = _ref.style,
16909
+ testID = _ref.testID;
16910
+ var theme = useTheme();
16911
+ var offset = checked ? theme.__hd__["switch"].widths[size] - theme.__hd__["switch"].thumbSizes[size] - theme.__hd__["switch"].spaces[size] * 2 : theme.__hd__["switch"].spaces.inactive;
16912
+
16913
+ var _useState = useState(function () {
16914
+ return new Animated.Value(offset);
16915
+ }),
16916
+ _useState2 = _slicedToArray(_useState, 1),
16917
+ animatedOffset = _useState2[0];
16918
+
16919
+ useEffect(function () {
16920
+ Animated.timing(animatedOffset, {
16921
+ toValue: offset,
16922
+ easing: Easing.inOut(Easing.cubic),
16923
+ useNativeDriver: false
16924
+ }).start();
16925
+ }, [checked]);
16926
+ return /*#__PURE__*/React.createElement(TouchableWithoutFeedback, {
16927
+ testID: testID,
16928
+ onPress: onPress,
16929
+ disabled: disabled
16930
+ }, /*#__PURE__*/React.createElement(StyledWrapper, {
16931
+ themeChecked: checked,
16932
+ themeSize: size,
16933
+ style: style
16934
+ }, disabled && /*#__PURE__*/React.createElement(StyledDisabledWrapper, {
16935
+ themeSize: size
16936
+ }), /*#__PURE__*/React.createElement(StyledThumbWrapper, {
16937
+ themeSize: size
16938
+ }, /*#__PURE__*/React.createElement(StyledKnot, {
16939
+ themeSize: size,
16940
+ style: {
16941
+ left: animatedOffset
16942
+ }
16943
+ }))));
16944
+ };
16945
+
16517
16946
  var childrenWithOverriddenStyle = function childrenWithOverriddenStyle(children) {
16518
16947
  return Children.map(children, function (child) {
16519
16948
  var element = child;
@@ -17165,7 +17594,7 @@ var StyledText = index$2(Text$1)(function (_ref2) {
17165
17594
  };
17166
17595
  });
17167
17596
 
17168
- var _excluded$1 = ["content", "intent", "style", "testID"];
17597
+ var _excluded = ["content", "intent", "style", "testID"];
17169
17598
 
17170
17599
  var Tag = function Tag(_ref) {
17171
17600
  var content = _ref.content,
@@ -17173,7 +17602,7 @@ var Tag = function Tag(_ref) {
17173
17602
  intent = _ref$intent === void 0 ? 'info' : _ref$intent,
17174
17603
  style = _ref.style,
17175
17604
  testID = _ref.testID,
17176
- nativeProps = _objectWithoutProperties$1(_ref, _excluded$1);
17605
+ nativeProps = _objectWithoutProperties$1(_ref, _excluded);
17177
17606
 
17178
17607
  return /*#__PURE__*/React.createElement(StyledView, _extends$3({}, nativeProps, {
17179
17608
  themeIntent: intent,
@@ -17184,69 +17613,4 @@ var Tag = function Tag(_ref) {
17184
17613
  }, content));
17185
17614
  };
17186
17615
 
17187
- var Container = index$2(View)(function (_ref) {
17188
- var theme = _ref.theme;
17189
- return {
17190
- position: 'relative',
17191
- width: '100%',
17192
- borderWidth: theme.__hd__.textInput.borderWidths.container,
17193
- borderRadius: theme.__hd__.textInput.radii.container,
17194
- padding: theme.__hd__.textInput.space.containerPadding,
17195
- flexDirection: 'row',
17196
- alignItems: 'center'
17197
- };
17198
- });
17199
- var Label = index$2(Typography.Text)(function (_ref2) {
17200
- var theme = _ref2.theme;
17201
- return {
17202
- position: 'absolute',
17203
- left: theme.__hd__.textInput.space.labelLeft,
17204
- top: theme.__hd__.textInput.space.labelTop,
17205
- backgroundColor: theme.__hd__.textInput.colors.labelBackground,
17206
- zIndex: 1,
17207
- paddingHorizontal: theme.__hd__.textInput.space.labelHorizontalPadding
17208
- };
17209
- });
17210
- var Prefix = index$2(Icon)(function (_ref3) {
17211
- var theme = _ref3.theme;
17212
- return {
17213
- marginRight: theme.__hd__.textInput.space.prefixMarginRight
17214
- };
17215
- });
17216
- var StyledTextInput = index$2(TextInput$1)(function (_ref4) {
17217
- var theme = _ref4.theme;
17218
- return {
17219
- flex: 1,
17220
- fontSize: theme.__hd__.textInput.fontSizes.text
17221
- };
17222
- });
17223
-
17224
- var _excluded = ["label", "prefix", "style", "testID", "accessibilityLabelledBy"];
17225
-
17226
- var TextInput = function TextInput(_ref) {
17227
- var label = _ref.label,
17228
- prefix = _ref.prefix,
17229
- style = _ref.style,
17230
- testID = _ref.testID,
17231
- accessibilityLabelledBy = _ref.accessibilityLabelledBy,
17232
- nativeProps = _objectWithoutProperties$1(_ref, _excluded);
17233
-
17234
- return /*#__PURE__*/React.createElement(Container, {
17235
- style: style,
17236
- testID: testID
17237
- }, label && /*#__PURE__*/React.createElement(Label, {
17238
- nativeID: accessibilityLabelledBy,
17239
- testID: "input-label",
17240
- fontSize: "small"
17241
- }, label), prefix && /*#__PURE__*/React.createElement(Prefix, {
17242
- testID: "input-prefix",
17243
- icon: prefix,
17244
- size: "xsmall"
17245
- }), /*#__PURE__*/React.createElement(StyledTextInput, _extends$3({
17246
- testID: "text-input" // @ts-ignore
17247
- ,
17248
- accessibilityLabelledBy: accessibilityLabelledBy
17249
- }, nativeProps)));
17250
- };
17251
-
17252
- export { Alert, Avatar, Badge$1 as Badge, BottomNavigation, BottomSheet, CompoundButton as Button, Card, Collapse, ContentNavigator, Divider, Drawer, index$1 as FAB, Icon, Progress, CompoundRadio as Radio, SectionHeading, Spinner, index as Tabs, Tag, TextInput, ThemeProvider, Typography, getTheme, scale, theme, useTheme };
17616
+ export { Alert, Avatar, Badge$1 as Badge, BottomNavigation, BottomSheet, CompoundButton as Button, Card, Collapse, ContentNavigator, Divider, Drawer, index$1 as FAB, Icon, Progress, CompoundRadio as Radio, SectionHeading, CompoundSelect as Select, Spinner, Switch, index as Tabs, Tag, TextInput, ThemeProvider, Typography, getTheme, scale, theme, useTheme };